@prose-reader/core 1.139.0 → 1.141.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.
- package/dist/cfi/CfiHandler.d.ts +2 -1
- package/dist/createReaderWithEnhancer.d.ts +26 -10
- package/dist/enhancers/selection/{SelectionTracker.d.ts → FrameSelectionTracker.d.ts} +2 -2
- package/dist/enhancers/selection/selectionEnhancer.d.ts +13 -6
- package/dist/enhancers/selection/trackSpineItemSelection.d.ts +9 -0
- package/dist/index.js +184 -112
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +184 -112
- package/dist/index.umd.cjs.map +1 -1
- package/dist/utils/frames.d.ts +1 -1
- package/dist/utils/rxjs.d.ts +1 -0
- package/package.json +3 -3
package/dist/cfi/CfiHandler.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ export declare class CfiHandler {
|
|
|
5
5
|
cfi: string;
|
|
6
6
|
private static tempDocument;
|
|
7
7
|
private static tempTextArea;
|
|
8
|
+
private static getTextArea;
|
|
8
9
|
constructor(str: string, opts: {});
|
|
10
|
+
destroy(): void;
|
|
9
11
|
removeIllegalOpts(parts: any[]): void;
|
|
10
|
-
private static getTextArea;
|
|
11
12
|
static generatePart(node: Element | Node, offset?: number, extra?: {}): string;
|
|
12
13
|
static generate(node: Node, offset?: number, extra?: {}): string;
|
|
13
14
|
static toParsed(cfi: any): any;
|
|
@@ -175,27 +175,43 @@ export declare const createReaderWithEnhancers: (options: Partial<import('./sett
|
|
|
175
175
|
} & {
|
|
176
176
|
selection: {
|
|
177
177
|
selection$: import('rxjs').Observable<{
|
|
178
|
-
|
|
178
|
+
itemIndex: number;
|
|
179
|
+
type: "change";
|
|
179
180
|
selection: Selection;
|
|
181
|
+
} | {
|
|
180
182
|
itemIndex: number;
|
|
183
|
+
type: "over";
|
|
184
|
+
event: Event;
|
|
185
|
+
selection: Selection;
|
|
181
186
|
} | undefined>;
|
|
182
187
|
selectionStart$: import('rxjs').Observable<boolean>;
|
|
183
188
|
selectionEnd$: import('rxjs').Observable<void>;
|
|
184
|
-
selectionOver$: import('rxjs').Observable<
|
|
185
|
-
|
|
189
|
+
selectionOver$: import('rxjs').Observable<{
|
|
190
|
+
itemIndex: number;
|
|
191
|
+
type: "over";
|
|
192
|
+
event: Event;
|
|
193
|
+
selection: Selection;
|
|
194
|
+
}>;
|
|
195
|
+
lastSelectionOnPointerdown$: import('rxjs').Observable<{
|
|
196
|
+
itemIndex: number;
|
|
197
|
+
type: "change";
|
|
186
198
|
selection: Selection;
|
|
199
|
+
} | {
|
|
187
200
|
itemIndex: number;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
document: Document;
|
|
201
|
+
type: "over";
|
|
202
|
+
event: Event;
|
|
191
203
|
selection: Selection;
|
|
204
|
+
} | undefined>;
|
|
205
|
+
getSelection: () => {
|
|
192
206
|
itemIndex: number;
|
|
193
|
-
|
|
194
|
-
getSelection: () => ({
|
|
195
|
-
document: Document;
|
|
207
|
+
type: "change";
|
|
196
208
|
selection: Selection;
|
|
209
|
+
} | {
|
|
197
210
|
itemIndex: number;
|
|
198
|
-
|
|
211
|
+
type: "over";
|
|
212
|
+
event: Event;
|
|
213
|
+
selection: Selection;
|
|
214
|
+
} | undefined;
|
|
199
215
|
createOrderedRangeFromSelection: (params: {
|
|
200
216
|
selection: {
|
|
201
217
|
anchorNode?: Node | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { DestroyableClass } from '../../utils/DestroyableClass';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class FrameSelectionTracker extends DestroyableClass {
|
|
4
4
|
selectionChange$: Observable<Selection | null>;
|
|
5
5
|
selectionOver$: Observable<readonly [Event, Selection]>;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(frame: HTMLIFrameElement);
|
|
7
7
|
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { EnhancerOutput, RootEnhancer } from '../types/enhancer';
|
|
3
3
|
import { SpineItem } from '../..';
|
|
4
|
-
type
|
|
5
|
-
|
|
4
|
+
type SelectionChange = {
|
|
5
|
+
itemIndex: number;
|
|
6
|
+
type: "change";
|
|
6
7
|
selection: Selection;
|
|
8
|
+
};
|
|
9
|
+
type SelectionOver = {
|
|
7
10
|
itemIndex: number;
|
|
8
|
-
|
|
11
|
+
type: "over";
|
|
12
|
+
event: Event;
|
|
13
|
+
selection: Selection;
|
|
14
|
+
};
|
|
15
|
+
type SelectionValue = SelectionChange | SelectionOver | undefined;
|
|
9
16
|
export declare const selectionEnhancer: <InheritOptions, InheritOutput extends EnhancerOutput<RootEnhancer>>(next: (options: InheritOptions) => InheritOutput) => (options: InheritOptions) => InheritOutput & {
|
|
10
17
|
selection: {
|
|
11
18
|
selection$: Observable<SelectionValue>;
|
|
12
19
|
selectionStart$: Observable<boolean>;
|
|
13
20
|
selectionEnd$: Observable<void>;
|
|
14
|
-
selectionOver$: Observable<
|
|
15
|
-
lastSelectionOnPointerdown$: Observable<SelectionValue
|
|
16
|
-
getSelection: () => SelectionValue
|
|
21
|
+
selectionOver$: Observable<SelectionOver>;
|
|
22
|
+
lastSelectionOnPointerdown$: Observable<SelectionValue>;
|
|
23
|
+
getSelection: () => SelectionValue;
|
|
17
24
|
createOrderedRangeFromSelection: (params: {
|
|
18
25
|
selection: {
|
|
19
26
|
anchorNode?: Node | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SpineItem } from '../../spineItem/SpineItem';
|
|
2
|
+
export declare const trackSpineItemSelection: (spineItem: SpineItem) => import('rxjs').Observable<{
|
|
3
|
+
type: "change";
|
|
4
|
+
selection: Selection;
|
|
5
|
+
} | {
|
|
6
|
+
type: "over";
|
|
7
|
+
event: Event;
|
|
8
|
+
selection: Selection;
|
|
9
|
+
} | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -89,6 +89,15 @@ function idle() {
|
|
|
89
89
|
function deferIdle(callback) {
|
|
90
90
|
return defer(() => idle().pipe(switchMap(callback)));
|
|
91
91
|
}
|
|
92
|
+
const observeMutation = (target, options) => {
|
|
93
|
+
return new Observable((subscriber) => {
|
|
94
|
+
const observer = new MutationObserver((mutations) => {
|
|
95
|
+
subscriber.next(mutations);
|
|
96
|
+
});
|
|
97
|
+
observer.observe(target, options);
|
|
98
|
+
return () => observer.disconnect();
|
|
99
|
+
});
|
|
100
|
+
};
|
|
92
101
|
class SettingsManagerOverload {
|
|
93
102
|
constructor(initialSettings, settingsManager) {
|
|
94
103
|
this.settingsManager = settingsManager;
|
|
@@ -194,7 +203,7 @@ const getAttributeValueFromString = (string, key) => {
|
|
|
194
203
|
};
|
|
195
204
|
const injectCSS = (frameElement, id, style, prepend) => {
|
|
196
205
|
if (frameElement && frameElement.contentDocument && frameElement.contentDocument.head) {
|
|
197
|
-
const userStyle =
|
|
206
|
+
const userStyle = frameElement.contentDocument.createElement(`style`);
|
|
198
207
|
userStyle.id = id;
|
|
199
208
|
userStyle.innerHTML = style;
|
|
200
209
|
if (prepend) {
|
|
@@ -212,7 +221,7 @@ const removeCSS = (frameElement, id) => {
|
|
|
212
221
|
}
|
|
213
222
|
}
|
|
214
223
|
};
|
|
215
|
-
const
|
|
224
|
+
const upsertCSSToFrame = (frameElement, id, style, prepend) => {
|
|
216
225
|
if (!frameElement) return;
|
|
217
226
|
removeCSS(frameElement, id);
|
|
218
227
|
injectCSS(frameElement, id, style, prepend);
|
|
@@ -293,7 +302,7 @@ const fontsEnhancer = (next) => (options) => {
|
|
|
293
302
|
if (item.renditionLayout !== `pre-paginated`) {
|
|
294
303
|
const frame = item.renderer.getDocumentFrame();
|
|
295
304
|
if (frame) {
|
|
296
|
-
|
|
305
|
+
upsertCSSToFrame(frame, `prose-reader-fonts`, getStyle());
|
|
297
306
|
}
|
|
298
307
|
}
|
|
299
308
|
});
|
|
@@ -306,7 +315,7 @@ const fontsEnhancer = (next) => (options) => {
|
|
|
306
315
|
if ((item == null ? void 0 : item.renditionLayout) !== `pre-paginated`) {
|
|
307
316
|
const frame = item == null ? void 0 : item.renderer.getDocumentFrame();
|
|
308
317
|
if (frame) {
|
|
309
|
-
|
|
318
|
+
upsertCSSToFrame(frame, `prose-reader-fonts`, getStyle());
|
|
310
319
|
}
|
|
311
320
|
}
|
|
312
321
|
});
|
|
@@ -531,7 +540,7 @@ const layoutEnhancer = (next) => (options) => {
|
|
|
531
540
|
}
|
|
532
541
|
const frame = spineItem == null ? void 0 : spineItem.renderer.getDocumentFrame();
|
|
533
542
|
if (frame) {
|
|
534
|
-
|
|
543
|
+
upsertCSSToFrame(
|
|
535
544
|
frame,
|
|
536
545
|
`prose-layout-enhancer-css`,
|
|
537
546
|
`
|
|
@@ -1695,7 +1704,7 @@ const themeEnhancer = (next) => (options) => {
|
|
|
1695
1704
|
reader.spineItemsManager.items.forEach((item) => {
|
|
1696
1705
|
const frame = item.renderer.getDocumentFrame();
|
|
1697
1706
|
if (frame) {
|
|
1698
|
-
|
|
1707
|
+
upsertCSSToFrame(frame, `prose-reader-theme`, getStyle());
|
|
1699
1708
|
}
|
|
1700
1709
|
applyChangeToSpineItemElement({ container: item.element });
|
|
1701
1710
|
});
|
|
@@ -1705,7 +1714,7 @@ const themeEnhancer = (next) => (options) => {
|
|
|
1705
1714
|
if ((item == null ? void 0 : item.renditionLayout) !== "pre-paginated") {
|
|
1706
1715
|
const frame = item == null ? void 0 : item.renderer.getDocumentFrame();
|
|
1707
1716
|
if (frame) {
|
|
1708
|
-
|
|
1717
|
+
upsertCSSToFrame(frame, `prose-reader-theme`, getStyle());
|
|
1709
1718
|
}
|
|
1710
1719
|
}
|
|
1711
1720
|
});
|
|
@@ -2921,6 +2930,18 @@ const _CfiHandler = class _CfiHandler {
|
|
|
2921
2930
|
this.removeIllegalOpts();
|
|
2922
2931
|
}
|
|
2923
2932
|
}
|
|
2933
|
+
static getTextArea() {
|
|
2934
|
+
if (!_CfiHandler.tempTextArea) {
|
|
2935
|
+
if (!_CfiHandler.tempDocument) {
|
|
2936
|
+
_CfiHandler.tempDocument = document.implementation.createHTMLDocument();
|
|
2937
|
+
}
|
|
2938
|
+
_CfiHandler.tempTextArea = _CfiHandler.tempDocument.createElement("textarea");
|
|
2939
|
+
}
|
|
2940
|
+
return _CfiHandler.tempTextArea;
|
|
2941
|
+
}
|
|
2942
|
+
destroy() {
|
|
2943
|
+
_CfiHandler.tempTextArea = null;
|
|
2944
|
+
}
|
|
2924
2945
|
removeIllegalOpts(parts) {
|
|
2925
2946
|
if (!parts) {
|
|
2926
2947
|
if (this.from) {
|
|
@@ -2943,15 +2964,6 @@ const _CfiHandler = class _CfiHandler {
|
|
|
2943
2964
|
}
|
|
2944
2965
|
}
|
|
2945
2966
|
}
|
|
2946
|
-
static getTextArea() {
|
|
2947
|
-
if (!_CfiHandler.tempTextArea) {
|
|
2948
|
-
if (!_CfiHandler.tempDocument) {
|
|
2949
|
-
_CfiHandler.tempDocument = document.implementation.createHTMLDocument();
|
|
2950
|
-
}
|
|
2951
|
-
_CfiHandler.tempTextArea = _CfiHandler.tempDocument.createElement("textarea");
|
|
2952
|
-
}
|
|
2953
|
-
return _CfiHandler.tempTextArea;
|
|
2954
|
-
}
|
|
2955
2967
|
static generatePart(node, offset, extra) {
|
|
2956
2968
|
let cfi = ``;
|
|
2957
2969
|
let o;
|
|
@@ -3660,6 +3672,7 @@ const resolveCfi = ({
|
|
|
3660
3672
|
if (doc) {
|
|
3661
3673
|
try {
|
|
3662
3674
|
const { node, offset: resolvedOffset } = cfiHandler.resolve(doc, {});
|
|
3675
|
+
cfiHandler.destroy();
|
|
3663
3676
|
return {
|
|
3664
3677
|
node,
|
|
3665
3678
|
offset: offset ?? resolvedOffset,
|
|
@@ -5557,10 +5570,25 @@ class DocumentRenderer extends DestroyableClass {
|
|
|
5557
5570
|
layout(params) {
|
|
5558
5571
|
return defer(() => this.onLayout(params)).pipe(
|
|
5559
5572
|
map$1((dims) => {
|
|
5560
|
-
|
|
5561
|
-
const
|
|
5562
|
-
|
|
5563
|
-
|
|
5573
|
+
var _a, _b;
|
|
5574
|
+
const isPrepaginated = this.item.renditionLayout === `pre-paginated` || !((_a = this.context.manifest) == null ? void 0 : _a.renditionLayout) && ((_b = this.context.manifest) == null ? void 0 : _b.renditionLayout) === `pre-paginated`;
|
|
5575
|
+
if (dims) {
|
|
5576
|
+
const { height, width } = dims;
|
|
5577
|
+
this.lastLayoutDims = { height, width };
|
|
5578
|
+
return this.lastLayoutDims;
|
|
5579
|
+
}
|
|
5580
|
+
if (isPrepaginated) {
|
|
5581
|
+
this.lastLayoutDims = {
|
|
5582
|
+
height: this.context.getPageSize().height,
|
|
5583
|
+
width: this.context.getPageSize().width
|
|
5584
|
+
};
|
|
5585
|
+
} else {
|
|
5586
|
+
this.lastLayoutDims = {
|
|
5587
|
+
height: this.context.getPageSize().height,
|
|
5588
|
+
width: this.context.getPageSize().width,
|
|
5589
|
+
...this.lastLayoutDims
|
|
5590
|
+
};
|
|
5591
|
+
}
|
|
5564
5592
|
return this.lastLayoutDims;
|
|
5565
5593
|
})
|
|
5566
5594
|
);
|
|
@@ -6510,7 +6538,7 @@ class SpineLayout extends DestroyableClass {
|
|
|
6510
6538
|
layoutInProgress.next(true);
|
|
6511
6539
|
const manifest = this.context.manifest;
|
|
6512
6540
|
const newItemLayoutInformation = [];
|
|
6513
|
-
const isGloballyPrePaginated = (manifest
|
|
6541
|
+
const isGloballyPrePaginated = isFullyPrePaginated(manifest) ?? false;
|
|
6514
6542
|
return from(this.spineItemsManager.items).pipe(
|
|
6515
6543
|
reduce(
|
|
6516
6544
|
(acc$, item, index) => acc$.pipe(
|
|
@@ -7399,7 +7427,7 @@ const accessibilityEnhancer = (next) => (options) => {
|
|
|
7399
7427
|
if (!item) return;
|
|
7400
7428
|
const frame = item.renderer.getDocumentFrame();
|
|
7401
7429
|
if (!frame) return;
|
|
7402
|
-
|
|
7430
|
+
upsertCSSToFrame(
|
|
7403
7431
|
frame,
|
|
7404
7432
|
`prose-reader-accessibility`,
|
|
7405
7433
|
`
|
|
@@ -7961,7 +7989,7 @@ const renderPrePaginated = ({
|
|
|
7961
7989
|
},
|
|
7962
7990
|
viewportDimensions
|
|
7963
7991
|
);
|
|
7964
|
-
|
|
7992
|
+
upsertCSSToFrame(frameElement, `prose-reader-css`, cssLink);
|
|
7965
7993
|
if (viewportDimensions) {
|
|
7966
7994
|
staticLayout$1(frameElement, {
|
|
7967
7995
|
width: viewportDimensions.width ?? 1,
|
|
@@ -8242,7 +8270,7 @@ const renderReflowable = ({
|
|
|
8242
8270
|
let contentWidth = pageWidth;
|
|
8243
8271
|
let contentHeight = pageHeight;
|
|
8244
8272
|
if (viewportDimensions == null ? void 0 : viewportDimensions.hasViewport) {
|
|
8245
|
-
|
|
8273
|
+
upsertCSSToFrame(
|
|
8246
8274
|
frameElement,
|
|
8247
8275
|
`prose-reader-html-renderer-framce-css`,
|
|
8248
8276
|
buildStyleForViewportFrame()
|
|
@@ -8277,7 +8305,7 @@ const renderReflowable = ({
|
|
|
8277
8305
|
pageWidth
|
|
8278
8306
|
})
|
|
8279
8307
|
);
|
|
8280
|
-
|
|
8308
|
+
upsertCSSToFrame(frameElement, `prose-reader-css`, frameStyle, true);
|
|
8281
8309
|
if (isUsingVerticalWriting) {
|
|
8282
8310
|
const pages = Math.ceil(
|
|
8283
8311
|
frameElement.contentDocument.documentElement.scrollHeight / pageHeight
|
|
@@ -8593,92 +8621,136 @@ const createOrderedRangeFromSelection = ({
|
|
|
8593
8621
|
return void 0;
|
|
8594
8622
|
}
|
|
8595
8623
|
};
|
|
8596
|
-
class
|
|
8597
|
-
constructor(
|
|
8624
|
+
class FrameSelectionTracker extends DestroyableClass {
|
|
8625
|
+
constructor(frame) {
|
|
8626
|
+
var _a;
|
|
8598
8627
|
super();
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
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)
|
|
8628
|
+
const frameDoc = frame.contentDocument || ((_a = frame.contentWindow) == null ? void 0 : _a.document);
|
|
8629
|
+
if (!frameDoc) {
|
|
8630
|
+
this.selectionChange$ = NEVER;
|
|
8631
|
+
this.selectionOver$ = NEVER;
|
|
8632
|
+
} else {
|
|
8633
|
+
const frameDocMutation$ = observeMutation(frameDoc.body, {
|
|
8634
|
+
childList: true,
|
|
8635
|
+
subtree: true
|
|
8636
|
+
}).pipe(
|
|
8637
|
+
filter$1(
|
|
8638
|
+
(mutations) => !!mutations.find((mutation) => {
|
|
8639
|
+
return mutation.type === "childList" && mutation.removedNodes.length;
|
|
8640
|
+
})
|
|
8620
8641
|
)
|
|
8621
|
-
)
|
|
8622
|
-
|
|
8642
|
+
);
|
|
8643
|
+
const iframeDestroyed$ = !frame.parentElement ? of(null) : observeMutation(frame.parentElement, {
|
|
8644
|
+
childList: true
|
|
8645
|
+
}).pipe(
|
|
8646
|
+
filter$1(
|
|
8647
|
+
(mutation) => !!mutation.find(
|
|
8648
|
+
(mutation2) => Array.from(mutation2.removedNodes).includes(frame)
|
|
8649
|
+
)
|
|
8650
|
+
)
|
|
8651
|
+
);
|
|
8652
|
+
this.selectionChange$ = merge(
|
|
8653
|
+
fromEvent(frameDoc, "selectionchange"),
|
|
8654
|
+
frameDocMutation$
|
|
8655
|
+
).pipe(
|
|
8656
|
+
map$1(() => frameDoc.getSelection()),
|
|
8657
|
+
takeUntil(merge(iframeDestroyed$, this.destroy$)),
|
|
8658
|
+
endWith(null)
|
|
8659
|
+
);
|
|
8660
|
+
this.selectionOver$ = fromEvent(frameDoc, "pointerdown").pipe(
|
|
8661
|
+
switchMap$1(
|
|
8662
|
+
() => merge(
|
|
8663
|
+
fromEvent(frameDoc, "pointerup"),
|
|
8664
|
+
fromEvent(frameDoc, "pointercancel"),
|
|
8665
|
+
fromEvent(frameDoc, "contextmenu")
|
|
8666
|
+
).pipe(
|
|
8667
|
+
first$1(),
|
|
8668
|
+
/**
|
|
8669
|
+
* The selection is still valid during the event even if it will
|
|
8670
|
+
* be discarded. The timeout make sure to detect this edge case.
|
|
8671
|
+
*/
|
|
8672
|
+
delay(0),
|
|
8673
|
+
map$1((event) => {
|
|
8674
|
+
const selection = frameDoc.getSelection();
|
|
8675
|
+
return selection && !selection.isCollapsed ? [event, selection] : void 0;
|
|
8676
|
+
}),
|
|
8677
|
+
filter$1(isDefined)
|
|
8678
|
+
)
|
|
8679
|
+
),
|
|
8680
|
+
takeUntil(merge(iframeDestroyed$, this.destroy$))
|
|
8681
|
+
);
|
|
8682
|
+
}
|
|
8623
8683
|
}
|
|
8624
8684
|
}
|
|
8685
|
+
const trackSpineItemSelection = (spineItem) => spineItem.loaded$.pipe(
|
|
8686
|
+
switchMap$1(() => {
|
|
8687
|
+
var _a;
|
|
8688
|
+
const frame = spineItem.renderer.getDocumentFrame();
|
|
8689
|
+
const frameDoc = (frame == null ? void 0 : frame.contentDocument) || ((_a = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _a.document);
|
|
8690
|
+
if (!frame || !frameDoc) return NEVER;
|
|
8691
|
+
const selectionTracker = new FrameSelectionTracker(frame);
|
|
8692
|
+
return merge(
|
|
8693
|
+
selectionTracker.selectionChange$.pipe(
|
|
8694
|
+
map$1((selection) => {
|
|
8695
|
+
if (selection == null ? void 0 : selection.toString()) {
|
|
8696
|
+
return {
|
|
8697
|
+
type: "change",
|
|
8698
|
+
selection
|
|
8699
|
+
};
|
|
8700
|
+
} else {
|
|
8701
|
+
return void 0;
|
|
8702
|
+
}
|
|
8703
|
+
})
|
|
8704
|
+
),
|
|
8705
|
+
selectionTracker.selectionOver$.pipe(
|
|
8706
|
+
map$1(([event, selection]) => {
|
|
8707
|
+
return {
|
|
8708
|
+
type: "over",
|
|
8709
|
+
event,
|
|
8710
|
+
selection
|
|
8711
|
+
};
|
|
8712
|
+
})
|
|
8713
|
+
)
|
|
8714
|
+
).pipe(
|
|
8715
|
+
takeUntil(spineItem.unloaded$),
|
|
8716
|
+
endWith(void 0),
|
|
8717
|
+
finalize(() => {
|
|
8718
|
+
selectionTracker.destroy();
|
|
8719
|
+
})
|
|
8720
|
+
);
|
|
8721
|
+
}),
|
|
8722
|
+
distinctUntilChanged$1()
|
|
8723
|
+
);
|
|
8625
8724
|
const selectionEnhancer = (next) => (options) => {
|
|
8626
8725
|
const reader = next(options);
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
tap$1((selection) => {
|
|
8645
|
-
if (selection == null ? void 0 : selection.toString()) {
|
|
8646
|
-
selectionSubject.next({
|
|
8647
|
-
document: frameDoc,
|
|
8648
|
-
selection,
|
|
8649
|
-
itemIndex
|
|
8650
|
-
});
|
|
8651
|
-
} else {
|
|
8652
|
-
selectionSubject.next(void 0);
|
|
8653
|
-
}
|
|
8654
|
-
})
|
|
8655
|
-
),
|
|
8656
|
-
selectionTracker.selectionOver$.pipe(
|
|
8657
|
-
tap$1(([event, selection]) => {
|
|
8658
|
-
selectionOverSubject.next([
|
|
8659
|
-
event,
|
|
8660
|
-
{
|
|
8661
|
-
document: frameDoc,
|
|
8662
|
-
selection,
|
|
8663
|
-
itemIndex
|
|
8664
|
-
}
|
|
8665
|
-
]);
|
|
8666
|
-
})
|
|
8667
|
-
)
|
|
8668
|
-
).pipe(takeUntil(destroy$)).subscribe();
|
|
8669
|
-
destroy(() => {
|
|
8670
|
-
selectionTracker.destroy();
|
|
8671
|
-
});
|
|
8672
|
-
}
|
|
8673
|
-
}
|
|
8674
|
-
}
|
|
8675
|
-
);
|
|
8676
|
-
const selection$ = selectionSubject.pipe(
|
|
8726
|
+
let lasSelection = void 0;
|
|
8727
|
+
const trackedSelection$ = reader.spineItemsManager.items$.pipe(
|
|
8728
|
+
switchMap$1((spineItems) => {
|
|
8729
|
+
const instances = spineItems.map((spineItem) => {
|
|
8730
|
+
const itemIndex = reader.spineItemsManager.getSpineItemIndex(spineItem) ?? 0;
|
|
8731
|
+
return trackSpineItemSelection(spineItem).pipe(
|
|
8732
|
+
map$1((entry) => {
|
|
8733
|
+
if (!entry) return void 0;
|
|
8734
|
+
return {
|
|
8735
|
+
...entry,
|
|
8736
|
+
itemIndex
|
|
8737
|
+
};
|
|
8738
|
+
})
|
|
8739
|
+
);
|
|
8740
|
+
});
|
|
8741
|
+
return merge(...instances);
|
|
8742
|
+
}),
|
|
8677
8743
|
distinctUntilChanged$1(),
|
|
8678
|
-
|
|
8679
|
-
|
|
8744
|
+
tap$1((value) => {
|
|
8745
|
+
lasSelection = value;
|
|
8746
|
+
}),
|
|
8747
|
+
shareReplay$1({ refCount: true, bufferSize: 1 })
|
|
8680
8748
|
);
|
|
8681
|
-
const
|
|
8749
|
+
const selection$ = trackedSelection$.pipe(
|
|
8750
|
+
filter$1((selection) => (selection == null ? void 0 : selection.type) === "change" || !selection),
|
|
8751
|
+
share()
|
|
8752
|
+
);
|
|
8753
|
+
const selectionStart$ = trackedSelection$.pipe(
|
|
8682
8754
|
map$1((selection) => !!selection),
|
|
8683
8755
|
distinctUntilChanged$1(),
|
|
8684
8756
|
filter$1((isSelecting) => isSelecting),
|
|
@@ -8690,15 +8762,18 @@ const selectionEnhancer = (next) => (options) => {
|
|
|
8690
8762
|
filter$1((selection) => !selection),
|
|
8691
8763
|
share()
|
|
8692
8764
|
);
|
|
8693
|
-
const selectionOver$ =
|
|
8765
|
+
const selectionOver$ = trackedSelection$.pipe(
|
|
8766
|
+
filter$1((selection) => (selection == null ? void 0 : selection.type) === "over"),
|
|
8767
|
+
share()
|
|
8768
|
+
);
|
|
8694
8769
|
const lastSelectionOnPointerdown$ = reader.context.containerElement$.pipe(
|
|
8695
8770
|
switchMap$1((container) => fromEvent(container, "pointerdown")),
|
|
8696
8771
|
withLatestFrom(selection$),
|
|
8697
8772
|
map$1(([, selection]) => selection),
|
|
8698
8773
|
startWith$1(void 0),
|
|
8699
|
-
shareReplay$1(1)
|
|
8700
|
-
takeUntil(reader.$.destroy$)
|
|
8774
|
+
shareReplay$1(1)
|
|
8701
8775
|
);
|
|
8776
|
+
selection$.pipe(takeUntil(reader.$.destroy$)).subscribe();
|
|
8702
8777
|
return {
|
|
8703
8778
|
...reader,
|
|
8704
8779
|
selection: {
|
|
@@ -8707,12 +8782,8 @@ const selectionEnhancer = (next) => (options) => {
|
|
|
8707
8782
|
selectionEnd$,
|
|
8708
8783
|
selectionOver$,
|
|
8709
8784
|
lastSelectionOnPointerdown$,
|
|
8710
|
-
getSelection: () =>
|
|
8785
|
+
getSelection: () => lasSelection,
|
|
8711
8786
|
createOrderedRangeFromSelection
|
|
8712
|
-
},
|
|
8713
|
-
destroy: () => {
|
|
8714
|
-
selectionSubject.complete();
|
|
8715
|
-
reader.destroy();
|
|
8716
8787
|
}
|
|
8717
8788
|
};
|
|
8718
8789
|
};
|
|
@@ -8777,9 +8848,10 @@ export {
|
|
|
8777
8848
|
isHtmlElement,
|
|
8778
8849
|
isShallowEqual2 as isShallowEqual,
|
|
8779
8850
|
mapKeysTo,
|
|
8851
|
+
observeMutation,
|
|
8780
8852
|
observeResize,
|
|
8781
8853
|
removeCSS,
|
|
8782
|
-
|
|
8854
|
+
upsertCSSToFrame,
|
|
8783
8855
|
waitForFrameLoad,
|
|
8784
8856
|
waitForFrameReady,
|
|
8785
8857
|
waitForSwitch
|