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
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import CoreInjector from '../../editorInjector/_core';
|
|
6
|
-
import { dom, unicode, env } from '../../helper';
|
|
6
|
+
import { dom, unicode, env, numbers } from '../../helper';
|
|
7
|
+
const { _w, isTouchDevice } = env;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {Omit<Selection_ & Partial<__se__EditorInjector>, 'selection'>} SelectionThis
|
|
@@ -28,6 +29,13 @@ function Selection_(editor) {
|
|
|
28
29
|
/** @type {HTMLElement|Text} */
|
|
29
30
|
this.selectionNode = null;
|
|
30
31
|
this.__iframeFocus = false;
|
|
32
|
+
this.__hasScrollParents = false;
|
|
33
|
+
this._scrollMargin = 0;
|
|
34
|
+
|
|
35
|
+
_w.setTimeout(() => {
|
|
36
|
+
this.__hasScrollParents = this.eventManager?.scrollparents.length > 0;
|
|
37
|
+
this._scrollMargin = !this.frameContext ? 40 : (numbers.get(_w.getComputedStyle(this.frameContext.get('wysiwyg')).scrollMargin, 0) || 40) + numbers.get(_w.getComputedStyle(this.frameContext.get('wrapper')).paddingBottom, 0);
|
|
38
|
+
}, 1000);
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
Selection_.prototype = {
|
|
@@ -37,19 +45,16 @@ Selection_.prototype = {
|
|
|
37
45
|
* @returns {Selection}
|
|
38
46
|
*/
|
|
39
47
|
get() {
|
|
40
|
-
const wSelection = this.editor.frameContext.get('_ww').getSelection();
|
|
41
48
|
let selection = null;
|
|
42
49
|
|
|
43
|
-
if (this._shadowRoot) {
|
|
44
|
-
selection =
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!selection) {
|
|
48
|
-
selection = wSelection;
|
|
50
|
+
if (typeof this.editor._shadowRoot?.getSelection === 'function') {
|
|
51
|
+
selection = this.editor._shadowRoot.getSelection();
|
|
52
|
+
} else {
|
|
53
|
+
selection = this.frameContext.get('_ww').getSelection();
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
if (!selection) return null;
|
|
52
|
-
if (!this.status._range && !this.
|
|
57
|
+
if (!this.status._range && !this.frameContext.get('wysiwyg').contains(selection.focusNode)) {
|
|
53
58
|
selection.removeAllRanges();
|
|
54
59
|
selection.addRange(this._createDefaultRange());
|
|
55
60
|
}
|
|
@@ -64,7 +69,7 @@ Selection_.prototype = {
|
|
|
64
69
|
*/
|
|
65
70
|
isRange(range) {
|
|
66
71
|
// return /Range/.test(Object.prototype.toString.call(range?.__proto__));
|
|
67
|
-
return range
|
|
72
|
+
return this.instanceCheck.isRange(range);
|
|
68
73
|
},
|
|
69
74
|
|
|
70
75
|
/**
|
|
@@ -75,7 +80,7 @@ Selection_.prototype = {
|
|
|
75
80
|
getRange() {
|
|
76
81
|
const range = this.status._range || this._createDefaultRange();
|
|
77
82
|
const selection = this.get();
|
|
78
|
-
if (range.collapsed === selection.isCollapsed || !this.
|
|
83
|
+
if (range.collapsed === selection.isCollapsed || !this.frameContext.get('wysiwyg').contains(selection.focusNode)) {
|
|
79
84
|
if (this.component.is(range.startContainer)) {
|
|
80
85
|
const compInfo = this.component.get(range.startContainer);
|
|
81
86
|
const container = compInfo?.container;
|
|
@@ -144,9 +149,11 @@ Selection_.prototype = {
|
|
|
144
149
|
eo = eo > 0 ? (ec.nodeType === 1 && !dom.check.isBreak(ec) ? 1 : ec.textContent ? ec.textContent.length : 0) : 0;
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
const range = this.
|
|
152
|
+
const range = this.frameContext.get('_wd').createRange();
|
|
148
153
|
|
|
149
154
|
try {
|
|
155
|
+
so = Math.min(so, sc.textContent?.length || 0);
|
|
156
|
+
eo = Math.min(eo, ec.textContent?.length || 0);
|
|
150
157
|
range.setStart(sc, so);
|
|
151
158
|
range.setEnd(ec, eo);
|
|
152
159
|
this.status.hasFocus = true;
|
|
@@ -166,7 +173,7 @@ Selection_.prototype = {
|
|
|
166
173
|
this.status._range = range;
|
|
167
174
|
this._rangeInfo(range, this.get());
|
|
168
175
|
|
|
169
|
-
if (this.
|
|
176
|
+
if (this.frameOptions.get('iframe')) this.__focus();
|
|
170
177
|
|
|
171
178
|
return range;
|
|
172
179
|
},
|
|
@@ -218,7 +225,7 @@ Selection_.prototype = {
|
|
|
218
225
|
*/
|
|
219
226
|
getRangeAndAddLine(range, container) {
|
|
220
227
|
if (this._isNone(range)) {
|
|
221
|
-
const parent = container?.parentElement || this.
|
|
228
|
+
const parent = container?.parentElement || this.frameContext.get('wysiwyg');
|
|
222
229
|
const op = dom.utils.createElement(this.options.get('defaultLine'), null, '<br>');
|
|
223
230
|
parent.insertBefore(op, container && container !== parent ? (!(/** @type {HTMLElement} */ (container).previousElementSibling) ? container : /** @type {HTMLElement} */ (container).nextElementSibling) : parent.firstElementChild);
|
|
224
231
|
this.setRange(op.firstElementChild, 0, op.firstElementChild, 1);
|
|
@@ -233,9 +240,9 @@ Selection_.prototype = {
|
|
|
233
240
|
* @returns {HTMLElement|Text}
|
|
234
241
|
*/
|
|
235
242
|
getNode() {
|
|
236
|
-
if (!this.
|
|
243
|
+
if (!this.frameContext.get('wysiwyg').contains(this.selectionNode)) this._init();
|
|
237
244
|
if (!this.selectionNode) {
|
|
238
|
-
const selectionNode = /** @type {HTMLElement|Text} */ (dom.query.getEdgeChild(this.
|
|
245
|
+
const selectionNode = /** @type {HTMLElement|Text} */ (dom.query.getEdgeChild(this.frameContext.get('wysiwyg').firstChild, (current) => current.childNodes.length === 0 || current.nodeType === 3, false));
|
|
239
246
|
if (!selectionNode) {
|
|
240
247
|
this._init();
|
|
241
248
|
} else {
|
|
@@ -254,7 +261,7 @@ Selection_.prototype = {
|
|
|
254
261
|
* @returns {{rects: RectsInfo_selection, position: "start"|"end", scrollLeft: number, scrollTop: number}}
|
|
255
262
|
*/
|
|
256
263
|
getRects(target, position) {
|
|
257
|
-
const targetAbs = dom.check.isElement(/** @type {Node} */ (target)) ?
|
|
264
|
+
const targetAbs = dom.check.isElement(/** @type {Node} */ (target)) ? _w.getComputedStyle(target).position === 'absolute' : false;
|
|
258
265
|
target = /** @type {Range} */ (!target || dom.check.isText(/** @type {Node} */ (target)) ? this.getRange() : target);
|
|
259
266
|
const globalScroll = this.offset.getGlobalScroll();
|
|
260
267
|
let isStartPosition = position === 'start';
|
|
@@ -291,7 +298,7 @@ Selection_.prototype = {
|
|
|
291
298
|
isStartPosition = true;
|
|
292
299
|
}
|
|
293
300
|
|
|
294
|
-
const iframeRects = /^iframe$/i.test(this.
|
|
301
|
+
const iframeRects = /^iframe$/i.test(this.frameContext.get('wysiwygFrame').nodeName) ? this.frameContext.get('wysiwygFrame').getClientRects()[0] : null;
|
|
295
302
|
if (!targetAbs && iframeRects) {
|
|
296
303
|
rects = {
|
|
297
304
|
left: rects.left + iframeRects.left,
|
|
@@ -316,7 +323,7 @@ Selection_.prototype = {
|
|
|
316
323
|
* @returns {{sc: Node, so: number, ec: Node, eo: number}} {sc: startContainer, so: startOffset, ec: endContainer, eo: endOffset}
|
|
317
324
|
*/
|
|
318
325
|
getDragEventLocationRange(e) {
|
|
319
|
-
const wd = this.
|
|
326
|
+
const wd = this.frameContext.get('_wd');
|
|
320
327
|
let r, sc, so, ec, eo;
|
|
321
328
|
|
|
322
329
|
if (wd.caretPositionFromPoint) {
|
|
@@ -348,21 +355,117 @@ Selection_.prototype = {
|
|
|
348
355
|
* @param {?Object<string, *>=} scrollOption option of scrollTo
|
|
349
356
|
*/
|
|
350
357
|
scrollTo(ref, scrollOption) {
|
|
351
|
-
if (ref
|
|
358
|
+
if (this.instanceCheck.isSelection(ref)) {
|
|
352
359
|
ref = ref.getRangeAt(0);
|
|
353
|
-
} else if (ref
|
|
360
|
+
} else if (this.instanceCheck.isNode(ref)) {
|
|
354
361
|
ref = this.setRange(ref, 1, ref, 1);
|
|
355
362
|
} else if (typeof ref?.startContainer === 'undefined') {
|
|
356
363
|
console.warn('[SUNEDITOR.html.scrollTo.warn] "selectionRange" must be Selection or Range or Node object.', ref);
|
|
357
364
|
}
|
|
358
365
|
|
|
359
|
-
|
|
360
|
-
const
|
|
366
|
+
scrollOption = { behavior: 'smooth', block: 'nearest', inline: 'nearest', ...scrollOption };
|
|
367
|
+
const el = dom.query.getParentElement(ref.startContainer, (current) => current.nodeType === 1);
|
|
368
|
+
|
|
369
|
+
const { frameContext, frameOptions } = this.editor;
|
|
370
|
+
const ww = frameContext.get('_ww');
|
|
371
|
+
const wwFrame = frameContext.get('wysiwygFrame');
|
|
372
|
+
const isIframe = frameOptions.get('iframe');
|
|
373
|
+
const isAutoHeight = frameOptions.get('height') === 'auto';
|
|
374
|
+
const initViewportHeight = this.status.initViewportHeight;
|
|
375
|
+
const viewportHeight = this.status.currentViewportHeight;
|
|
376
|
+
const scrollY = isAutoHeight ? _w.scrollY : isIframe ? ww.scrollY : wwFrame.scrollTop;
|
|
377
|
+
const realToolbarHeight = this.context.get('toolbar_main').offsetHeight;
|
|
378
|
+
const toolbarHeight = this.toolbar._sticky ? realToolbarHeight : 0;
|
|
379
|
+
const statusbarHeight = frameContext.get('statusbar')?.offsetHeight || 0;
|
|
380
|
+
|
|
381
|
+
if (this.__hasScrollParents || (!isIframe && (!isTouchDevice || initViewportHeight - viewportHeight < 150))) {
|
|
382
|
+
el?.scrollIntoView(scrollOption);
|
|
383
|
+
|
|
384
|
+
if (scrollOption?.behavior === 'auto') {
|
|
385
|
+
if (toolbarHeight && scrollY > _w.scrollY) {
|
|
386
|
+
_w.scrollBy(0, -toolbarHeight);
|
|
387
|
+
} else if (isAutoHeight) {
|
|
388
|
+
_w.scrollBy(0, statusbarHeight);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
361
391
|
|
|
362
|
-
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
363
394
|
|
|
364
|
-
|
|
365
|
-
|
|
395
|
+
// --- When there is no upper scroll and it is an iframe ---
|
|
396
|
+
const PADDING = this._scrollMargin;
|
|
397
|
+
const viewHeight = isAutoHeight ? viewportHeight : wwFrame.offsetHeight;
|
|
398
|
+
const elH = el.offsetHeight || 0;
|
|
399
|
+
|
|
400
|
+
const behavior = scrollOption?.behavior;
|
|
401
|
+
if (isAutoHeight) {
|
|
402
|
+
if (isIframe) {
|
|
403
|
+
const rect = this.getRects(ref, 'end').rects;
|
|
404
|
+
const topMargin = rect.top + elH - toolbarHeight;
|
|
405
|
+
const bottomMargin = viewHeight - PADDING - (rect.top + elH);
|
|
406
|
+
if (topMargin >= 0 && bottomMargin >= 0) return;
|
|
407
|
+
|
|
408
|
+
const newScrollTop = scrollY - (topMargin < 0 ? -(topMargin - PADDING) : bottomMargin);
|
|
409
|
+
_w.scrollTo({
|
|
410
|
+
top: newScrollTop,
|
|
411
|
+
behavior
|
|
412
|
+
});
|
|
413
|
+
} else {
|
|
414
|
+
const rect = this.offset.getGlobal(el);
|
|
415
|
+
const scrollMargin = viewHeight + scrollY - rect.top - elH;
|
|
416
|
+
|
|
417
|
+
if (scrollMargin - PADDING > 0 && viewHeight > scrollMargin + PADDING + toolbarHeight) return;
|
|
418
|
+
|
|
419
|
+
const newScrollTop = scrollMargin <= PADDING ? scrollY - scrollMargin + PADDING + statusbarHeight : scrollY - scrollMargin + (viewHeight - elH - PADDING);
|
|
420
|
+
_w.scrollTo({
|
|
421
|
+
top: newScrollTop,
|
|
422
|
+
behavior
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
// local scroll
|
|
427
|
+
const { top } = this.offset.getLocal(el);
|
|
428
|
+
|
|
429
|
+
const keepLocalScroll = top - PADDING > 0 && top + PADDING <= viewHeight;
|
|
430
|
+
const rectScroll = top - PADDING > 0 ? top + PADDING - viewHeight : top - (toolbarHeight + elH);
|
|
431
|
+
let newScrollTop = scrollY + rectScroll;
|
|
432
|
+
|
|
433
|
+
// frame scroll
|
|
434
|
+
const gy = _w.scrollY;
|
|
435
|
+
const globalRect = this.offset.getGlobal();
|
|
436
|
+
const topMargin = gy - globalRect.top + realToolbarHeight;
|
|
437
|
+
const bottomMargin = globalRect.top + globalRect.height - (gy + viewportHeight) + realToolbarHeight;
|
|
438
|
+
|
|
439
|
+
// set frame scroll
|
|
440
|
+
if (topMargin > 0) {
|
|
441
|
+
const newFrameY = (keepLocalScroll ? top : top + scrollY - newScrollTop) - elH - PADDING - topMargin;
|
|
442
|
+
if (newFrameY < 0) {
|
|
443
|
+
newScrollTop += realToolbarHeight;
|
|
444
|
+
_w.scrollTo({
|
|
445
|
+
top: gy + newFrameY,
|
|
446
|
+
behavior: 'smooth'
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (bottomMargin > 0) {
|
|
451
|
+
const newFrameY = (keepLocalScroll ? top : top + scrollY - newScrollTop) + elH + PADDING - (globalRect.height - bottomMargin);
|
|
452
|
+
if (newFrameY > 0) {
|
|
453
|
+
newScrollTop += statusbarHeight;
|
|
454
|
+
_w.scrollTo({
|
|
455
|
+
top: gy + newFrameY,
|
|
456
|
+
behavior: 'smooth'
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// set local scroll
|
|
462
|
+
if (!keepLocalScroll) {
|
|
463
|
+
(isIframe ? ww : wwFrame).scrollTo({
|
|
464
|
+
top: newScrollTop,
|
|
465
|
+
behavior
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
366
469
|
},
|
|
367
470
|
|
|
368
471
|
/**
|
|
@@ -389,8 +492,8 @@ Selection_.prototype = {
|
|
|
389
492
|
* @returns {Range}
|
|
390
493
|
*/
|
|
391
494
|
_createDefaultRange() {
|
|
392
|
-
const wysiwyg = this.
|
|
393
|
-
const range = this.
|
|
495
|
+
const wysiwyg = this.frameContext.get('wysiwyg');
|
|
496
|
+
const range = this.frameContext.get('_wd').createRange();
|
|
394
497
|
|
|
395
498
|
let firstFormat = wysiwyg.firstElementChild;
|
|
396
499
|
let focusEl = null;
|
|
@@ -439,7 +542,7 @@ Selection_.prototype = {
|
|
|
439
542
|
* @description Saving the range object and the currently selected node of editor
|
|
440
543
|
*/
|
|
441
544
|
_init() {
|
|
442
|
-
const activeEl = this.
|
|
545
|
+
const activeEl = this.frameContext.get('_wd').activeElement;
|
|
443
546
|
if (dom.check.isInputElement(activeEl)) {
|
|
444
547
|
this.selectionNode = activeEl;
|
|
445
548
|
return activeEl;
|
|
@@ -471,10 +574,10 @@ Selection_.prototype = {
|
|
|
471
574
|
if (caption) {
|
|
472
575
|
caption.focus();
|
|
473
576
|
} else {
|
|
474
|
-
this.
|
|
577
|
+
this.frameContext.get('wysiwyg').focus();
|
|
475
578
|
}
|
|
476
579
|
} finally {
|
|
477
|
-
|
|
580
|
+
_w.setTimeout(() => (this.__iframeFocus = false), 0);
|
|
478
581
|
}
|
|
479
582
|
},
|
|
480
583
|
|
|
@@ -525,7 +628,7 @@ Selection_.prototype = {
|
|
|
525
628
|
}
|
|
526
629
|
|
|
527
630
|
// startContainer
|
|
528
|
-
tempCon = dom.check.isWysiwygFrame(startCon) ? this.
|
|
631
|
+
tempCon = dom.check.isWysiwygFrame(startCon) ? this.frameContext.get('wysiwyg').firstChild : startCon;
|
|
529
632
|
tempOffset = startOff;
|
|
530
633
|
|
|
531
634
|
if (dom.check.isBreak(tempCon) || (tempCon.nodeType === 1 && tempCon.childNodes.length > 0)) {
|
|
@@ -541,7 +644,7 @@ Selection_.prototype = {
|
|
|
541
644
|
|
|
542
645
|
let format = this.format.getLine(tempCon, null);
|
|
543
646
|
if (format === this.format.getBlock(format, null)) {
|
|
544
|
-
tempCon
|
|
647
|
+
tempCon ||= tempConCache;
|
|
545
648
|
format = dom.utils.createElement(dom.query.getParentElement(tempCon, dom.check.isTableCell) ? 'DIV' : this.options.get('defaultLine'));
|
|
546
649
|
tempCon.parentNode.insertBefore(format, tempCon);
|
|
547
650
|
if (tempCon !== tempConCache) format.appendChild(tempCon);
|
|
@@ -566,7 +669,7 @@ Selection_.prototype = {
|
|
|
566
669
|
startOff = tempOffset;
|
|
567
670
|
|
|
568
671
|
// endContainer
|
|
569
|
-
tempCon = dom.check.isWysiwygFrame(endCon) ? this.
|
|
672
|
+
tempCon = dom.check.isWysiwygFrame(endCon) ? this.frameContext.get('wysiwyg').lastChild : endCon;
|
|
570
673
|
tempOffset = endOff;
|
|
571
674
|
|
|
572
675
|
if (dom.check.isBreak(tempCon) || (tempCon.nodeType === 1 && tempCon.childNodes.length > 0)) {
|
|
@@ -18,18 +18,31 @@ const { _w } = env;
|
|
|
18
18
|
* @description Toolbar class
|
|
19
19
|
* @param {__se__EditorCore} editor - The root editor instance
|
|
20
20
|
* @param {Object} options - toolbar options
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
21
|
+
* @param {"toolbar"|"toolbar_sub"} options.keyName - toolbar key name
|
|
22
|
+
* @param {boolean} options.balloon - balloon toolbar
|
|
23
|
+
* @param {boolean} options.inline - inline toolbar
|
|
24
|
+
* @param {boolean} options.balloonAlways - balloon toolbar always show
|
|
25
25
|
* @param {Array<Node>} options.res - responsive toolbar button list
|
|
26
26
|
*/
|
|
27
27
|
function Toolbar(editor, { keyName, balloon, inline, balloonAlways, res }) {
|
|
28
28
|
CoreInjector.call(this, editor);
|
|
29
29
|
|
|
30
30
|
// members
|
|
31
|
-
this.
|
|
32
|
-
|
|
31
|
+
this.isSub = keyName === 'toolbar_sub';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @type {Object}
|
|
35
|
+
* @description Key names for the toolbar elements.
|
|
36
|
+
* @property {"toolbar_sub_main"|"toolbar_main"} main - Main toolbar key name
|
|
37
|
+
* @property {"toolbar_sub_buttonTray"|"toolbar_buttonTray"} buttonTray - Button tray key name
|
|
38
|
+
* @property {"toolbar_sub_width"|"toolbar_width"} width - Toolbar width key name
|
|
39
|
+
*/
|
|
40
|
+
this.keyName = {
|
|
41
|
+
main: this.isSub ? 'toolbar_sub_main' : 'toolbar_main',
|
|
42
|
+
buttonTray: this.isSub ? 'toolbar_sub_buttonTray' : 'toolbar_buttonTray',
|
|
43
|
+
width: this.isSub ? 'toolbar_sub_width' : 'toolbar_width'
|
|
44
|
+
};
|
|
45
|
+
|
|
33
46
|
this.currentMoreLayerActiveButton = null;
|
|
34
47
|
this._isBalloon = balloon;
|
|
35
48
|
this._isInline = inline;
|
|
@@ -64,7 +77,7 @@ Toolbar.prototype = {
|
|
|
64
77
|
this._moreLayerOff();
|
|
65
78
|
this.menu.dropdownOff();
|
|
66
79
|
this.menu.containerOff();
|
|
67
|
-
dom.utils.setDisabled(this.context.get(this.keyName
|
|
80
|
+
dom.utils.setDisabled(this.context.get(this.keyName.buttonTray).querySelectorAll('.se-menu-list .se-toolbar-btn[data-type]'), true);
|
|
68
81
|
},
|
|
69
82
|
|
|
70
83
|
/**
|
|
@@ -72,7 +85,7 @@ Toolbar.prototype = {
|
|
|
72
85
|
* @description Enable the toolbar
|
|
73
86
|
*/
|
|
74
87
|
enable() {
|
|
75
|
-
dom.utils.setDisabled(this.context.get(this.keyName
|
|
88
|
+
dom.utils.setDisabled(this.context.get(this.keyName.buttonTray).querySelectorAll('.se-menu-list .se-toolbar-btn[data-type]'), false);
|
|
76
89
|
},
|
|
77
90
|
|
|
78
91
|
/**
|
|
@@ -85,8 +98,8 @@ Toolbar.prototype = {
|
|
|
85
98
|
} else if (this._isBalloon) {
|
|
86
99
|
this._showBalloon();
|
|
87
100
|
} else {
|
|
88
|
-
this.context.get(this.keyName
|
|
89
|
-
if (!this.isSub) this.
|
|
101
|
+
this.context.get(this.keyName.main).style.display = '';
|
|
102
|
+
if (!this.isSub) this.frameContext.get('_stickyDummy').style.display = '';
|
|
90
103
|
}
|
|
91
104
|
|
|
92
105
|
if (!this.isSub) this.resetResponsiveToolbar();
|
|
@@ -98,12 +111,12 @@ Toolbar.prototype = {
|
|
|
98
111
|
*/
|
|
99
112
|
hide() {
|
|
100
113
|
if (this._isInline) {
|
|
101
|
-
this.context.get(this.keyName
|
|
102
|
-
this.context.get(this.keyName
|
|
114
|
+
this.context.get(this.keyName.main).style.display = 'none';
|
|
115
|
+
this.context.get(this.keyName.main).style.top = '0px';
|
|
103
116
|
this._inlineToolbarAttr.isShow = false;
|
|
104
117
|
} else {
|
|
105
|
-
this.context.get(this.keyName
|
|
106
|
-
if (!this.isSub) this.
|
|
118
|
+
this.context.get(this.keyName.main).style.display = 'none';
|
|
119
|
+
if (!this.isSub) this.frameContext.get('_stickyDummy').style.display = 'none';
|
|
107
120
|
if (this._isBalloon) {
|
|
108
121
|
this._balloonOffset = {
|
|
109
122
|
top: 0,
|
|
@@ -123,10 +136,10 @@ Toolbar.prototype = {
|
|
|
123
136
|
const responsiveSize = this._rButtonsize;
|
|
124
137
|
if (responsiveSize) {
|
|
125
138
|
let w = 0;
|
|
126
|
-
if (((this._isBalloon || this._isInline) && this.options.get('toolbar_width') === 'auto') || (this.editor.isSubBalloon && this.options.get('
|
|
127
|
-
w = this.
|
|
139
|
+
if (((this._isBalloon || this._isInline) && this.options.get('toolbar_width') === 'auto') || (this.editor.isSubBalloon && this.options.get('toolbar_sub_width') === 'auto')) {
|
|
140
|
+
w = this.frameContext.get('topArea').offsetWidth;
|
|
128
141
|
} else {
|
|
129
|
-
w = this.context.get(this.keyName
|
|
142
|
+
w = this.context.get(this.keyName.main).offsetWidth;
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
let responsiveWidth = 'default';
|
|
@@ -156,33 +169,40 @@ Toolbar.prototype = {
|
|
|
156
169
|
this.menu.dropdownOff();
|
|
157
170
|
this.menu.containerOff();
|
|
158
171
|
|
|
159
|
-
const {
|
|
160
|
-
const newToolbar = CreateToolBar(buttonList, this.plugins,
|
|
172
|
+
const { icons, lang } = this;
|
|
173
|
+
const newToolbar = CreateToolBar(buttonList, this.plugins, this.editor.__options, icons, lang, true);
|
|
161
174
|
|
|
162
175
|
newToolbar.updateButtons.forEach((v) => UpdateButton(v.button, v.plugin, this.icons, this.lang));
|
|
163
176
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
177
|
+
this.context.get(this.keyName.main).replaceChild(newToolbar.buttonTray, this.context.get(this.keyName.buttonTray));
|
|
178
|
+
this.context.set(this.keyName.buttonTray, newToolbar.buttonTray);
|
|
179
|
+
|
|
180
|
+
this._resetButtonInfo();
|
|
181
|
+
|
|
182
|
+
this.triggerEvent('onSetToolbarButtons', { buttonTray: newToolbar.buttonTray, frameContext: this.frameContext });
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @private
|
|
187
|
+
* @this {ToolbarThis}
|
|
188
|
+
* @description Reset the common buttons info.
|
|
189
|
+
*/
|
|
190
|
+
_resetButtonInfo() {
|
|
191
|
+
this.editor.allCommandButtons = new Map();
|
|
192
|
+
this.editor.subAllCommandButtons = new Map();
|
|
167
193
|
this.editor.commandTargets = new Map();
|
|
168
194
|
this.editor.shortcutsKeyMap = new Map();
|
|
169
|
-
this.editor.__saveCommandButtons(cmdButtons, newToolbar.buttonTray);
|
|
170
|
-
this.editor.__cachingShortcuts();
|
|
171
|
-
|
|
172
|
-
this.context.get(this.keyName + '.main').replaceChild(newToolbar.buttonTray, this.context.get(this.keyName + '.buttonTray'));
|
|
173
|
-
this.context.set(this.keyName + '.buttonTray', newToolbar.buttonTray);
|
|
174
195
|
|
|
175
|
-
this.editor.
|
|
196
|
+
this.editor.__cachingButtons(this.isSub ? 'sub' : 'main');
|
|
197
|
+
this.editor.__cachingShortcuts();
|
|
176
198
|
|
|
177
|
-
this.history.resetButtons(this.
|
|
199
|
+
this.history.resetButtons(this.frameContext.get('key'), null);
|
|
178
200
|
this._resetSticky();
|
|
179
201
|
|
|
180
202
|
this.editor.effectNode = null;
|
|
181
203
|
this.viewer._setButtonsActive();
|
|
182
204
|
if (this.status.hasFocus) this.eventManager.applyTagEffect();
|
|
183
|
-
if (this.
|
|
184
|
-
|
|
185
|
-
this.triggerEvent('onSetToolbarButtons', { buttonTray: newToolbar.buttonTray, frameContext: this.editor.frameContext });
|
|
205
|
+
if (this.frameContext.get('isReadOnly')) this.ui.setControllerOnDisabledButtons(true);
|
|
186
206
|
},
|
|
187
207
|
|
|
188
208
|
/**
|
|
@@ -191,17 +211,17 @@ Toolbar.prototype = {
|
|
|
191
211
|
* @description Reset the sticky toolbar position based on the editor state.
|
|
192
212
|
*/
|
|
193
213
|
_resetSticky() {
|
|
194
|
-
const wrapper = this.
|
|
214
|
+
const wrapper = this.frameContext.get('wrapper');
|
|
195
215
|
if (!wrapper) return;
|
|
196
216
|
|
|
197
|
-
const toolbar = this.context.get(this.keyName
|
|
198
|
-
if (this.
|
|
217
|
+
const toolbar = this.context.get(this.keyName.main);
|
|
218
|
+
if (this.frameContext.get('isFullScreen') || toolbar.offsetWidth === 0 || this.options.get('toolbar_sticky') < 0) return;
|
|
199
219
|
|
|
200
220
|
const currentScrollY = this._isViewPortSize ? _w.visualViewport.pageTop : _w.scrollY;
|
|
201
221
|
|
|
202
|
-
const minHeight = this.
|
|
222
|
+
const minHeight = this.frameContext.get('_minHeight');
|
|
203
223
|
const editorHeight = wrapper.offsetHeight;
|
|
204
|
-
const editorOffset = this.offset.getGlobal(this.
|
|
224
|
+
const editorOffset = this.offset.getGlobal(this.frameContext.get('topArea'));
|
|
205
225
|
const y = currentScrollY + this.options.get('toolbar_sticky');
|
|
206
226
|
const t = (this._isBalloon || this._isInline ? editorOffset.top : this.offset.getGlobal(this.options.get('toolbar_container')).top) - (this._isInline ? toolbar.offsetHeight : 0);
|
|
207
227
|
const inlineOffset = 1;
|
|
@@ -225,10 +245,10 @@ Toolbar.prototype = {
|
|
|
225
245
|
* @description Enable sticky toolbar mode and adjust position.
|
|
226
246
|
*/
|
|
227
247
|
_onSticky(inlineOffset) {
|
|
228
|
-
const toolbar = this.context.get(this.keyName
|
|
248
|
+
const toolbar = this.context.get(this.keyName.main);
|
|
229
249
|
|
|
230
250
|
if (!this._isInline) {
|
|
231
|
-
const stickyDummy = !this.options.get('toolbar_container') ? this.
|
|
251
|
+
const stickyDummy = !this.options.get('toolbar_container') ? this.frameContext.get('_stickyDummy') : this.context.get('_stickyDummy');
|
|
232
252
|
stickyDummy.style.height = toolbar.offsetHeight + 'px';
|
|
233
253
|
stickyDummy.style.display = 'block';
|
|
234
254
|
}
|
|
@@ -259,13 +279,13 @@ Toolbar.prototype = {
|
|
|
259
279
|
* @description Disable sticky toolbar mode.
|
|
260
280
|
*/
|
|
261
281
|
_offSticky() {
|
|
262
|
-
const stickyDummy = !this.options.get('toolbar_container') ? this.
|
|
282
|
+
const stickyDummy = !this.options.get('toolbar_container') ? this.frameContext.get('_stickyDummy') : this.context.get('_stickyDummy');
|
|
263
283
|
stickyDummy.style.display = 'none';
|
|
264
284
|
|
|
265
|
-
const toolbar = this.context.get(this.keyName
|
|
285
|
+
const toolbar = this.context.get(this.keyName.main);
|
|
266
286
|
toolbar.style.top = this._isInline ? this._inlineToolbarAttr.top : '';
|
|
267
287
|
toolbar.style.width = this._isInline ? this._inlineToolbarAttr.width : '';
|
|
268
|
-
this.
|
|
288
|
+
this.frameContext.get('wrapper').style.marginTop = '';
|
|
269
289
|
|
|
270
290
|
dom.utils.removeClass(toolbar, 'se-toolbar-sticky');
|
|
271
291
|
this._sticky = false;
|
|
@@ -312,7 +332,7 @@ Toolbar.prototype = {
|
|
|
312
332
|
if (this.isSub) this.resetResponsiveToolbar();
|
|
313
333
|
|
|
314
334
|
const range = rangeObj || this.selection.getRange();
|
|
315
|
-
const toolbar = this.context.get(this.keyName
|
|
335
|
+
const toolbar = this.context.get(this.keyName.main);
|
|
316
336
|
const selection = this.selection.get();
|
|
317
337
|
|
|
318
338
|
let isDirTop;
|
|
@@ -321,13 +341,13 @@ Toolbar.prototype = {
|
|
|
321
341
|
} else if (selection.focusNode === selection.anchorNode) {
|
|
322
342
|
isDirTop = selection.focusOffset < selection.anchorOffset;
|
|
323
343
|
} else {
|
|
324
|
-
const childNodes = dom.query.getListChildNodes(range.commonAncestorContainer, null);
|
|
344
|
+
const childNodes = dom.query.getListChildNodes(range.commonAncestorContainer, null, null);
|
|
325
345
|
isDirTop = dom.utils.getArrayIndex(childNodes, selection.focusNode) < dom.utils.getArrayIndex(childNodes, selection.anchorNode);
|
|
326
346
|
}
|
|
327
347
|
|
|
328
348
|
this._setBalloonOffset(isDirTop, range);
|
|
329
349
|
|
|
330
|
-
this.triggerEvent('onShowToolbar', { toolbar, mode: 'balloon', frameContext: this.
|
|
350
|
+
this.triggerEvent('onShowToolbar', { toolbar, mode: 'balloon', frameContext: this.frameContext });
|
|
331
351
|
},
|
|
332
352
|
|
|
333
353
|
/**
|
|
@@ -338,8 +358,8 @@ Toolbar.prototype = {
|
|
|
338
358
|
* @param {Range} [range] - Selection range
|
|
339
359
|
*/
|
|
340
360
|
_setBalloonOffset(positionTop, range) {
|
|
341
|
-
const toolbar = this.context.get(this.keyName
|
|
342
|
-
const topArea = this.
|
|
361
|
+
const toolbar = this.context.get(this.keyName.main);
|
|
362
|
+
const topArea = this.frameContext.get('topArea');
|
|
343
363
|
const offsets = this.offset.getGlobal(topArea);
|
|
344
364
|
const stickyTop = offsets.top;
|
|
345
365
|
|
|
@@ -355,7 +375,7 @@ Toolbar.prototype = {
|
|
|
355
375
|
let left = container.offsetLeft;
|
|
356
376
|
let top = container.offsetTop;
|
|
357
377
|
|
|
358
|
-
while (!container.parentElement.contains(editorParent)
|
|
378
|
+
while (!container.parentElement.contains(editorParent) && !/^(BODY|HTML)$/i.test(container.parentElement.nodeName)) {
|
|
359
379
|
container = container.offsetParent;
|
|
360
380
|
left += container.offsetLeft;
|
|
361
381
|
top += container.offsetTop;
|
|
@@ -381,14 +401,14 @@ Toolbar.prototype = {
|
|
|
381
401
|
_showInline() {
|
|
382
402
|
if (!this._isInline) return;
|
|
383
403
|
|
|
384
|
-
const toolbar = this.context.get(this.keyName
|
|
404
|
+
const toolbar = this.context.get(this.keyName.main);
|
|
385
405
|
toolbar.style.visibility = 'hidden';
|
|
386
406
|
this._offSticky();
|
|
387
407
|
|
|
388
408
|
toolbar.style.display = 'block';
|
|
389
409
|
toolbar.style.top = '0px';
|
|
390
|
-
this._inlineToolbarAttr.width = toolbar.style.width = this.options.get(this.keyName
|
|
391
|
-
this._inlineToolbarAttr.top = toolbar.style.top = -1 + (this.offset.getGlobal(this.
|
|
410
|
+
this._inlineToolbarAttr.width = toolbar.style.width = this.options.get(this.keyName.width);
|
|
411
|
+
this._inlineToolbarAttr.top = toolbar.style.top = -1 + (this.offset.getGlobal(this.frameContext.get('topArea')).top - this.offset.getGlobal(toolbar).top - toolbar.offsetHeight) + 'px';
|
|
392
412
|
|
|
393
413
|
this._resetSticky();
|
|
394
414
|
this._inlineToolbarAttr.isShow = true;
|
|
@@ -418,7 +438,8 @@ Toolbar.prototype = {
|
|
|
418
438
|
*/
|
|
419
439
|
_moreLayerOff() {
|
|
420
440
|
if (this.currentMoreLayerActiveButton) {
|
|
421
|
-
|
|
441
|
+
/** @type {HTMLElement} */
|
|
442
|
+
const layer = this.context.get(this.keyName.main).querySelector('.' + this.currentMoreLayerActiveButton.getAttribute('data-command'));
|
|
422
443
|
layer.style.display = 'none';
|
|
423
444
|
dom.utils.removeClass(this.currentMoreLayerActiveButton, 'on');
|
|
424
445
|
this.currentMoreLayerActiveButton = null;
|