suneditor 2.47.10 → 2.47.11

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