suneditor 3.2.4 → 3.2.5

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,6 +1,6 @@
1
1
  {
2
2
  "name": "suneditor",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "Vanilla JavaScript based WYSIWYG web editor",
5
5
  "author": "Yi JiHong",
6
6
  "license": "MIT",
@@ -40,6 +40,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
40
40
 
41
41
  if (selectRange && hardDelete(ports)) {
42
42
  actions.push(A.preventStop());
43
+ actions.push(A.caretScrollTo(range));
43
44
  return true;
44
45
  }
45
46
 
@@ -66,6 +67,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
66
67
  actions.push(A.preventStop());
67
68
  actions.push(A.delFormatRemoveAndMove(range.startContainer, formatEl));
68
69
  actions.push(A.historyPush(true));
70
+ actions.push(A.caretScrollTo(range));
69
71
  return false;
70
72
  }
71
73
 
@@ -107,6 +109,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
107
109
  }
108
110
 
109
111
  actions.push(A.editorNativeFocus());
112
+ actions.push(A.caretScrollTo(range));
110
113
  return false;
111
114
  }
112
115
 
@@ -201,6 +204,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
201
204
  }
202
205
  }
203
206
 
207
+ actions.push(A.caretScrollTo(range));
204
208
  return true;
205
209
  }
206
210
 
@@ -233,6 +237,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
233
237
  ),
234
238
  );
235
239
  actions.push(A.historyPush(true));
240
+ actions.push(A.caretScrollTo(range));
236
241
  return true;
237
242
  }
238
243
  }
@@ -244,6 +249,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
244
249
  if (fileComponentInfo) {
245
250
  actions.push(A.preventStop());
246
251
  actions.push(A.backspaceComponentRemove(false, formatEl.firstChild, formatEl, fileComponentInfo));
252
+ actions.push(A.caretScrollTo(range));
247
253
  return true;
248
254
  }
249
255
  }
@@ -276,6 +282,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
276
282
  actions.push(A.preventStop());
277
283
  actions.push(A.domUtilsRemoveItem(prev));
278
284
  }
285
+ actions.push(A.caretScrollTo(range));
279
286
  return true;
280
287
  }
281
288
 
@@ -283,6 +290,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
283
290
  if (sel && dom.check.isNonEditable(sel.previousSibling)) {
284
291
  actions.push(A.preventStop());
285
292
  actions.push(A.domUtilsRemoveItem(sel.previousSibling));
293
+ actions.push(A.caretScrollTo(range));
286
294
  return true;
287
295
  }
288
296
  }
@@ -300,6 +308,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
300
308
  actions.push(A.preventStop());
301
309
  actions.push(A.backspaceBrLineRowMerge(range.startContainer, rowStartBr));
302
310
  actions.push(A.historyPush(true));
311
+ actions.push(A.caretScrollTo(range));
303
312
  return false;
304
313
  }
305
314
  }
@@ -315,6 +324,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
315
324
  actions.push(A.preventStop());
316
325
  actions.push(A.backspaceSoftBreakMerge(range.startContainer));
317
326
  actions.push(A.historyPush(true));
327
+ actions.push(A.caretScrollTo(range));
318
328
  return false;
319
329
  }
320
330
 
@@ -331,6 +341,7 @@ export function reduceBackspaceDown(actions, ports, ctx) {
331
341
  actions.push(A.preventStop());
332
342
  actions.push(A.backspaceEmptyLineMergePrev(formatEl, emptyLinePrev));
333
343
  actions.push(A.historyPush(true));
344
+ actions.push(A.caretScrollTo(range));
334
345
  return false;
335
346
  }
336
347
 
@@ -482,21 +482,28 @@ class Selection_ {
482
482
  el?.scrollIntoView(scrollOption);
483
483
  }
484
484
 
485
- if (scrollOption?.behavior === 'auto' && scrollY !== _w.scrollY) {
486
- if (positionToolbarHeight) {
487
- if (isBottom) {
485
+ if (scrollOption?.behavior === 'auto') {
486
+ if (positionToolbarHeight && !isBottom) {
487
+ // A sticky toolbar overlays the viewport band [0 .. positionToolbarHeight].
488
+ // caret on a wrapped line — and nudge it below the toolbar. Guards:
489
+ // height > 0 — skip a collapsed range's zero rect (phantom full-toolbar scroll)
490
+ // top >= 0 — skip off-screen / mid-animation rects; `behavior:'auto'` follows
491
+ // the page's CSS scroll-behavior, so on `smooth` hosts it's async
492
+ // top < band — only correct when actually under the toolbar; caps the nudge at
493
+ // toolbar height so a stale measurement can't overshoot
494
+ const caretNow = ref?.getBoundingClientRect?.();
495
+ if (caretNow?.height > 0 && caretNow.top >= 0 && caretNow.top < positionToolbarHeight) {
496
+ _w.scrollBy(0, -(positionToolbarHeight - caretNow.top));
497
+ }
498
+ } else if (scrollY !== _w.scrollY) {
499
+ if (positionToolbarHeight) {
488
500
  // bottom toolbar covers the bottom — scroll down more so the element clears the toolbar
489
501
  if (scrollY < _w.scrollY) {
490
502
  _w.scrollBy(0, positionToolbarHeight);
491
503
  }
492
- } else {
493
- // top toolbar covers the top — scroll up more so the element clears the toolbar
494
- if (scrollY > _w.scrollY) {
495
- _w.scrollBy(0, -positionToolbarHeight);
496
- }
504
+ } else if (isAutoHeight) {
505
+ _w.scrollBy(0, statusbarHeight);
497
506
  }
498
- } else if (isAutoHeight) {
499
- _w.scrollBy(0, statusbarHeight);
500
507
  }
501
508
  }
502
509
 
@@ -532,7 +539,11 @@ class Selection_ {
532
539
  const rectTop = refRect?.height > 0 ? refRect.top + scrollY : this.#$.offset.getGlobal(el).top;
533
540
  const scrollMargin = viewHeight + scrollY - rectTop - elH;
534
541
 
535
- if (scrollMargin - PADDING > 0 && viewHeight > scrollMargin + PADDING + topToolbarH) return;
542
+ // Top clearance: with a sticky toolbar, the caret is already clear once its top
543
+ // felt right. With no toolbar (topToolbarH === 0), keep the original PADDING.
544
+ const caretTop = rectTop - scrollY;
545
+ const topClear = topToolbarH > 0 ? caretTop >= topToolbarH : viewHeight > scrollMargin + PADDING;
546
+ if (scrollMargin - PADDING > 0 && topClear) return;
536
547
 
537
548
  const newScrollTop =
538
549
  scrollMargin <= PADDING