@textbus/platform-browser 3.0.0-alpha.50 → 3.0.0-alpha.51

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.
@@ -1,5 +1,5 @@
1
1
  import { Injector } from '@tanbo/di';
2
- import { Selection, SelectionPaths, AbstractSelection, Scheduler } from '@textbus/core';
2
+ import { Selection, SelectionPaths, AbstractSelection, Renderer } from '@textbus/core';
3
3
  import { SelectionBridge } from '../core/selection-bridge';
4
4
  import { Rect } from '../_utils/uikit';
5
5
  export interface RemoteSelection {
@@ -24,7 +24,7 @@ export declare abstract class CollaborateSelectionAwarenessDelegate {
24
24
  export declare class CollaborateCursor {
25
25
  private injector;
26
26
  private nativeSelection;
27
- private scheduler;
27
+ private renderer;
28
28
  private selection;
29
29
  private awarenessDelegate?;
30
30
  private host;
@@ -36,7 +36,7 @@ export declare class CollaborateCursor {
36
36
  private subscription;
37
37
  private currentSelection;
38
38
  private container;
39
- constructor(injector: Injector, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
39
+ constructor(injector: Injector, nativeSelection: SelectionBridge, renderer: Renderer, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
40
40
  refresh(): void;
41
41
  destroy(): void;
42
42
  draw(paths: RemoteSelection[]): void;
@@ -10,7 +10,6 @@ interface CaretStyle {
10
10
  }
11
11
  interface CompositionState {
12
12
  slot: Slot;
13
- index: number;
14
13
  data: string;
15
14
  }
16
15
  declare class ExperimentalCaret implements Caret {
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
2
  import { InjectionToken, Injectable, Inject, Injector, Optional } from '@tanbo/di';
3
- import { VTextNode, VElement, Controller, Selection, RootComponentRef, Renderer, Scheduler, Slot, ContentType, Keyboard, Commander, makeError, Starter, NativeRenderer, NativeSelectionBridge, OutputRenderer, Registry, invokeListener, History } from '@textbus/core';
3
+ import { VTextNode, VElement, Controller, Selection, RootComponentRef, Renderer, Slot, ContentType, Keyboard, Commander, Scheduler, makeError, Starter, NativeRenderer, NativeSelectionBridge, OutputRenderer, Registry, invokeListener, History } from '@textbus/core';
4
4
  import { Subject, filter, fromEvent, Subscription, merge, map, Observable, distinctUntilChanged } from '@tanbo/stream';
5
5
 
6
6
  function createElement(tagName, options = {}) {
@@ -59,8 +59,8 @@ function getLayoutRectByRange(range) {
59
59
  }
60
60
  else if (beforeNode.nodeType === Node.TEXT_NODE) {
61
61
  const range2 = document.createRange();
62
- range2.setStart(beforeNode, beforeNode.textContent.length);
63
- range2.setEnd(beforeNode, beforeNode.textContent.length);
62
+ range2.selectNodeContents(beforeNode);
63
+ range2.collapse();
64
64
  return range2.getBoundingClientRect();
65
65
  }
66
66
  }
@@ -776,10 +776,10 @@ SelectionBridge = __decorate([
776
776
  class CollaborateSelectionAwarenessDelegate {
777
777
  }
778
778
  let CollaborateCursor = class CollaborateCursor {
779
- constructor(injector, nativeSelection, scheduler, selection, awarenessDelegate) {
779
+ constructor(injector, nativeSelection, renderer, selection, awarenessDelegate) {
780
780
  this.injector = injector;
781
781
  this.nativeSelection = nativeSelection;
782
- this.scheduler = scheduler;
782
+ this.renderer = renderer;
783
783
  this.selection = selection;
784
784
  this.awarenessDelegate = awarenessDelegate;
785
785
  this.host = createElement('div', {
@@ -845,7 +845,7 @@ let CollaborateCursor = class CollaborateCursor {
845
845
  }), fromEvent(window, 'resize').subscribe(() => {
846
846
  this.canvas.style.height = document.documentElement.clientHeight + 'px';
847
847
  this.refresh();
848
- }), this.scheduler.onDocChanged.subscribe(() => {
848
+ }), this.renderer.onViewUpdated.subscribe(() => {
849
849
  this.refresh();
850
850
  }));
851
851
  }
@@ -1017,7 +1017,7 @@ CollaborateCursor = __decorate([
1017
1017
  __param(4, Optional()),
1018
1018
  __metadata("design:paramtypes", [Injector,
1019
1019
  SelectionBridge,
1020
- Scheduler,
1020
+ Renderer,
1021
1021
  Selection,
1022
1022
  CollaborateSelectionAwarenessDelegate])
1023
1023
  ], CollaborateCursor);
@@ -1767,16 +1767,17 @@ let MagicInput = class MagicInput extends Input {
1767
1767
  }));
1768
1768
  }
1769
1769
  handleInput(textarea) {
1770
- let startIndex = 0;
1771
- this.subscription.add(fromEvent(textarea, 'compositionstart').subscribe(() => {
1772
- startIndex = this.selection.startOffset;
1773
- }), fromEvent(textarea, 'compositionupdate').subscribe(ev => {
1770
+ this.subscription.add(fromEvent(textarea, 'compositionupdate').subscribe(ev => {
1771
+ if (ev.data === ' ') {
1772
+ // 处理搜狗五笔不符合 composition 事件预期,会意外跳光标的问题
1773
+ return;
1774
+ }
1775
+ const slot = this.selection.startSlot;
1774
1776
  this.caret.compositionState = {
1775
- slot: this.selection.startSlot,
1776
- index: startIndex,
1777
+ slot,
1777
1778
  data: ev.data
1778
1779
  };
1779
- this.caret.refresh(true);
1780
+ slot.changeMarker.forceMarkDirtied();
1780
1781
  }), fromEvent(textarea, 'compositionend').subscribe(() => {
1781
1782
  this.caret.compositionState = null;
1782
1783
  }));
package/bundles/index.js CHANGED
@@ -61,8 +61,8 @@ function getLayoutRectByRange(range) {
61
61
  }
62
62
  else if (beforeNode.nodeType === Node.TEXT_NODE) {
63
63
  const range2 = document.createRange();
64
- range2.setStart(beforeNode, beforeNode.textContent.length);
65
- range2.setEnd(beforeNode, beforeNode.textContent.length);
64
+ range2.selectNodeContents(beforeNode);
65
+ range2.collapse();
66
66
  return range2.getBoundingClientRect();
67
67
  }
68
68
  }
@@ -778,10 +778,10 @@ exports.SelectionBridge = __decorate([
778
778
  class CollaborateSelectionAwarenessDelegate {
779
779
  }
780
780
  exports.CollaborateCursor = class CollaborateCursor {
781
- constructor(injector, nativeSelection, scheduler, selection, awarenessDelegate) {
781
+ constructor(injector, nativeSelection, renderer, selection, awarenessDelegate) {
782
782
  this.injector = injector;
783
783
  this.nativeSelection = nativeSelection;
784
- this.scheduler = scheduler;
784
+ this.renderer = renderer;
785
785
  this.selection = selection;
786
786
  this.awarenessDelegate = awarenessDelegate;
787
787
  this.host = createElement('div', {
@@ -847,7 +847,7 @@ exports.CollaborateCursor = class CollaborateCursor {
847
847
  }), stream.fromEvent(window, 'resize').subscribe(() => {
848
848
  this.canvas.style.height = document.documentElement.clientHeight + 'px';
849
849
  this.refresh();
850
- }), this.scheduler.onDocChanged.subscribe(() => {
850
+ }), this.renderer.onViewUpdated.subscribe(() => {
851
851
  this.refresh();
852
852
  }));
853
853
  }
@@ -1019,7 +1019,7 @@ exports.CollaborateCursor = __decorate([
1019
1019
  __param(4, di.Optional()),
1020
1020
  __metadata("design:paramtypes", [di.Injector,
1021
1021
  exports.SelectionBridge,
1022
- core.Scheduler,
1022
+ core.Renderer,
1023
1023
  core.Selection,
1024
1024
  CollaborateSelectionAwarenessDelegate])
1025
1025
  ], exports.CollaborateCursor);
@@ -1769,16 +1769,17 @@ exports.MagicInput = class MagicInput extends Input {
1769
1769
  }));
1770
1770
  }
1771
1771
  handleInput(textarea) {
1772
- let startIndex = 0;
1773
- this.subscription.add(stream.fromEvent(textarea, 'compositionstart').subscribe(() => {
1774
- startIndex = this.selection.startOffset;
1775
- }), stream.fromEvent(textarea, 'compositionupdate').subscribe(ev => {
1772
+ this.subscription.add(stream.fromEvent(textarea, 'compositionupdate').subscribe(ev => {
1773
+ if (ev.data === ' ') {
1774
+ // 处理搜狗五笔不符合 composition 事件预期,会意外跳光标的问题
1775
+ return;
1776
+ }
1777
+ const slot = this.selection.startSlot;
1776
1778
  this.caret.compositionState = {
1777
- slot: this.selection.startSlot,
1778
- index: startIndex,
1779
+ slot,
1779
1780
  data: ev.data
1780
1781
  };
1781
- this.caret.refresh(true);
1782
+ slot.changeMarker.forceMarkDirtied();
1782
1783
  }), stream.fromEvent(textarea, 'compositionend').subscribe(() => {
1783
1784
  this.caret.compositionState = null;
1784
1785
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "3.0.0-alpha.50",
3
+ "version": "3.0.0-alpha.51",
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",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@tanbo/di": "^1.1.4",
29
29
  "@tanbo/stream": "^1.1.9",
30
- "@textbus/core": "^3.0.0-alpha.50",
30
+ "@textbus/core": "^3.0.0-alpha.51",
31
31
  "reflect-metadata": "^0.1.13"
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": "ad396a0f17fc18d1eaddd2532f223c1252cf5d6f"
51
+ "gitHead": "4f2557bae5aa8800130c827f502d4439bddb1ff4"
52
52
  }