suneditor 2.46.2 → 3.0.0-alpha.10

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 +11 -1560
  6. package/dist/suneditor.min.css +1 -0
  7. package/dist/suneditor.min.js +1 -2
  8. package/package.json +97 -70
  9. package/src/assets/icons/_default.js +194 -0
  10. package/src/assets/suneditor-contents.css +643 -0
  11. package/src/assets/suneditor.css +3394 -0
  12. package/src/core/base/eventHandlers/handler_toolbar.js +114 -0
  13. package/src/core/base/eventHandlers/handler_ww_clipboard.js +37 -0
  14. package/src/core/base/eventHandlers/handler_ww_dragDrop.js +74 -0
  15. package/src/core/base/eventHandlers/handler_ww_key_input.js +1002 -0
  16. package/src/core/base/eventHandlers/handler_ww_mouse.js +147 -0
  17. package/src/core/base/eventManager.js +1156 -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 +147 -0
  21. package/src/core/class/component.js +639 -0
  22. package/src/core/class/format.js +3258 -0
  23. package/src/core/class/html.js +1710 -0
  24. package/src/core/class/menu.js +260 -0
  25. package/src/core/class/nodeTransform.js +405 -0
  26. package/src/core/class/notice.js +42 -0
  27. package/src/core/class/offset.js +575 -0
  28. package/src/core/class/selection.js +511 -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 +1601 -0
  33. package/src/core/section/actives.js +145 -0
  34. package/src/core/section/constructor.js +1252 -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 +388 -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 +210 -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 +210 -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 +323 -0
  72. package/src/modules/Figure.js +1176 -0
  73. package/src/modules/FileBrowser.js +271 -0
  74. package/src/modules/FileManager.js +307 -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 +90 -0
  88. package/src/plugins/dropdown/font.js +113 -0
  89. package/src/plugins/dropdown/fontColor.js +90 -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 +181 -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 +492 -0
  104. package/src/plugins/modal/image.js +1064 -0
  105. package/src/plugins/modal/link.js +211 -0
  106. package/src/plugins/modal/math.js +363 -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,1591 +1,42 @@
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)
15
15
 
