@textbus/platform-browser 4.0.0-alpha.53 → 4.0.0-alpha.54

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.
@@ -911,16 +911,20 @@ class ExperimentalCaret {
911
911
  this.domRenderer = domRenderer;
912
912
  this.scheduler = scheduler;
913
913
  this.editorMask = editorMask;
914
+ this.changeFromSelf = false;
915
+ this.getLimit = function () {
916
+ return {
917
+ top: 0,
918
+ bottom: document.documentElement.clientHeight
919
+ };
920
+ };
914
921
  this.timer = null;
915
- this.oldPosition = null;
916
922
  this._display = true;
917
923
  this.flashing = true;
918
- this.subs = [];
919
924
  this.subscription = new Subscription();
920
925
  this.positionChangeEvent = new Subject();
921
926
  this.styleChangeEvent = new Subject();
922
927
  this.oldRange = null;
923
- this.isFixed = false;
924
928
  this.onPositionChange = this.positionChangeEvent.pipe(distinctUntilChanged());
925
929
  this.onStyleChange = this.styleChangeEvent.asObservable();
926
930
  this.elementRef = createElement('div', {
@@ -948,20 +952,12 @@ class ExperimentalCaret {
948
952
  }));
949
953
  this.editorMask.appendChild(this.elementRef);
950
954
  }
