@textbus/platform-browser 4.0.0-alpha.74 → 4.0.0

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.
@@ -22,5 +22,4 @@ export interface UIElementParams {
22
22
  on?: Record<string, (ev: Event) => void>;
23
23
  }
24
24
  export declare function createElement(tagName: string, options?: UIElementParams): HTMLElement;
25
- export declare function createTextNode(content: string): Text;
26
25
  export declare function getLayoutRectByRange(range: Range): Rect;
@@ -34,9 +34,6 @@ function createElement(tagName, options = {}) {
34
34
  }
35
35
  return el;
36
36
  }
37
- function createTextNode(content) {
38
- return document.createTextNode(content);
39
- }
40
37
  function getLayoutRectByRange(range) {
41
38
  let { startContainer, startOffset } = range;
42
39
  if (startContainer.nodeType === Node.TEXT_NODE) {
@@ -62,7 +59,13 @@ function getLayoutRectByRange(range) {
62
59
  const range2 = document.createRange();
63
60
  range2.setStart(beforeNode, beforeNode.textContent.length);
64
61
  range2.setEnd(beforeNode, beforeNode.textContent.length);
65
- return range2.getBoundingClientRect();
62
+ const rect = range2.getBoundingClientRect();
63
+ return {
64
+ left: rect.right,
65
+ top: rect.top,
66
+ width: range.collapsed ? 0 : rect.width,
67
+ height: rect.height
68
+ };
66
69
  }
67
70
  }
68
71
  const offsetNode = startContainer.childNodes[startOffset];
@@ -102,7 +105,12 @@ function getLayoutRectByRange(range) {
102
105
  }
103
106
  const rect = span.getBoundingClientRect();
104
107
  startContainer.removeChild(span);
105
- return rect;
108
+ return {
109
+ left: rect.left,
110
+ top: rect.top,
111
+ width: range.collapsed ? 0 : rect.width,
112
+ height: rect.height
113
+ };
106
114
  }
107
115
 
108
116
  const isWindows = () => /win(dows|32|64)/i.test(navigator.userAgent);
@@ -2309,4 +2317,4 @@ class BrowserModule {
2309
2317
  }
2310
2318
  }
2311
2319
 
2312
- export { BrowserModule, CollaborateCursor, CollaborateSelectionAwarenessDelegate, DomAdapter, EDITOR_OPTIONS, Input, MagicInput, NativeInput, Parser, SelectionBridge, VIEW_CONTAINER, VIEW_DOCUMENT, VIEW_MASK, createElement, createTextNode, getLayoutRectByRange, isFirefox, isMac, isMobileBrowser, isSafari, isWindows };
2320
+ export { BrowserModule, CollaborateCursor, CollaborateSelectionAwarenessDelegate, DomAdapter, EDITOR_OPTIONS, Input, MagicInput, NativeInput, Parser, SelectionBridge, VIEW_CONTAINER, VIEW_DOCUMENT, VIEW_MASK, createElement, getLayoutRectByRange, isFirefox, isMac, isMobileBrowser, isSafari, isWindows };
package/bundles/index.js CHANGED
@@ -36,9 +36,6 @@ function createElement(tagName, options = {}) {
36
36
  }
37
37
  return el;
38
38
  }
39
- function createTextNode(content) {
40
- return document.createTextNode(content);
41
- }
42
39
  function getLayoutRectByRange(range) {
43
40
  let { startContainer, startOffset } = range;
44
41
  if (startContainer.nodeType === Node.TEXT_NODE) {
@@ -64,7 +61,13 @@ function getLayoutRectByRange(range) {
64
61
  const range2 = document.createRange();
65
62
  range2.setStart(beforeNode, beforeNode.textContent.length);
66
63
  range2.setEnd(beforeNode, beforeNode.textContent.length);
67
- return range2.getBoundingClientRect();
64
+ const rect = range2.getBoundingClientRect();
65
+ return {
66
+ left: rect.right,
67
+ top: rect.top,
68
+ width: range.collapsed ? 0 : rect.width,
69
+ height: rect.height
70
+ };
68
71
  }
69
72
  }
70
73
  const offsetNode = startContainer.childNodes[startOffset];
@@ -104,7 +107,12 @@ function getLayoutRectByRange(range) {
104
107
  }
105
108
  const rect = span.getBoundingClientRect();
106
109
  startContainer.removeChild(span);
107
- return rect;
110
+ return {
111
+ left: rect.left,
112
+ top: rect.top,
113
+ width: range.collapsed ? 0 : rect.width,
114
+ height: rect.height
115
+ };
108
116
  }
109
117
 
110
118
  const isWindows = () => /win(dows|32|64)/i.test(navigator.userAgent);
@@ -2320,7 +2328,6 @@ exports.VIEW_CONTAINER = VIEW_CONTAINER;
2320
2328
  exports.VIEW_DOCUMENT = VIEW_DOCUMENT;
2321
2329
  exports.VIEW_MASK = VIEW_MASK;
2322
2330
  exports.createElement = createElement;
2323
- exports.createTextNode = createTextNode;
2324
2331
  exports.getLayoutRectByRange = getLayoutRectByRange;
2325
2332
  exports.isFirefox = isFirefox;
2326
2333
  exports.isMac = isMac;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.0.0-alpha.74",
3
+ "version": "4.0.0",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -26,8 +26,8 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.5",
29
- "@textbus/collaborate": "^4.0.0-alpha.74",
30
- "@textbus/core": "^4.0.0-alpha.74",
29
+ "@textbus/collaborate": "^4.0.0",
30
+ "@textbus/core": "^4.0.0",
31
31
  "@viewfly/core": "^1.0.0-alpha.22"
32
32
  },
33
33
  "devDependencies": {
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "fcd0c2f0e5111a1019cdd92144cde932fb4f5acd"
51
+ "gitHead": "cf4fd289b73bc777124a32fe42bb58eba05a34f1"
52
52
  }