16
- > The Suneditor is a lightweight, flexible, customizable WYSIWYG text editor for your web applications.
17
- > - Pasting from Microsoft Word and Excel.
18
- > - Custom table selection, merge and split.
19
- > - Media embed, images upload.
20
- > - Can use CodeMirror, KaTeX.
21
- > - And.. many other features :)
22
-
23
16
  ![WYSIWYG HTML Editor](http://suneditor.com/docs/screen-main-w.png?v=2700)
24
17
 
25
- ## Table of contents
26
- - [Browser Support](#browser-support)
27
- - [Install](#install)
28
- - [Getting Started](#getting-started)
29
- - [When inserting custom tags in the editor](#when-inserting-custom-tags-in-the-editor)
30
- - [Use import statement](#use-import-statement)
31
- - [Load only what you want](#1-load-only-what-you-want)
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
- - [Init function](#init-function)
35
- - [Use CodeMirror](#use-codemirror)
36
- - [Use KaTeX (math plugin)](#use-katex-math-plugin)
37
- - [Options](#options)
38
- - [Functions](#functions)
39
- - [Plugins list](#plugins-list)
40
- - [Examples](#examples)
41
- - [Options template](#options-template)
42
- - [Custom plugins](#custom-plugins)
43
- - [Document](#document)
44
- - [Other libraries using SunEditor](#other-libraries-using-sunEditor)
45
- - [suneditor-react](#lib-suneditor-react)
46
- - [angular-suneditor](#lib-angular-suneditor)
47
- - [Using SunEditor with Livewire & Alpine.JS](#lib-livewire-alpine)
48
- - [Plugin for Pluxml](#lib-pluxml)
49
- - [AEM-SunEditor](#lib-aem-suneditor)
50
- - [License](#license)
51
-
52
-
53
18
  #### Browser Support
54
19
 
55
- | <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
- |:---:|:---:|:---:|:---:|:---:|:---:|
57
- | Yes | Yes | Yes | Yes | Yes | 11+ |
20
+ | <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 |
21
+ |:---:|:---:|:---:|:---:|:---:|
22
+ | Yes | Yes | Yes | Yes | Yes |
58
23
 
59
24
  ## Install
60
25
  #### Npm
61
26
  ``` sh
62
27
  $ npm install suneditor --save
63
28
  ```
64
- #### Bower
65
- ``` sh
66
- $ bower install suneditor --save
67
- ```
68
29
  #### CDN
69
30
  ``` html
70
31
  <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"> -->
32
+ <!-- <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/assets/suneditor.css" rel="stylesheet"> -->
33
+ <!-- <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/assets/suneditor-contents.css" rel="stylesheet"> -->
73
34
  <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/suneditor.min.js"></script>
74
35
  <!-- languages (Basic Language: English/en) -->
75
- <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/src/lang/ko.js"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/src/langs/ko.js"></script>
76
37
  ```
77
38
  [jsdelivr/suneditor](https://www.jsdelivr.com/package/npm/suneditor)
78
39
 
79
- ## Getting Started
80
- ### 1. Target Element
81
- ```html
82
- <textarea id="sample">Hi</textarea>
83
- ```
84
-
85
- ### 2. Create
86
- ```javascript
87
- /**
88
- * ID : 'suneditor_sample'
89
- * ClassName : 'sun-eidtor'
90
- */
91
- // ID or DOM object
92
- const editor = SUNEDITOR.create((document.getElementById('sample') || 'sample'),{
93
- // All of the plugins are loaded in the "window.SUNEDITOR" object in dist/suneditor.min.js file
94
- // Insert options
95
- // Language global object (default: en)
96
- lang: SUNEDITOR_LANG['ko']
97
- });
98
- ```
99
-
100
- ### 3. Contents display
101
- ```java
102
- 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.
104
- Then add "sun-editor-editable" to the class name of the Tag element that displays the content.
105
- 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.
107
- ```
108
-
109
- ## When inserting custom tags in the editor
110
- ```text
111
- - 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.
113
- "se-component" is the component type of the editor.
114
- Class name for wrapper tags such as images and videos.
115
- ```
116
-
117
- ## Use import statement
118
-
119
- ### 1. Load only what you want
120
- ```javascript
121
- import 'suneditor/dist/css/suneditor.min.css'
122
- // import 'suneditor/assets/css/suneditor.css'
123
- // import 'suneditor/assets/css/suneditor-contents.css'
124
- import suneditor from 'suneditor'
125
-
126
- // How to import plugins
127
- import image from 'suneditor/src/plugins/dialog/link'
128
- import list from 'suneditor/src/plugins/submenu/list'
129
- import {font, video} from 'suneditor/src/plugins'
130
-
131
- // 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'
135
-
136
- suneditor.create('sample', {
137
- plugins: [font, video, image, list],
138
- buttonList: [
139
- ['font', 'video', 'image', 'list']
140
- ],
141
- lang: lang.ko
142
- });
143
- ```
144
-
145
- ### 2. Load all plugins
146
- ```javascript
147
- import 'suneditor/dist/css/suneditor.min.css'
148
- import suneditor from 'suneditor'
149
- import plugins from 'suneditor/src/plugins'
150
-
151
- suneditor.create('sample', {
152
- plugins: plugins,
153
- buttonList: [
154
- ['undo', 'redo'],
155
- ['font', 'fontSize', 'formatBlock'],
156
- ['paragraphStyle', 'blockquote'],
157
- ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
158
- ['fontColor', 'hiliteColor', 'textStyle'],
159
- ['removeFormat'],
160
- '/', // Line break
161
- ['outdent', 'indent'],
162
- ['align', 'horizontalRule', 'list', 'lineHeight'],
163
- ['table', 'link', 'image', 'video', 'audio' /** ,'math' */], // You must add the 'katex' library at options to use the 'math' plugin.
164
- /** ['imageGallery'] */ // You must add the "imageGalleryUrl".
165
- ['fullScreen', 'showBlocks', 'codeView'],
166
- ['preview', 'print'],
167
- ['save', 'template'],
168
- /** ['dir', 'dir_ltr', 'dir_rtl'] */ // "dir": Toggle text direction, "dir_ltr": Right to Left, "dir_rtl": Left to Right
169
- ]
170
- })
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
- ```
197
-
198
- ## Init function
199
- ```text
200
- The init function can be used by predefining options and calling the create function on the returned object.
201
- The value of the option argument put in the "create" function call takes precedence
202
- ```
203
- ```javascript
204
- import 'suneditor/dist/css/suneditor.min.css'
205
- import suneditor from 'suneditor'
206
- import plugins from 'suneditor/src/plugins'
207
-
208
- // all plugins
209
- const initEditor = suneditor.init({
210
- plugins: plugins,
211
- height: 200,
212
- buttonList: [
213
- [
214
- 'undo', 'redo',
215
- 'font', 'fontSize', 'formatBlock',
216
- 'paragraphStyle', 'blockquote',
217
- 'bold', 'underline', 'italic', 'strike', 'subscript', 'superscript',
218
- 'fontColor', 'hiliteColor', 'textStyle',
219
- 'removeFormat',
220
- 'outdent', 'indent',
221
- 'align', 'horizontalRule', 'list', 'lineHeight',
222
- 'table', 'link', 'image', 'video', 'audio', /** 'math', */ // You must add the 'katex' library at options to use the 'math' plugin.
223
- /** 'imageGallery', */ // You must add the "imageGalleryUrl".
224
- 'fullScreen', 'showBlocks', 'codeView',
225
- 'preview', 'print', 'save', 'template',
226
- /** 'dir', 'dir_ltr', 'dir_rtl' */ // "dir": Toggle text direction, "dir_ltr": Right to Left, "dir_rtl": Left to Right
227
- ]
228
- ]
229
- });
230
-
231
- initEditor.create('sample_1', {
232
- // The value of the option argument put in the "create" function call takes precedence
233
- });
234
-
235
- initEditor.create('sample_2', {
236
- // The value of the option argument put in the "create" function call takes precedence
237
- height: 'auto',
238
- buttonList: [
239
- ['bold', 'underline', 'italic'],
240
- ['removeFormat'],
241
- ['preview', 'print']
242
- ]
243
- });
244
- ```
245
-
246
- ## Use CodeMirror
247
- ```html
248
- <!-- https://github.com/codemirror/CodeMirror -->
249
- <!-- codeMirror (^5.0.0) -->
250
- <!-- Use version 5.x.x -->
251
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codemirror@5.49.0/lib/codemirror.min.css">
252
- <script src="https://cdn.jsdelivr.net/npm/codemirror@5.49.0/lib/codemirror.min.js"></script>
253
- <script src="https://cdn.jsdelivr.net/npm/codemirror@5.49.0/mode/htmlmixed/htmlmixed.js"></script>
254
- <script src="https://cdn.jsdelivr.net/npm/codemirror@5.49.0/mode/xml/xml.js"></script>
255
- <script src="https://cdn.jsdelivr.net/npm/codemirror@5.49.0/mode/css/css.js"></script>
256
- ```
257
- ```javascript
258
- import 'suneditor/dist/css/suneditor.min.css'
259
- import suneditor from 'suneditor'
260
- // Import codeMirror
261
- import CodeMirror from 'codemirror'
262
- import 'codemirror/mode/htmlmixed/htmlmixed'
263
- import 'codemirror/lib/codemirror.css'
264
-
265
- suneditor.create('sample', {
266
- codeMirror: CodeMirror // window.CodeMirror,
267
- // Set options
268
- // codeMirror: {
269
- // src: CodeMirror,
270
- // options: {...}
271
- // }
272
- buttonList: [
273
- ['codeView']
274
- ],
275
- height: 400
276
- });
277
- ```
278
-
279
- ## Use KaTeX (math plugin)
280
- ```html
281
- <!-- https://github.com/KaTeX/KaTeX -->
282
- <!-- KaTeX (^0.11.1) -->
283
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">
284
- <script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"></script>
285
- ```
286
- ```javascript
287
- import 'suneditor/dist/css/suneditor.min.css'
288
- import suneditor from 'suneditor'
289
- // Import katex
290
- import katex from 'katex'
291
- import 'katex/dist/katex.min.css'
292
-
293
- suneditor.create('sample', {
294
- katex: katex // window.katex,
295
- // Set options
296
- // katex: {
297
- // src: katex,
298
- // options: {...}
299
- // }
300
- buttonList: [
301
- ['math']
302
- ]
303
- });
304
- ```
305
-
306
- <!-- ## Use mention plugin
307
- ```javascript
308
- import { mention } from 'suneditor/dist/plugins';
309
-
310
- // implement your api to find the user to mention.
311
- mention.getItems = async function(term) {
312
- return callApi('/users?q='+escape(term));
313
- }
314
-
315
- // renderItem shows a user in the list
316
- mention.renderItem = function(user) {
317
- return '<span>' + user.name + '</span>';
318
- }
319
-
320
- // getId should return a unique id
321
- mention.getId = function(user) {
322
- return user.id;
323
- }
324
-
325
- // getValue should return what you want to display in the editor
326
- mention.getValue = function(user) {
327
- return '@' + user.name;
328
- }
329
-
330
- // getLinkHref should return the link target
331
- mention.getLinkHref = function(user) {
332
- return user.profile;
333
- }
334
-
335
- let editor = suneditor.create('sample', {
336
- plugins: [mention],
337
- buttonList: [
338
- ['mention']
339
- ]
340
- })
341
-
342
- // if you would like to have this triggered when pressing @
343
- editor.core.callPlugin('mention');
344
- editor.onKeyDown = e => {
345
- if (e.key === '@') {
346
- editor.core.context.mention.open();
347
- e.preventDefault();
348
- e.stopPropagation();
349
- }
350
- }
351
-
352
- // when saving changes from the editor you will want to obtain the mentions added
353
- let newMentions = editor.core.getMentions();
354
-
355
- ``` -->
356
-
357
- ## Options
358
- ```java
359
- plugins: [
360
- /** command */
361
- blockquote,
362
- /** Submenu */
363
- align,
364
- font,
365
- fontColor,
366
- fontSize,
367
- formatBlock,
368
- hiliteColor,
369
- horizontalRule,
370
- lineHeight,
371
- list,
372
- paragraphStyle,
373
- table,
374
- template,
375
- textStyle,
376
- /** Dialog */
377
- image,
378
- link,
379
- video,
380
- audio,
381
- math, // You must add the 'katex' library at options to use the 'math' plugin.
382
- /** File browser */
383
- // You must add the "imageGalleryUrl".
384
- // A button is added to the image modal.
385
- // You can also use image gallery by adding it directly to the button list. (You must add "image" plugin.)
386
- imageGallery
387
- ]
388
- : Plugins array. default: null {Array}
389
- // * Custom options and default options are all treated the same.
390
- // * When using a custom plugin and a default plugin together, register as follows.
391
- // * {custom_plugin, ...plugins}
392
-
393
- // Values
394
- strictMode : Option to disable clean mode, which checks the styles, classes, etc. of the editor content. default : false {Boolean}
395
- 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' }
398
- ex) {
399
- bold: 'b',
400
- strike: 's'
401
- }
402
- 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}
408
- ex) {
409
- "spellcheck": false
410
- }
411
-
412
- // Whitelist, Blacklist -----------------------------------------------------------------------------------------
413
- // (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}
416
- ex) 'mark|canvas|label|select|option|input|//' // "//" This means HTML comments.
417
- ex) '*' // This means all tags are allowed. (Not available on "blacklist")
418
- tagsBlacklist : Blacklist of the editor default tags. default: null {String}
419
- 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}
427
- // -- Fixed whitelist --
428
- // 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'
430
- ex) {
431
- 'all': 'style|data-.+', // Apply to all tags
432
- 'input': 'checked|name' // Apply to input tag
433
- '???': '*' // "*" === all attributes
434
- }
435
- attributesBlacklist : Add attribute blacklist of tags that should be deleted in editor. default: null {Object}
436
- ex) {
437
- 'all': 'id', // Apply to all tags
438
- 'input': 'style' // Apply to input tag
439
- '???': '*' // "*" === all attributes
440
- }
441
- // Layout-------------------------------------------------------------------------------------------------------
442
- mode : The mode of the editor ('classic', 'inline', 'balloon', 'balloon-always'). default: 'classic' {String}
443
- rtl : If true, the editor is set to RTL(Right To Left) mode. default: false {Boolean}
444
- 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}
446
- ex) 'class|style': Attributes other than "class" and "style" are deleted at line break.
447
- '*': All attributes are deleted at line break.
448
- toolbarWidth : The width of the toolbar. Applies only when the editor mode is
449
- 'inline' or 'balloon' mode. default: 'auto' {Number|String}
450
- toolbarContainer: A custom HTML selector placing the toolbar inside.
451
- The class name of the element must be 'sun-editor'.
452
- Element or querySelector argument. default: null {Element|String}
453
- ex) document.querySelector('#id') || '#id'
454
- stickyToolbar : Top offset value of "sticky toolbar".
455
- Set to 0, '0px', '50px'...
456
- 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}
458
- fullScreenOffset: Top offset value of "full Screen".
459
- Set to 0, '0px', '50px'... default: 0 {Number|String}
460
- 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}
463
- ex) {'scrolling': 'no'}
464
- iframeCSSFileName : Name or Array of the CSS file to apply inside the iframe.
465
- You can also use regular expressions.
466
- Applied by searching by filename in the link tag of document,
467
- or put the URL value (".css" can be omitted). default: 'suneditor' {Array|String}
468
- ex) '.+' or ['suneditor', 'http://suneditor.com/sample/css/sample.css', '.+\\.min\\.css']
469
- 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>"
472
- 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}
476
- Use version 5.x.x // https://github.com/codemirror/CodeMirror
477
- ex) codeMirror: CodeMirror // Default option
478
- codeMirror: { // Custom option
479
- src: CodeMirror,
480
- options: {
481
- /** default options **
482
- * mode: 'htmlmixed',
483
- * htmlMode: true,
484
- * lineNumbers: true
485
- * lineWrapping: true
486
- */
487
- }
488
- }
489
- katex : Required library for math plugins. default: null {Object}
490
- Use version 0.x.x // https://github.com/KaTeX/KaTeX
491
- ex) katex: katex // Default option
492
- katex: { // Custom option
493
- src: katex,
494
- options: {
495
- /** default options **
496
- * throwOnError: false,
497
- */
498
- }
499
- }
500
- mathFontSize : Math plugin font size list. default: [{..}] {Array}
501
- Default value: [
502
- {text: '1', value: '1em', default: true},
503
- {text: '1.5', value: '1.5em'},
504
- {text: '2', value: '2em'},
505
- {text: '2.5', value: '2.5em'}
506
- ]
507
-
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.
515
- 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.
519
- The class name of the element must be 'sun-editor'.
520
- Element or querySelector argument. default: null {Element|String}
521
- ex) document.querySelector('#id') || '#id'
522
-
523
- // Character count-----------------------------------------------------------------------------------------------
524
- 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.
527
- 'char': Characters length.
528
- '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}
533
-
534
- // Width size----------------------------------------------------------------------------------------------------
535
- width : The width size of the editor. default: clientWidth||'100%' {Number|String}
536
- minWidth : The min-width size of the editor.
537
- Used when 'width' value is 'auto' or '~%'. default: null {Number|String}
538
- maxWidth : The max-width size of the editor.
539
- Used when 'width' value is 'auto' or '~%'. default: null {Number|String}
540
-
541
- // Height size---------------------------------------------------------------------------------------------------
542
- height : The height size of the editor. default: clientHeight||'auto' {Number|String}
543
- minHeight : The min-height size of the editor.
544
- Used when 'height' value is 'auto'. default: null {Number|String}
545
- maxHeight : The max-height size of the editor.
546
- Used when 'height' value is 'auto'. default: null {Number|String}
547
-
548
- // 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.)
553
- ex) 'font-family: cursive; font-size: 10px;'
554
-
555
- // Defining menu items-------------------------------------------------------------------------------------------
556
- font : Change default font-family array. default: [...] {Array}
557
- Default value: [
558
- 'Arial', 'Comic Sans MS', 'Courier New', 'Impact',
559
- 'Georgia','tahoma', 'Trebuchet MS', 'Verdana'
560
- ]
561
- fontSize : Change default font-size array. default: [...] {Array}
562
- Default value: [
563
- 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
564
- ]
565
- fontSizeUnit : The font size unit. default: 'px' {String}
566
- alignItems : A list of drop-down options for the 'align' plugin. default: rtl === true ? ['right', 'center', 'left', 'justify'] : ['left', 'center', 'right', 'justify'] {Array}
567
- formats : Change default formatBlock array. default: [...] {Array}
568
- Default value: [
569
- 'p', 'div', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
570
- // "blockquote": range format, "pre": free format, "Other tags": replace format
571
- ],
572
- Custom: [{
573
- tag: 'div', // Tag name
574
- 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)_"
578
- }]
579
- colorList : Change default color array of color picker. default: [..[..]..] {Array}
580
- Default value: [
581
- '#ff0000', '#ff5e00', '#ffe400', '#abf200', '#00d8ff', '#0055ff', '#6600ff', '#ff00dd', '#000000',
582
- '#ffd8d8', '#fae0d4', '#faf4c0', '#e4f7ba', '#d4f4fa', '#d9e5ff', '#e8d9ff', '#ffd9fa', '#f1f1f1',
583
- '#ffa7a7', '#ffc19e', '#faed7d', '#cef279', '#b2ebf4', '#b2ccff', '#d1b2ff', '#ffb2f5', '#bdbdbd',
584
- '#f15f5f', '#f29661', '#e5d85c', '#bce55c', '#5cd1e5', '#6699ff', '#a366ff', '#f261df', '#8c8c8c',
585
- '#980000', '#993800', '#998a00', '#6b9900', '#008299', '#003399', '#3d0099', '#990085', '#353535',
586
- '#670000', '#662500', '#665c00', '#476600', '#005766', '#002266', '#290066', '#660058', '#222222'
587
- ]
588
- ex) [
589
- ['#ccc', '#dedede', 'OrangeRed', 'Orange', 'RoyalBlue', 'SaddleBrown'], // Line break
590
- ['SlateGray', 'BurlyWood', 'DeepPink', 'FireBrick', 'Gold', 'SeaGreen']
591
- ]
592
- lineHeights : Change default line-height array. default: [{}..] {Array}
593
- Default value: [
594
- {text: '1', value: 1},
595
- {text: '1.15', value: 1.15},
596
- {text: '1.5', value: 1.5},
597
- {text: '2', value: 2}
598
- ]
599
- ex) [
600
- {text: 'Single', value: 1},
601
- {text: 'Double', value: 2}
602
- ]
603
- paragraphStyles : You can apply custom class to format.
604
- ex) '.sun-editor-editable .__se__customClass'
605
- '.sun-editor .__se__customClass' // If you want to apply styles to menu items as well
606
- Default value: [
607
- {
608
- name: 'Spaced', // Format style name
609
- class: '__se__p-spaced', // Define style for used class (Class names must always begin with "__se__")
610
- _class: '' // You can control the style of the tags displayed in the menu by putting a class on the button of the menu.
611
- },
612
- {
613
- name: 'Bordered',
614
- class: '__se__p-bordered'
615
- },
616
- {
617
- name: 'Neon',
618
- class: '__se__p-neon'
619
- }
620
- ]
621
- ex) [
622
- 'spaced', 'neon', // The default value is called by name only and the name is called in the language file.
623
- {
624
- name: 'Custom',
625
- class: '__se__customClass'
626
- }
627
- ]
628
- textStyles : You can apply custom style or class to selected text.
629
- ex(using a class)) '.sun-editor-editable .__se__customClass'
630
- '.sun-editor .__se__customClass' // If you want to apply styles to menu items as well
631
- Default value: [
632
- {
633
- name: 'Code',
634
- class: '__se__t-code',
635
- tag: 'code',
636
- },
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
- {
644
- name: 'Shadow',
645
- class: '__se__t-shadow', // Class names (Class names must always begin with "__se__")
646
- tag: 'span'
647
- }
648
- ]
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
-
658
- // Image---------------------------------------------------------------------------------------------------------
659
- imageResizing : Can resize the image. default: true {Boolean}
660
- imageHeightShow : Choose whether the image height input is visible. default: true {Boolean}
661
- 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}
664
- imageSizeOnlyPercentage : If true, image size can only be scaled by percentage. default: false {Boolean}
665
- imageRotation : Choose whether to image rotation buttons display.
666
- 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}
669
- 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}
671
- imageUploadHeader : Http Header when uploading images. default: null {Object}
672
- imageUploadUrl : The image upload to server mapping address. default: null {String}
673
- (When not used the "imageUploadUrl" option, image is enters base64 data)
674
- ex) "/editor/uploadImage"
675
- request format: {
676
- "file-0": File,
677
- "file-1": File
678
- }
679
- response format: {
680
- "errorMessage": "insert error message",
681
- "result": [
682
- {
683
- "url": "/download/editorImg/test_image.jpg",
684
- "name": "test_image.jpg",
685
- "size": "561276"
686
- }
687
- ]
688
- }
689
- 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}
693
- ex) "*" or ".jpg, .png .."
694
- // Image - image gallery
695
- imageGalleryUrl : The url of the image gallery, if you use the image gallery.
696
- 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}
698
- ex) "/editor/getGallery"
699
- response format: {
700
- "result": [
701
- {
702
- "src": "/download/editorImg/test_image.jpg", // @Require
703
- "thumbnail": "/download/editorImg/test_thumbnail.jpg", // @Option - Thumbnail image to be displayed in the image gallery.
704
- "name": "Test image", // @Option - default: src.split('/').pop()
705
- "alt": "Alt text", // @Option - default: src.split('/').pop()
706
- "tag": "Tag name" // @Option
707
- }
708
- ],
709
- "nullMessage": "Text string or HTML string", // It is displayed when "result" is empty.
710
- "errorMessage": "Insert error message", // It is displayed when an error occurs.
711
- }
712
- You can redefine the "plugins.imageGallery.drawItems" method.
713
- imageGalleryHeader: Http Header when get image gallery. default: null {Object}
714
-
715
- // Video----------------------------------------------------------------------------------------------------------
716
- videoResizing : Can resize the video (iframe, video). default: true {Boolean}
717
- videoHeightShow : Choose whether the video height input is visible. default: true {Boolean}
718
- videoAlignShow : Choose whether the video align radio buttons are visible. default: true {Boolean}
719
- 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}
722
- videoSizeOnlyPercentage : If true, video size can only be scaled by percentage. default: false {Boolean}
723
- videoRotation : Choose whether to video rotation buttons display.
724
- 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}
726
- videoRatio : The default aspect ratio of the video.
727
- Up to four decimal places are allowed. default: 0.5625 (16:9) {Float}
728
- videoRatioList : Video ratio selection options.
729
- default: [
730
- {name: '16:9', value: 0.5625},
731
- {name: '4:3', value: 0.75},
732
- {name: '21:9', value: 0.4285}
733
- ],
734
- ex) [
735
- {name: 'Classic Film 3:2', value: 0.6666},
736
- {name: 'HD', value: 0.5625}
737
- ]
738
- youtubeQuery : The query string of a YouTube embedded URL. default: '' {String}
739
- It takes precedence over the value user entered.
740
- ex) 'autoplay=1&mute=1&enablejsapi=1&controls=0&rel=0&modestbranding=1'
741
- // 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}
743
- 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}
745
- videoUploadHeader : Http Header when uploading videos. default: null {Object}
746
- videoUploadUrl : The video upload to server mapping address. default: null {String}
747
- ex) "/editor/uploadVideo"
748
- request format: {
749
- "file-0": File,
750
- "file-1": File
751
- }
752
- Use video tags. (supported video formats: '.mp4', '.webm', '.ogg')
753
- response format: {
754
- "errorMessage": "insert error message",
755
- "result": [
756
- {
757
- "url": "/download/editorVideos/test_video.mp4",
758
- "name": "test_video.mp4",
759
- "size": "561276"
760
- }
761
- ]
762
- }
763
- 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}
766
- videoTagAttrs : Define "Attributes" of the video tag. default: null {Object}
767
- ex) { poster: "http://suneditor.com/docs/loading.gif", autoplay: true }
768
- videoIframeAttrs : Define "Attributes" of the iframe tag. (Youtube, Vimeo). default: null {Object}
769
- ex) { style: "border: 2px solid red;" }
770
- videoAccept : Define the "accept" attribute of the input. default: "*" {String}
771
- ex) "*" or ".mp4, .avi .."
772
-
773
- // 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}
777
- 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}
779
- audioUploadHeader : Http Header when uploading audios. default: null {Object}
780
- audioUploadUrl : The audio upload to server mapping address. default: null {String}
781
- ex) "/editor/uploadAudio"
782
- request format: {
783
- "file-0": File,
784
- "file-1": File
785
- }
786
- Use audio tags. (supported audio formats: '.mp4', '.webm', '.ogg')
787
- response format: {
788
- "errorMessage": "insert error message",
789
- "result": [
790
- {
791
- "url": "/download/editorAudios/test_audio.mp3",
792
- "name": "test_audio.mp3",
793
- "size": "561276"
794
- }
795
- ]
796
- }
797
- 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}
800
- audioTagAttrs : Define "Attributes" of the audio tag. default: null {Object}
801
- ex) { controlslist: "nodownload", autoplay: true }
802
- videoAccept : Define the "accept" attribute of the input. default: "*" {String}
803
- ex) "*" or ".mp3, .wav .."
804
-
805
- // Table----------------------------------------------------------------------------------------------------------
806
- tableCellControllerPosition : Define position to the table cell controller('cell', 'top'). default: 'cell' {String}
807
-
808
- // Link-----------------------------------------------------------------------------------------------------------
809
- 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
- // https://www.w3schools.com/tags/att_a_rel.asp
814
- ex) [
815
- 'author',
816
- 'external',
817
- 'help',
818
- 'license',
819
- 'next',
820
- 'follow',
821
- 'nofollow',
822
- 'noreferrer',
823
- 'noopener',
824
- 'prev',
825
- 'search',
826
- 'tag'
827
- ]
828
- linkRelDefault : Defines default "rel" attributes of anchor tag. default: {} {Object}
829
- ex) linkRelDefault: {
830
- default: 'nofollow', // Default rel
831
- check_new_window: 'noreferrer noopener', // When "open new window" is checked
832
- check_bookmark: 'bookmark' // When "bookmark" is checked
833
- },
834
- // If properties other than "default" start with "only:", the existing "rel" is cleared and applied.
835
- linkRelDefault: {
836
- check_new_window: 'only:noreferrer noopener'
837
- }
838
- linkNoPrefix : If true, disables the automatic prefixing of the host URL to the value of the link. default: false {Boolean}
839
-
840
- // HR----------------------------------------------------------------------------------------------------
841
- hrItems : Defines the hr items.
842
- "class" or "style" must be specified.
843
- 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'}
847
- ]
848
- ex) [ {name: "Outset", style: "border-style: outset;"} ]
849
-
850
-
851
- // Key actions----------------------------------------------------------------------------------------------------
852
- tabDisable : If true, disables the interaction of the editor and tab key. default: false {Boolean}
853
- shortcutsDisable: You can disable shortcuts. default: [] {Array}
854
- ex) ['bold', 'strike', 'underline', 'italic', 'undo', 'indent', 'save']
855
- shortcutsHint : If false, hide the shortcuts hint. default: true {Boolean}
856
-
857
- // Defining save button-------------------------------------------------------------------------------------------
858
- callBackSave : Callback functions that is called when the Save button is clicked.
859
- Arguments - (contents, isChanged). default: functions.save {Function}
860
-
861
- // Templates Array------------------------------------------------------------------------------------------------
862
- templates : If you use a template plugin, add it.
863
- Defines a list of templates. default: null {Array}
864
- ex) [
865
- {
866
- name: 'Template-1',
867
- html: '<p>HTML source1</p>'
868
- },
869
- {
870
- name: 'Template-2',
871
- html: '<p>HTML source2</p>'
872
- }
873
- ]
874
-
875
- // ETC------------------------------------------------------------------------------------------------------------
876
- __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}
879
- icons : You can redefine icons. default: null {Object}
880
- ex) {
881
- bold: '<span class="se-icon-text">B</span>',
882
- table: '<i class="xx xxx></i>',
883
- insert_row_above: '<svg></svg>'
884
- }
885
-
886
- // Buttons--------------------------------------------------------------------------------------------------------
887
- buttonList : Defines button list to array {Array}
888
- default: [
889
- ['undo', 'redo'],
890
- // ['font', 'fontSize', 'formatBlock'],
891
- // ['paragraphStyle', 'blockquote'],
892
- ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
893
- // ['fontColor', 'hiliteColor', 'textStyle'],
894
- ['removeFormat'],
895
- ['outdent', 'indent'],
896
- // ['align', 'horizontalRule', 'list', 'lineHeight'],
897
- // ['table', 'link', 'image', 'video', 'math'], // You must add the 'katex' library at options to use the 'math' plugin.
898
- // ['imageGallery'], // You must add the "imageGalleryUrl".
899
- ['fullScreen', 'showBlocks', 'codeView'],
900
- ['preview', 'print'],
901
- // ['save', 'template'],
902
- // ['dir', 'dir_ltr', 'dir_rtl'],
903
- // '/', Line break
904
- ]
905
-
906
- ----------------- ex) When do not use group: ----------------------------------------------------------------------
907
- // If you don't want to use a group, put all the buttons in one array.
908
- [
909
- ['undo', 'redo', 'bold', 'underline', 'fontColor', 'table', 'link', 'image', 'video']
910
- ]
911
-
912
- ------------------ex) Alignment of button group:-------------------------------------------------------------------
913
- // Set "-[align]" to the first item in the group. (default: left)
914
- [
915
- ['-left', 'undo', 'redo']
916
- ['-right', 'bold', 'underline', 'italic', 'strike'],
917
- ]
918
-
919
- ------------------ex) Options in the button group(#):--------------------------------------------------------------
920
- // Set "#fix" - Fixed the order of buttons within a group in the "rtl" mode.
921
- [
922
- ['bold'],
923
- ['preview', 'print'],
924
- ['-left', '#fix', 'rtl_l', 'rtl_r']
925
- ]
926
-
927
- ----------------- ex) More button: --------------------------------------------------------------------------------
928
- // The more button is defined as a string starting with a colon.(":").
929
- // :Identifier - Title attribute - Button's innerHTML
930
- /**
931
- * "Identifier": The button's identifier. Please specify uniquely.
932
- * "Title attribute": Title attribute of the button to be displayed as a tooltip.
933
- * "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
938
- */
939
- [
940
- ['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
946
- ]
947
-
948
- ----------------- ex) Responsive setting: -------------------------------------------------------------------------
949
- // You can specify the arrangement of buttons according to the screen size in advance.
950
- // Responsive settings start with a percent sign.("%").
951
- // %510(Number based on "px")
952
- [
953
- // Default
954
- ['undo', 'redo'],
955
- ['font', 'fontSize', 'formatBlock'],
956
- ['paragraphStyle', 'blockquote'],
957
- ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
958
- ['fontColor', 'hiliteColor', 'textStyle'],
959
- ['removeFormat'],
960
- ['outdent', 'indent'],
961
- ['align', 'horizontalRule', 'list', 'lineHeight'],
962
- ['table', 'link', 'image', 'video', 'audio', 'math'],
963
- ['imageGallery'],
964
- ['fullScreen', 'showBlocks', 'codeView'],
965
- ['preview', 'print'],
966
- ['save', 'template'],
967
- ['-left', '#fix', 'dir_ltr', 'dir_rtl'],
968
- // (min-width:992px)
969
- ['%992', [
970
- ['undo', 'redo'],
971
- [':p-More Paragraph-default.more_paragraph', 'font', 'fontSize', 'formatBlock', 'paragraphStyle', 'blockquote'],
972
- ['bold', 'underline', 'italic', 'strike'],
973
- [':t-More Text-default.more_text', 'subscript', 'superscript', 'fontColor', 'hiliteColor', 'textStyle'],
974
- ['removeFormat'],
975
- ['outdent', 'indent'],
976
- ['align', 'horizontalRule', 'list', 'lineHeight'],
977
- ['-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']
980
- ]],
981
- // (min-width:768px)
982
- ['%768', [
983
- ['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'],
988
- ['-right', 'dir'],
989
- ['-right', ':i-More Misc-default.more_vertical', 'fullScreen', 'showBlocks', 'codeView', 'preview', 'print', 'save', 'template']
990
- ]]
991
- ]
992
-
993
- ```
994
-
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
40
 
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
41
  ## License
1591
42
  Suneditor may be freely distributed under the MIT license.