suneditor 3.2.1 → 3.2.2

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.1",
3
+ "version": "3.2.2",
4
4
  "description": "Vanilla JavaScript based WYSIWYG web editor",
5
5
  "author": "Yi JiHong",
6
6
  "license": "MIT",
@@ -1348,6 +1348,7 @@
1348
1348
 
1349
1349
  /** --- popover UA override ---------------------------------------------------- */
1350
1350
  .sun-editor .se-controller[popover],
1351
+ .sun-editor .se-block-handle[popover],
1351
1352
  .sun-editor.sun-editor-carrier-wrapper .se-drag-cursor[popover] {
1352
1353
  inset: unset;
1353
1354
  margin: 0;
@@ -1358,6 +1359,7 @@
1358
1359
  .sun-editor .se-loading-box[popover],
1359
1360
  .sun-editor .se-toast[popover],
1360
1361
  .sun-editor .se-browser[popover],
1362
+ .sun-editor .se-block-handle[popover],
1361
1363
  .sun-editor .se-menu-tray[popover] {
1362
1364
  background: none;
1363
1365
  border: none;
@@ -119,6 +119,30 @@ class BlockHandle {
119
119
  em.addEvent(this.#$.frameContext.get('eventWysiwyg'), 'keydown', this.#onWrapperKeyDown.bind(this), true);
120
120
  }
121
121
 
122
+ /**
123
+ * @description Show the handle.
124
+ */
125
+ #showHandle() {
126
+ this.#handle.style.display = 'flex';
127
+ try {
128
+ this.#handle.showPopover?.();
129
+ } catch {
130
+ // already open
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @description Hide the handle and drop it out of the top layer.
136
+ */
137
+ #hideHandle() {
138
+ try {
139
+ this.#handle.hidePopover?.();
140
+ } catch {
141
+ // already hidden
142
+ }
143
+ this.#handle.style.display = 'none';
144
+ }
145
+
122
146
  /**
123
147
  * @description Position the block handle for the given mouse target. Uses rAF throttle.
124
148
  * Called from wysiwyg mousemove.
@@ -156,7 +180,7 @@ class BlockHandle {
156
180
  */
157
181
  hideNow() {
158
182
  this.#cancelHide();
159
- this.#handle.style.display = 'none';
183
+ this.#hideHandle();
160
184
  this.#actionMenu?.close();
161
185
  this.#setCurrentBlock(null);
162
186
  }
@@ -267,7 +291,7 @@ class BlockHandle {
267
291
  if (this.#hideTimer) return;
268
292
  this.#hideTimer = _w.setTimeout(() => {
269
293
  this.#hideTimer = null;
270
- this.#handle.style.display = 'none';
294
+ this.#hideHandle();
271
295
  this.#actionMenu?.close();
272
296
  this.#setCurrentBlock(null);
273
297
  }, 200);
@@ -323,11 +347,8 @@ class BlockHandle {
323
347
  */
324
348
  #onAreaMouseLeave(e) {
325
349
  if (this.#actionMenu?.isOpen) return;
326
-
327
- const related = /** @type {Node} */ (e?.relatedTarget);
328
- if (related && this.#handle?.contains(related)) return;
329
-
330
- this.#scheduleHide();
350
+ if (this.#stayAlive(/** @type {Node} */ (e?.relatedTarget))) return;
351
+ this.hideNow();
331
352
  }
332
353
 
333
354
  /**
@@ -335,11 +356,19 @@ class BlockHandle {
335
356
  */
336
357
  #onWrapperMouseLeave(e) {
337
358
  if (this.#actionMenu?.isOpen) return;
338
- const related = /** @type {Node} */ (e?.relatedTarget);
339
- if (related && this.#handle?.contains(related)) return;
340
- this.#cancelHide();
341
- this.#handle.style.display = 'none';
342
- this.#setCurrentBlock(null);
359
+ if (this.#stayAlive(/** @type {Node} */ (e?.relatedTarget))) return;
360
+ this.hideNow();
361
+ }
362
+
363
+ /**
364
+ * @description Whether a mouseleave's `relatedTarget` is still within the editor interaction zone
365
+ * @param {Node|null} related - `relatedTarget` of the mouseleave event
366
+ * @returns {boolean}
367
+ */
368
+ #stayAlive(related) {
369
+ if (!related) return false;
370
+ const wrapper = this.#area?.parentElement;
371
+ return !!(this.#handle?.contains(related) || wrapper?.contains(related));
343
372
  }
344
373
 
345
374
  /**
@@ -412,13 +441,13 @@ class BlockHandle {
412
441
  if (isIframe) {
413
442
  const iframeH = wysiwygFrameEl.clientHeight || 0;
414
443
  if (blockRect.bottom <= 0 || blockRect.top >= iframeH) {
415
- this.#handle.style.display = 'none';
444
+ this.#hideHandle();
416
445
  return;
417
446
  }
418
447
  } else {
419
448
  const wwFrameRect = wysiwygFrameEl.getBoundingClientRect();
420
449
  if (blockRect.bottom <= wwFrameRect.top || blockRect.top >= wwFrameRect.bottom) {
421
- this.#handle.style.display = 'none';
450
+ this.#hideHandle();
422
451
  return;
423
452
  }
424
453
  }
@@ -460,7 +489,7 @@ class BlockHandle {
460
489
  this.#handle.style.right = '';
461
490
  this.#handle.style.left = areaRect.left + scrollX + totalOffset + 'px';
462
491
  }
463
- this.#handle.style.display = 'flex';
492
+ this.#showHandle();
464
493
 
465
494
  if (wasHidden) {
466
495
  void this.#handle.offsetHeight;
@@ -299,7 +299,7 @@ function Constructor(editorTargets, options) {
299
299
  if (isBlockHandle) {
300
300
  blockHandleArea = dom.utils.createElement('DIV', { class: 'se-block-handle-area' });
301
301
 
302
- const blockHandleGroup = dom.utils.createElement('DIV', { class: 'se-block-handle' });
302
+ const blockHandleGroup = dom.utils.createElement('DIV', { class: 'se-block-handle', popover: 'manual' });
303
303
  const blockHandlePlus = dom.utils.createElement(
304
304
  'DIV',
305
305
  { class: 'se-block-handle-btn se-block-handle-plus' },