@textbus/platform-browser 4.4.2 → 4.5.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.
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
- import { Slot, Textbus, Adapter, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, makeError, NativeSelectionBridge, FocusManager, Component, Registry } from '@textbus/core';
3
- import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
2
+ import { Slot, Textbus, Adapter, Controller, Selection, RootComponentRef, Scheduler, ContentType, Event, invokeListener, Keyboard, Commander, makeError, NativeSelectionBridge, FocusManager, Component, Registry } from '@textbus/core';
3
+ import { Subject, filter, fromEvent, delay, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
4
4
  import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
5
5
 
6
6
  function createElement(tagName, options = {}) {
@@ -383,7 +383,7 @@ class DomAdapter extends Adapter {
383
383
  * Textbus PC 端选区桥接实现
384
384
  */
385
385
  let SelectionBridge = class SelectionBridge {
386
- constructor(config, textbus, controller, selection, rootComponentRef, input, domAdapter) {
386
+ constructor(config, textbus, controller, selection, rootComponentRef, input, scheduler, domAdapter) {
387
387
  Object.defineProperty(this, "config", {
388
388
  enumerable: true,
389
389
  configurable: true,
@@ -408,6 +408,12 @@ let SelectionBridge = class SelectionBridge {
408
408
  writable: true,
409
409
  value: input
410
410
  });
411
+ Object.defineProperty(this, "scheduler", {
412
+ enumerable: true,
413
+ configurable: true,
414
+ writable: true,
415
+ value: scheduler
416
+ });
411
417
  Object.defineProperty(this, "domAdapter", {
412
418
  enumerable: true,
413
419
  configurable: true,
@@ -792,7 +798,15 @@ let SelectionBridge = class SelectionBridge {
792
798
  }
793
799
  }));
794
800
  }
795
- this.subs.push(fromEvent(document, 'selectionchange').pipe().subscribe(() => {
801
+ let isUpdating = false;
802
+ this.subs.push(this.scheduler.onDocChange.subscribe(() => {
803
+ isUpdating = true;
804
+ }), this.scheduler.onDocChanged.pipe(delay()).subscribe(() => {
805
+ isUpdating = false;
806
+ }), fromEvent(document, 'selectionchange').pipe().subscribe(() => {
807
+ if (isUpdating) {
808
+ return;
809
+ }
796
810
  if (this.syncSelectionFromNativeSelectionChange) {
797
811
  this.syncSelection(connector);
798
812
  }
@@ -1050,6 +1064,7 @@ SelectionBridge = __decorate([
1050
1064
  Selection,
1051
1065
  RootComponentRef,
1052
1066
  Input,
1067
+ Scheduler,
1053
1068
  DomAdapter])
1054
1069
  ], SelectionBridge);
1055
1070
 
package/bundles/index.js CHANGED
@@ -385,7 +385,7 @@ class DomAdapter extends core$1.Adapter {
385
385
  * Textbus PC 端选区桥接实现
386
386
  */
387
387
  exports.SelectionBridge = class SelectionBridge {
388
- constructor(config, textbus, controller, selection, rootComponentRef, input, domAdapter) {
388
+ constructor(config, textbus, controller, selection, rootComponentRef, input, scheduler, domAdapter) {
389
389
  Object.defineProperty(this, "config", {
390
390
  enumerable: true,
391
391
  configurable: true,
@@ -410,6 +410,12 @@ exports.SelectionBridge = class SelectionBridge {
410
410
  writable: true,
411
411
  value: input
412
412
  });
413
+ Object.defineProperty(this, "scheduler", {
414
+ enumerable: true,
415
+ configurable: true,
416
+ writable: true,
417
+ value: scheduler
418
+ });
413
419
  Object.defineProperty(this, "domAdapter", {
414
420
  enumerable: true,
415
421
  configurable: true,
@@ -794,7 +800,15 @@ exports.SelectionBridge = class SelectionBridge {
794
800
  }
795
801
  }));
796
802
  }
797
- this.subs.push(stream.fromEvent(document, 'selectionchange').pipe().subscribe(() => {
803
+ let isUpdating = false;
804
+ this.subs.push(this.scheduler.onDocChange.subscribe(() => {
805
+ isUpdating = true;
806
+ }), this.scheduler.onDocChanged.pipe(stream.delay()).subscribe(() => {
807
+ isUpdating = false;
808
+ }), stream.fromEvent(document, 'selectionchange').pipe().subscribe(() => {
809
+ if (isUpdating) {
810
+ return;
811
+ }
798
812
  if (this.syncSelectionFromNativeSelectionChange) {
799
813
  this.syncSelection(connector);
800
814
  }
@@ -1052,6 +1066,7 @@ exports.SelectionBridge = __decorate([
1052
1066
  core$1.Selection,
1053
1067
  core$1.RootComponentRef,
1054
1068
  Input,
1069
+ core$1.Scheduler,
1055
1070
  DomAdapter])
1056
1071
  ], exports.SelectionBridge);
1057
1072
 
@@ -1,5 +1,5 @@
1
1
  import { Observable } from '@tanbo/stream';
2
- import { NativeSelectionBridge, NativeSelectionConnector, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection, Textbus } from '@textbus/core';
2
+ import { NativeSelectionBridge, NativeSelectionConnector, SelectionPosition, AbstractSelection, RootComponentRef, Controller, Selection, Textbus, Scheduler } from '@textbus/core';
3
3
  import { Rect } from './_utils/uikit';
4
4
  import { Input } from './types';
5
5
  import { ViewOptions } from './browser-module';
@@ -12,6 +12,7 @@ export declare class SelectionBridge implements NativeSelectionBridge {
12
12
  private selection;
13
13
  private rootComponentRef;
14
14
  private input;
15
+ private scheduler;
15
16
  private domAdapter;
16
17
  onSelectionChange: Observable<Range | null>;
17
18
  nativeSelection: globalThis.Selection;
@@ -25,7 +26,7 @@ export declare class SelectionBridge implements NativeSelectionBridge {
25
26
  private docContainer;
26
27
  private cacheCaretPositionTimer;
27
28
  private oldCaretPosition;
28
- constructor(config: ViewOptions, textbus: Textbus, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, domAdapter: DomAdapter);
29
+ constructor(config: ViewOptions, textbus: Textbus, controller: Controller, selection: Selection, rootComponentRef: RootComponentRef, input: Input, scheduler: Scheduler, domAdapter: DomAdapter);
29
30
  connect(connector: NativeSelectionConnector): void;
30
31
  disConnect(): void;
31
32
  getRect(location: SelectionPosition): Rect | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "4.4.2",
3
+ "version": "4.5.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,14 +26,14 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.7",
29
- "@textbus/core": "^4.4.2",
30
- "@viewfly/core": "^1.2.1"
29
+ "@textbus/core": "^4.5.0",
30
+ "@viewfly/core": "^1.2.3"
31
31
  },
32
32
  "devDependencies": {
33
- "@rollup/plugin-commonjs": "^23.0.2",
34
- "@rollup/plugin-typescript": "^9.0.2",
33
+ "@rollup/plugin-commonjs": "^28.0.2",
34
+ "@rollup/plugin-typescript": "^12.1.2",
35
35
  "rimraf": "^3.0.2",
36
- "rollup": "^3.2.5",
36
+ "rollup": "4.22.4",
37
37
  "tslib": "^2.4.1"
38
38
  },
39
39
  "author": {
@@ -47,5 +47,5 @@
47
47
  "bugs": {
48
48
  "url": "https://github.com/textbus/textbus.git/issues"
49
49
  },
50
- "gitHead": "5132df31e69783964c69512d22f037204162681a"
50
+ "gitHead": "327e764487545a35d97eae525b61307642b8f386"
51
51
  }