suneditor 2.46.2 → 3.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +7 -0
- package/.eslintrc.json +64 -0
- package/CONTRIBUTING.md +36 -0
- package/LICENSE.txt +1 -1
- package/README.md +11 -1560
- package/dist/suneditor.min.css +1 -0
- package/dist/suneditor.min.js +1 -2
- package/package.json +97 -70
- package/src/assets/icons/_default.js +194 -0
- package/src/assets/suneditor-contents.css +643 -0
- package/src/assets/suneditor.css +3394 -0
- package/src/core/base/eventHandlers/handler_toolbar.js +114 -0
- package/src/core/base/eventHandlers/handler_ww_clipboard.js +37 -0
- package/src/core/base/eventHandlers/handler_ww_dragDrop.js +74 -0
- package/src/core/base/eventHandlers/handler_ww_key_input.js +1002 -0
- package/src/core/base/eventHandlers/handler_ww_mouse.js +147 -0
- package/src/core/base/eventManager.js +1156 -0
- package/src/core/base/events.js +320 -0
- package/src/core/base/history.js +301 -0
- package/src/core/class/char.js +147 -0
- package/src/core/class/component.js +639 -0
- package/src/core/class/format.js +3258 -0
- package/src/core/class/html.js +1710 -0
- package/src/core/class/menu.js +260 -0
- package/src/core/class/nodeTransform.js +405 -0
- package/src/core/class/notice.js +42 -0
- package/src/core/class/offset.js +575 -0
- package/src/core/class/selection.js +511 -0
- package/src/core/class/shortcuts.js +38 -0
- package/src/core/class/toolbar.js +440 -0
- package/src/core/class/viewer.js +646 -0
- package/src/core/editor.js +1601 -0
- package/src/core/section/actives.js +145 -0
- package/src/core/section/constructor.js +1252 -0
- package/src/core/section/context.js +97 -0
- package/src/editorInjector/_classes.js +22 -0
- package/src/editorInjector/_core.js +28 -0
- package/src/editorInjector/index.js +13 -0
- package/src/helper/converter.js +388 -0
- package/src/helper/domUtils.js +1177 -0
- package/src/helper/env.js +250 -0
- package/src/helper/index.js +19 -0
- package/src/helper/numbers.js +68 -0
- package/src/helper/unicode.js +43 -0
- package/src/langs/ckb.js +161 -0
- package/src/langs/cs.js +161 -0
- package/src/langs/da.js +161 -0
- package/src/langs/de.js +162 -0
- package/src/langs/en.js +210 -0
- package/src/langs/es.js +162 -0
- package/src/langs/fa.js +159 -0
- package/src/langs/fr.js +161 -0
- package/src/langs/he.js +162 -0
- package/src/{lang → langs}/index.js +0 -2
- package/src/langs/it.js +162 -0
- package/src/langs/ja.js +162 -0
- package/src/langs/ko.js +210 -0
- package/src/langs/lv.js +162 -0
- package/src/langs/nl.js +162 -0
- package/src/langs/pl.js +162 -0
- package/src/langs/pt_br.js +162 -0
- package/src/langs/ro.js +162 -0
- package/src/langs/ru.js +162 -0
- package/src/langs/se.js +162 -0
- package/src/langs/tr.js +159 -0
- package/src/langs/ua.js +162 -0
- package/src/langs/ur.js +162 -0
- package/src/langs/zh_cn.js +162 -0
- package/src/modules/ApiManager.js +168 -0
- package/src/modules/ColorPicker.js +302 -0
- package/src/modules/Controller.js +323 -0
- package/src/modules/Figure.js +1176 -0
- package/src/modules/FileBrowser.js +271 -0
- package/src/modules/FileManager.js +307 -0
- package/src/modules/HueSlider.js +513 -0
- package/src/modules/Modal.js +177 -0
- package/src/modules/ModalAnchorEditor.js +494 -0
- package/src/modules/SelectMenu.js +447 -0
- package/src/modules/_DragHandle.js +16 -0
- package/src/modules/index.js +14 -0
- package/src/plugins/command/blockquote.js +47 -47
- package/src/plugins/command/exportPdf.js +168 -0
- package/src/plugins/command/fileUpload.js +389 -0
- package/src/plugins/command/list_bulleted.js +112 -0
- package/src/plugins/command/list_numbered.js +115 -0
- package/src/plugins/dropdown/align.js +143 -0
- package/src/plugins/dropdown/backgroundColor.js +90 -0
- package/src/plugins/dropdown/font.js +113 -0
- package/src/plugins/dropdown/fontColor.js +90 -0
- package/src/plugins/dropdown/formatBlock.js +141 -0
- package/src/plugins/dropdown/hr.js +111 -0
- package/src/plugins/dropdown/layout.js +72 -0
- package/src/plugins/dropdown/lineHeight.js +114 -0
- package/src/plugins/dropdown/list.js +107 -0
- package/src/plugins/dropdown/paragraphStyle.js +117 -0
- package/src/plugins/dropdown/table.js +2810 -0
- package/src/plugins/dropdown/template.js +71 -0
- package/src/plugins/dropdown/textStyle.js +137 -0
- package/src/plugins/field/mention.js +181 -0
- package/src/plugins/fileBrowser/imageGallery.js +76 -59
- package/src/plugins/index.js +86 -24
- package/src/plugins/input/fontSize.js +357 -0
- package/src/plugins/modal/audio.js +492 -0
- package/src/plugins/modal/image.js +1064 -0
- package/src/plugins/modal/link.js +211 -0
- package/src/plugins/modal/math.js +363 -0
- package/src/plugins/modal/video.js +870 -0
- package/src/suneditor.js +62 -67
- package/src/themes/test.css +61 -0
- package/typings/CommandPlugin.d.ts +8 -0
- package/typings/DialogPlugin.d.ts +20 -0
- package/typings/FileBrowserPlugin.d.ts +30 -0
- package/typings/Lang.d.ts +124 -0
- package/typings/Module.d.ts +15 -0
- package/typings/Plugin.d.ts +42 -0
- package/typings/SubmenuPlugin.d.ts +8 -0
- package/typings/_classes.d.ts +17 -0
- package/typings/_colorPicker.d.ts +60 -0
- package/typings/_core.d.ts +55 -0
- package/typings/align.d.ts +5 -0
- package/{src/plugins/dialog → typings}/audio.d.ts +1 -1
- package/typings/backgroundColor.d.ts +5 -0
- package/{src/plugins/command → typings}/blockquote.d.ts +1 -1
- package/typings/char.d.ts +39 -0
- package/typings/component.d.ts +38 -0
- package/typings/context.d.ts +39 -0
- package/typings/converter.d.ts +33 -0
- package/typings/dialog.d.ts +28 -0
- package/typings/domUtils.d.ts +361 -0
- package/typings/editor.d.ts +7 -0
- package/typings/editor.ts +542 -0
- package/typings/env.d.ts +70 -0
- package/typings/eventManager.d.ts +37 -0
- package/typings/events.d.ts +262 -0
- package/typings/fileBrowser.d.ts +42 -0
- package/typings/fileManager.d.ts +67 -0
- package/typings/font.d.ts +5 -0
- package/typings/fontColor.d.ts +5 -0
- package/typings/fontSize.d.ts +5 -0
- package/typings/format.d.ts +191 -0
- package/typings/formatBlock.d.ts +5 -0
- package/typings/history.d.ts +48 -0
- package/typings/horizontalRule.d.ts +5 -0
- package/{src/plugins/dialog → typings}/image.d.ts +1 -1
- package/{src/plugins/fileBrowser → typings}/imageGallery.d.ts +1 -1
- package/typings/index.d.ts +21 -0
- package/{src/plugins/modules/index.d.ts → typings/index.modules.d.ts} +3 -3
- package/typings/index.plugins.d.ts +58 -0
- package/typings/lineHeight.d.ts +5 -0
- package/{src/plugins/dialog → typings}/link.d.ts +1 -1
- package/typings/list.d.ts +5 -0
- package/{src/plugins/dialog → typings}/math.d.ts +1 -1
- package/typings/mediaContainer.d.ts +25 -0
- package/typings/node.d.ts +57 -0
- package/typings/notice.d.ts +16 -0
- package/typings/numbers.d.ts +29 -0
- package/typings/offset.d.ts +24 -0
- package/typings/options.d.ts +589 -0
- package/typings/paragraphStyle.d.ts +5 -0
- package/typings/resizing.d.ts +141 -0
- package/typings/selection.d.ts +94 -0
- package/typings/shortcuts.d.ts +13 -0
- package/typings/suneditor.d.ts +9 -0
- package/typings/table.d.ts +5 -0
- package/typings/template.d.ts +5 -0
- package/typings/textStyle.d.ts +5 -0
- package/typings/toolbar.d.ts +32 -0
- package/typings/unicode.d.ts +25 -0
- package/{src/plugins/dialog → typings}/video.d.ts +1 -1
- package/dist/css/suneditor.min.css +0 -1
- package/src/assets/css/suneditor-contents.css +0 -562
- package/src/assets/css/suneditor.css +0 -566
- package/src/assets/defaultIcons.js +0 -103
- package/src/lang/Lang.d.ts +0 -144
- package/src/lang/ckb.d.ts +0 -5
- package/src/lang/ckb.js +0 -188
- package/src/lang/cs.d.ts +0 -5
- package/src/lang/cs.js +0 -188
- package/src/lang/da.d.ts +0 -5
- package/src/lang/da.js +0 -191
- package/src/lang/de.d.ts +0 -5
- package/src/lang/de.js +0 -188
- package/src/lang/en.d.ts +0 -5
- package/src/lang/en.js +0 -188
- package/src/lang/es.d.ts +0 -5
- package/src/lang/es.js +0 -188
- package/src/lang/fa.d.ts +0 -5
- package/src/lang/fa.js +0 -188
- package/src/lang/fr.d.ts +0 -5
- package/src/lang/fr.js +0 -188
- package/src/lang/he.d.ts +0 -5
- package/src/lang/he.js +0 -188
- package/src/lang/index.d.ts +0 -23
- package/src/lang/it.d.ts +0 -5
- package/src/lang/it.js +0 -188
- package/src/lang/ja.d.ts +0 -5
- package/src/lang/ja.js +0 -188
- package/src/lang/ko.d.ts +0 -5
- package/src/lang/ko.js +0 -188
- package/src/lang/lv.d.ts +0 -5
- package/src/lang/lv.js +0 -188
- package/src/lang/nl.d.ts +0 -5
- package/src/lang/nl.js +0 -188
- package/src/lang/pl.d.ts +0 -5
- package/src/lang/pl.js +0 -188
- package/src/lang/pt_br.d.ts +0 -5
- package/src/lang/pt_br.js +0 -189
- package/src/lang/ro.d.ts +0 -5
- package/src/lang/ro.js +0 -188
- package/src/lang/ru.d.ts +0 -5
- package/src/lang/ru.js +0 -188
- package/src/lang/se.d.ts +0 -5
- package/src/lang/se.js +0 -191
- package/src/lang/tr.d.ts +0 -5
- package/src/lang/tr.js +0 -191
- package/src/lang/ua.d.ts +0 -5
- package/src/lang/ua.js +0 -188
- package/src/lang/ur.d.ts +0 -5
- package/src/lang/ur.js +0 -188
- package/src/lang/zh_cn.d.ts +0 -5
- package/src/lang/zh_cn.js +0 -187
- package/src/lib/constructor.js +0 -954
- package/src/lib/context.d.ts +0 -42
- package/src/lib/context.js +0 -71
- package/src/lib/core.d.ts +0 -1135
- package/src/lib/core.js +0 -9395
- package/src/lib/history.d.ts +0 -48
- package/src/lib/history.js +0 -219
- package/src/lib/util.d.ts +0 -678
- package/src/lib/util.js +0 -2131
- package/src/options.d.ts +0 -608
- package/src/plugins/CommandPlugin.d.ts +0 -8
- package/src/plugins/DialogPlugin.d.ts +0 -20
- package/src/plugins/FileBrowserPlugin.d.ts +0 -30
- package/src/plugins/Module.d.ts +0 -15
- package/src/plugins/Plugin.d.ts +0 -42
- package/src/plugins/SubmenuPlugin.d.ts +0 -8
- package/src/plugins/dialog/audio.js +0 -559
- package/src/plugins/dialog/image.js +0 -1126
- package/src/plugins/dialog/link.js +0 -223
- package/src/plugins/dialog/math.js +0 -295
- package/src/plugins/dialog/mention.js +0 -242
- package/src/plugins/dialog/video.js +0 -979
- package/src/plugins/index.d.ts +0 -79
- package/src/plugins/modules/_anchor.js +0 -461
- package/src/plugins/modules/_colorPicker.d.ts +0 -60
- package/src/plugins/modules/_colorPicker.js +0 -201
- package/src/plugins/modules/_notice.d.ts +0 -21
- package/src/plugins/modules/_notice.js +0 -72
- package/src/plugins/modules/_selectMenu.js +0 -119
- package/src/plugins/modules/component.d.ts +0 -25
- package/src/plugins/modules/component.js +0 -81
- package/src/plugins/modules/dialog.d.ts +0 -28
- package/src/plugins/modules/dialog.js +0 -175
- package/src/plugins/modules/fileBrowser.d.ts +0 -42
- package/src/plugins/modules/fileBrowser.js +0 -374
- package/src/plugins/modules/fileManager.d.ts +0 -67
- package/src/plugins/modules/fileManager.js +0 -326
- package/src/plugins/modules/index.js +0 -9
- package/src/plugins/modules/resizing.d.ts +0 -154
- package/src/plugins/modules/resizing.js +0 -903
- package/src/plugins/submenu/align.d.ts +0 -5
- package/src/plugins/submenu/align.js +0 -160
- package/src/plugins/submenu/font.d.ts +0 -5
- package/src/plugins/submenu/font.js +0 -123
- package/src/plugins/submenu/fontColor.d.ts +0 -5
- package/src/plugins/submenu/fontColor.js +0 -101
- package/src/plugins/submenu/fontSize.d.ts +0 -5
- package/src/plugins/submenu/fontSize.js +0 -112
- package/src/plugins/submenu/formatBlock.d.ts +0 -5
- package/src/plugins/submenu/formatBlock.js +0 -273
- package/src/plugins/submenu/hiliteColor.d.ts +0 -5
- package/src/plugins/submenu/hiliteColor.js +0 -102
- package/src/plugins/submenu/horizontalRule.d.ts +0 -5
- package/src/plugins/submenu/horizontalRule.js +0 -98
- package/src/plugins/submenu/lineHeight.d.ts +0 -5
- package/src/plugins/submenu/lineHeight.js +0 -104
- package/src/plugins/submenu/list.d.ts +0 -5
- package/src/plugins/submenu/list.js +0 -456
- package/src/plugins/submenu/paragraphStyle.d.ts +0 -5
- package/src/plugins/submenu/paragraphStyle.js +0 -135
- package/src/plugins/submenu/table.d.ts +0 -5
- package/src/plugins/submenu/table.js +0 -1431
- package/src/plugins/submenu/template.d.ts +0 -5
- package/src/plugins/submenu/template.js +0 -72
- package/src/plugins/submenu/textStyle.d.ts +0 -5
- package/src/plugins/submenu/textStyle.js +0 -167
- package/src/suneditor.d.ts +0 -9
- package/src/suneditor_build.js +0 -18
- /package/{src/plugins/dialog → typings}/mention.d.ts +0 -0
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* wysiwyg web editor
|
|
3
|
-
*
|
|
4
|
-
* suneditor.js
|
|
5
|
-
* Copyright 2017 JiHong Lee.
|
|
6
|
-
* MIT license.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
name: 'formatBlock',
|
|
12
|
-
display: 'submenu',
|
|
13
|
-
add: function (core, targetElement) {
|
|
14
|
-
const context = core.context;
|
|
15
|
-
context.formatBlock = {
|
|
16
|
-
targetText: targetElement.querySelector('.txt'),
|
|
17
|
-
targetTooltip: targetElement.parentNode.querySelector('.se-tooltip-text'),
|
|
18
|
-
_formatList: null,
|
|
19
|
-
currentFormat: ''
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/** set submenu */
|
|
23
|
-
let listDiv = this.setSubmenu(core);
|
|
24
|
-
|
|
25
|
-
/** add event listeners */
|
|
26
|
-
listDiv.querySelector('ul').addEventListener('click', this.pickUp.bind(core));
|
|
27
|
-
context.formatBlock._formatList = listDiv.querySelectorAll('li button');
|
|
28
|
-
|
|
29
|
-
/** append target button menu */
|
|
30
|
-
core.initMenuTarget(this.name, targetElement, listDiv);
|
|
31
|
-
|
|
32
|
-
/** empty memory */
|
|
33
|
-
listDiv = null;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
setSubmenu: function (core) {
|
|
37
|
-
const option = core.options;
|
|
38
|
-
const lang_toolbar = core.lang.toolbar;
|
|
39
|
-
const listDiv = core.util.createElement('DIV');
|
|
40
|
-
listDiv.className = 'se-submenu se-list-layer se-list-format';
|
|
41
|
-
|
|
42
|
-
const defaultFormats = ['p', 'div', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
43
|
-
const formatList = !option.formats || option.formats.length === 0 ? defaultFormats : option.formats;
|
|
44
|
-
|
|
45
|
-
let list = '<div class="se-list-inner"><ul class="se-list-basic">';
|
|
46
|
-
for (let i = 0, len = formatList.length, format, tagName, command, name, h, attrs, className; i < len; i++) {
|
|
47
|
-
format = formatList[i];
|
|
48
|
-
|
|
49
|
-
if (typeof format === 'string' && defaultFormats.indexOf(format) > -1) {
|
|
50
|
-
tagName = format.toLowerCase();
|
|
51
|
-
command = tagName === 'blockquote' ? 'range' : tagName === 'pre' ? 'free' : 'replace';
|
|
52
|
-
h = /^h/.test(tagName) ? tagName.match(/\d+/)[0] : '';
|
|
53
|
-
name = lang_toolbar['tag_' + (h ? 'h' : tagName)] + h;
|
|
54
|
-
className = '';
|
|
55
|
-
attrs = '';
|
|
56
|
-
} else {
|
|
57
|
-
tagName = format.tag.toLowerCase();
|
|
58
|
-
command = format.command;
|
|
59
|
-
name = format.name || tagName;
|
|
60
|
-
className = format.class;
|
|
61
|
-
attrs = className ? ' class="' + className + '"' : '';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
list += '<li>' +
|
|
65
|
-
'<button type="button" class="se-btn-list" data-command="' + command + '" data-value="' + tagName + '" data-class="' + className + '" title="' + name + '" aria-label="' + name + '">' +
|
|
66
|
-
'<' + tagName + attrs + '>' + name + '</' + tagName + '>' +
|
|
67
|
-
'</button></li>';
|
|
68
|
-
}
|
|
69
|
-
list += '</ul></div>';
|
|
70
|
-
|
|
71
|
-
listDiv.innerHTML = list;
|
|
72
|
-
|
|
73
|
-
return listDiv;
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @Override core
|
|
78
|
-
*/
|
|
79
|
-
active: function (element) {
|
|
80
|
-
let formatTitle = this.lang.toolbar.formats;
|
|
81
|
-
const target = this.context.formatBlock.targetText;
|
|
82
|
-
|
|
83
|
-
if (!element) {
|
|
84
|
-
this.util.changeTxt(target, formatTitle);
|
|
85
|
-
} else if (this.util.isFormatElement(element)) {
|
|
86
|
-
const formatContext = this.context.formatBlock;
|
|
87
|
-
const formatList = formatContext._formatList;
|
|
88
|
-
const nodeName = element.nodeName.toLowerCase();
|
|
89
|
-
const className = (element.className.match(/(\s|^)__se__format__[^\s]+/) || [''])[0].trim();
|
|
90
|
-
|
|
91
|
-
for (let i = 0, len = formatList.length, f; i < len; i++) {
|
|
92
|
-
f = formatList[i];
|
|
93
|
-
if (nodeName === f.getAttribute('data-value') && className === f.getAttribute('data-class')) {
|
|
94
|
-
formatTitle = f.title;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.util.changeTxt(target, formatTitle);
|
|
100
|
-
target.setAttribute('data-value', nodeName);
|
|
101
|
-
target.setAttribute('data-class', className);
|
|
102
|
-
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return false;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @Override submenu
|
|
111
|
-
*/
|
|
112
|
-
on: function () {
|
|
113
|
-
const formatContext = this.context.formatBlock;
|
|
114
|
-
const formatList = formatContext._formatList;
|
|
115
|
-
const target = formatContext.targetText;
|
|
116
|
-
const currentFormat = (target.getAttribute('data-value') || '') + (target.getAttribute('data-class') || '');
|
|
117
|
-
|
|
118
|
-
if (currentFormat !== formatContext.currentFormat) {
|
|
119
|
-
for (let i = 0, len = formatList.length, f; i < len; i++) {
|
|
120
|
-
f = formatList[i];
|
|
121
|
-
if (currentFormat === f.getAttribute('data-value') + f.getAttribute('data-class')) {
|
|
122
|
-
this.util.addClass(f, 'active');
|
|
123
|
-
} else {
|
|
124
|
-
this.util.removeClass(f, 'active');
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
formatContext.currentFormat = currentFormat;
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
pickUp: function (e) {
|
|
133
|
-
e.preventDefault();
|
|
134
|
-
e.stopPropagation();
|
|
135
|
-
|
|
136
|
-
let target = e.target;
|
|
137
|
-
let command = null, value = null, tag = null, className = '';
|
|
138
|
-
|
|
139
|
-
while (!command && !/UL/i.test(target.tagName)) {
|
|
140
|
-
command = target.getAttribute('data-command');
|
|
141
|
-
value = target.getAttribute('data-value');
|
|
142
|
-
className = target.getAttribute('data-class');
|
|
143
|
-
if (command) {
|
|
144
|
-
tag = target.firstChild;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
target = target.parentNode;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (!command) return;
|
|
151
|
-
|
|
152
|
-
// blockquote
|
|
153
|
-
if (command === 'range') {
|
|
154
|
-
const rangeElement = tag.cloneNode(false);
|
|
155
|
-
this.applyRangeFormatElement(rangeElement);
|
|
156
|
-
}
|
|
157
|
-
// free, replace
|
|
158
|
-
else {
|
|
159
|
-
let range = this.getRange();
|
|
160
|
-
let selectedFormsts = this.getSelectedElementsAndComponents(false);
|
|
161
|
-
|
|
162
|
-
if (selectedFormsts.length === 0) {
|
|
163
|
-
range = this.getRange_addLine(range, null);
|
|
164
|
-
selectedFormsts = this.getSelectedElementsAndComponents(false);
|
|
165
|
-
if (selectedFormsts.length === 0) return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const startOffset = range.startOffset;
|
|
169
|
-
const endOffset = range.endOffset;
|
|
170
|
-
|
|
171
|
-
const util = this.util;
|
|
172
|
-
let first = selectedFormsts[0];
|
|
173
|
-
let last = selectedFormsts[selectedFormsts.length - 1];
|
|
174
|
-
const firstPath = util.getNodePath(range.startContainer, first, null, null);
|
|
175
|
-
const lastPath = util.getNodePath(range.endContainer, last, null, null);
|
|
176
|
-
|
|
177
|
-
// remove selected list
|
|
178
|
-
const rlist = this.detachList(selectedFormsts, false);
|
|
179
|
-
if (rlist.sc) first = rlist.sc;
|
|
180
|
-
if (rlist.ec) last = rlist.ec;
|
|
181
|
-
|
|
182
|
-
// change format tag
|
|
183
|
-
this.setRange(util.getNodeFromPath(firstPath, first), startOffset, util.getNodeFromPath(lastPath, last), endOffset);
|
|
184
|
-
const modifiedFormsts = this.getSelectedElementsAndComponents(false);
|
|
185
|
-
|
|
186
|
-
// free format
|
|
187
|
-
if (command === 'free') {
|
|
188
|
-
const len = modifiedFormsts.length - 1;
|
|
189
|
-
let parentNode = modifiedFormsts[len].parentNode;
|
|
190
|
-
let freeElement = tag.cloneNode(false);
|
|
191
|
-
const focusElement = freeElement;
|
|
192
|
-
|
|
193
|
-
for (let i = len, f, html, before, next, inner, isComp, first = true; i >= 0; i--) {
|
|
194
|
-
f = modifiedFormsts[i];
|
|
195
|
-
if (f === (!modifiedFormsts[i + 1] ? null : modifiedFormsts[i + 1].parentNode)) continue;
|
|
196
|
-
|
|
197
|
-
isComp = util.isComponent(f);
|
|
198
|
-
html = isComp ? '' : f.innerHTML.replace(/(?!>)\s+(?=<)|\n/g, ' ');
|
|
199
|
-
before = util.getParentElement(f, function (current) {
|
|
200
|
-
return current.parentNode === parentNode;
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
if (parentNode !== f.parentNode || isComp) {
|
|
204
|
-
if (util.isFormatElement(parentNode)) {
|
|
205
|
-
parentNode.parentNode.insertBefore(freeElement, parentNode.nextSibling);
|
|
206
|
-
parentNode = parentNode.parentNode;
|
|
207
|
-
} else {
|
|
208
|
-
parentNode.insertBefore(freeElement, before ? before.nextSibling : null);
|
|
209
|
-
parentNode = f.parentNode;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
next = freeElement.nextSibling;
|
|
213
|
-
if (next && freeElement.nodeName === next.nodeName && util.isSameAttributes(freeElement, next)) {
|
|
214
|
-
freeElement.innerHTML += '<BR>' + next.innerHTML;
|
|
215
|
-
util.removeItem(next);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
freeElement = tag.cloneNode(false);
|
|
219
|
-
first = true;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
inner = freeElement.innerHTML;
|
|
223
|
-
freeElement.innerHTML = ((first || !html || !inner || /<br>$/i.test(html)) ? html : html + '<BR>') + inner;
|
|
224
|
-
|
|
225
|
-
if (i === 0) {
|
|
226
|
-
parentNode.insertBefore(freeElement, f);
|
|
227
|
-
next = f.nextSibling;
|
|
228
|
-
if (next && freeElement.nodeName === next.nodeName && util.isSameAttributes(freeElement, next)) {
|
|
229
|
-
freeElement.innerHTML += '<BR>' + next.innerHTML;
|
|
230
|
-
util.removeItem(next);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const prev = freeElement.previousSibling;
|
|
234
|
-
if (prev && freeElement.nodeName === prev.nodeName && util.isSameAttributes(freeElement, prev)) {
|
|
235
|
-
prev.innerHTML += '<BR>' + freeElement.innerHTML;
|
|
236
|
-
util.removeItem(freeElement);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (!isComp) util.removeItem(f);
|
|
241
|
-
if (!!html) first = false;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
this.setRange(focusElement, 0, focusElement, 0);
|
|
245
|
-
}
|
|
246
|
-
// replace format
|
|
247
|
-
else {
|
|
248
|
-
for (let i = 0, len = modifiedFormsts.length, node, newFormat; i < len; i++) {
|
|
249
|
-
node = modifiedFormsts[i];
|
|
250
|
-
|
|
251
|
-
if ((node.nodeName.toLowerCase() !== value.toLowerCase() || (node.className.match(/(\s|^)__se__format__[^\s]+/) || [''])[0].trim() !== className) && !util.isComponent(node)) {
|
|
252
|
-
newFormat = tag.cloneNode(false);
|
|
253
|
-
util.copyFormatAttributes(newFormat, node);
|
|
254
|
-
newFormat.innerHTML = node.innerHTML;
|
|
255
|
-
|
|
256
|
-
node.parentNode.replaceChild(newFormat, node);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (i === 0) first = newFormat || node;
|
|
260
|
-
if (i === len - 1) last = newFormat || node;
|
|
261
|
-
newFormat = null;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
this.setRange(util.getNodeFromPath(firstPath, first), startOffset, util.getNodeFromPath(lastPath, last), endOffset);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// history stack
|
|
268
|
-
this.history.push(false);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
this.submenuOff();
|
|
272
|
-
}
|
|
273
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* wysiwyg web editor
|
|
3
|
-
*
|
|
4
|
-
* suneditor.js
|
|
5
|
-
* Copyright 2017 JiHong Lee.
|
|
6
|
-
* MIT license.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
import colorPicker from '../modules/_colorPicker';
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
name: 'hiliteColor',
|
|
14
|
-
display: 'submenu',
|
|
15
|
-
add: function (core, targetElement) {
|
|
16
|
-
core.addModule([colorPicker]);
|
|
17
|
-
|
|
18
|
-
const context = core.context;
|
|
19
|
-
context.hiliteColor = {
|
|
20
|
-
previewEl: null,
|
|
21
|
-
colorInput: null,
|
|
22
|
-
colorList: null
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** set submenu */
|
|
26
|
-
let listDiv = this.setSubmenu(core);
|
|
27
|
-
context.hiliteColor.colorInput = listDiv.querySelector('._se_color_picker_input');
|
|
28
|
-
|
|
29
|
-
/** add event listeners */
|
|
30
|
-
context.hiliteColor.colorInput.addEventListener('keyup', this.onChangeInput.bind(core));
|
|
31
|
-
listDiv.querySelector('._se_color_picker_submit').addEventListener('click', this.submit.bind(core));
|
|
32
|
-
listDiv.querySelector('._se_color_picker_remove').addEventListener('click', this.remove.bind(core));
|
|
33
|
-
listDiv.addEventListener('click', this.pickup.bind(core));
|
|
34
|
-
|
|
35
|
-
context.hiliteColor.colorList = listDiv.querySelectorAll('li button');
|
|
36
|
-
|
|
37
|
-
/** append target button menu */
|
|
38
|
-
core.initMenuTarget(this.name, targetElement, listDiv);
|
|
39
|
-
|
|
40
|
-
/** empty memory */
|
|
41
|
-
listDiv = null;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
setSubmenu: function (core) {
|
|
45
|
-
const colorArea = core.context.colorPicker.colorListHTML;
|
|
46
|
-
const listDiv = core.util.createElement('DIV');
|
|
47
|
-
|
|
48
|
-
listDiv.className = 'se-submenu se-list-layer';
|
|
49
|
-
listDiv.innerHTML = colorArea;
|
|
50
|
-
|
|
51
|
-
return listDiv;
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @Override submenu
|
|
56
|
-
*/
|
|
57
|
-
on: function () {
|
|
58
|
-
const contextPicker = this.context.colorPicker;
|
|
59
|
-
const contextHiliteColor = this.context.hiliteColor;
|
|
60
|
-
|
|
61
|
-
contextPicker._colorInput = contextHiliteColor.colorInput;
|
|
62
|
-
const color = this.wwComputedStyle.backgroundColor;
|
|
63
|
-
contextPicker._defaultColor = color ? this.plugins.colorPicker.isHexColor(color) ? color : this.plugins.colorPicker.rgb2hex(color) : "#ffffff";
|
|
64
|
-
contextPicker._styleProperty = 'backgroundColor';
|
|
65
|
-
contextPicker._colorList = contextHiliteColor.colorList;
|
|
66
|
-
|
|
67
|
-
this.plugins.colorPicker.init.call(this, this.getSelectionNode(), null);
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @Override _colorPicker
|
|
72
|
-
*/
|
|
73
|
-
onChangeInput: function (e) {
|
|
74
|
-
this.plugins.colorPicker.setCurrentColor.call(this, e.target.value);
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
submit: function () {
|
|
78
|
-
this.plugins.hiliteColor.applyColor.call(this, this.context.colorPicker._currentColor);
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
pickup: function (e) {
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
e.stopPropagation();
|
|
84
|
-
|
|
85
|
-
this.plugins.hiliteColor.applyColor.call(this, e.target.getAttribute('data-value'));
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
remove: function () {
|
|
89
|
-
this.nodeChange(null, ['background-color'], ['span'], true);
|
|
90
|
-
this.submenuOff();
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
applyColor: function (color) {
|
|
94
|
-
if (!color) return;
|
|
95
|
-
|
|
96
|
-
const newNode = this.util.createElement('SPAN');
|
|
97
|
-
newNode.style.backgroundColor = color;
|
|
98
|
-
this.nodeChange(newNode, ['background-color'], null, null);
|
|
99
|
-
|
|
100
|
-
this.submenuOff();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* wysiwyg web editor
|
|
3
|
-
*
|
|
4
|
-
* suneditor.js
|
|
5
|
-
* Copyright 2017 JiHong Lee.
|
|
6
|
-
* MIT license.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
name: 'horizontalRule',
|
|
12
|
-
display: 'submenu',
|
|
13
|
-
add: function (core, targetElement) {
|
|
14
|
-
core.context.horizontalRule = {
|
|
15
|
-
currentHR: null,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/** set submenu */
|
|
19
|
-
let listDiv = this.setSubmenu(core);
|
|
20
|
-
|
|
21
|
-
/** add event listeners */
|
|
22
|
-
listDiv.querySelector('ul').addEventListener('click', this.horizontalRulePick.bind(core));
|
|
23
|
-
|
|
24
|
-
/** append target button menu */
|
|
25
|
-
core.initMenuTarget(this.name, targetElement, listDiv);
|
|
26
|
-
|
|
27
|
-
/** empty memory */
|
|
28
|
-
listDiv = null;
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
setSubmenu: function (core) {
|
|
32
|
-
const lang = core.lang;
|
|
33
|
-
const listDiv = core.util.createElement('DIV');
|
|
34
|
-
const items = core.options.hrItems || [{name: lang.toolbar.hr_solid, class: '__se__solid'}, {name: lang.toolbar.hr_dashed, class: '__se__dashed'}, {name: lang.toolbar.hr_dotted, class: '__se__dotted'}];
|
|
35
|
-
|
|
36
|
-
let list = '';
|
|
37
|
-
for (let i = 0, len = items.length; i < len; i++) {
|
|
38
|
-
list += '<li>' +
|
|
39
|
-
'<button type="button" class="se-btn-list btn_line" data-command="horizontalRule" data-value="' + items[i].class + '" title="' + items[i].name + '" aria-label="' + items[i].name + '">' +
|
|
40
|
-
'<hr' + (items[i].class ? ' class="' + items[i].class + '"' : '') + (items[i].style ? ' style="' + items[i].style + '"' : '') + '/>' +
|
|
41
|
-
'</button>' +
|
|
42
|
-
'</li>';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
listDiv.className = 'se-submenu se-list-layer se-list-line';
|
|
46
|
-
listDiv.innerHTML = '' +
|
|
47
|
-
'<div class="se-list-inner">' +
|
|
48
|
-
'<ul class="se-list-basic">' +
|
|
49
|
-
list +
|
|
50
|
-
'</ul>' +
|
|
51
|
-
'</div>';
|
|
52
|
-
|
|
53
|
-
return listDiv;
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
active: function (element) {
|
|
57
|
-
if (!element) {
|
|
58
|
-
if (this.util.hasClass(this.context.horizontalRule.currentHR, 'on')) {
|
|
59
|
-
this.controllersOff();
|
|
60
|
-
}
|
|
61
|
-
} else if (/HR/i.test(element.nodeName)) {
|
|
62
|
-
this.context.horizontalRule.currentHR = element;
|
|
63
|
-
if (!this.util.hasClass(element, 'on')) {
|
|
64
|
-
this.util.addClass(element, 'on');
|
|
65
|
-
this.controllersOn('hr', this.util.removeClass.bind(this.util, element, 'on'));
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return false;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
appendHr: function (hrTemp) {
|
|
74
|
-
this.focus();
|
|
75
|
-
return this.insertComponent(hrTemp.cloneNode(false), false, true, false);
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
horizontalRulePick: function (e) {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
e.stopPropagation();
|
|
81
|
-
|
|
82
|
-
let target = e.target;
|
|
83
|
-
let command = target.getAttribute('data-command');
|
|
84
|
-
|
|
85
|
-
while (!command && !/UL/i.test(target.tagName)) {
|
|
86
|
-
target = target.parentNode;
|
|
87
|
-
command = target.getAttribute('data-command');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (!command) return;
|
|
91
|
-
|
|
92
|
-
const oNode = this.plugins.horizontalRule.appendHr.call(this, target.firstElementChild);
|
|
93
|
-
if (oNode) {
|
|
94
|
-
this.setRange(oNode, 0, oNode, 0);
|
|
95
|
-
this.submenuOff();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* wysiwyg web editor
|
|
3
|
-
*
|
|
4
|
-
* suneditor.js
|
|
5
|
-
* Copyright 20197 JiHong Lee.
|
|
6
|
-
* MIT license.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
name: 'lineHeight',
|
|
12
|
-
display: 'submenu',
|
|
13
|
-
add: function (core, targetElement) {
|
|
14
|
-
const context = core.context;
|
|
15
|
-
context.lineHeight = {
|
|
16
|
-
_sizeList: null,
|
|
17
|
-
currentSize: -1
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** set submenu */
|
|
21
|
-
let listDiv = this.setSubmenu(core);
|
|
22
|
-
let listUl = listDiv.querySelector('ul');
|
|
23
|
-
|
|
24
|
-
/** add event listeners */
|
|
25
|
-
listUl.addEventListener('click', this.pickup.bind(core));
|
|
26
|
-
|
|
27
|
-
context.lineHeight._sizeList = listUl.querySelectorAll('li button');
|
|
28
|
-
|
|
29
|
-
/** append target button menu */
|
|
30
|
-
core.initMenuTarget(this.name, targetElement, listDiv);
|
|
31
|
-
|
|
32
|
-
/** empty memory */
|
|
33
|
-
listDiv = null, listUl = null;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
setSubmenu: function (core) {
|
|
37
|
-
const option = core.options;
|
|
38
|
-
const lang = core.lang;
|
|
39
|
-
const listDiv = core.util.createElement('DIV');
|
|
40
|
-
|
|
41
|
-
listDiv.className = 'se-submenu se-list-layer';
|
|
42
|
-
|
|
43
|
-
const sizeList = !option.lineHeights ? [
|
|
44
|
-
{text: '1', value: 1},
|
|
45
|
-
{text: '1.15', value: 1.15},
|
|
46
|
-
{text: '1.5', value: 1.5},
|
|
47
|
-
{text: '2', value: 2}
|
|
48
|
-
] : option.lineHeights;
|
|
49
|
-
|
|
50
|
-
let list = '<div class="se-list-inner">' +
|
|
51
|
-
'<ul class="se-list-basic">' +
|
|
52
|
-
'<li><button type="button" class="default_value se-btn-list" title="' + lang.toolbar.default + '" aria-label="' + lang.toolbar.default + '">(' + lang.toolbar.default + ')</button></li>';
|
|
53
|
-
for (let i = 0, len = sizeList.length, size; i < len; i++) {
|
|
54
|
-
size = sizeList[i];
|
|
55
|
-
list += '<li><button type="button" class="se-btn-list" data-value="' + size.value + '" title="' + size.text + '" aria-label="' + size.text + '">' + size.text + '</button></li>';
|
|
56
|
-
}
|
|
57
|
-
list += '</ul></div>';
|
|
58
|
-
|
|
59
|
-
listDiv.innerHTML = list;
|
|
60
|
-
|
|
61
|
-
return listDiv;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @Override submenu
|
|
66
|
-
*/
|
|
67
|
-
on: function () {
|
|
68
|
-
const lineHeightContext = this.context.lineHeight;
|
|
69
|
-
const sizeList = lineHeightContext._sizeList;
|
|
70
|
-
const format = this.util.getFormatElement(this.getSelectionNode());
|
|
71
|
-
const currentSize = !format ? '' : format.style.lineHeight + '';
|
|
72
|
-
|
|
73
|
-
if (currentSize !== lineHeightContext.currentSize) {
|
|
74
|
-
for (let i = 0, len = sizeList.length; i < len; i++) {
|
|
75
|
-
if (currentSize === sizeList[i].getAttribute('data-value')) {
|
|
76
|
-
this.util.addClass(sizeList[i], 'active');
|
|
77
|
-
} else {
|
|
78
|
-
this.util.removeClass(sizeList[i], 'active');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
lineHeightContext.currentSize = currentSize;
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
pickup: function (e) {
|
|
87
|
-
if (!/^BUTTON$/i.test(e.target.tagName)) return false;
|
|
88
|
-
|
|
89
|
-
e.preventDefault();
|
|
90
|
-
e.stopPropagation();
|
|
91
|
-
|
|
92
|
-
const value = e.target.getAttribute('data-value') || '';
|
|
93
|
-
const formats = this.getSelectedElements();
|
|
94
|
-
|
|
95
|
-
for (let i = 0, len = formats.length; i < len; i++) {
|
|
96
|
-
formats[i].style.lineHeight = value;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.submenuOff();
|
|
100
|
-
|
|
101
|
-
// history stack
|
|
102
|
-
this.history.push(false);
|
|
103
|
-
}
|
|
104
|
-
};
|