suneditor 3.0.0-beta.4 → 3.0.0-beta.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.0.0-beta.4",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "Vanilla javascript based WYSIWYG web editor",
5
5
  "author": "Yi JiHong",
6
6
  "license": "MIT",
@@ -288,7 +288,7 @@ Offset.prototype = {
288
288
  }
289
289
  }
290
290
 
291
- el = /** @type {HTMLElement} */ (this._shadowRoot?.host);
291
+ el = /** @type {HTMLElement} */ (this.editor._shadowRoot?.host);
292
292
  if (el) ohOffsetEl = owOffsetEl = topArea;
293
293
  while (el) {
294
294
  t += el.scrollTop;
@@ -37,15 +37,12 @@ Selection_.prototype = {
37
37
  * @returns {Selection}
38
38
  */
39
39
  get() {
40
- const wSelection = this.editor.frameContext.get('_ww').getSelection();
41
40
  let selection = null;
42
41
 
43
- if (this._shadowRoot) {
44
- selection = wSelection.getComposedRanges?.();
45
- }
46
-
47
- if (!selection) {
48
- selection = wSelection;
42
+ if (typeof this.editor._shadowRoot?.getSelection === 'function') {
43
+ selection = this.editor._shadowRoot.getSelection();
44
+ } else {
45
+ selection = this.editor.frameContext.get('_ww').getSelection();
49
46
  }
50
47
 
51
48
  if (!selection) return null;
@@ -311,7 +311,7 @@ function Editor(multiTargets, options) {
311
311
 
312
312
  /**
313
313
  * @description Closest ShadowRoot to editor if found
314
- * @type {ShadowRoot}
314
+ * @type {ShadowRoot & { getSelection?: () => Selection }} - Chromium-based browsers (Chrome, Edge, etc.) has a getSelection method on the ShadowRoot
315
315
  */
316
316
  this._shadowRoot = null;
317
317
 
@@ -84,9 +84,4 @@ export default function CoreInjector(editor) {
84
84
  * @type {Document}
85
85
  */
86
86
  this._d = editor._d;
87
- /**
88
- * @description The shadow root object (if any).
89
- * @type {__se__EditorCore['_shadowRoot']}
90
- */
91
- this._shadowRoot = editor._shadowRoot;
92
87
  }
@@ -37,8 +37,6 @@ function EditorInjector(editor) {
37
37
  this._w;
38
38
  /** @type {import('./_core').default['_d']} */
39
39
  this._d;
40
- /** @type {import('./_core').default['_shadowRoot']} */
41
- this._shadowRoot;
42
40
 
43
41
  // ClassInjector props
44
42
  /** @type {import('./_classes').default['toolbar']} */
@@ -235,7 +235,7 @@ class Controller extends EditorInjector {
235
235
  if ((await this.triggerEvent('onBeforeShowController', { caller: this.kind, frameContext: this.editor.frameContext, info })) === false) return;
236
236
 
237
237
  form.style.display = 'block';
238
- if (this._shadowRoot) {
238
+ if (this.editor._shadowRoot) {
239
239
  this.__shadowRootEventForm = form;
240
240
  this.__shadowRootEventListener = (e) => e.stopPropagation();
241
241
  form.addEventListener('mousedown', this.__shadowRootEventListener);
@@ -266,9 +266,11 @@ declare class Editor {
266
266
  _lineBreaker_b: HTMLElement;
267
267
  /**
268
268
  * @description Closest ShadowRoot to editor if found
269
- * @type {ShadowRoot}
269
+ * @type {ShadowRoot & { getSelection?: () => Selection }} - Chromium-based browsers (Chrome, Edge, etc.) has a getSelection method on the ShadowRoot
270
270
  */
271
- _shadowRoot: ShadowRoot;
271
+ _shadowRoot: ShadowRoot & {
272
+ getSelection?: () => Selection;
273
+ };
272
274
  /**
273
275
  * @description Plugin call event map
274
276
  * @type {Map<string, Array<((...args: *) => *) & { index: number }>>}
@@ -84,9 +84,4 @@ export default class CoreInjector {
84
84
  * @type {Document}
85
85
  */
86
86
  _d: Document;
87
- /**
88
- * @description The shadow root object (if any).
89
- * @type {__se__EditorCore['_shadowRoot']}
90
- */
91
- _shadowRoot: __se__EditorCore['_shadowRoot'];
92
87
  }
@@ -40,8 +40,6 @@ declare class EditorInjector {
40
40
  _w: import('./_core').default['_w'];
41
41
  /** @type {import('./_core').default['_d']} */
42
42
  _d: import('./_core').default['_d'];
43
- /** @type {import('./_core').default['_shadowRoot']} */
44
- _shadowRoot: import('./_core').default['_shadowRoot'];
45
43
  /** @type {import('./_classes').default['toolbar']} */
46
44
  toolbar: import('./_classes').default['toolbar'];
47
45
  /** @type {import('./_classes').default['subToolbar']} */