@textbus/platform-browser 4.2.3 → 4.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.
@@ -1126,18 +1126,32 @@ class ExperimentalCaret {
1126
1126
  if (this.changeFromSelf) {
1127
1127
  this.changeFromSelf = false;
1128
1128
  const selfRect = this.elementRef.getBoundingClientRect();
1129
+ const scrollContainer = this.getScrollContainer(startContainer);
1130
+ const scrollRect = scrollContainer === document.documentElement ?
1131
+ { top: 0, bottom: document.documentElement.clientHeight } :
1132
+ scrollContainer.getBoundingClientRect();
1129
1133
  const limit = this.getLimit();
1130
- if (selfRect.top < limit.top) {
1131
- this.elementRef.scrollIntoView({
1132
- block: 'start'
1133
- });
1134
+ const top = Math.max(limit.top, scrollRect.top);
1135
+ const bottom = Math.min(limit.bottom, scrollRect.bottom);
1136
+ if (selfRect.top < top) {
1137
+ scrollContainer.scrollTop -= top - selfRect.top;
1134
1138
  }
1135
- else if (selfRect.bottom > limit.bottom) {
1136
- this.elementRef.scrollIntoView({
1137
- block: 'end'
1138
- });
1139
+ else if (selfRect.bottom > bottom) {
1140
+ scrollContainer.scrollTop += selfRect.bottom - bottom;
1141
+ }
1142
+ }
1143
+ }
1144
+ getScrollContainer(container) {
1145
+ while (container) {
1146
+ if (container instanceof Element) {
1147
+ const styles = getComputedStyle(container);
1148
+ if (styles.overflow !== 'visible' || styles.overflowX !== 'visible' || styles.overflowY !== 'visible') {
1149
+ return container;
1150
+ }
1139
1151
  }
1152
+ container = container.parentNode;
1140
1153
  }
1154
+ return document.documentElement;
1141
1155
  }
1142
1156
  }
1143
1157
  /**
package/bundles/index.js CHANGED
@@ -1128,18 +1128,32 @@ class ExperimentalCaret {
1128
1128
  if (this.changeFromSelf) {
1129
1129
  this.changeFromSelf = false;
1130
1130
  const selfRect = this.elementRef.getBoundingClientRect();
1131
+ const scrollContainer = this.getScrollContainer(startContainer);
1132
+ const scrollRect = scrollContainer === document.documentElement ?
1133
+ { top: 0, bottom: document.documentElement.clientHeight } :
1134
+ scrollContainer.getBoundingClientRect();
1131
1135
  const limit = this.getLimit();
1132
- if (selfRect.top < limit.top) {
1133
- this.elementRef.scrollIntoView({
1134
- block: 'start'
1135
- });
1136
+ const top = Math.max(limit.top, scrollRect.top);
1137
+ const bottom = Math.min(limit.bottom, scrollRect.bottom);
1138
+ if (selfRect.top < top) {
1139
+ scrollContainer.scrollTop -= top - selfRect.top;
1136
1140
  }
1137
- else if (selfRect.bottom > limit.bottom) {
1138
- this.elementRef.scrollIntoView({
1139
- block: 'end'
1140
- });
1141
+ else if (selfRect.bottom > bottom) {
1142
+ scrollContainer.scrollTop += selfRect.bottom - bottom;
1143
+ }
1144
+ }
1145
+ }
1146
+ getScrollContainer(container) {
1147
+ while (container) {
1148
+ if (container instanceof Element) {
1149
+ const styles = getComputedStyle(container);
1150
+ if (styles.overflow !== 'visible' || styles.overflowX !== 'visible' || styles.overflowY !== 'visible') {
1151
+ return container;
1152
+ }
1141
1153
  }
1154
+ container = container.parentNode;
1142
1155
  }
1156
+ return document.documentElement;
1143
1157
  }
1144
1158
  }
1145
1159
  /**
@@ -34,6 +34,7 @@ declare class ExperimentalCaret implements Caret {
34
34
  hide(): void;
35
35
  destroy(): void;
36
36
  private updateCursorPosition;
37
+ private getScrollContainer;
37
38
  }
38
39
  /**
39
40
  * Textbus PC 端输入实现
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.2.3",
3
+ "version": "4.2.5",
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.6",
29
- "@textbus/core": "^4.2.3",
30
- "@viewfly/core": "^1.0.5"
29
+ "@textbus/core": "^4.2.4",
30
+ "@viewfly/core": "^1.1.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@rollup/plugin-commonjs": "^23.0.2",
@@ -47,5 +47,5 @@
47
47
  "bugs": {
48
48
  "url": "https://github.com/textbus/textbus.git/issues"
49
49
  },
50
- "gitHead": "d77564bc33b44ff9d04a03e9e69d7fbc2672087b"
50
+ "gitHead": "e976c07880be8cb3390a1cf956f09c872537064a"
51
51
  }