@prose-reader/core 1.137.0 → 1.138.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.
@@ -181,7 +181,7 @@ export declare const createReaderWithEnhancers: (options: Partial<import('./sett
181
181
  } | undefined>;
182
182
  selectionStart$: import('rxjs').Observable<boolean>;
183
183
  selectionEnd$: import('rxjs').Observable<void>;
184
- selectionAfterPointerUp$: import('rxjs').Observable<[Event, {
184
+ selectionOver$: import('rxjs').Observable<[Event, {
185
185
  document: Document;
186
186
  selection: Selection;
187
187
  itemIndex: number;
@@ -2,6 +2,6 @@ import { Observable } from 'rxjs';
2
2
  import { DestroyableClass } from '../../utils/DestroyableClass';
3
3
  export declare class SelectionTracker extends DestroyableClass {
4
4
  selectionChange$: Observable<Selection | null>;
5
- selectionAfterPointerUp$: Observable<readonly [Event, Selection]>;
5
+ selectionOver$: Observable<readonly [Event, Selection]>;
6
6
  constructor(document: Document);
7
7
  }
@@ -11,7 +11,7 @@ export declare const selectionEnhancer: <InheritOptions, InheritOutput extends E
11
11
  selection$: Observable<SelectionValue>;
12
12
  selectionStart$: Observable<boolean>;
13
13
  selectionEnd$: Observable<void>;
14
- selectionAfterPointerUp$: Observable<[Event, SelectionValue]>;
14
+ selectionOver$: Observable<[Event, SelectionValue]>;
15
15
  lastSelectionOnPointerdown$: Observable<SelectionValue | undefined>;
16
16
  getSelection: () => SelectionValue | undefined;
17
17
  createOrderedRangeFromSelection: (params: {
package/dist/index.js CHANGED
@@ -8599,17 +8599,26 @@ class SelectionTracker extends DestroyableClass {
8599
8599
  this.selectionChange$ = fromEvent(document2, "selectionchange").pipe(
8600
8600
  map$1(() => document2.getSelection())
8601
8601
  );
8602
- this.selectionAfterPointerUp$ = fromEvent(document2, "pointerup").pipe(
8603
- /**
8604
- * The selection is still valid during the event even if it will
8605
- * be discarded. The timeout make sure to detect this edge case.
8606
- */
8607
- delay(0),
8608
- map$1((event) => {
8609
- const selection = document2.getSelection();
8610
- return selection && !selection.isCollapsed ? [event, selection] : void 0;
8611
- }),
8612
- filter$1(isDefined)
8602
+ this.selectionOver$ = fromEvent(document2, "pointerdown").pipe(
8603
+ switchMap$1(
8604
+ () => merge(
8605
+ fromEvent(document2, "pointerup"),
8606
+ fromEvent(document2, "pointercancel"),
8607
+ fromEvent(document2, "contextmenu")
8608
+ ).pipe(
8609
+ first$1(),
8610
+ /**
8611
+ * The selection is still valid during the event even if it will
8612
+ * be discarded. The timeout make sure to detect this edge case.
8613
+ */
8614
+ delay(0),
8615
+ map$1((event) => {
8616
+ const selection = document2.getSelection();
8617
+ return selection && !selection.isCollapsed ? [event, selection] : void 0;
8618
+ }),
8619
+ filter$1(isDefined)
8620
+ )
8621
+ )
8613
8622
  );
8614
8623
  }
8615
8624
  }
@@ -8618,7 +8627,7 @@ const selectionEnhancer = (next) => (options) => {
8618
8627
  const selectionSubject = new BehaviorSubject(
8619
8628
  void 0
8620
8629
  );
8621
- const selectionWithPointerUpSubject = new Subject();
8630
+ const selectionOverSubject = new Subject();
8622
8631
  reader.hookManager.register(
8623
8632
  `item.onDocumentLoad`,
8624
8633
  ({ itemId, destroy$, destroy }) => {
@@ -8644,9 +8653,9 @@ const selectionEnhancer = (next) => (options) => {
8644
8653
  }
8645
8654
  })
8646
8655
  ),
8647
- selectionTracker.selectionAfterPointerUp$.pipe(
8656
+ selectionTracker.selectionOver$.pipe(
8648
8657
  tap$1(([event, selection]) => {
8649
- selectionWithPointerUpSubject.next([
8658
+ selectionOverSubject.next([
8650
8659
  event,
8651
8660
  {
8652
8661
  document: frameDoc,
@@ -8681,7 +8690,7 @@ const selectionEnhancer = (next) => (options) => {
8681
8690
  filter$1((selection) => !selection),
8682
8691
  share()
8683
8692
  );
8684
- const selectionAfterPointerUp$ = selectionWithPointerUpSubject.asObservable();
8693
+ const selectionOver$ = selectionOverSubject.asObservable();
8685
8694
  const lastSelectionOnPointerdown$ = reader.context.containerElement$.pipe(
8686
8695
  switchMap$1((container) => fromEvent(container, "pointerdown")),
8687
8696
  withLatestFrom(selection$),
@@ -8696,7 +8705,7 @@ const selectionEnhancer = (next) => (options) => {
8696
8705
  selection$,
8697
8706
  selectionStart$,
8698
8707
  selectionEnd$,
8699
- selectionAfterPointerUp$,
8708
+ selectionOver$,
8700
8709
  lastSelectionOnPointerdown$,
8701
8710
  getSelection: () => selectionSubject.getValue(),
8702
8711
  createOrderedRangeFromSelection