suneditor 2.44.2 → 2.44.4
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/LICENSE.txt +20 -20
- package/README.md +1585 -1585
- package/dist/css/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +2 -2
- package/package.json +71 -71
- package/src/assets/css/suneditor-contents.css +556 -556
- package/src/assets/css/suneditor.css +0 -0
- package/src/assets/defaultIcons.js +103 -103
- package/src/lang/Lang.d.ts +143 -143
- package/src/lang/ckb.d.ts +4 -4
- package/src/lang/ckb.js +187 -187
- package/src/lang/da.d.ts +4 -4
- package/src/lang/da.js +191 -191
- package/src/lang/de.d.ts +4 -4
- package/src/lang/de.js +187 -187
- package/src/lang/en.d.ts +4 -4
- package/src/lang/en.js +187 -187
- package/src/lang/es.d.ts +4 -4
- package/src/lang/es.js +187 -187
- package/src/lang/fr.d.ts +4 -4
- package/src/lang/fr.js +188 -188
- package/src/lang/he.d.ts +4 -4
- package/src/lang/he.js +188 -188
- package/src/lang/index.d.ts +22 -21
- package/src/lang/index.js +25 -24
- package/src/lang/it.d.ts +4 -4
- package/src/lang/it.js +188 -188
- package/src/lang/ja.d.ts +4 -4
- package/src/lang/ja.js +187 -187
- package/src/lang/ko.d.ts +4 -4
- package/src/lang/ko.js +187 -187
- package/src/lang/lv.d.ts +4 -4
- package/src/lang/lv.js +187 -187
- package/src/lang/nl.d.ts +4 -4
- package/src/lang/nl.js +187 -187
- package/src/lang/pl.d.ts +4 -4
- package/src/lang/pl.js +187 -187
- package/src/lang/pt_br.d.ts +4 -4
- package/src/lang/pt_br.js +189 -189
- package/src/lang/ro.d.ts +4 -4
- package/src/lang/ro.js +187 -187
- package/src/lang/ru.d.ts +4 -4
- package/src/lang/ru.js +187 -187
- package/src/lang/se.d.ts +4 -4
- package/src/lang/se.js +191 -191
- package/src/lang/ua.d.ts +5 -5
- package/src/lang/ua.js +188 -188
- package/src/lang/ur.d.ts +5 -0
- package/src/lang/ur.js +188 -0
- package/src/lang/zh_cn.d.ts +4 -4
- package/src/lang/zh_cn.js +187 -187
- package/src/lib/constructor.js +1 -2
- package/src/lib/context.d.ts +42 -42
- package/src/lib/context.js +0 -0
- package/src/lib/core.d.ts +1101 -1101
- package/src/lib/core.js +220 -99
- package/src/lib/history.d.ts +48 -48
- package/src/lib/history.js +218 -218
- package/src/lib/util.d.ts +677 -677
- package/src/lib/util.js +38 -12
- package/src/options.d.ts +608 -608
- package/src/plugins/CommandPlugin.d.ts +7 -7
- package/src/plugins/DialogPlugin.d.ts +19 -19
- package/src/plugins/FileBrowserPlugin.d.ts +29 -29
- package/src/plugins/Module.d.ts +14 -14
- package/src/plugins/Plugin.d.ts +41 -41
- package/src/plugins/SubmenuPlugin.d.ts +7 -7
- package/src/plugins/command/blockquote.d.ts +4 -4
- package/src/plugins/command/blockquote.js +46 -46
- package/src/plugins/dialog/audio.d.ts +4 -4
- package/src/plugins/dialog/audio.js +556 -554
- package/src/plugins/dialog/image.d.ts +4 -4
- package/src/plugins/dialog/image.js +1122 -1107
- package/src/plugins/dialog/link.d.ts +4 -4
- package/src/plugins/dialog/link.js +223 -223
- package/src/plugins/dialog/math.d.ts +4 -4
- package/src/plugins/dialog/math.js +294 -294
- package/src/plugins/dialog/mention.d.ts +5 -5
- package/src/plugins/dialog/mention.js +242 -242
- package/src/plugins/dialog/video.d.ts +4 -4
- package/src/plugins/dialog/video.js +983 -981
- package/src/plugins/fileBrowser/imageGallery.d.ts +4 -4
- package/src/plugins/fileBrowser/imageGallery.js +63 -63
- package/src/plugins/index.d.ts +79 -79
- package/src/plugins/index.js +32 -32
- package/src/plugins/modules/_anchor.js +461 -462
- package/src/plugins/modules/_colorPicker.d.ts +59 -59
- package/src/plugins/modules/_colorPicker.js +0 -0
- package/src/plugins/modules/_notice.d.ts +20 -20
- package/src/plugins/modules/_notice.js +72 -72
- package/src/plugins/modules/_selectMenu.js +118 -118
- package/src/plugins/modules/component.d.ts +24 -24
- package/src/plugins/modules/component.js +82 -82
- package/src/plugins/modules/dialog.d.ts +27 -27
- package/src/plugins/modules/dialog.js +174 -174
- package/src/plugins/modules/fileBrowser.d.ts +41 -41
- package/src/plugins/modules/fileBrowser.js +373 -373
- package/src/plugins/modules/fileManager.d.ts +66 -66
- package/src/plugins/modules/fileManager.js +325 -324
- package/src/plugins/modules/index.d.ts +10 -10
- package/src/plugins/modules/index.js +8 -8
- package/src/plugins/modules/resizing.d.ts +153 -153
- package/src/plugins/modules/resizing.js +895 -895
- package/src/plugins/submenu/align.d.ts +4 -4
- package/src/plugins/submenu/align.js +160 -160
- package/src/plugins/submenu/font.d.ts +4 -4
- package/src/plugins/submenu/font.js +120 -120
- package/src/plugins/submenu/fontColor.d.ts +4 -4
- package/src/plugins/submenu/fontColor.js +0 -0
- package/src/plugins/submenu/fontSize.d.ts +4 -4
- package/src/plugins/submenu/fontSize.js +112 -112
- package/src/plugins/submenu/formatBlock.d.ts +4 -4
- package/src/plugins/submenu/formatBlock.js +273 -273
- package/src/plugins/submenu/hiliteColor.d.ts +4 -4
- package/src/plugins/submenu/hiliteColor.js +0 -0
- package/src/plugins/submenu/horizontalRule.d.ts +4 -4
- package/src/plugins/submenu/horizontalRule.js +98 -98
- package/src/plugins/submenu/lineHeight.d.ts +4 -4
- package/src/plugins/submenu/lineHeight.js +104 -104
- package/src/plugins/submenu/list.d.ts +4 -4
- package/src/plugins/submenu/list.js +456 -455
- package/src/plugins/submenu/paragraphStyle.d.ts +4 -4
- package/src/plugins/submenu/paragraphStyle.js +135 -135
- package/src/plugins/submenu/table.d.ts +4 -4
- package/src/plugins/submenu/template.d.ts +4 -4
- package/src/plugins/submenu/template.js +71 -71
- package/src/plugins/submenu/textStyle.d.ts +4 -4
- package/src/plugins/submenu/textStyle.js +167 -167
- package/src/suneditor.d.ts +9 -9
- package/src/suneditor.js +75 -75
- package/src/suneditor_build.js +17 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DialogPlugin } from '../DialogPlugin';
|
|
2
|
-
|
|
3
|
-
declare const link: DialogPlugin;
|
|
4
|
-
|
|
1
|
+
import { DialogPlugin } from '../DialogPlugin';
|
|
2
|
+
|
|
3
|
+
declare const link: DialogPlugin;
|
|
4
|
+
|
|
5
5
|
export default link;
|
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* wysiwyg web editor
|
|
3
|
-
*
|
|
4
|
-
* suneditor.js
|
|
5
|
-
* Copyright 2017 JiHong Lee.
|
|
6
|
-
* MIT license.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
import dialog from '../modules/dialog';
|
|
11
|
-
import anchor from '../modules/_anchor';
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
name: 'link',
|
|
15
|
-
display: 'dialog',
|
|
16
|
-
add: function (core) {
|
|
17
|
-
core.addModule([dialog, anchor]);
|
|
18
|
-
|
|
19
|
-
const context = core.context;
|
|
20
|
-
const contextLink = context.link = {
|
|
21
|
-
focusElement: null, // @Override dialog // This element has focus when the dialog is opened.
|
|
22
|
-
_linkAnchor: null,
|
|
23
|
-
anchorCtx: null
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** link dialog */
|
|
27
|
-
let link_dialog = this.setDialog(core);
|
|
28
|
-
contextLink.modal = link_dialog;
|
|
29
|
-
|
|
30
|
-
/** link controller */
|
|
31
|
-
let link_controller = this.setController_LinkButton(core);
|
|
32
|
-
contextLink.linkController = link_controller;
|
|
33
|
-
|
|
34
|
-
link_dialog.querySelector('form').addEventListener('submit', this.submit.bind(core));
|
|
35
|
-
link_controller.addEventListener('click', this.onClick_linkController.bind(core));
|
|
36
|
-
|
|
37
|
-
/** append html */
|
|
38
|
-
context.dialog.modal.appendChild(link_dialog);
|
|
39
|
-
|
|
40
|
-
/** append controller */
|
|
41
|
-
context.element.relative.appendChild(link_controller);
|
|
42
|
-
|
|
43
|
-
/** link event */
|
|
44
|
-
core.plugins.anchor.initEvent.call(core, 'link', link_dialog);
|
|
45
|
-
contextLink.focusElement = context.anchor.caller.link.urlInput;
|
|
46
|
-
|
|
47
|
-
/** empty memory */
|
|
48
|
-
link_dialog = null, link_controller = null;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
/** dialog */
|
|
52
|
-
setDialog: function (core) {
|
|
53
|
-
const lang = core.lang;
|
|
54
|
-
const dialog = core.util.createElement('DIV');
|
|
55
|
-
const icons = core.icons;
|
|
56
|
-
|
|
57
|
-
dialog.className = 'se-dialog-content';
|
|
58
|
-
dialog.style.display = 'none';
|
|
59
|
-
let html = '' +
|
|
60
|
-
'<form>' +
|
|
61
|
-
'<div class="se-dialog-header">' +
|
|
62
|
-
'<button type="button" data-command="close" class="se-btn se-dialog-close" title="' + lang.dialogBox.close + '" aria-label="' + lang.dialogBox.close + '">' +
|
|
63
|
-
icons.cancel +
|
|
64
|
-
'</button>' +
|
|
65
|
-
'<span class="se-modal-title">' + lang.dialogBox.linkBox.title + '</span>' +
|
|
66
|
-
'</div>' +
|
|
67
|
-
core.context.anchor.forms.innerHTML +
|
|
68
|
-
'<div class="se-dialog-footer">' +
|
|
69
|
-
'<button type="submit" class="se-btn-primary" title="' + lang.dialogBox.submitButton + '" aria-label="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
|
|
70
|
-
'</div>' +
|
|
71
|
-
'</form>';
|
|
72
|
-
|
|
73
|
-
dialog.innerHTML = html;
|
|
74
|
-
return dialog;
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/** modify controller button */
|
|
78
|
-
setController_LinkButton: function (core) {
|
|
79
|
-
const lang = core.lang;
|
|
80
|
-
const icons = core.icons;
|
|
81
|
-
const link_btn = core.util.createElement('DIV');
|
|
82
|
-
|
|
83
|
-
link_btn.className = 'se-controller se-controller-link';
|
|
84
|
-
link_btn.innerHTML = '' +
|
|
85
|
-
'<div class="se-arrow se-arrow-up"></div>' +
|
|
86
|
-
'<div class="link-content"><span><a target="_blank" href=""></a> </span>' +
|
|
87
|
-
'<div class="se-btn-group">' +
|
|
88
|
-
'<button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">' +
|
|
89
|
-
icons.edit +
|
|
90
|
-
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.edit + '</span></span>' +
|
|
91
|
-
'</button>' +
|
|
92
|
-
'<button type="button" data-command="unlink" tabindex="-1" class="se-btn se-tooltip">' +
|
|
93
|
-
icons.unlink +
|
|
94
|
-
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.unlink + '</span></span>' +
|
|
95
|
-
'</button>' +
|
|
96
|
-
'<button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">' +
|
|
97
|
-
icons.delete +
|
|
98
|
-
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.remove + '</span></span>' +
|
|
99
|
-
'</button>' +
|
|
100
|
-
'</div>' +
|
|
101
|
-
'</div>';
|
|
102
|
-
|
|
103
|
-
return link_btn;
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @Override dialog
|
|
108
|
-
*/
|
|
109
|
-
open: function () {
|
|
110
|
-
this.plugins.dialog.open.call(this, 'link', 'link' === this.currentControllerName);
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
submit: function (e) {
|
|
114
|
-
this.showLoading();
|
|
115
|
-
|
|
116
|
-
e.preventDefault();
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
const oA = this.plugins.anchor.createAnchor.call(this, this.context.anchor.caller.link, false);
|
|
121
|
-
if (oA === null) return;
|
|
122
|
-
|
|
123
|
-
if (!this.context.dialog.updateModal) {
|
|
124
|
-
const selectedFormats = this.getSelectedElements();
|
|
125
|
-
if (selectedFormats.length > 1) {
|
|
126
|
-
const oFormat = this.util.createElement(selectedFormats[0].nodeName);
|
|
127
|
-
oFormat.appendChild(oA);
|
|
128
|
-
if (!this.insertNode(oFormat, null, true)) return;
|
|
129
|
-
} else {
|
|
130
|
-
if (!this.insertNode(oA, null, true)) return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
this.setRange(oA.childNodes[0], 0, oA.childNodes[0], oA.textContent.length);
|
|
134
|
-
} else {
|
|
135
|
-
// set range
|
|
136
|
-
const textNode = this.context.link._linkAnchor.childNodes[0];
|
|
137
|
-
this.setRange(textNode, 0, textNode, textNode.textContent.length);
|
|
138
|
-
}
|
|
139
|
-
} finally {
|
|
140
|
-
this.plugins.dialog.close.call(this);
|
|
141
|
-
this.closeLoading();
|
|
142
|
-
// history stack
|
|
143
|
-
this.history.push(false);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return false;
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* @Override core
|
|
151
|
-
*/
|
|
152
|
-
active: function (element) {
|
|
153
|
-
if (!element) {
|
|
154
|
-
if (this.controllerArray.indexOf(this.context.link.linkController) > -1) {
|
|
155
|
-
this.controllersOff();
|
|
156
|
-
}
|
|
157
|
-
} else if (this.util.isAnchor(element) && element.getAttribute('data-image-link') === null) {
|
|
158
|
-
if (this.controllerArray.indexOf(this.context.link.linkController) < 0) {
|
|
159
|
-
this.plugins.link.call_controller.call(this, element);
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return false;
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @Override dialog
|
|
169
|
-
*/
|
|
170
|
-
on: function (update) {
|
|
171
|
-
this.plugins.anchor.on.call(this, this.context.anchor.caller.link, update);
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
call_controller: function (selectionATag) {
|
|
175
|
-
this.editLink = this.context.link._linkAnchor = this.context.anchor.caller.link.linkAnchor = selectionATag;
|
|
176
|
-
const linkBtn = this.context.link.linkController;
|
|
177
|
-
const link = linkBtn.querySelector('a');
|
|
178
|
-
|
|
179
|
-
link.href = selectionATag.href;
|
|
180
|
-
link.title = selectionATag.textContent;
|
|
181
|
-
link.textContent = selectionATag.textContent;
|
|
182
|
-
|
|
183
|
-
this.util.addClass(selectionATag, 'on');
|
|
184
|
-
this.setControllerPosition(linkBtn, selectionATag, 'bottom', {left: 0, top: 0});
|
|
185
|
-
this.controllersOn(linkBtn, selectionATag, 'link', this.util.removeClass.bind(this.util, this.context.link._linkAnchor, 'on'));
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
onClick_linkController: function (e) {
|
|
189
|
-
e.stopPropagation();
|
|
190
|
-
|
|
191
|
-
const command = e.target.getAttribute('data-command') || e.target.parentNode.getAttribute('data-command');
|
|
192
|
-
if (!command) return;
|
|
193
|
-
|
|
194
|
-
e.preventDefault();
|
|
195
|
-
|
|
196
|
-
if (/update/.test(command)) {
|
|
197
|
-
this.plugins.dialog.open.call(this, 'link', true);
|
|
198
|
-
} else if (/unlink/.test(command)) {
|
|
199
|
-
const sc = this.util.getChildElement(this.context.link._linkAnchor, function (current) { return current.childNodes.length === 0 || current.nodeType === 3; }, false);
|
|
200
|
-
const ec = this.util.getChildElement(this.context.link._linkAnchor, function (current) { return current.childNodes.length === 0 || current.nodeType === 3; }, true);
|
|
201
|
-
this.setRange(sc, 0, ec, ec.textContent.length);
|
|
202
|
-
this.nodeChange(null, null, ['A'], false);
|
|
203
|
-
} else {
|
|
204
|
-
/** delete */
|
|
205
|
-
this.util.removeItem(this.context.link._linkAnchor);
|
|
206
|
-
this.context.anchor.caller.link.linkAnchor = null;
|
|
207
|
-
this.focus();
|
|
208
|
-
|
|
209
|
-
// history stack
|
|
210
|
-
this.history.push(false);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
this.controllersOff();
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* @Override dialog
|
|
218
|
-
*/
|
|
219
|
-
init: function () {
|
|
220
|
-
this.context.link.linkController.style.display = 'none';
|
|
221
|
-
this.plugins.anchor.init.call(this, this.context.anchor.caller.link);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* wysiwyg web editor
|
|
3
|
+
*
|
|
4
|
+
* suneditor.js
|
|
5
|
+
* Copyright 2017 JiHong Lee.
|
|
6
|
+
* MIT license.
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
import dialog from '../modules/dialog';
|
|
11
|
+
import anchor from '../modules/_anchor';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
name: 'link',
|
|
15
|
+
display: 'dialog',
|
|
16
|
+
add: function (core) {
|
|
17
|
+
core.addModule([dialog, anchor]);
|
|
18
|
+
|
|
19
|
+
const context = core.context;
|
|
20
|
+
const contextLink = context.link = {
|
|
21
|
+
focusElement: null, // @Override dialog // This element has focus when the dialog is opened.
|
|
22
|
+
_linkAnchor: null,
|
|
23
|
+
anchorCtx: null
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** link dialog */
|
|
27
|
+
let link_dialog = this.setDialog(core);
|
|
28
|
+
contextLink.modal = link_dialog;
|
|
29
|
+
|
|
30
|
+
/** link controller */
|
|
31
|
+
let link_controller = this.setController_LinkButton(core);
|
|
32
|
+
contextLink.linkController = link_controller;
|
|
33
|
+
|
|
34
|
+
link_dialog.querySelector('form').addEventListener('submit', this.submit.bind(core));
|
|
35
|
+
link_controller.addEventListener('click', this.onClick_linkController.bind(core));
|
|
36
|
+
|
|
37
|
+
/** append html */
|
|
38
|
+
context.dialog.modal.appendChild(link_dialog);
|
|
39
|
+
|
|
40
|
+
/** append controller */
|
|
41
|
+
context.element.relative.appendChild(link_controller);
|
|
42
|
+
|
|
43
|
+
/** link event */
|
|
44
|
+
core.plugins.anchor.initEvent.call(core, 'link', link_dialog);
|
|
45
|
+
contextLink.focusElement = context.anchor.caller.link.urlInput;
|
|
46
|
+
|
|
47
|
+
/** empty memory */
|
|
48
|
+
link_dialog = null, link_controller = null;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/** dialog */
|
|
52
|
+
setDialog: function (core) {
|
|
53
|
+
const lang = core.lang;
|
|
54
|
+
const dialog = core.util.createElement('DIV');
|
|
55
|
+
const icons = core.icons;
|
|
56
|
+
|
|
57
|
+
dialog.className = 'se-dialog-content';
|
|
58
|
+
dialog.style.display = 'none';
|
|
59
|
+
let html = '' +
|
|
60
|
+
'<form>' +
|
|
61
|
+
'<div class="se-dialog-header">' +
|
|
62
|
+
'<button type="button" data-command="close" class="se-btn se-dialog-close" title="' + lang.dialogBox.close + '" aria-label="' + lang.dialogBox.close + '">' +
|
|
63
|
+
icons.cancel +
|
|
64
|
+
'</button>' +
|
|
65
|
+
'<span class="se-modal-title">' + lang.dialogBox.linkBox.title + '</span>' +
|
|
66
|
+
'</div>' +
|
|
67
|
+
core.context.anchor.forms.innerHTML +
|
|
68
|
+
'<div class="se-dialog-footer">' +
|
|
69
|
+
'<button type="submit" class="se-btn-primary" title="' + lang.dialogBox.submitButton + '" aria-label="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
|
|
70
|
+
'</div>' +
|
|
71
|
+
'</form>';
|
|
72
|
+
|
|
73
|
+
dialog.innerHTML = html;
|
|
74
|
+
return dialog;
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/** modify controller button */
|
|
78
|
+
setController_LinkButton: function (core) {
|
|
79
|
+
const lang = core.lang;
|
|
80
|
+
const icons = core.icons;
|
|
81
|
+
const link_btn = core.util.createElement('DIV');
|
|
82
|
+
|
|
83
|
+
link_btn.className = 'se-controller se-controller-link';
|
|
84
|
+
link_btn.innerHTML = '' +
|
|
85
|
+
'<div class="se-arrow se-arrow-up"></div>' +
|
|
86
|
+
'<div class="link-content"><span><a target="_blank" href=""></a> </span>' +
|
|
87
|
+
'<div class="se-btn-group">' +
|
|
88
|
+
'<button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">' +
|
|
89
|
+
icons.edit +
|
|
90
|
+
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.edit + '</span></span>' +
|
|
91
|
+
'</button>' +
|
|
92
|
+
'<button type="button" data-command="unlink" tabindex="-1" class="se-btn se-tooltip">' +
|
|
93
|
+
icons.unlink +
|
|
94
|
+
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.unlink + '</span></span>' +
|
|
95
|
+
'</button>' +
|
|
96
|
+
'<button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">' +
|
|
97
|
+
icons.delete +
|
|
98
|
+
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.remove + '</span></span>' +
|
|
99
|
+
'</button>' +
|
|
100
|
+
'</div>' +
|
|
101
|
+
'</div>';
|
|
102
|
+
|
|
103
|
+
return link_btn;
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @Override dialog
|
|
108
|
+
*/
|
|
109
|
+
open: function () {
|
|
110
|
+
this.plugins.dialog.open.call(this, 'link', 'link' === this.currentControllerName);
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
submit: function (e) {
|
|
114
|
+
this.showLoading();
|
|
115
|
+
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const oA = this.plugins.anchor.createAnchor.call(this, this.context.anchor.caller.link, false);
|
|
121
|
+
if (oA === null) return;
|
|
122
|
+
|
|
123
|
+
if (!this.context.dialog.updateModal) {
|
|
124
|
+
const selectedFormats = this.getSelectedElements();
|
|
125
|
+
if (selectedFormats.length > 1) {
|
|
126
|
+
const oFormat = this.util.createElement(selectedFormats[0].nodeName);
|
|
127
|
+
oFormat.appendChild(oA);
|
|
128
|
+
if (!this.insertNode(oFormat, null, true)) return;
|
|
129
|
+
} else {
|
|
130
|
+
if (!this.insertNode(oA, null, true)) return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.setRange(oA.childNodes[0], 0, oA.childNodes[0], oA.textContent.length);
|
|
134
|
+
} else {
|
|
135
|
+
// set range
|
|
136
|
+
const textNode = this.context.link._linkAnchor.childNodes[0];
|
|
137
|
+
this.setRange(textNode, 0, textNode, textNode.textContent.length);
|
|
138
|
+
}
|
|
139
|
+
} finally {
|
|
140
|
+
this.plugins.dialog.close.call(this);
|
|
141
|
+
this.closeLoading();
|
|
142
|
+
// history stack
|
|
143
|
+
this.history.push(false);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return false;
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @Override core
|
|
151
|
+
*/
|
|
152
|
+
active: function (element) {
|
|
153
|
+
if (!element) {
|
|
154
|
+
if (this.controllerArray.indexOf(this.context.link.linkController) > -1) {
|
|
155
|
+
this.controllersOff();
|
|
156
|
+
}
|
|
157
|
+
} else if (this.util.isAnchor(element) && element.getAttribute('data-image-link') === null) {
|
|
158
|
+
if (this.controllerArray.indexOf(this.context.link.linkController) < 0) {
|
|
159
|
+
this.plugins.link.call_controller.call(this, element);
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return false;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @Override dialog
|
|
169
|
+
*/
|
|
170
|
+
on: function (update) {
|
|
171
|
+
this.plugins.anchor.on.call(this, this.context.anchor.caller.link, update);
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
call_controller: function (selectionATag) {
|
|
175
|
+
this.editLink = this.context.link._linkAnchor = this.context.anchor.caller.link.linkAnchor = selectionATag;
|
|
176
|
+
const linkBtn = this.context.link.linkController;
|
|
177
|
+
const link = linkBtn.querySelector('a');
|
|
178
|
+
|
|
179
|
+
link.href = selectionATag.href;
|
|
180
|
+
link.title = selectionATag.textContent;
|
|
181
|
+
link.textContent = selectionATag.textContent;
|
|
182
|
+
|
|
183
|
+
this.util.addClass(selectionATag, 'on');
|
|
184
|
+
this.setControllerPosition(linkBtn, selectionATag, 'bottom', {left: 0, top: 0});
|
|
185
|
+
this.controllersOn(linkBtn, selectionATag, 'link', this.util.removeClass.bind(this.util, this.context.link._linkAnchor, 'on'));
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
onClick_linkController: function (e) {
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
|
|
191
|
+
const command = e.target.getAttribute('data-command') || e.target.parentNode.getAttribute('data-command');
|
|
192
|
+
if (!command) return;
|
|
193
|
+
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
|
|
196
|
+
if (/update/.test(command)) {
|
|
197
|
+
this.plugins.dialog.open.call(this, 'link', true);
|
|
198
|
+
} else if (/unlink/.test(command)) {
|
|
199
|
+
const sc = this.util.getChildElement(this.context.link._linkAnchor, function (current) { return current.childNodes.length === 0 || current.nodeType === 3; }, false);
|
|
200
|
+
const ec = this.util.getChildElement(this.context.link._linkAnchor, function (current) { return current.childNodes.length === 0 || current.nodeType === 3; }, true);
|
|
201
|
+
this.setRange(sc, 0, ec, ec.textContent.length);
|
|
202
|
+
this.nodeChange(null, null, ['A'], false);
|
|
203
|
+
} else {
|
|
204
|
+
/** delete */
|
|
205
|
+
this.util.removeItem(this.context.link._linkAnchor);
|
|
206
|
+
this.context.anchor.caller.link.linkAnchor = null;
|
|
207
|
+
this.focus();
|
|
208
|
+
|
|
209
|
+
// history stack
|
|
210
|
+
this.history.push(false);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.controllersOff();
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @Override dialog
|
|
218
|
+
*/
|
|
219
|
+
init: function () {
|
|
220
|
+
this.context.link.linkController.style.display = 'none';
|
|
221
|
+
this.plugins.anchor.init.call(this, this.context.anchor.caller.link);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DialogPlugin } from '../DialogPlugin';
|
|
2
|
-
|
|
3
|
-
declare const math: DialogPlugin;
|
|
4
|
-
|
|
1
|
+
import { DialogPlugin } from '../DialogPlugin';
|
|
2
|
+
|
|
3
|
+
declare const math: DialogPlugin;
|
|
4
|
+
|
|
5
5
|
export default math;
|