suneditor 3.0.0-alpha.2 → 3.0.0-alpha.3
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/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { domUtils } from '../../../helper';
|
|
2
2
|
import { _DragHandle } from '../../../modules';
|
|
3
3
|
|
|
4
|
-
export function OnDragOver_wysiwyg(dragCursor,
|
|
4
|
+
export function OnDragOver_wysiwyg(fc, dragCursor, _iframeTopArea, _innerToolbar, e) {
|
|
5
5
|
e.preventDefault();
|
|
6
6
|
|
|
7
7
|
const { sc, so, ec, eo } = this.selection.getEventLocationRange(e);
|
|
8
8
|
|
|
9
|
-
const cursorRange =
|
|
9
|
+
const cursorRange = fc.get('_wd').createRange();
|
|
10
10
|
cursorRange.setStart(sc, so);
|
|
11
11
|
cursorRange.setEnd(ec, eo);
|
|
12
12
|
|
|
13
13
|
const _offset = { y: 0, x: 0 };
|
|
14
|
-
if (
|
|
15
|
-
const iframeOffset = this.offset.getGlobal(
|
|
16
|
-
|
|
14
|
+
if (_iframeTopArea) {
|
|
15
|
+
const iframeOffset = this.offset.getGlobal(_iframeTopArea);
|
|
16
|
+
const toolbarH = _innerToolbar ? this.context.get('toolbar.main').offsetHeight : 0;
|
|
17
|
+
_offset.y = iframeOffset.top + toolbarH - this._w.scrollY;
|
|
17
18
|
_offset.x = iframeOffset.left - this._w.scrollX;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -28,6 +29,10 @@ export function OnDragOver_wysiwyg(dragCursor, _iframe, e) {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
export function OnDragEnd_wysiwyg(dragCursor) {
|
|
33
|
+
dragCursor.style.display = 'none';
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
export function OnDrop_wysiwyg(frameContext, dragCursor, e) {
|
|
32
37
|
try {
|
|
33
38
|
if (frameContext.get('isReadOnly')) {
|
|
@@ -11,7 +11,7 @@ import { ButtonsHandler, OnClick_menuTray, OnClick_toolbar } from './eventHandle
|
|
|
11
11
|
import { OnMouseDown_wysiwyg, OnMouseUp_wysiwyg, OnClick_wysiwyg, OnMouseMove_wysiwyg, OnMouseLeave_wysiwyg } from './eventHandlers/handler_ww_mouse';
|
|
12
12
|
import { OnInput_wysiwyg, OnKeyDown_wysiwyg, OnKeyUp_wysiwyg } from './eventHandlers/handler_ww_key_input';
|
|
13
13
|
import { OnPaste_wysiwyg, OnCopy_wysiwyg, OnCut_wysiwyg } from './eventHandlers/handler_ww_clipboard';
|
|
14
|
-
import { OnDragOver_wysiwyg, OnDrop_wysiwyg } from './eventHandlers/handler_ww_dragDrop';
|
|
14
|
+
import { OnDragOver_wysiwyg, OnDragEnd_wysiwyg, OnDrop_wysiwyg } from './eventHandlers/handler_ww_dragDrop';
|
|
15
15
|
|
|
16
16
|
const { _w, ON_OVER_COMPONENT, isMobile } = env;
|
|
17
17
|
|
|
@@ -656,7 +656,13 @@ EventManager.prototype = {
|
|
|
656
656
|
this.addEvent(eventWysiwyg, 'paste', OnPaste_wysiwyg.bind(this, fc), false);
|
|
657
657
|
this.addEvent(eventWysiwyg, 'copy', OnCopy_wysiwyg.bind(this, fc), false);
|
|
658
658
|
this.addEvent(eventWysiwyg, 'cut', OnCut_wysiwyg.bind(this, fc), false);
|
|
659
|
-
this.addEvent(
|
|
659
|
+
this.addEvent(
|
|
660
|
+
eventWysiwyg,
|
|
661
|
+
'dragover',
|
|
662
|
+
OnDragOver_wysiwyg.bind(this, fc, dragCursor, isIframe ? this.editor.frameContext.get('topArea') : null, !this.options.get('toolbar_container') && !this.editor.isBalloon && !this.editor.isInline),
|
|
663
|
+
false
|
|
664
|
+
);
|
|
665
|
+
this.addEvent(eventWysiwyg, 'dragend', OnDragEnd_wysiwyg.bind(this, dragCursor), false);
|
|
660
666
|
this.addEvent(eventWysiwyg, 'drop', OnDrop_wysiwyg.bind(this, fc, dragCursor), false);
|
|
661
667
|
this.addEvent(eventWysiwyg, 'scroll', OnScroll_wysiwyg.bind(this, fc, eventWysiwyg), { passive: true, useCapture: false });
|
|
662
668
|
this.addEvent(eventWysiwyg, 'focus', OnFocus_wysiwyg.bind(this, fc), false);
|
package/src/core/class/offset.js
CHANGED
|
@@ -376,22 +376,26 @@ Offset.prototype = {
|
|
|
376
376
|
const tmbw = clientSize.h - targetRect.bottom;
|
|
377
377
|
let toolbarH = !this.editor.toolbar._sticky && (this.editor.isBalloon || this.editor.isInline) ? 0 : this.context.get('toolbar.main').offsetHeight;
|
|
378
378
|
let rmt, rmb;
|
|
379
|
+
let rt = 0;
|
|
379
380
|
if (this.editor.frameContext.get('isFullScreen')) {
|
|
380
381
|
rmt = tmtw - toolbarH;
|
|
381
382
|
rmb = tmbw;
|
|
382
383
|
} else {
|
|
383
384
|
const tMargin = targetRect.top;
|
|
384
385
|
const bMargin = clientSize.h - targetRect.bottom;
|
|
386
|
+
const editorOffset = this.getGlobal();
|
|
387
|
+
const editorScroll = this.getGlobalScroll();
|
|
388
|
+
const statusBarH = this.editor.frameContext.get('statusbar')?.offsetHeight || 0;
|
|
385
389
|
|
|
386
390
|
if (isIframe) {
|
|
387
|
-
const editorOffset = this.getGlobal();
|
|
388
|
-
const editorScroll = this.getGlobalScroll();
|
|
389
391
|
const emt = editorOffset.top - editorScroll.top - editorScroll.ts;
|
|
390
392
|
const editorH = this.editor.frameContext.get('topArea').offsetHeight;
|
|
391
393
|
rmt = targetRect.top - emt;
|
|
392
|
-
rmb = bMargin - (editorScroll.oh - (editorH + emt) +
|
|
394
|
+
rmb = bMargin - (editorScroll.oh - (editorH + emt) + statusBarH);
|
|
393
395
|
} else {
|
|
394
|
-
|
|
396
|
+
rt = !this.editor.toolbar._sticky && !this.options.get('toolbar_container') ? toolbarH : 0;
|
|
397
|
+
const wst = !isTargetAbs && /\d+/.test(this.editor.frameOptions.get('height')) ? editorOffset.top - _w.scrollY + rt : 0;
|
|
398
|
+
const wsb = !isTargetAbs && /\d+/.test(this.editor.frameOptions.get('height')) ? _w.innerHeight - (editorOffset.top + editorOffset.height - _w.scrollY) : 0;
|
|
395
399
|
let st = wst;
|
|
396
400
|
if (toolbarH > wst) {
|
|
397
401
|
if (this.editor.toolbar._sticky) {
|
|
@@ -402,10 +406,12 @@ Offset.prototype = {
|
|
|
402
406
|
}
|
|
403
407
|
} else if (this.options.get('toolbar_container')) {
|
|
404
408
|
toolbarH = 0;
|
|
409
|
+
} else {
|
|
410
|
+
st = wst + (this.editor.toolbar._sticky ? toolbarH : 0);
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
rmt = targetRect.top - st;
|
|
408
|
-
rmb = wwScroll.rects.bottom - targetRect.bottom;
|
|
414
|
+
rmb = wwScroll.rects.bottom - targetRect.bottom - wsb - statusBarH;
|
|
409
415
|
}
|
|
410
416
|
|
|
411
417
|
// display margin
|
|
@@ -413,7 +419,7 @@ Offset.prototype = {
|
|
|
413
419
|
rmb = rmb > 0 ? bMargin : rmb;
|
|
414
420
|
}
|
|
415
421
|
|
|
416
|
-
if (isWWTarget && (rmb + targetH <= 0 || rmt + targetH <= 0)) return;
|
|
422
|
+
if (isWWTarget && (rmb + targetH <= 0 || rmt + rt + targetH <= 0)) return;
|
|
417
423
|
|
|
418
424
|
let t = addOffset.top;
|
|
419
425
|
let y = 0;
|
|
@@ -425,7 +431,7 @@ Offset.prototype = {
|
|
|
425
431
|
if (y < 0) {
|
|
426
432
|
arrowDir = 'down';
|
|
427
433
|
t -= targetH + elH + ah * 2;
|
|
428
|
-
y = rmt - (elH + ah);
|
|
434
|
+
y = toolbarH + rmt - (elH + ah);
|
|
429
435
|
if (y < 0) {
|
|
430
436
|
arrowDir = '';
|
|
431
437
|
t -= y;
|
|
@@ -235,13 +235,13 @@ Selection.prototype = {
|
|
|
235
235
|
eo = e.rangeOffset;
|
|
236
236
|
} else if (this.editor.frameContext.get('_wd').caretRangeFromPoint) {
|
|
237
237
|
let r = this.editor.frameContext.get('_wd').caretRangeFromPoint(e.clientX, e.clientY);
|
|
238
|
-
if (!r) r = this.
|
|
238
|
+
if (!r) r = this.getRange();
|
|
239
239
|
sc = r.startContainer;
|
|
240
240
|
so = r.startOffset;
|
|
241
241
|
ec = r.endContainer;
|
|
242
242
|
eo = r.endOffset;
|
|
243
243
|
} else {
|
|
244
|
-
const r = this.
|
|
244
|
+
const r = this.getRange();
|
|
245
245
|
sc = r.startContainer;
|
|
246
246
|
so = r.startOffset;
|
|
247
247
|
ec = r.endContainer;
|
|
@@ -264,7 +264,7 @@ Selection.prototype = {
|
|
|
264
264
|
if (ref instanceof Selection) {
|
|
265
265
|
ref = ref.getRangeAt(0);
|
|
266
266
|
} else if (ref instanceof Node) {
|
|
267
|
-
ref = this.
|
|
267
|
+
ref = this.setRange(ref, 1, ref, 1);
|
|
268
268
|
} else if (typeof ref?.startContainer === 'undefined') {
|
|
269
269
|
console.warn('[SUNEDITOR.html.scrollTo.warn] "selectionRange" must be Selection or Range or Node object.', ref);
|
|
270
270
|
}
|
|
@@ -387,8 +387,10 @@ Selection.prototype = {
|
|
|
387
387
|
let rangeObj = this.getRange();
|
|
388
388
|
if (this._isNone(rangeObj)) {
|
|
389
389
|
if (!domUtils.isWysiwygFrame(rangeObj.startContainer) || !domUtils.isWysiwygFrame(rangeObj.endContainer)) return false;
|
|
390
|
-
const ww = rangeObj.
|
|
391
|
-
|
|
390
|
+
const ww = rangeObj.commonAncestorContainer;
|
|
391
|
+
const first = ww.children[rangeObj.startOffset];
|
|
392
|
+
const end = ww.children[rangeObj.endOffset];
|
|
393
|
+
rangeObj = this.setRange(first, 0, end, first === end ? 0 : 1);
|
|
392
394
|
}
|
|
393
395
|
|
|
394
396
|
const range = rangeObj;
|