suneditor 3.0.0-beta.3 → 3.0.0-beta.30
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.
- package/CONTRIBUTING.md +8 -8
- package/README.md +44 -49
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +95 -53
- package/src/assets/design/color.css +2 -2
- package/src/assets/design/size.css +2 -0
- package/src/assets/icons/defaultIcons.js +16 -1
- package/src/assets/suneditor-contents.css +9 -8
- package/src/assets/suneditor.css +29 -26
- package/src/core/{section → base}/actives.js +20 -12
- package/src/core/base/history.js +4 -4
- package/src/core/class/char.js +10 -10
- package/src/core/class/component.js +146 -57
- package/src/core/class/format.js +94 -2458
- package/src/core/class/html.js +187 -129
- package/src/core/class/inline.js +1853 -0
- package/src/core/class/listFormat.js +582 -0
- package/src/core/class/menu.js +14 -3
- package/src/core/class/nodeTransform.js +9 -14
- package/src/core/class/offset.js +162 -197
- package/src/core/class/selection.js +137 -34
- package/src/core/class/toolbar.js +73 -52
- package/src/core/class/ui.js +11 -11
- package/src/core/class/viewer.js +56 -55
- package/src/core/config/context.js +122 -0
- package/src/core/config/frameContext.js +204 -0
- package/src/core/config/options.js +639 -0
- package/src/core/editor.js +181 -108
- package/src/core/event/actions/index.js +229 -0
- package/src/core/event/effects/common.registry.js +60 -0
- package/src/core/event/effects/keydown.registry.js +551 -0
- package/src/core/event/effects/ruleHelpers.js +145 -0
- package/src/core/{base → event}/eventManager.js +119 -201
- package/src/core/event/executor.js +21 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
- package/src/core/event/handlers/handler_ww_input.js +77 -0
- package/src/core/event/handlers/handler_ww_key.js +228 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
- package/src/core/event/ports.js +211 -0
- package/src/core/event/reducers/keydown.reducer.js +89 -0
- package/src/core/event/rules/keydown.rule.arrow.js +54 -0
- package/src/core/event/rules/keydown.rule.backspace.js +202 -0
- package/src/core/event/rules/keydown.rule.delete.js +126 -0
- package/src/core/event/rules/keydown.rule.enter.js +144 -0
- package/src/core/event/rules/keydown.rule.tab.js +29 -0
- package/src/core/section/constructor.js +79 -388
- package/src/core/section/documentType.js +47 -26
- package/src/core/util/instanceCheck.js +59 -0
- package/src/editorInjector/_classes.js +4 -0
- package/src/editorInjector/_core.js +17 -7
- package/src/editorInjector/index.js +10 -2
- package/src/events.js +6 -0
- package/src/helper/clipboard.js +24 -10
- package/src/helper/converter.js +17 -12
- package/src/helper/dom/domCheck.js +22 -3
- package/src/helper/dom/domQuery.js +91 -45
- package/src/helper/dom/domUtils.js +93 -19
- package/src/helper/dom/index.js +4 -0
- package/src/helper/env.js +11 -7
- package/src/helper/keyCodeMap.js +4 -3
- package/src/langs/ckb.js +1 -1
- package/src/langs/cs.js +1 -1
- package/src/langs/da.js +1 -1
- package/src/langs/de.js +1 -1
- package/src/langs/en.js +1 -1
- package/src/langs/es.js +1 -1
- package/src/langs/fa.js +1 -1
- package/src/langs/fr.js +1 -1
- package/src/langs/he.js +1 -1
- package/src/langs/hu.js +1 -1
- package/src/langs/it.js +1 -1
- package/src/langs/ja.js +1 -1
- package/src/langs/km.js +1 -1
- package/src/langs/ko.js +1 -1
- package/src/langs/lv.js +1 -1
- package/src/langs/nl.js +1 -1
- package/src/langs/pl.js +1 -1
- package/src/langs/pt_br.js +10 -10
- package/src/langs/ro.js +1 -1
- package/src/langs/ru.js +1 -1
- package/src/langs/se.js +1 -1
- package/src/langs/tr.js +1 -1
- package/src/langs/uk.js +1 -1
- package/src/langs/ur.js +1 -1
- package/src/langs/zh_cn.js +1 -1
- package/src/modules/ApiManager.js +25 -18
- package/src/modules/Browser.js +52 -61
- package/src/modules/ColorPicker.js +37 -38
- package/src/modules/Controller.js +85 -79
- package/src/modules/Figure.js +275 -187
- package/src/modules/FileManager.js +86 -92
- package/src/modules/HueSlider.js +67 -35
- package/src/modules/Modal.js +84 -77
- package/src/modules/ModalAnchorEditor.js +62 -79
- package/src/modules/SelectMenu.js +89 -86
- package/src/plugins/browser/audioGallery.js +9 -5
- package/src/plugins/browser/fileBrowser.js +10 -6
- package/src/plugins/browser/fileGallery.js +9 -5
- package/src/plugins/browser/imageGallery.js +9 -5
- package/src/plugins/browser/videoGallery.js +11 -6
- package/src/plugins/command/blockquote.js +1 -0
- package/src/plugins/command/exportPDF.js +11 -8
- package/src/plugins/command/fileUpload.js +41 -29
- package/src/plugins/command/list_bulleted.js +2 -1
- package/src/plugins/command/list_numbered.js +2 -1
- package/src/plugins/dropdown/align.js +8 -2
- package/src/plugins/dropdown/backgroundColor.js +19 -11
- package/src/plugins/dropdown/font.js +15 -9
- package/src/plugins/dropdown/fontColor.js +19 -11
- package/src/plugins/dropdown/formatBlock.js +7 -2
- package/src/plugins/dropdown/hr.js +7 -3
- package/src/plugins/dropdown/layout.js +6 -2
- package/src/plugins/dropdown/lineHeight.js +8 -3
- package/src/plugins/dropdown/list.js +2 -1
- package/src/plugins/dropdown/paragraphStyle.js +15 -11
- package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
- package/src/plugins/dropdown/template.js +6 -2
- package/src/plugins/dropdown/textStyle.js +7 -3
- package/src/plugins/field/mention.js +33 -27
- package/src/plugins/input/fontSize.js +44 -37
- package/src/plugins/input/pageNavigator.js +3 -2
- package/src/plugins/modal/audio.js +90 -85
- package/src/plugins/modal/drawing.js +58 -66
- package/src/plugins/modal/embed.js +193 -180
- package/src/plugins/modal/image.js +441 -439
- package/src/plugins/modal/link.js +31 -8
- package/src/plugins/modal/math.js +23 -22
- package/src/plugins/modal/video.js +233 -230
- package/src/plugins/popup/anchor.js +24 -18
- package/src/suneditor.js +69 -24
- package/src/typedef.js +42 -19
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/core/class/char.d.ts +1 -1
- package/types/core/class/component.d.ts +29 -7
- package/types/core/class/format.d.ts +4 -354
- package/types/core/class/html.d.ts +13 -4
- package/types/core/class/inline.d.ts +263 -0
- package/types/core/class/listFormat.d.ts +135 -0
- package/types/core/class/menu.d.ts +10 -2
- package/types/core/class/offset.d.ts +24 -26
- package/types/core/class/selection.d.ts +2 -0
- package/types/core/class/toolbar.d.ts +24 -11
- package/types/core/class/ui.d.ts +1 -1
- package/types/core/class/viewer.d.ts +1 -1
- package/types/core/config/context.d.ts +157 -0
- package/types/core/config/frameContext.d.ts +367 -0
- package/types/core/config/options.d.ts +1119 -0
- package/types/core/editor.d.ts +101 -66
- package/types/core/event/actions/index.d.ts +47 -0
- package/types/core/event/effects/common.registry.d.ts +50 -0
- package/types/core/event/effects/keydown.registry.d.ts +73 -0
- package/types/core/event/effects/ruleHelpers.d.ts +31 -0
- package/types/core/{base → event}/eventManager.d.ts +15 -46
- package/types/core/event/executor.d.ts +6 -0
- package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
- package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
- package/types/core/event/ports.d.ts +255 -0
- package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
- package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
- package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
- package/types/core/section/constructor.d.ts +101 -631
- package/types/core/section/documentType.d.ts +14 -4
- package/types/core/util/instanceCheck.d.ts +50 -0
- package/types/editorInjector/_classes.d.ts +4 -0
- package/types/editorInjector/_core.d.ts +17 -7
- package/types/editorInjector/index.d.ts +10 -2
- package/types/events.d.ts +1 -0
- package/types/helper/clipboard.d.ts +2 -2
- package/types/helper/converter.d.ts +6 -9
- package/types/helper/dom/domCheck.d.ts +7 -0
- package/types/helper/dom/domQuery.d.ts +19 -8
- package/types/helper/dom/domUtils.d.ts +24 -2
- package/types/helper/dom/index.d.ts +86 -1
- package/types/helper/env.d.ts +6 -1
- package/types/helper/index.d.ts +7 -1
- package/types/helper/keyCodeMap.d.ts +3 -3
- package/types/index.d.ts +23 -117
- package/types/langs/index.d.ts +2 -2
- package/types/modules/ApiManager.d.ts +1 -8
- package/types/modules/Browser.d.ts +4 -62
- package/types/modules/ColorPicker.d.ts +4 -21
- package/types/modules/Controller.d.ts +8 -64
- package/types/modules/Figure.d.ts +54 -50
- package/types/modules/FileManager.d.ts +1 -13
- package/types/modules/HueSlider.d.ts +13 -3
- package/types/modules/Modal.d.ts +0 -43
- package/types/modules/ModalAnchorEditor.d.ts +0 -73
- package/types/modules/SelectMenu.d.ts +0 -85
- package/types/modules/index.d.ts +3 -3
- package/types/plugins/browser/audioGallery.d.ts +29 -18
- package/types/plugins/browser/fileBrowser.d.ts +38 -27
- package/types/plugins/browser/fileGallery.d.ts +29 -18
- package/types/plugins/browser/imageGallery.d.ts +24 -16
- package/types/plugins/browser/videoGallery.d.ts +29 -18
- package/types/plugins/command/blockquote.d.ts +1 -0
- package/types/plugins/command/exportPDF.d.ts +18 -18
- package/types/plugins/command/fileUpload.d.ts +65 -45
- package/types/plugins/command/list_bulleted.d.ts +1 -0
- package/types/plugins/command/list_numbered.d.ts +1 -0
- package/types/plugins/dropdown/align.d.ts +13 -8
- package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
- package/types/plugins/dropdown/font.d.ts +13 -12
- package/types/plugins/dropdown/fontColor.d.ts +30 -19
- package/types/plugins/dropdown/formatBlock.d.ts +13 -8
- package/types/plugins/dropdown/hr.d.ts +15 -11
- package/types/plugins/dropdown/layout.d.ts +15 -11
- package/types/plugins/dropdown/lineHeight.d.ts +16 -11
- package/types/plugins/dropdown/list.d.ts +1 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
- package/types/plugins/dropdown/table/index.d.ts +582 -0
- package/types/plugins/dropdown/table.d.ts +41 -86
- package/types/plugins/dropdown/template.d.ts +15 -11
- package/types/plugins/dropdown/textStyle.d.ts +19 -11
- package/types/plugins/field/mention.d.ts +58 -56
- package/types/plugins/index.d.ts +38 -38
- package/types/plugins/input/fontSize.d.ts +46 -50
- package/types/plugins/modal/audio.d.ts +26 -56
- package/types/plugins/modal/drawing.d.ts +0 -85
- package/types/plugins/modal/embed.d.ts +15 -79
- package/types/plugins/modal/image.d.ts +24 -136
- package/types/plugins/modal/link.d.ts +34 -15
- package/types/plugins/modal/math.d.ts +0 -16
- package/types/plugins/modal/video.d.ts +17 -86
- package/types/plugins/popup/anchor.d.ts +1 -8
- package/types/suneditor.d.ts +70 -19
- package/types/typedef.d.ts +60 -46
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
- package/src/core/section/context.js +0 -102
- package/types/core/section/context.d.ts +0 -45
- package/types/langs/_Lang.d.ts +0 -194
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
- /package/types/core/{section → base}/actives.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.d.ts +0 -0
|
@@ -1,347 +1,39 @@
|
|
|
1
1
|
import _icons from '../../assets/icons/defaultIcons';
|
|
2
2
|
import _defaultLang from '../../langs/en';
|
|
3
|
-
import { CreateContext
|
|
3
|
+
import { CreateContext } from '../config/context';
|
|
4
|
+
import { CreateFrameContext } from '../config/frameContext';
|
|
4
5
|
import { dom, numbers, converter, env } from '../../helper';
|
|
6
|
+
import { DEFAULTS } from '../config/options';
|
|
5
7
|
|
|
6
8
|
const _d = env._d;
|
|
7
|
-
const DEFAULT_BUTTON_LIST = [
|
|
8
|
-
['undo', 'redo'],
|
|
9
|
-
'|',
|
|
10
|
-
['bold', 'underline', 'italic', 'strike', '|', 'subscript', 'superscript'],
|
|
11
|
-
'|',
|
|
12
|
-
['removeFormat'],
|
|
13
|
-
'|',
|
|
14
|
-
['outdent', 'indent'],
|
|
15
|
-
'|',
|
|
16
|
-
['fullScreen', 'showBlocks', 'codeView'],
|
|
17
|
-
'|',
|
|
18
|
-
['preview', 'print']
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const REQUIRED_FORMAT_LINE = 'div';
|
|
22
|
-
const REQUIRED_ELEMENT_WHITELIST = 'br|div';
|
|
23
|
-
const DEFAULT_ELEMENT_WHITELIST =
|
|
24
|
-
'p|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|thead|tbody|tr|th|td|caption|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary';
|
|
25
|
-
const DEFAULT_TEXT_STYLE_TAGS = 'strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code|summary';
|
|
26
|
-
|
|
27
|
-
/* scopeSelectionTags */
|
|
28
|
-
const DEFAULT_SCOPE_SELECTION_TAGS = 'td|table|li|ol|ul|pre|figcaption|blockquote|dl|dt|dd';
|
|
29
|
-
|
|
30
|
-
const _video_audio_attr = '|controls|autoplay|loop|muted|poster|preload|playsinline|volume|crossorigin|disableRemotePlayback|controlsList';
|
|
31
|
-
const _iframe_attr = '|allowfullscreen|sandbox|loading|allow|referrerpolicy|frameborder|scrolling';
|
|
32
|
-
const DEFAULT_ATTRIBUTE_WHITELIST = 'contenteditable|target|href|title|download|rel|src|alt|class|type|colspan|rowspan' + _video_audio_attr + _iframe_attr;
|
|
33
|
-
|
|
34
|
-
const DEFAULT_FORMAT_LINE = 'P|H[1-6]|LI|TH|TD|DETAILS';
|
|
35
|
-
const DEFAULT_FORMAT_BR_LINE = 'PRE';
|
|
36
|
-
const DEFAULT_FORMAT_CLOSURE_BR_LINE = '';
|
|
37
|
-
const DEFAULT_FORMAT_BLOCK = 'BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|CAPTION|DETAILS';
|
|
38
|
-
const DEFAULT_FORMAT_CLOSURE_BLOCK = 'TH|TD';
|
|
39
|
-
|
|
40
|
-
const DEFAULT_ALLOWED_EMPTY_NODE_LIST = '.se-component, pre, blockquote, hr, li, table, img, iframe, video, audio, canvas, details';
|
|
41
|
-
|
|
42
|
-
const DEFAULT_SIZE_UNITS = ['px', 'pt', 'em', 'rem'];
|
|
43
|
-
|
|
44
|
-
const DEFAULT_CLASS_NAME = '^__se__|^se-|^katex|^MathJax';
|
|
45
|
-
const DEFAULT_CLASS_MJX = 'mjx-container|mjx-math|mjx-mrow|mjx-mi|mjx-mo|mjx-mn|mjx-msup|mjx-mfrac|mjx-munderover';
|
|
46
|
-
const DEFAULT_EXTRA_TAG_MAP = { script: false, style: false, meta: false, link: false, '[a-z]+:[a-z]+': false };
|
|
47
|
-
|
|
48
|
-
const DEFAULT_TAG_STYLES = {
|
|
49
|
-
'table|th|td': 'border|border-[a-z]+|background-color|text-align|float|font-weight|text-decoration|font-style',
|
|
50
|
-
'ol|ul': 'list-style-type'
|
|
51
|
-
};
|
|
52
|
-
const DEFAULT_TEXT_STYLES = 'font-family|font-size|color|background-color';
|
|
53
|
-
const DEFAULT_LINE_STYLES = 'text-align|margin-left|margin-right|line-height';
|
|
54
|
-
const DEFAULT_CONTENT_STYLES =
|
|
55
|
-
'background|background-clip|background-color|' +
|
|
56
|
-
'border|border-bottom|border-collapse|border-color|border-image|border-left-width|border-radius|border-right-width|border-spacing|border-style|border-top|border-width|' +
|
|
57
|
-
'box-shadow|box-sizing|' +
|
|
58
|
-
'caption-side|color|content|' +
|
|
59
|
-
'direction|display|' +
|
|
60
|
-
'float|font|font-family|font-size|font-style|font-weight|' +
|
|
61
|
-
'height|' +
|
|
62
|
-
'left|letter-spacing|line-height|list-style-position|list-style-type|' +
|
|
63
|
-
'margin|margin-block-end|margin-block-start|margin-bottom|margin-inline-end|margin-inline-start|margin-left|margin-right|margin-top|max-width|min-width|' +
|
|
64
|
-
'outline|overflow|' +
|
|
65
|
-
'position|padding|padding-bottom|padding-inline-start|padding-left|padding-right|padding-top|' +
|
|
66
|
-
'page-break-before|page-break-after|page-break-inside|' +
|
|
67
|
-
'rotate|rotateX|rotateY|' +
|
|
68
|
-
'table-layout|text-align|text-decoration|text-shadow|text-transform|top|' +
|
|
69
|
-
'text-indent|text-rendering|' +
|
|
70
|
-
'vertical-align|visibility|' +
|
|
71
|
-
'white-space|width|word-break|word-wrap';
|
|
72
|
-
|
|
73
|
-
const RETAIN_STYLE_MODE = ['repeat', 'always', 'none'];
|
|
74
9
|
|
|
75
10
|
/**
|
|
76
|
-
* @typedef {
|
|
77
|
-
* @property {string} [value=""] - Initial value for the editor.
|
|
78
|
-
* @property {string} [placeholder=""] - Placeholder text.
|
|
79
|
-
* @property {Object<string, string>} [editableFrameAttributes={}] - Attributes for the editable frame[.sun-editor-editable]. (e.g. [key]: value)
|
|
80
|
-
* @property {string} [width="100%"] - Width for the editor.
|
|
81
|
-
* @property {string} [minWidth=""] - Min width for the editor.
|
|
82
|
-
* @property {string} [maxWidth=""] - Max width for the editor.
|
|
83
|
-
* @property {string} [height="auto"] - Height for the editor.
|
|
84
|
-
* @property {string} [minHeight=""] - Min height for the editor.
|
|
85
|
-
* @property {string} [maxHeight=""] - Max height for the editor.
|
|
86
|
-
* @property {string} [editorStyle=""] - Style string of the top frame of the editor. (e.g. "border: 1px solid #ccc;").
|
|
87
|
-
* @property {boolean} [iframe=false] - Content will be placed in an iframe and isolated from the rest of the page.
|
|
88
|
-
* @property {boolean} [iframe_fullPage=false] - Allows the usage of HTML, HEAD, BODY tags and DOCTYPE declaration on the "iframe".
|
|
89
|
-
* @property {Object<string, string>} [iframe_attributes={}] - Attributes of the "iframe". (e.g. {'scrolling': 'no'})
|
|
90
|
-
* @property {string} [iframe_cssFileName="suneditor"] - Name or Array of the CSS file to apply inside the iframe.
|
|
91
|
-
* - You can also use regular expressions.
|
|
92
|
-
* - Applied by searching by filename in the link tag of document,
|
|
93
|
-
* - or put the URL value (".css" can be omitted).
|
|
94
|
-
* @property {boolean} [statusbar=true] - Enables the status bar.
|
|
95
|
-
* @property {boolean} [statusbar_showPathLabel=true] - Displays the current node structure to status bar.
|
|
96
|
-
* @property {boolean} [statusbar_resizeEnable=true] - Enables resize function of bottom status bar
|
|
97
|
-
* @property {boolean} [charCounter=false] - Shows the number of characters in the editor.
|
|
98
|
-
* - If the maxCharCount option has a value, it becomes true.
|
|
99
|
-
* @property {number} [charCounter_max] - The maximum number of characters allowed to be inserted into the editor.
|
|
100
|
-
* @property {string} [charCounter_label] - Text to be displayed in the "charCounter" area of the bottom bar. (e.g. "Characters : 20/200")
|
|
101
|
-
* @property {"char"|"byte"|"byte-html"} [charCounter_type="char"] - Defines the calculation method of the "charCounter" option.
|
|
102
|
-
* - 'char': Characters length.
|
|
103
|
-
* - 'byte': Binary data size of characters.
|
|
104
|
-
* - 'byte-html': Binary data size of the full HTML string.
|
|
11
|
+
* @typedef {import('../config/options').AllBaseOptions} AllBaseOptions_constructor
|
|
105
12
|
*/
|
|
106
13
|
|
|
107
14
|
/**
|
|
108
|
-
* @typedef {Object}
|
|
109
|
-
* @property {
|
|
110
|
-
* @property {
|
|
111
|
-
* @property {
|
|
112
|
-
* @property {
|
|
113
|
-
* @property {
|
|
114
|
-
* @property {
|
|
115
|
-
* @property {string}
|
|
116
|
-
* @property {string}
|
|
117
|
-
* @property {
|
|
118
|
-
* @property {
|
|
119
|
-
* @property {string}
|
|
120
|
-
* @property {
|
|
121
|
-
* @property {
|
|
122
|
-
* @property {
|
|
123
|
-
* @property {boolean} [tabDisable=false] - Disables tab key input.
|
|
124
|
-
* @property {boolean} [autoLinkify] - Automatically converts URLs into hyperlinks. ("Link" plugin required)
|
|
125
|
-
* @property {Array<string>} [autoStyleify=["bold", "underline", "italic", "strike"]] - Styles applied automatically on text input.
|
|
126
|
-
* @property {Object<string, string|number>} [scrollToOptions={behavior: "auto", block: "nearest"}] - Configuration for scroll behavior when navigating editor content.
|
|
127
|
-
* @property {Object<string, string|number>} [componentScrollToOptions={behavior: "smooth", block: "center"}] - Configuration for scroll behavior when navigating components.
|
|
128
|
-
* @property {"repeat"|"always"|"none"} [retainStyleMode="repeat"] - This option determines how inline elements (such as <span>, <strong>, etc.) are handled when deleting text.
|
|
129
|
-
* - "repeat": Inline styles are retained unless the backspace key is repeatedly pressed. If the user continuously presses backspace, the styles will eventually be removed.
|
|
130
|
-
* - "none": Inline styles are not retained at all. When deleting text, the associated inline elements are immediately removed along with it.
|
|
131
|
-
* - "always": Inline styles persist indefinitely unless explicitly removed. Even if all text inside an inline element is deleted, the element itself remains until manually removed.
|
|
132
|
-
* @property {Object<string, boolean>} [allowedExtraTags={script: false, style: false, meta: false, link: false, "[a-z]+:[a-z]+": false}] - Specifies extra allowed or disallowed tags.
|
|
133
|
-
* @property {Object<string, (...args: *) => *>} [events={}] - Custom event handlers.
|
|
134
|
-
* @property {string} [__textStyleTags="strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code|summary"] - The basic tags that serves as the base for "textStyleTags"
|
|
135
|
-
* @property {string} [textStyleTags="strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code|summary"] - Additional text style tags.
|
|
136
|
-
* @property {Object<string, string>} [convertTextTags={bold: "strong", underline: "u", italic: "em", strike: "del", subscript: "sub", superscript: "sup"}] - Maps text styles to specific HTML tags.
|
|
137
|
-
* @property {Object<string, string>} [__tagStyles={'table|th|td': 'border|border-[a-z]+|background-color|text-align|float|font-weight|text-decoration|font-style', 'ol|ul': 'list-style-type'}] - The basic tags that serves as the base for "tagStyles"
|
|
138
|
-
* @property {Object<string, string>} [tagStyles={}] - Specifies allowed styles for HTML tags.
|
|
139
|
-
* @property {string} [spanStyles="font-family|font-size|color|background-color"] - Specifies allowed styles for the "span" tag.
|
|
140
|
-
* @property {string} [lineStyles="text-align|margin-left|margin-right|line-height"] - Specifies allowed styles for the "line" element (p..).
|
|
141
|
-
* @property {string} [textDirection="ltr"] - Text direction: "ltr" or "rtl".
|
|
142
|
-
* @property {Array<string>} [reverseButtons=['indent-outdent']] - An array of command pairs whose shortcut icons should be opposite each other, depending on the "textDirection" mode.
|
|
143
|
-
* @property {number} [historyStackDelayTime=400] - Delay time for history stack updates (ms).
|
|
144
|
-
* @property {string} [lineAttrReset=""] - Line properties that should be reset when changing lines (e.g. "id|name").
|
|
145
|
-
* @property {string} [printClass=""] - Class name for printing.
|
|
146
|
-
* @property {string} [defaultLine="p"] - Default line element when inserting new lines.
|
|
147
|
-
* @property {"line"|"br"} [defaultLineBreakFormat="line"] - Specifies the default line break format.
|
|
148
|
-
* - [Recommended] "line" : is a line break that is divided into general tags.
|
|
149
|
-
* - [Not recommended] "br" : Line breaks are treated as <br> on the same line. (like shift+enter)
|
|
150
|
-
* - Line breaks are handled as <br> within "line".
|
|
151
|
-
* - You can create a new "line" by entering a line break twice in a row.
|
|
152
|
-
* - Formats that include "line", such as "Quote", still operate on a "line" basis.
|
|
153
|
-
* - ● suneditor processes work in "line" units.
|
|
154
|
-
* - ● When set to "br", performance may decrease when editing a lot of data.
|
|
155
|
-
* @property {Array<string>} [scopeSelectionTags=["td", "table", "li", "ol", "ul", "pre", "figcaption", "blockquote", "dl", "dt", "dd"]] - Tags treated as whole units when selecting all content.
|
|
156
|
-
* @property {string} [__defaultElementWhitelist="br|div"] - Default allowed HTML elements. The default values are maintained.
|
|
157
|
-
* @property {string} [elementWhitelist=""] - Allowed HTML elements. Delimiter: "|" (e.g. "p|div", "*").
|
|
158
|
-
* @property {string} [elementBlacklist=""] - Disallowed HTML elements. Delimiter: "|" (e.g. "script|style").
|
|
159
|
-
* @property {string} [__defaultAttributeWhitelist] - Allowed attributes. Delimiter: "|" (e.g. "href|target").
|
|
160
|
-
* @property {Object<string, string>} [attributeWhitelist=""] - Allowed attributes. (e.g. {a: "href|target", img: "src|alt"}).
|
|
161
|
-
* @property {Object<string, string>} [attributeBlacklist=""] - Disallowed attributes. (e.g. {a: "href|target", img: "src|alt"}).
|
|
162
|
-
* @property {string} [__defaultFormatLine="P|DIV|H[1-6]|LI|TH|TD|DETAILS"] - Overrides the editor's default "line" element.
|
|
163
|
-
* @property {string} [formatLine="P|DIV|H[1-6]|LI|TH|TD|DETAILS"] - Specifies the editor's "line" elements.
|
|
164
|
-
* - (P, DIV, H[1-6], PRE, LI | class="__se__format__line_xxx")
|
|
165
|
-
* - "line" element also contain "brLine" element
|
|
166
|
-
* @property {string} [__defaultFormatBrLine="PRE"] - Overrides the editor's default "brLine" element.
|
|
167
|
-
* @property {string} [formatBrLine="PRE"] - Specifies the editor's "brLine" elements. (e.g. "PRE").
|
|
168
|
-
* - (PRE | class="__se__format__br_line_xxx")
|
|
169
|
-
* - "brLine" elements is included in the "line" element.
|
|
170
|
-
* - "brLine" elements's line break is "BR" tag.
|
|
171
|
-
* ※ Entering the Enter key in the space on the last line ends "brLine" and appends "line".
|
|
172
|
-
* @property {string} [__defaultFormatClosureBrLine=""] - Overrides the editor's default "closureBrLine" element.
|
|
173
|
-
* @property {string} [formatClosureBrLine=""] - Specifies the editor's "closureBrLine" elements.
|
|
174
|
-
* - (class="__se__format__br_line__closure_xxx")
|
|
175
|
-
* - "closureBrLine" elements is included in the "brLine".
|
|
176
|
-
* - "closureBrLine" elements's line break is "BR" tag.
|
|
177
|
-
* - ※ You cannot exit this format with the Enter key or Backspace key.
|
|
178
|
-
* - ※ Use it only in special cases. ([ex] format of table cells)
|
|
179
|
-
* @property {string} [__defaultFormatBlock="BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|CAPTION|DETAILS"] - Overrides the editor's default "block" element.
|
|
180
|
-
* @property {string} [formatBlock="BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|CAPTION|DETAILS"] - Specifies the editor's "block" elements.
|
|
181
|
-
* - (BLOCKQUOTE, OL, UL, FIGCAPTION, TABLE, THEAD, TBODY, TR, TH, TD | class="__se__format__block_xxx")
|
|
182
|
-
* - "block" is wrap the "line" and "component"
|
|
183
|
-
* @property {string} [__defaultFormatClosureBlock="TH|TD"] - Overrides the editor's default "closureBlock" element.
|
|
184
|
-
* @property {string} [formatClosureBlock="TH|TD"] - Specifies the editor's "closureBlock" elements.
|
|
185
|
-
* - (TH, TD | class="__se__format__block_closure_xxx")
|
|
186
|
-
* - "closureBlock" elements is included in the "block".
|
|
187
|
-
* - "closureBlock" element is wrap the "line" and "component"
|
|
188
|
-
* - ※ You cannot exit this format with the Enter key or Backspace key.
|
|
189
|
-
* - ※ Use it only in special cases. ([ex] format of table cells)
|
|
190
|
-
* @property {string} [allowedEmptyTags=".se-component, pre, blockquote, hr, li, table, img, iframe, video, audio, canvas, details"] - Allowed empty tags.
|
|
191
|
-
* @property {number|string} [toolbar_width="auto"] - Toolbar width.
|
|
192
|
-
* @property {Element|string} [toolbar_container] - Container element for the toolbar.
|
|
193
|
-
* @property {number} [toolbar_sticky=0] - Enables sticky toolbar with optional offset.
|
|
194
|
-
* @property {boolean} [toolbar_hide=false] - Hides toolbar initially.
|
|
195
|
-
* @property {Object} [subToolbar] - Sub-toolbar configuration.
|
|
196
|
-
* @property {Array<Array<string>>} [subToolbar.buttonList] - List of Sub-toolbar buttons, grouped by sub-arrays.
|
|
197
|
-
* @property {"balloon"|"balloon-always"} [subToolbar.mode="balloon"] - Sub-toolbar mode: "balloon", "balloon-always".
|
|
198
|
-
* @property {number|string} [subToolbar.width="auto"] - Sub-toolbar width.
|
|
199
|
-
* @property {Element|string} [statusbar_container] - Container element for the status bar.
|
|
200
|
-
* @property {boolean} [shortcutsHint=true] - Displays shortcut hints in tooltips.
|
|
201
|
-
* @property {boolean} [shortcutsDisable=false] - Disables keyboard shortcuts.
|
|
202
|
-
* @property {Object<string, Array<string>>} [shortcuts] - Custom keyboard shortcuts.
|
|
203
|
-
* @property {number} [fullScreenOffset=0] - Offset applied when entering fullscreen mode.
|
|
204
|
-
* @property {string} [previewTemplate] - Custom template for preview mode.
|
|
205
|
-
* @property {string} [printTemplate] - Custom template for print mode.
|
|
206
|
-
* @property {boolean} [componentAutoSelect=false] - Enables automatic selection of inserted components.
|
|
207
|
-
* @property {string} [defaultUrlProtocol] - Default URL protocol for links.
|
|
208
|
-
* @property {string} [allUsedStyles] - Specifies additional styles to the list of allowed styles. Delimiter: "|" (e.g. "color|background-color").
|
|
209
|
-
* @property {Object<"copy", number>} [toastMessageTime] - {"copy": 1500} - Duration for displaying toast messages.
|
|
210
|
-
* @property {Object<string, string>} [icons] - Overrides the default icons.
|
|
211
|
-
* @property {string} [freeCodeViewMode=false] - Enables free code view mode.
|
|
212
|
-
* @property {boolean} [__lineFormatFilter=true] - Line format filter configuration.
|
|
213
|
-
* @property {boolean} [__pluginRetainFilter=true] - Plugin retain filter configuration.
|
|
214
|
-
* @property {Array<string>} [__listCommonStyle=["fontSize", "color", "fontFamily", "fontWeight", "fontStyle"]] - Defines the list of styles that are applied directly to the `<li>` element
|
|
215
|
-
* - when a text style is applied to the entire list item.
|
|
216
|
-
* - For example, when changing the font size or color of a list item (`<li>`),
|
|
217
|
-
* - these styles will be applied to the `<li>` tag instead of wrapping the content inside additional tags.
|
|
218
|
-
* @property {Object<string, *>} [externalLibs] - External libraries like CodeMirror or MathJax.
|
|
219
|
-
*
|
|
220
|
-
* @property {Object<string, *>} [Dynamic_pluginOptions] - Dynamic plugin options, where the key is the plugin name and the value is its configuration.
|
|
15
|
+
* @typedef {Object} ConstructorReturnType
|
|
16
|
+
* @property {__se__Context} context - Editor context object
|
|
17
|
+
* @property {HTMLElement} carrierWrapper - Carrier wrapper element
|
|
18
|
+
* @property {__se__BaseOptions} options - Processed editor options (Map)
|
|
19
|
+
* @property {Object<string, *>} plugins - Loaded plugins
|
|
20
|
+
* @property {Object<string, string>} icons - Icon set
|
|
21
|
+
* @property {Object<string, string>} lang - Language pack
|
|
22
|
+
* @property {string|null} value - Initial editor value
|
|
23
|
+
* @property {string|null} rootId - Root frame ID
|
|
24
|
+
* @property {Array<string|null>} rootKeys - Array of frame keys
|
|
25
|
+
* @property {Map<string|null, ReturnType<import('../config/frameContext').CreateFrameContext>>} frameRoots - Map of frame contexts
|
|
26
|
+
* @property {Object<string, Array<HTMLElement>>} pluginCallButtons - Plugin toolbar buttons
|
|
27
|
+
* @property {Array<HTMLElement>} responsiveButtons - Responsive toolbar buttons
|
|
28
|
+
* @property {Object<string, Array<HTMLElement>>|[]} pluginCallButtons_sub - Sub-toolbar plugin buttons
|
|
29
|
+
* @property {Array<HTMLElement>} responsiveButtons_sub - Sub-toolbar responsive buttons
|
|
221
30
|
*/
|
|
222
31
|
|
|
223
|
-
/**
|
|
224
|
-
* @typedef {EditorBaseOptions & EditorFrameOptions} EditorInitOptions
|
|
225
|
-
*/
|
|
226
|
-
|
|
227
|
-
/** ------------- [OPTIONS FRAG] ------------- */
|
|
228
|
-
/**
|
|
229
|
-
* @description For all EditorInitOptions keys, only boolean | null values are allowed.
|
|
230
|
-
* - 'fixed' → Immutable / null → Resettable.
|
|
231
|
-
* @type {Partial<Record<keyof EditorInitOptions, "fixed" | true>>}
|
|
232
|
-
*/
|
|
233
|
-
export const OPTION_FRAME_FIXED_FLAG = {
|
|
234
|
-
value: 'fixed',
|
|
235
|
-
placeholder: true,
|
|
236
|
-
editableFrameAttributes: true,
|
|
237
|
-
width: true,
|
|
238
|
-
minWidth: true,
|
|
239
|
-
maxWidth: true,
|
|
240
|
-
height: true,
|
|
241
|
-
minHeight: true,
|
|
242
|
-
maxHeight: true,
|
|
243
|
-
editorStyle: true,
|
|
244
|
-
iframe: 'fixed',
|
|
245
|
-
iframe_fullPage: 'fixed',
|
|
246
|
-
iframe_attributes: true,
|
|
247
|
-
iframe_cssFileName: true,
|
|
248
|
-
statusbar: true,
|
|
249
|
-
statusbar_showPathLabel: true,
|
|
250
|
-
statusbar_resizeEnable: 'fixed',
|
|
251
|
-
charCounter: true,
|
|
252
|
-
charCounter_max: true,
|
|
253
|
-
charCounter_label: true,
|
|
254
|
-
charCounter_type: true
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* @description For all EditorInitOptions keys, only boolean | null values are allowed.
|
|
258
|
-
* - 'fixed' → Immutable / null → Resettable.
|
|
259
|
-
* @type {Partial<Record<keyof EditorInitOptions, "fixed" | true>>}
|
|
260
|
-
*/
|
|
261
|
-
export const OPTION_FIXED_FLAG = {
|
|
262
|
-
plugins: 'fixed',
|
|
263
|
-
excludedPlugins: 'fixed',
|
|
264
|
-
buttonList: 'fixed',
|
|
265
|
-
v2Migration: 'fixed',
|
|
266
|
-
strictMode: 'fixed',
|
|
267
|
-
mode: 'fixed',
|
|
268
|
-
type: 'fixed',
|
|
269
|
-
theme: true,
|
|
270
|
-
lang: 'fixed',
|
|
271
|
-
fontSizeUnits: 'fixed',
|
|
272
|
-
allowedClassName: 'fixed',
|
|
273
|
-
closeModalOutsideClick: 'fixed',
|
|
274
|
-
copyFormatKeepOn: true,
|
|
275
|
-
syncTabIndent: true,
|
|
276
|
-
tabDisable: true,
|
|
277
|
-
autoLinkify: true,
|
|
278
|
-
autoStyleify: true,
|
|
279
|
-
scrollToOptions: true,
|
|
280
|
-
componentScrollToOptions: true,
|
|
281
|
-
retainStyleMode: true,
|
|
282
|
-
allowedExtraTags: 'fixed',
|
|
283
|
-
events: true,
|
|
284
|
-
__textStyleTags: 'fixed',
|
|
285
|
-
textStyleTags: 'fixed',
|
|
286
|
-
convertTextTags: 'fixed',
|
|
287
|
-
__tagStyles: 'fixed',
|
|
288
|
-
tagStyles: 'fixed',
|
|
289
|
-
spanStyles: 'fixed',
|
|
290
|
-
lineStyles: 'fixed',
|
|
291
|
-
textDirection: true,
|
|
292
|
-
reverseButtons: 'fixed',
|
|
293
|
-
historyStackDelayTime: true,
|
|
294
|
-
lineAttrReset: true,
|
|
295
|
-
printClass: true,
|
|
296
|
-
defaultLine: 'fixed',
|
|
297
|
-
defaultLineBreakFormat: true,
|
|
298
|
-
scopeSelectionTags: true,
|
|
299
|
-
__defaultElementWhitelist: 'fixed',
|
|
300
|
-
elementWhitelist: 'fixed',
|
|
301
|
-
elementBlacklist: 'fixed',
|
|
302
|
-
__defaultAttributeWhitelist: 'fixed',
|
|
303
|
-
attributeWhitelist: 'fixed',
|
|
304
|
-
attributeBlacklist: 'fixed',
|
|
305
|
-
__defaultFormatLine: 'fixed',
|
|
306
|
-
formatLine: 'fixed',
|
|
307
|
-
__defaultFormatBrLine: 'fixed',
|
|
308
|
-
formatBrLine: 'fixed',
|
|
309
|
-
__defaultFormatClosureBrLine: 'fixed',
|
|
310
|
-
formatClosureBrLine: 'fixed',
|
|
311
|
-
__defaultFormatBlock: 'fixed',
|
|
312
|
-
formatBlock: 'fixed',
|
|
313
|
-
__defaultFormatClosureBlock: 'fixed',
|
|
314
|
-
formatClosureBlock: 'fixed',
|
|
315
|
-
allowedEmptyTags: true,
|
|
316
|
-
toolbar_width: true,
|
|
317
|
-
toolbar_container: 'fixed',
|
|
318
|
-
toolbar_sticky: true,
|
|
319
|
-
toolbar_hide: true,
|
|
320
|
-
subToolbar: 'fixed',
|
|
321
|
-
statusbar_container: 'fixed',
|
|
322
|
-
shortcutsHint: true,
|
|
323
|
-
shortcutsDisable: 'fixed',
|
|
324
|
-
shortcuts: 'fixed',
|
|
325
|
-
fullScreenOffset: true,
|
|
326
|
-
previewTemplate: true,
|
|
327
|
-
printTemplate: true,
|
|
328
|
-
componentAutoSelect: true,
|
|
329
|
-
defaultUrlProtocol: true,
|
|
330
|
-
allUsedStyles: 'fixed',
|
|
331
|
-
toastMessageTime: true,
|
|
332
|
-
icons: 'fixed',
|
|
333
|
-
freeCodeViewMode: true,
|
|
334
|
-
__lineFormatFilter: true,
|
|
335
|
-
__pluginRetainFilter: true,
|
|
336
|
-
__listCommonStyle: 'fixed',
|
|
337
|
-
externalLibs: 'fixed'
|
|
338
|
-
};
|
|
339
|
-
|
|
340
32
|
/**
|
|
341
33
|
* @description Creates a new SunEditor instance with specified options.
|
|
342
|
-
* @param {Array<{target: Element, key: *, options:
|
|
343
|
-
* @param {
|
|
344
|
-
* @returns {
|
|
34
|
+
* @param {Array<{target: Element, key: *, options: __se__EditorFrameOptions}>} editorTargets - Target element or multi-root object.
|
|
35
|
+
* @param {__se__EditorOptions} options - Configuration options for the editor.
|
|
36
|
+
* @returns {ConstructorReturnType} - SunEditor instance with context, options, and DOM elements.
|
|
345
37
|
*/
|
|
346
38
|
function Constructor(editorTargets, options) {
|
|
347
39
|
if (typeof options !== 'object') options = {};
|
|
@@ -431,7 +123,7 @@ function Constructor(editorTargets, options) {
|
|
|
431
123
|
subbar.style.visibility = 'hidden';
|
|
432
124
|
// subbar mode must be balloon-*
|
|
433
125
|
subbar.className += ' se-toolbar-balloon se-toolbar-sub';
|
|
434
|
-
subbar.style.width = o.get('
|
|
126
|
+
subbar.style.width = o.get('toolbar_sub_width');
|
|
435
127
|
subbar.appendChild(dom.utils.createElement('DIV', { class: 'se-arrow' }));
|
|
436
128
|
}
|
|
437
129
|
|
|
@@ -569,7 +261,7 @@ function Constructor(editorTargets, options) {
|
|
|
569
261
|
* @param {Element|null} button Command button element
|
|
570
262
|
* @param {Map<string, *>} keyMap Map to store shortcut key info
|
|
571
263
|
* @param {Array} rc "_reverseCommandArray" option
|
|
572
|
-
* @param {
|
|
264
|
+
* @param {Set} reverseKeys Reverse key array
|
|
573
265
|
*/
|
|
574
266
|
export function CreateShortcuts(command, button, values, keyMap, rc, reverseKeys) {
|
|
575
267
|
if (!values || values.length < 2) return;
|
|
@@ -580,7 +272,7 @@ export function CreateShortcuts(command, button, values, keyMap, rc, reverseKeys
|
|
|
580
272
|
a = values[i].split('+');
|
|
581
273
|
|
|
582
274
|
plugin = null;
|
|
583
|
-
method = a
|
|
275
|
+
method = a.at(-1).trim?.();
|
|
584
276
|
if (method.startsWith('~')) {
|
|
585
277
|
// plugin key, method
|
|
586
278
|
plugin = command;
|
|
@@ -630,7 +322,7 @@ export function CreateShortcuts(command, button, values, keyMap, rc, reverseKeys
|
|
|
630
322
|
if (!keyMap.has(k)) {
|
|
631
323
|
r = rc.indexOf(command);
|
|
632
324
|
r = r === -1 ? '' : numbers.isOdd(r) ? rc[r + 1] : rc[r - 1];
|
|
633
|
-
if (r) reverseKeys.
|
|
325
|
+
if (r) reverseKeys.add(k);
|
|
634
326
|
|
|
635
327
|
keyMap.set(k, { c, s, edge, space, enter, textTrigger, plugin, command, method, r, type: button?.getAttribute('data-type'), button, key: k });
|
|
636
328
|
}
|
|
@@ -661,23 +353,27 @@ function _mergeObject(a, b) {
|
|
|
661
353
|
}, {});
|
|
662
354
|
}
|
|
663
355
|
|
|
356
|
+
/**
|
|
357
|
+
* @typedef {Object} InitOptionsReturnType
|
|
358
|
+
* @property {__se__BaseOptions} o - Processed base options (Map containing {@link AllBaseOptions_constructor} keys)
|
|
359
|
+
* @property {Object<string, string>} i - Icon set
|
|
360
|
+
* @property {Object<string, string>} l - Language pack
|
|
361
|
+
* @property {string|null} v - Initial editor value
|
|
362
|
+
* @property {Array<string[]|string>} buttons - Toolbar button list (arrays for groups, strings for single buttons)
|
|
363
|
+
* @property {Array<string[]|string>|null} subButtons - Sub-toolbar button list
|
|
364
|
+
* @property {Element|null} statusbarContainer - Container element for status bar (if specified)
|
|
365
|
+
* @property {Map<string|null, __se__FrameOptions>} frameMap - Map of frame-specific options (frame key => {@link __se__FrameOptions})
|
|
366
|
+
*/
|
|
367
|
+
|
|
664
368
|
/**
|
|
665
369
|
* @description Initialize options
|
|
666
|
-
* @param {
|
|
667
|
-
* @param {Array<{target: Element, key: *, options:
|
|
370
|
+
* @param {__se__EditorOptions} options Configuration options for the editor.
|
|
371
|
+
* @param {Array<{target: Element, key: *, options: __se__EditorFrameOptions}>} editorTargets Target textarea
|
|
668
372
|
* @param {Object<string, *>} plugins Plugins object
|
|
669
|
-
* @returns {
|
|
670
|
-
* - o: options
|
|
671
|
-
* - i: icons
|
|
672
|
-
* - l: lang
|
|
673
|
-
* - v: value
|
|
674
|
-
* - buttons: Toolbar button list
|
|
675
|
-
* - subButtons: Sub-Toolbar button list
|
|
676
|
-
* - statusbarContainer: statusbar container
|
|
677
|
-
* - frameMap: converted options map
|
|
373
|
+
* @returns {InitOptionsReturnType} Initialized options and configuration
|
|
678
374
|
*/
|
|
679
375
|
export function InitOptions(options, editorTargets, plugins) {
|
|
680
|
-
const buttonList = options.buttonList ||
|
|
376
|
+
const buttonList = options.buttonList || DEFAULTS.BUTTON_LIST;
|
|
681
377
|
const o = new Map();
|
|
682
378
|
|
|
683
379
|
/** Multi root */
|
|
@@ -695,7 +391,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
695
391
|
tagFilter: modeValue,
|
|
696
392
|
formatFilter: modeValue,
|
|
697
393
|
classFilter: modeValue,
|
|
698
|
-
|
|
394
|
+
textStyleTagFilter: modeValue,
|
|
699
395
|
attrFilter: modeValue,
|
|
700
396
|
styleFilter: modeValue,
|
|
701
397
|
...(typeof options.strictMode === 'boolean' ? {} : options.strictMode)
|
|
@@ -709,8 +405,8 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
709
405
|
o.set('_themeClass', options.theme ? ` se-theme-${options.theme}` : '');
|
|
710
406
|
o.set('_type_options', options.type?.split(':')[1] || '');
|
|
711
407
|
o.set('externalLibs', options.externalLibs || {});
|
|
712
|
-
o.set('fontSizeUnits', Array.isArray(options.fontSizeUnits) && options.fontSizeUnits.length > 0 ? options.fontSizeUnits.map((v) => v.toLowerCase()) :
|
|
713
|
-
o.set('allowedClassName', new RegExp(`${options.allowedClassName && typeof options.allowedClassName === 'string' ? options.allowedClassName + '|' : ''}${
|
|
408
|
+
o.set('fontSizeUnits', Array.isArray(options.fontSizeUnits) && options.fontSizeUnits.length > 0 ? options.fontSizeUnits.map((v) => v.toLowerCase()) : DEFAULTS.SIZE_UNITS);
|
|
409
|
+
o.set('allowedClassName', new RegExp(`${options.allowedClassName && typeof options.allowedClassName === 'string' ? options.allowedClassName + '|' : ''}${DEFAULTS.CLASS_NAME}`));
|
|
714
410
|
o.set('closeModalOutsideClick', !!options.closeModalOutsideClick);
|
|
715
411
|
|
|
716
412
|
// format
|
|
@@ -721,18 +417,14 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
721
417
|
o.set('autoLinkify', options.autoLinkify ?? !!plugins.link);
|
|
722
418
|
o.set('autoStyleify', Array.isArray(options.autoStyleify) ? options.autoStyleify : ['bold', 'underline', 'italic', 'strike']);
|
|
723
419
|
|
|
724
|
-
// scroll options
|
|
725
|
-
o.set('scrollToOptions', { behavior: 'auto', block: 'nearest', ...options.scrollToOptions });
|
|
726
|
-
o.set('componentScrollToOptions', { behavior: 'smooth', block: 'center', ...options.componentScrollToOptions });
|
|
727
|
-
|
|
728
420
|
let retainStyleMode = options.retainStyleMode;
|
|
729
|
-
if (typeof retainStyleMode === 'string' && !RETAIN_STYLE_MODE.includes(retainStyleMode)) {
|
|
730
|
-
console.error(`Invalid retainStyleMode: ${retainStyleMode}. Valid options are ${RETAIN_STYLE_MODE.join(', ')}. Using default 'once'.`);
|
|
421
|
+
if (typeof retainStyleMode === 'string' && !DEFAULTS.RETAIN_STYLE_MODE.includes(retainStyleMode)) {
|
|
422
|
+
console.error(`Invalid retainStyleMode: ${retainStyleMode}. Valid options are ${DEFAULTS.RETAIN_STYLE_MODE.join(', ')}. Using default 'once'.`);
|
|
731
423
|
retainStyleMode = 'repeat';
|
|
732
424
|
}
|
|
733
425
|
o.set('retainStyleMode', retainStyleMode);
|
|
734
426
|
|
|
735
|
-
const allowedExtraTags = { ...
|
|
427
|
+
const allowedExtraTags = { ...DEFAULTS.EXTRA_TAG_MAP, ...options.allowedExtraTags, '-': true };
|
|
736
428
|
const extraKeys = Object.keys(allowedExtraTags);
|
|
737
429
|
const allowedKeys = extraKeys.filter((k) => allowedExtraTags[k]).join('|');
|
|
738
430
|
const disallowedKeys = extraKeys.filter((k) => !allowedExtraTags[k]).join('|');
|
|
@@ -742,7 +434,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
742
434
|
o.set('events', options.events || {});
|
|
743
435
|
|
|
744
436
|
// text style tags
|
|
745
|
-
o.set('textStyleTags', (typeof options.__textStyleTags === 'string' ? options.__textStyleTags :
|
|
437
|
+
o.set('textStyleTags', (typeof options.__textStyleTags === 'string' ? options.__textStyleTags : DEFAULTS.TEXT_STYLE_TAGS) + (options.textStyleTags ? '|' + options.textStyleTags : ''));
|
|
746
438
|
const textTags = _mergeObject(
|
|
747
439
|
{
|
|
748
440
|
bold: 'strong',
|
|
@@ -758,15 +450,15 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
758
450
|
o.set('_textStyleTags', Object.values(textTags).concat(['span', 'li']));
|
|
759
451
|
o.set(
|
|
760
452
|
'tagStyles',
|
|
761
|
-
[{ ...
|
|
453
|
+
[{ ...DEFAULTS.TAG_STYLES, ...(options.__tagStyles || {}) }, options.tagStyles || {}].reduce((_default, _new) => {
|
|
762
454
|
for (const key in _new) {
|
|
763
455
|
_default[key] = _new[key];
|
|
764
456
|
}
|
|
765
457
|
return _default;
|
|
766
458
|
}, {})
|
|
767
459
|
);
|
|
768
|
-
o.set('_textStylesRegExp', new RegExp(`\\s*[^-a-zA-Z](${
|
|
769
|
-
o.set('_lineStylesRegExp', new RegExp(`\\s*[^-a-zA-Z](${
|
|
460
|
+
o.set('_textStylesRegExp', new RegExp(`\\s*[^-a-zA-Z](${DEFAULTS.SPAN_STYLES}${options.spanStyles ? '|' + options.spanStyles : ''})\\s*:[^;]+(?!;)*`, 'gi'));
|
|
461
|
+
o.set('_lineStylesRegExp', new RegExp(`\\s*[^-a-zA-Z](${DEFAULTS.LINE_STYLES}${options.lineStyles ? '|' + options.lineStyles : ''})\\s*:[^;]+(?!;)*`, 'gi'));
|
|
770
462
|
o.set('_defaultStyleTagMap', {
|
|
771
463
|
strong: textTags.bold,
|
|
772
464
|
b: textTags.bold,
|
|
@@ -816,7 +508,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
816
508
|
|
|
817
509
|
// etc
|
|
818
510
|
o.set('historyStackDelayTime', typeof options.historyStackDelayTime === 'number' ? options.historyStackDelayTime : 400);
|
|
819
|
-
o.set('_editableClass', 'sun-editor-editable' + o.get('_themeClass') + (o.get('_rtl') ? ' se-rtl' : '') + (o.get('type') === 'document' ? ' se-type-document-editable' : ''));
|
|
511
|
+
o.set('_editableClass', 'sun-editor-editable' + o.get('_themeClass') + (o.get('_rtl') ? ' se-rtl' : '') + (o.get('type') === 'document' ? ' se-type-document-editable-a4' : ''));
|
|
820
512
|
o.set('lineAttrReset', ['id'].concat(options.lineAttrReset && typeof options.lineAttrReset === 'string' ? options.lineAttrReset.toLowerCase().split('|') : []));
|
|
821
513
|
o.set('printClass', typeof options.printClass === 'string' ? options.printClass + ' ' + o.get('_editableClass') : null);
|
|
822
514
|
|
|
@@ -824,10 +516,10 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
824
516
|
// default line
|
|
825
517
|
o.set('defaultLine', typeof options.defaultLine === 'string' && options.defaultLine.length > 0 ? options.defaultLine : 'p');
|
|
826
518
|
o.set('defaultLineBreakFormat', options.defaultLineBreakFormat || 'line');
|
|
827
|
-
o.set('scopeSelectionTags', options.scopeSelectionTags ||
|
|
519
|
+
o.set('scopeSelectionTags', options.scopeSelectionTags || DEFAULTS.SCOPE_SELECTION_TAGS);
|
|
828
520
|
// element
|
|
829
521
|
const elw = (typeof options.elementWhitelist === 'string' ? options.elementWhitelist : '').toLowerCase();
|
|
830
|
-
const mjxEls = o.get('externalLibs').mathjax ?
|
|
522
|
+
const mjxEls = o.get('externalLibs').mathjax ? DEFAULTS.CLASS_MJX + '|' : '';
|
|
831
523
|
o.set('elementWhitelist', elw + (elw ? '|' : '') + mjxEls + o.get('_allowedExtraTag'));
|
|
832
524
|
const elb = _createBlacklist((typeof options.elementBlacklist === 'string' ? options.elementBlacklist : '').toLowerCase(), o.get('defaultLine'));
|
|
833
525
|
o.set('elementBlacklist', elb + (elb ? '|' : '') + o.get('_disallowedExtraTag'));
|
|
@@ -839,7 +531,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
839
531
|
'formatClosureBrLine',
|
|
840
532
|
_createFormatInfo(
|
|
841
533
|
options.formatClosureBrLine,
|
|
842
|
-
(options.__defaultFormatClosureBrLine = typeof options.__defaultFormatClosureBrLine === 'string' ? options.__defaultFormatClosureBrLine :
|
|
534
|
+
(options.__defaultFormatClosureBrLine = typeof options.__defaultFormatClosureBrLine === 'string' ? options.__defaultFormatClosureBrLine : DEFAULTS.FORMAT_CLOSURE_BR_LINE).toLowerCase(),
|
|
843
535
|
o.get('elementBlacklist')
|
|
844
536
|
)
|
|
845
537
|
);
|
|
@@ -847,15 +539,15 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
847
539
|
'formatBrLine',
|
|
848
540
|
_createFormatInfo(
|
|
849
541
|
(options.formatBrLine || '') + '|' + o.get('formatClosureBrLine').str,
|
|
850
|
-
(options.__defaultFormatBrLine = typeof options.__defaultFormatBrLine === 'string' ? options.__defaultFormatBrLine :
|
|
542
|
+
(options.__defaultFormatBrLine = typeof options.__defaultFormatBrLine === 'string' ? options.__defaultFormatBrLine : DEFAULTS.FORMAT_BR_LINE).toLowerCase(),
|
|
851
543
|
o.get('elementBlacklist')
|
|
852
544
|
)
|
|
853
545
|
);
|
|
854
546
|
o.set(
|
|
855
547
|
'formatLine',
|
|
856
548
|
_createFormatInfo(
|
|
857
|
-
REQUIRED_FORMAT_LINE + '|' + (options.formatLine || '') + '|' + o.get('formatBrLine').str,
|
|
858
|
-
(options.__defaultFormatLine = typeof options.__defaultFormatLine === 'string' ? options.__defaultFormatLine :
|
|
549
|
+
DEFAULTS.REQUIRED_FORMAT_LINE + '|' + (options.formatLine || '') + '|' + o.get('formatBrLine').str,
|
|
550
|
+
(options.__defaultFormatLine = typeof options.__defaultFormatLine === 'string' ? options.__defaultFormatLine : DEFAULTS.FORMAT_LINE).toLowerCase(),
|
|
859
551
|
o.get('elementBlacklist')
|
|
860
552
|
)
|
|
861
553
|
);
|
|
@@ -869,7 +561,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
869
561
|
'formatClosureBlock',
|
|
870
562
|
_createFormatInfo(
|
|
871
563
|
options.formatClosureBlock,
|
|
872
|
-
(options.__defaultFormatClosureBlock = typeof options.__defaultFormatClosureBlock === 'string' ? options.__defaultFormatClosureBlock :
|
|
564
|
+
(options.__defaultFormatClosureBlock = typeof options.__defaultFormatClosureBlock === 'string' ? options.__defaultFormatClosureBlock : DEFAULTS.FORMAT_CLOSURE_BLOCK).toLowerCase(),
|
|
873
565
|
o.get('elementBlacklist')
|
|
874
566
|
)
|
|
875
567
|
);
|
|
@@ -877,16 +569,16 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
877
569
|
'formatBlock',
|
|
878
570
|
_createFormatInfo(
|
|
879
571
|
(options.formatBlock || '') + '|' + o.get('formatClosureBlock').str,
|
|
880
|
-
(options.__defaultFormatBlock = typeof options.__defaultFormatBlock === 'string' ? options.__defaultFormatBlock :
|
|
572
|
+
(options.__defaultFormatBlock = typeof options.__defaultFormatBlock === 'string' ? options.__defaultFormatBlock : DEFAULTS.FORMAT_BLOCK).toLowerCase(),
|
|
881
573
|
o.get('elementBlacklist')
|
|
882
574
|
)
|
|
883
575
|
);
|
|
884
576
|
|
|
885
|
-
o.set('allowedEmptyTags',
|
|
577
|
+
o.set('allowedEmptyTags', DEFAULTS.ALLOWED_EMPTY_NODE_LIST + (options.allowedEmptyTags ? ', ' + options.allowedEmptyTags : ''));
|
|
886
578
|
|
|
887
579
|
/** __defaults */
|
|
888
|
-
o.set('__defaultElementWhitelist', REQUIRED_ELEMENT_WHITELIST + '|' + (typeof options.__defaultElementWhitelist === 'string' ? options.__defaultElementWhitelist :
|
|
889
|
-
o.set('__defaultAttributeWhitelist', (typeof options.__defaultAttributeWhitelist === 'string' ? options.__defaultAttributeWhitelist :
|
|
580
|
+
o.set('__defaultElementWhitelist', DEFAULTS.REQUIRED_ELEMENT_WHITELIST + '|' + (typeof options.__defaultElementWhitelist === 'string' ? options.__defaultElementWhitelist : DEFAULTS.ELEMENT_WHITELIST).toLowerCase());
|
|
581
|
+
o.set('__defaultAttributeWhitelist', (typeof options.__defaultAttributeWhitelist === 'string' ? options.__defaultAttributeWhitelist : DEFAULTS.ATTRIBUTE_WHITELIST).toLowerCase());
|
|
890
582
|
// --- create element whitelist (__defaultElementWhiteList + elementWhitelist + format[line, BrLine, Block, Closureblock, ClosureBrLine] - elementBlacklist)
|
|
891
583
|
o.set('_editorElementWhitelist', o.get('elementWhitelist') === '*' ? '*' : _createWhitelist(o));
|
|
892
584
|
|
|
@@ -904,7 +596,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
904
596
|
console.warn('[SUNEDITOR.create.subToolbar.fail] When the "mode" option is "balloon-*", the "subToolbar" option is omitted.');
|
|
905
597
|
} else {
|
|
906
598
|
o.set('_subMode', subbar.mode || 'balloon');
|
|
907
|
-
o.set('
|
|
599
|
+
o.set('toolbar_sub_width', subbar.width ? (numbers.is(subbar.width) ? subbar.width + 'px' : subbar.width) : 'auto');
|
|
908
600
|
subButtons = o.get('_rtl') ? subbar.buttonList.reverse() : subbar.buttonList;
|
|
909
601
|
o.set('buttons_sub', new Set(subButtons.toString().split(',')));
|
|
910
602
|
}
|
|
@@ -945,12 +637,12 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
945
637
|
_h3: ['c+s+Digit3|Numpad3+$~formatBlock.applyHeaderByShortcut', '']
|
|
946
638
|
},
|
|
947
639
|
options.shortcuts || {}
|
|
948
|
-
|
|
640
|
+
].reduce((_default, _new) => {
|
|
949
641
|
for (const key in _new) {
|
|
950
642
|
_default[key] = _new[key];
|
|
951
643
|
}
|
|
952
644
|
return _default;
|
|
953
|
-
|
|
645
|
+
}, {});
|
|
954
646
|
o.set('shortcuts', shortcuts);
|
|
955
647
|
|
|
956
648
|
/** View */
|
|
@@ -959,7 +651,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
959
651
|
o.set('printTemplate', typeof options.printTemplate === 'string' ? options.printTemplate : null);
|
|
960
652
|
|
|
961
653
|
/** --- Media select */
|
|
962
|
-
o.set('
|
|
654
|
+
o.set('componentInsertBehavior', ['auto', 'select', 'line', 'none'].includes(options.componentInsertBehavior) ? options.componentInsertBehavior : 'auto');
|
|
963
655
|
|
|
964
656
|
/** --- Url input protocol */
|
|
965
657
|
o.set('defaultUrlProtocol', typeof options.defaultUrlProtocol === 'string' ? options.defaultUrlProtocol : null);
|
|
@@ -991,14 +683,14 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
991
683
|
_default[key] = _new[key];
|
|
992
684
|
}
|
|
993
685
|
return _default;
|
|
994
|
-
|
|
686
|
+
}, {});
|
|
995
687
|
o.set('icons', icons);
|
|
996
688
|
|
|
997
689
|
/** Create all used styles */
|
|
998
|
-
const allUsedStyles = new Set(
|
|
690
|
+
const allUsedStyles = new Set(DEFAULTS.CONTENT_STYLES.split('|'));
|
|
999
691
|
const _ss = options.spanStyles?.split('|') || [];
|
|
1000
692
|
const _ls = o.get('__listCommonStyle');
|
|
1001
|
-
const _dts =
|
|
693
|
+
const _dts = DEFAULTS.SPAN_STYLES.split('|');
|
|
1002
694
|
for (let i = 0, len = _dts.length; i < len; i++) {
|
|
1003
695
|
allUsedStyles.add(_dts[i]);
|
|
1004
696
|
}
|
|
@@ -1045,7 +737,7 @@ export function CreateStatusbar(targetOptions, statusbar) {
|
|
|
1045
737
|
let charCounter = null;
|
|
1046
738
|
|
|
1047
739
|
if (targetOptions.get('statusbar')) {
|
|
1048
|
-
statusbar
|
|
740
|
+
statusbar ||= dom.utils.createElement('DIV', { class: 'se-status-bar sun-editor-common' });
|
|
1049
741
|
|
|
1050
742
|
/** navigation */
|
|
1051
743
|
navigation = statusbar.querySelector('.se-navigation') || dom.utils.createElement('DIV', { class: 'se-navigation sun-editor-common' });
|
|
@@ -1085,9 +777,9 @@ export function CreateStatusbar(targetOptions, statusbar) {
|
|
|
1085
777
|
|
|
1086
778
|
/**
|
|
1087
779
|
* @description Initialize options.
|
|
1088
|
-
* @param {
|
|
1089
|
-
* @param {
|
|
1090
|
-
* @returns {Map
|
|
780
|
+
* @param {__se__EditorFrameOptions} o - Target options
|
|
781
|
+
* @param {__se__EditorOptions} origin - Full options
|
|
782
|
+
* @returns {__se__FrameOptions} Processed frame options Map
|
|
1091
783
|
*/
|
|
1092
784
|
function InitFrameOptions(o, origin) {
|
|
1093
785
|
const fo = new Map();
|
|
@@ -1121,7 +813,7 @@ function InitFrameOptions(o, origin) {
|
|
|
1121
813
|
// value
|
|
1122
814
|
fo.set('value', value);
|
|
1123
815
|
fo.set('placeholder', placeholder);
|
|
1124
|
-
fo.set('editableFrameAttributes', editableFrameAttributes
|
|
816
|
+
fo.set('editableFrameAttributes', { spellcheck: 'false', ...editableFrameAttributes });
|
|
1125
817
|
// styles
|
|
1126
818
|
fo.set('width', width ? (numbers.is(width) ? width + 'px' : width) : '100%');
|
|
1127
819
|
fo.set('minWidth', (numbers.is(minWidth) ? minWidth + 'px' : minWidth) || '');
|
|
@@ -1167,7 +859,7 @@ function _initTargetElements(key, options, topDiv, targetOptions) {
|
|
|
1167
859
|
/** editor */
|
|
1168
860
|
// wysiwyg div or iframe
|
|
1169
861
|
const wysiwygDiv = dom.utils.createElement(!targetOptions.get('iframe') ? 'DIV' : 'IFRAME', {
|
|
1170
|
-
class: 'se-wrapper-inner se-wrapper-wysiwyg',
|
|
862
|
+
class: 'se-wrapper-inner se-wrapper-wysiwyg' + (options.get('type') === 'document' ? ' se-type-document-iframe-a4' : ''),
|
|
1171
863
|
'data-root-key': key
|
|
1172
864
|
});
|
|
1173
865
|
|
|
@@ -1393,7 +1085,7 @@ function _createModuleGroup() {
|
|
|
1393
1085
|
* @returns {{li: HTMLElement, button: HTMLElement}}
|
|
1394
1086
|
*/
|
|
1395
1087
|
function _createButton(className, title, dataCommand, dataType, innerHTML, _disabled, icons) {
|
|
1396
|
-
|
|
1088
|
+
innerHTML ||= '';
|
|
1397
1089
|
|
|
1398
1090
|
const oLi = dom.utils.createElement('LI');
|
|
1399
1091
|
const label = title || '';
|
|
@@ -1407,7 +1099,7 @@ function _createButton(className, title, dataCommand, dataType, innerHTML, _disa
|
|
|
1407
1099
|
'data-type': dataType,
|
|
1408
1100
|
'aria-label': label.replace(/<span .+<\/span>/, ''),
|
|
1409
1101
|
tabindex: '-1'
|
|
1410
|
-
|
|
1102
|
+
})
|
|
1411
1103
|
);
|
|
1412
1104
|
|
|
1413
1105
|
if (!isDiv) {
|
|
@@ -1587,7 +1279,6 @@ export function CreateToolBar(buttonList, plugins, options, icons, lang, isUpdat
|
|
|
1587
1279
|
// default command
|
|
1588
1280
|
if (button === 'copy' && !env.isClipboardSupported) {
|
|
1589
1281
|
console.warn('[SUNEDITOR.constructor.warn] Clipboard is not supported in this browser. : [copy] button is not rendered.');
|
|
1590
|
-
continue;
|
|
1591
1282
|
}
|
|
1592
1283
|
modules = defaultButtonList[button];
|
|
1593
1284
|
}
|