951
- refresh(isFixedCaret = false) {
952
- this.isFixed = isFixedCaret;
955
+ refresh() {
953
956
  if (this.oldRange) {
954
957
  this.show(this.oldRange, false);
955
958
  }
956
- this.isFixed = false;
957
959
  }
958
960
  show(range, restart) {
959
- const oldRect = this.elementRef.getBoundingClientRect();
960
- this.oldPosition = {
961
- top: oldRect.top,
962
- left: oldRect.left,
963
- height: oldRect.height
964
- };
965
961
  this.oldRange = range;
966
962
  if (restart || this.scheduler.lastChangesHasLocalUpdate) {
967
963
  clearTimeout(this.timer);
@@ -991,61 +987,6 @@ class ExperimentalCaret {
991
987
  destroy() {
992
988
  clearTimeout(this.timer);
993
989
  this.subscription.unsubscribe();
994
- this.subs.forEach(i => i.unsubscribe());
995
- }
996
- correctScrollTop(scroller) {
997
- this.subs.forEach(i => i.unsubscribe());
998
- this.subs = [];
999
- const scheduler = this.scheduler;
1000
- let docIsChanged = true;
1001
- function limitPosition(position) {
1002
- const { top, bottom } = scroller.getLimit();
1003
- const caretTop = position.top;
1004
- if (caretTop + position.height > bottom) {
1005
- const offset = caretTop - bottom + position.height;
1006
- scroller.setOffset(offset);
1007
- }
1008
- else if (position.top < top) {
1009
- scroller.setOffset(-(top - position.top));
1010
- }
1011
- }
1012
- let isPressed = false;
1013
- this.subs.push(scroller.onScroll.subscribe(() => {
1014
- if (this.oldPosition) {
1015
- const rect = this.rect;
1016
- this.oldPosition.top = rect.top;
1017
- this.oldPosition.left = rect.left;
1018
- this.oldPosition.height = rect.height;
1019
- }
1020
- }), fromEvent(document, 'mousedown', true).subscribe(() => {
1021
- isPressed = true;
1022
- }), fromEvent(document, 'mouseup', true).subscribe(() => {
1023
- isPressed = false;
1024
- }), scheduler.onDocChange.subscribe(() => {
1025
- docIsChanged = true;
1026
- }), this.onPositionChange.subscribe(position => {
1027
- if (position) {
1028
- if (docIsChanged) {
1029
- if (scheduler.lastChangesHasLocalUpdate) {
1030
- limitPosition(position);
1031
- }
1032
- else if (this.oldPosition) {
1033
- const offset = Math.floor(position.top - this.oldPosition.top);
1034
- scroller.setOffset(offset);
1035
- }
1036
- }
1037
- else if (!isPressed) {
1038
- if (this.isFixed && this.oldPosition) {
1039
- const offset = Math.floor(position.top - this.oldPosition.top);
1040
- scroller.setOffset(offset);
1041
- }
1042
- else {
1043
- limitPosition(position);
1044
- }
1045
- }
1046
- }
1047
- docIsChanged = false;
1048
- }));
1049
990
  }
1050
991
  updateCursorPosition(nativeRange) {
1051
992
  const startContainer = nativeRange.startContainer;
@@ -1103,6 +1044,21 @@ class ExperimentalCaret {
1103
1044
  top: rectTop,
1104
1045
  height: boxHeight
1105
1046
  });
1047
+ if (this.changeFromSelf) {
1048
+ this.changeFromSelf = false;
1049
+ const selfRect = this.elementRef.getBoundingClientRect();
1050
+ const limit = this.getLimit();
1051
+ if (selfRect.top < limit.top) {
1052
+ this.elementRef.scrollIntoView({
1053
+ block: 'start'
1054
+ });
1055
+ }
1056
+ else if (selfRect.bottom > limit.bottom) {
1057
+ this.elementRef.scrollIntoView({
1058
+ block: 'end'
1059
+ });
1060
+ }
1061
+ }
1106
1062
  }
1107
1063
  }
1108
1064
  /**
@@ -1324,6 +1280,7 @@ let MagicInput = class MagicInput extends Input {
1324
1280
  key = keys.charAt(+ev.code.substring(5));
1325
1281
  ev.preventDefault();
1326
1282
  }
1283
+ this.caret.changeFromSelf = true;
1327
1284
  const is = this.keyboard.execShortcut({
1328
1285
  key: key,
1329
1286
  altKey: ev.altKey,
@@ -1334,6 +1291,9 @@ let MagicInput = class MagicInput extends Input {
1334
1291
  this.ignoreComposition = true;
1335
1292
  ev.preventDefault();
1336
1293
  }
1294
+ else {
1295
+ this.caret.changeFromSelf = false;
1296
+ }
1337
1297
  }));
1338
1298
  }
1339
1299
  handleInput(textarea) {
@@ -1342,6 +1302,7 @@ let MagicInput = class MagicInput extends Input {
1342
1302
  return !this.ignoreComposition;
1343
1303
  })).subscribe(() => {
1344
1304
  if (!this.selection.isCollapsed) {
1305
+ this.caret.changeFromSelf = true;
1345
1306
  this.commander.delete();
1346
1307
  }
1347
1308
  this.composition = true;
@@ -1367,7 +1328,8 @@ let MagicInput = class MagicInput extends Input {
1367
1328
  offset: ev.data.length,
1368
1329
  index: startIndex
1369
1330
  };
1370
- this.caret.refresh(true);
1331
+ this.caret.changeFromSelf = true;
1332
+ this.caret.refresh();
1371
1333
  const event = new Event(startSlot, {
1372
1334
  index: startIndex,
1373
1335
  data: ev.data
@@ -1401,6 +1363,7 @@ let MagicInput = class MagicInput extends Input {
1401
1363
  this.composition = false;
1402
1364
  this.domAdapter.composition = null;
1403
1365
  if (text) {
1366
+ this.caret.changeFromSelf = true;
1404
1367
  this.commander.write(text);
1405
1368
  }
1406
1369
  else {
@@ -1755,9 +1718,7 @@ class NativeCaret {
1755
1718
  height: 0
1756
1719
  };
1757
1720
  }
1758
- constructor(scheduler) {
1759
- this.scheduler = scheduler;
1760
- this.oldPosition = null;
1721
+ constructor() {
1761
1722
  this._nativeRange = null;
1762
1723
  this.subs = [];
1763
1724
  this.positionChangeEvent = new Subject();
@@ -1766,59 +1727,6 @@ class NativeCaret {
1766
1727
  refresh() {
1767
1728
  //
1768
1729
  }
1769
- correctScrollTop(scroller) {
1770
- this.destroy();
1771
- const scheduler = this.scheduler;
1772
- let docIsChanged = true;
1773
- function limitPosition(position) {
1774
- const { top, bottom } = scroller.getLimit();
1775
- const caretTop = position.top;
1776
- if (caretTop + position.height > bottom) {
1777
- const offset = caretTop - bottom + position.height;
1778
- scroller.setOffset(offset);
1779
- }
1780
- else if (position.top < top) {
1781
- scroller.setOffset(-(top - position.top));
1782
- }
1783
- }
1784
- let isPressed = false;
1785
- this.subs.push(scroller.onScroll.subscribe(() => {
1786
- if (this.oldPosition) {
1787
- const rect = this.rect;
1788
- this.oldPosition.top = rect.top;
1789
- this.oldPosition.left = rect.left;
1790
- this.oldPosition.height = rect.height;
1791
- }
1792
- }), fromEvent(document, 'mousedown', true).subscribe(() => {
1793
- isPressed = true;
1794
- }), fromEvent(document, 'mouseup', true).subscribe(() => {
1795
- isPressed = false;
1796
- }), scheduler.onDocChange.subscribe(() => {
1797
- docIsChanged = true;
1798
- }), this.onPositionChange.subscribe(position => {
1799
- if (position) {
1800
- if (docIsChanged) {
1801
- if (scheduler.lastChangesHasLocalUpdate) {
1802
- limitPosition(position);
1803
- }
1804
- else if (this.oldPosition) {
1805
- const offset = Math.floor(position.top - this.oldPosition.top);
1806
- scroller.setOffset(offset);
1807
- }
1808
- }
1809
- else if (!isPressed) {
1810
- if (this.oldPosition) {
1811
- const offset = Math.floor(position.top - this.oldPosition.top);
1812
- scroller.setOffset(offset);
1813
- }
1814
- else {
1815
- limitPosition(position);
1816
- }
1817
- }
1818
- }
1819
- docIsChanged = false;
1820
- }));
1821
- }
1822
1730
  destroy() {
1823
1731
  this.subs.forEach(i => i.unsubscribe());
1824
1732
  this.subs = [];
@@ -1836,16 +1744,15 @@ let NativeInput = class NativeInput extends Input {
1836
1744
  get disabled() {
1837
1745
  return this._disabled;
1838
1746
  }
1839
- constructor(textbus, parser, scheduler, selection, keyboard, domAdapter, commander, controller) {
1747
+ constructor(textbus, parser, selection, keyboard, domAdapter, commander, controller) {
1840
1748
  super();
1841
1749
  this.parser = parser;
1842
- this.scheduler = scheduler;
1843
1750
  this.selection = selection;
1844
1751
  this.keyboard = keyboard;
1845
1752
  this.domAdapter = domAdapter;
1846
1753
  this.commander = commander;
1847
1754
  this.controller = controller;
1848
- this.caret = new NativeCaret(this.scheduler);
1755
+ this.caret = new NativeCaret();
1849
1756
  this.composition = false;
1850
1757
  // compositionState: CompositionState | null = null
1851
1758
  this.onReady = Promise.resolve();
@@ -2177,7 +2084,6 @@ NativeInput = __decorate([
2177
2084
  Injectable(),
2178
2085
  __metadata("design:paramtypes", [Textbus,
2179
2086
  Parser,
2180
- Scheduler,
2181
2087
  Selection,
2182
2088
  Keyboard,
2183
2089
  DomAdapter,
@@ -2296,11 +2202,24 @@ class BrowserModule {
2296
2202
  right: 0,
2297
2203
  top: 0,
2298
2204
  bottom: 0,
2299
- zIndex: 1,
2300
2205
  pointerEvents: 'none',
2301
2206
  // overflow: 'hidden'
2302
2207
  }
2303
2208
  });
2209
+ const maskWrapper = createElement('div', {
2210
+ styles: {
2211
+ position: 'absolute',
2212
+ left: 0,
2213
+ right: 0,
2214
+ top: 0,
2215
+ bottom: 0,
2216
+ margin: '0 -2px',
2217
+ zIndex: 1,
2218
+ pointerEvents: 'none',
2219
+ overflow: 'hidden'
2220
+ },
2221
+ children: [mask]
2222
+ });
2304
2223
  const wrapper = createElement('div', {
2305
2224
  attrs: {
2306
2225
  'data-textbus-view': VIEW_CONTAINER,
@@ -2311,7 +2230,7 @@ class BrowserModule {
2311
2230
  position: 'relative',
2312
2231
  flexDirection: 'column'
2313
2232
  },
2314
- children: [mask]
2233
+ children: [maskWrapper]
2315
2234
  });
2316
2235
  return {
2317
2236
  wrapper,
package/bundles/index.js CHANGED
@@ -913,16 +913,20 @@ class ExperimentalCaret {
913
913
  this.domRenderer = domRenderer;
914
914
  this.scheduler = scheduler;
915
915
  this.editorMask = editorMask;
916
+ this.changeFromSelf = false;
917
+ this.getLimit = function () {
918
+ return {
919
+ top: 0,
920
+ bottom: document.documentElement.clientHeight
921
+ };
922
+ };
916
923
  this.timer = null;
917
- this.oldPosition = null;
918
924
  this._display = true;
919
925
  this.flashing = true;
920
- this.subs = [];
921
926
  this.subscription = new stream.Subscription();
922
927
  this.positionChangeEvent = new stream.Subject();
923
928
  this.styleChangeEvent = new stream.Subject();
924
929
  this.oldRange = null;
925
- this.isFixed = false;
926
930
  this.onPositionChange = this.positionChangeEvent.pipe(stream.distinctUntilChanged());
927
931
  this.onStyleChange = this.styleChangeEvent.asObservable();
928
932
  this.elementRef = createElement('div', {
@@ -950,20 +954,12 @@ class ExperimentalCaret {
950
954
  }));
951
955
  this.editorMask.appendChild(this.elementRef);
952
956
  }
953
- refresh(isFixedCaret = false) {
954
- this.isFixed = isFixedCaret;
957
+ refresh() {
955
958
  if (this.oldRange) {
956
959
  this.show(this.oldRange, false);
957
960
  }
958
- this.isFixed = false;
959
961
  }
960
962
  show(range, restart) {
961
- const oldRect = this.elementRef.getBoundingClientRect();
962
- this.oldPosition = {
963
- top: oldRect.top,
964
- left: oldRect.left,
965
- height: oldRect.height
966
- };
967
963
  this.oldRange = range;
968
964
  if (restart || this.scheduler.lastChangesHasLocalUpdate) {
969
965
  clearTimeout(this.timer);
@@ -993,61 +989,6 @@ class ExperimentalCaret {
993
989
  destroy() {
994
990
  clearTimeout(this.timer);
995
991
  this.subscription.unsubscribe();
996
- this.subs.forEach(i => i.unsubscribe());
997
- }
998
- correctScrollTop(scroller) {
999
- this.subs.forEach(i => i.unsubscribe());
1000
- this.subs = [];
1001
- const scheduler = this.scheduler;
1002
- let docIsChanged = true;
1003
- function limitPosition(position) {
1004
- const { top, bottom } = scroller.getLimit();
1005
- const caretTop = position.top;
1006
- if (caretTop + position.height > bottom) {
1007
- const offset = caretTop - bottom + position.height;
1008
- scroller.setOffset(offset);
1009
- }
1010
- else if (position.top < top) {
1011
- scroller.setOffset(-(top - position.top));
1012
- }
1013
- }
1014
- let isPressed = false;
1015
- this.subs.push(scroller.onScroll.subscribe(() => {
1016
- if (this.oldPosition) {
1017
- const rect = this.rect;
1018
- this.oldPosition.top = rect.top;
1019
- this.oldPosition.left = rect.left;
1020
- this.oldPosition.height = rect.height;
1021
- }
1022
- }), stream.fromEvent(document, 'mousedown', true).subscribe(() => {
1023
- isPressed = true;
1024
- }), stream.fromEvent(document, 'mouseup', true).subscribe(() => {
1025
- isPressed = false;
1026
- }), scheduler.onDocChange.subscribe(() => {
1027
- docIsChanged = true;
1028
- }), this.onPositionChange.subscribe(position => {
1029
- if (position) {
1030
- if (docIsChanged) {
1031
- if (scheduler.lastChangesHasLocalUpdate) {
1032
- limitPosition(position);
1033
- }
1034
- else if (this.oldPosition) {
1035
- const offset = Math.floor(position.top - this.oldPosition.top);
1036
- scroller.setOffset(offset);
1037
- }
1038
- }
1039
- else if (!isPressed) {
1040
- if (this.isFixed && this.oldPosition) {
1041
- const offset = Math.floor(position.top - this.oldPosition.top);
1042
- scroller.setOffset(offset);
1043
- }
1044
- else {
1045
- limitPosition(position);
1046
- }
1047
- }
1048
- }
1049
- docIsChanged = false;
1050
- }));
1051
992
  }
1052
993
  updateCursorPosition(nativeRange) {
1053
994
  const startContainer = nativeRange.startContainer;
@@ -1105,6 +1046,21 @@ class ExperimentalCaret {
1105
1046
  top: rectTop,
1106
1047
  height: boxHeight
1107
1048
  });
1049
+ if (this.changeFromSelf) {
1050
+ this.changeFromSelf = false;
1051
+ const selfRect = this.elementRef.getBoundingClientRect();
1052
+ const limit = this.getLimit();
1053
+ if (selfRect.top < limit.top) {
1054
+ this.elementRef.scrollIntoView({
1055
+ block: 'start'
1056
+ });
1057
+ }
1058
+ else if (selfRect.bottom > limit.bottom) {
1059
+ this.elementRef.scrollIntoView({
1060
+ block: 'end'
1061
+ });
1062
+ }
1063
+ }
1108
1064
  }
1109
1065
  }
1110
1066
  /**
@@ -1326,6 +1282,7 @@ exports.MagicInput = class MagicInput extends Input {
1326
1282
  key = keys.charAt(+ev.code.substring(5));
1327
1283
  ev.preventDefault();
1328
1284
  }
1285
+ this.caret.changeFromSelf = true;
1329
1286
  const is = this.keyboard.execShortcut({
1330
1287
  key: key,
1331
1288
  altKey: ev.altKey,
@@ -1336,6 +1293,9 @@ exports.MagicInput = class MagicInput extends Input {
1336
1293
  this.ignoreComposition = true;
1337
1294
  ev.preventDefault();
1338
1295
  }
1296
+ else {
1297
+ this.caret.changeFromSelf = false;
1298
+ }
1339
1299
  }));
1340
1300
  }
1341
1301
  handleInput(textarea) {
@@ -1344,6 +1304,7 @@ exports.MagicInput = class MagicInput extends Input {
1344
1304
  return !this.ignoreComposition;
1345
1305
  })).subscribe(() => {
1346
1306
  if (!this.selection.isCollapsed) {
1307
+ this.caret.changeFromSelf = true;
1347
1308
  this.commander.delete();
1348
1309
  }
1349
1310
  this.composition = true;
@@ -1369,7 +1330,8 @@ exports.MagicInput = class MagicInput extends Input {
1369
1330
  offset: ev.data.length,
1370
1331
  index: startIndex
1371
1332
  };
1372
- this.caret.refresh(true);
1333
+ this.caret.changeFromSelf = true;
1334
+ this.caret.refresh();
1373
1335
  const event = new core$1.Event(startSlot, {
1374
1336
  index: startIndex,
1375
1337
  data: ev.data
@@ -1403,6 +1365,7 @@ exports.MagicInput = class MagicInput extends Input {
1403
1365
  this.composition = false;
1404
1366
  this.domAdapter.composition = null;
1405
1367
  if (text) {
1368
+ this.caret.changeFromSelf = true;
1406
1369
  this.commander.write(text);
1407
1370
  }
1408
1371
  else {
@@ -1757,9 +1720,7 @@ class NativeCaret {
1757
1720
  height: 0
1758
1721
  };
1759
1722
  }
1760
- constructor(scheduler) {
1761
- this.scheduler = scheduler;
1762
- this.oldPosition = null;
1723
+ constructor() {
1763
1724
  this._nativeRange = null;
1764
1725
  this.subs = [];
1765
1726
  this.positionChangeEvent = new stream.Subject();
@@ -1768,59 +1729,6 @@ class NativeCaret {
1768
1729
  refresh() {
1769
1730
  //
1770
1731
  }
1771
- correctScrollTop(scroller) {
1772
- this.destroy();
1773
- const scheduler = this.scheduler;
1774
- let docIsChanged = true;
1775
- function limitPosition(position) {
1776
- const { top, bottom } = scroller.getLimit();
1777
- const caretTop = position.top;
1778
- if (caretTop + position.height > bottom) {
1779
- const offset = caretTop - bottom + position.height;
1780
- scroller.setOffset(offset);
1781
- }
1782
- else if (position.top < top) {
1783
- scroller.setOffset(-(top - position.top));
1784
- }
1785
- }
1786
- let isPressed = false;
1787
- this.subs.push(scroller.onScroll.subscribe(() => {
1788
- if (this.oldPosition) {
1789
- const rect = this.rect;
1790
- this.oldPosition.top = rect.top;
1791
- this.oldPosition.left = rect.left;
1792
- this.oldPosition.height = rect.height;
1793
- }
1794
- }), stream.fromEvent(document, 'mousedown', true).subscribe(() => {
1795
- isPressed = true;
1796
- }), stream.fromEvent(document, 'mouseup', true).subscribe(() => {
1797
- isPressed = false;
1798
- }), scheduler.onDocChange.subscribe(() => {
1799
- docIsChanged = true;
1800
- }), this.onPositionChange.subscribe(position => {
1801
- if (position) {
1802
- if (docIsChanged) {
1803
- if (scheduler.lastChangesHasLocalUpdate) {
1804
- limitPosition(position);
1805
- }
1806
- else if (this.oldPosition) {
1807
- const offset = Math.floor(position.top - this.oldPosition.top);
1808
- scroller.setOffset(offset);
1809
- }
1810
- }
1811
- else if (!isPressed) {
1812
- if (this.oldPosition) {
1813
- const offset = Math.floor(position.top - this.oldPosition.top);
1814
- scroller.setOffset(offset);
1815
- }
1816
- else {
1817
- limitPosition(position);
1818
- }
1819
- }
1820
- }
1821
- docIsChanged = false;
1822
- }));
1823
- }
1824
1732
  destroy() {
1825
1733
  this.subs.forEach(i => i.unsubscribe());
1826
1734
  this.subs = [];
@@ -1838,16 +1746,15 @@ exports.NativeInput = class NativeInput extends Input {
1838
1746
  get disabled() {
1839
1747
  return this._disabled;
1840
1748
  }
1841
- constructor(textbus, parser, scheduler, selection, keyboard, domAdapter, commander, controller) {
1749
+ constructor(textbus, parser, selection, keyboard, domAdapter, commander, controller) {
1842
1750
  super();
1843
1751
  this.parser = parser;
1844
- this.scheduler = scheduler;
1845
1752
  this.selection = selection;
1846
1753
  this.keyboard = keyboard;
1847
1754
  this.domAdapter = domAdapter;
1848
1755
  this.commander = commander;
1849
1756
  this.controller = controller;
1850
- this.caret = new NativeCaret(this.scheduler);
1757
+ this.caret = new NativeCaret();
1851
1758
  this.composition = false;
1852
1759
  // compositionState: CompositionState | null = null
1853
1760
  this.onReady = Promise.resolve();
@@ -2179,7 +2086,6 @@ exports.NativeInput = __decorate([
2179
2086
  core.Injectable(),
2180
2087
  __metadata("design:paramtypes", [core$1.Textbus,
2181
2088
  exports.Parser,
2182
- core$1.Scheduler,
2183
2089
  core$1.Selection,
2184
2090
  core$1.Keyboard,
2185
2091
  DomAdapter,
@@ -2298,11 +2204,24 @@ class BrowserModule {
2298
2204
  right: 0,
2299
2205
  top: 0,
2300
2206
  bottom: 0,
2301
- zIndex: 1,
2302
2207
  pointerEvents: 'none',
2303
2208
  // overflow: 'hidden'
2304
2209
  }
2305
2210
  });
2211
+ const maskWrapper = createElement('div', {
2212
+ styles: {
2213
+ position: 'absolute',
2214
+ left: 0,
2215
+ right: 0,
2216
+ top: 0,
2217
+ bottom: 0,
2218
+ margin: '0 -2px',
2219
+ zIndex: 1,
2220
+ pointerEvents: 'none',
2221
+ overflow: 'hidden'
2222
+ },
2223
+ children: [mask]
2224
+ });
2306
2225
  const wrapper = createElement('div', {
2307
2226
  attrs: {
2308
2227
  'data-textbus-view': VIEW_CONTAINER,
@@ -2313,7 +2232,7 @@ class BrowserModule {
2313
2232
  position: 'relative',
2314
2233
  flexDirection: 'column'
2315
2234
  },
2316
- children: [mask]
2235
+ children: [maskWrapper]
2317
2236
  });
2318
2237
  return {
2319
2238
  wrapper,
@@ -1,7 +1,7 @@
1
1
  import { Observable } from '@tanbo/stream';
2
2
  import { Commander, Controller, Keyboard, Scheduler, Selection, Textbus } from '@textbus/core';
3
3
  import { Parser } from './parser';
4
- import { Caret, CaretPosition, Input, Scroller } from './types';
4
+ import { Caret, CaretLimit, CaretPosition, Input } from './types';
5
5
  import { DomAdapter } from './dom-adapter';
6
6
  interface CaretStyle {
7
7
  height: string;
@@ -15,26 +15,24 @@ declare class ExperimentalCaret implements Caret {
15
15
  onPositionChange: Observable<CaretPosition | null>;
16
16
  onStyleChange: Observable<CaretStyle>;
17
17
  elementRef: HTMLElement;
18
+ changeFromSelf: boolean;
19
+ getLimit: () => CaretLimit;
18
20
  get rect(): DOMRect;
19
21
  private timer;
20
22
  private caret;
21
- private oldPosition;
22
23
  private set display(value);
23
24
  private get display();
24
25
  private _display;
25
26
  private flashing;
26
- private subs;
27
27
  private subscription;
28
28
  private positionChangeEvent;
29
29
  private styleChangeEvent;
30
30
  private oldRange;
31
- private isFixed;
32
31
  constructor(domRenderer: DomAdapter, scheduler: Scheduler, editorMask: HTMLElement);
33
- refresh(isFixedCaret?: boolean): void;
32
+ refresh(): void;
34
33
  show(range: Range, restart: boolean): void;
35
34
  hide(): void;
36
35
  destroy(): void;
37
- correctScrollTop(scroller: Scroller): void;
38
36
  private updateCursorPosition;
39
37
  }
40
38
  /**
@@ -1,26 +1,22 @@
1
1
  import { Observable } from '@tanbo/stream';
2
- import { Commander, Controller, Keyboard, Scheduler, Selection, Textbus } from '@textbus/core';
3
- import { Caret, CaretPosition, Input, Scroller } from './types';
2
+ import { Commander, Controller, Keyboard, Selection, Textbus } from '@textbus/core';
3
+ import { Caret, CaretPosition, Input } from './types';
4
4
  import { Parser } from './parser';
5
5
  import { DomAdapter } from './dom-adapter';
6
6
  declare class NativeCaret implements Caret {
7
- private scheduler;
8
7
  onPositionChange: Observable<CaretPosition | null>;
9
8
  set nativeRange(range: Range | null);
10
9
  get nativeRange(): Range | null;
11
10
  get rect(): import("./_utils/uikit").Rect;
12
- private oldPosition;
13
11
  private _nativeRange;
14
12
  private subs;
15
13
  private positionChangeEvent;
16
- constructor(scheduler: Scheduler);
14
+ constructor();
17
15
  refresh(): void;
18
- correctScrollTop(scroller: Scroller): void;
19
16
  destroy(): void;
20
17
  }
21
18
  export declare class NativeInput extends Input {
22
19
  private parser;
23
- private scheduler;
24
20
  private selection;
25
21
  private keyboard;
26
22
  private domAdapter;
@@ -40,7 +36,7 @@ export declare class NativeInput extends Input {
40
36
  private isMac;
41
37
  private isMobileBrowser;
42
38
  private ignoreComposition;
43
- constructor(textbus: Textbus, parser: Parser, scheduler: Scheduler, selection: Selection, keyboard: Keyboard, domAdapter: DomAdapter, commander: Commander, controller: Controller);
39
+ constructor(textbus: Textbus, parser: Parser, selection: Selection, keyboard: Keyboard, domAdapter: DomAdapter, commander: Commander, controller: Controller);
44
40
  focus(nativeRange: Range): void;
45
41
  blur(): void;
46
42
  destroy(): void;
@@ -4,11 +4,6 @@ export interface CaretLimit {
4
4
  top: number;
5
5
  bottom: number;
6
6
  }
7
- export interface Scroller {
8
- onScroll: Observable<any>;
9
- getLimit(): CaretLimit;
10
- setOffset(offsetScrollTop: number): void;
11
- }
12
7
  export interface CaretPosition {
13
8
  left: number;
14
9
  top: number;
@@ -17,8 +12,7 @@ export interface CaretPosition {
17
12
  export interface Caret {
18
13
  onPositionChange: Observable<CaretPosition | null>;
19
14
  readonly rect: Rect;
20
- refresh(isFixedCaret: boolean): void;
21
- correctScrollTop(scroller: Scroller): void;
15
+ refresh(): void;
22
16
  }
23
17
  export declare abstract class Input {
24
18
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.0.0-alpha.53",
3
+ "version": "4.0.0-alpha.54",
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,9 +26,9 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.4",
29
- "@textbus/collaborate": "^4.0.0-alpha.53",
30
- "@textbus/core": "^4.0.0-alpha.53",
31
- "@viewfly/core": "^1.0.0-alpha.4",
29
+ "@textbus/collaborate": "^4.0.0-alpha.54",
30
+ "@textbus/core": "^4.0.0-alpha.54",
31
+ "@viewfly/core": "^1.0.0-alpha.5",
32
32
  "reflect-metadata": "^0.1.13"
33
33
  },
34
34
  "devDependencies": {
@@ -49,5 +49,5 @@
49
49
  "bugs": {
50
50
  "url": "https://github.com/textbus/textbus.git/issues"
51
51
  },
52
- "gitHead": "457054dfa61a943b0fa35a306be8cbaeee9c9110"
52
+ "gitHead": "2797081feb8bf81936f41778775c9eb2dae35e59"
53
53
  }