@embedpdf/plugin-selection 2.5.0 → 2.6.1
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +159 -81
- package/dist/index.js.map +1 -1
- package/dist/lib/handlers/marquee-selection.handler.d.ts +9 -7
- package/dist/lib/handlers/text-selection.handler.d.ts +8 -6
- package/dist/lib/selection-plugin.d.ts +7 -4
- package/dist/lib/types.d.ts +71 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +59 -16
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +59 -16
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/index.d.ts +1 -0
- package/dist/shared/components/marquee-selection.d.ts +18 -5
- package/dist/shared/components/selection-layer.d.ts +18 -1
- package/dist/shared/components/text-selection.d.ts +21 -0
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/marquee-selection.d.ts +18 -5
- package/dist/shared-preact/components/selection-layer.d.ts +18 -1
- package/dist/shared-preact/components/text-selection.d.ts +21 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/marquee-selection.d.ts +18 -5
- package/dist/shared-react/components/selection-layer.d.ts +18 -1
- package/dist/shared-react/components/text-selection.d.ts +21 -0
- package/dist/svelte/components/MarqueeSelection.svelte.d.ts +12 -2
- package/dist/svelte/components/SelectionLayer.svelte.d.ts +11 -1
- package/dist/svelte/components/TextSelection.svelte.d.ts +22 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +93 -17
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/index.d.ts +1 -0
- package/dist/vue/components/marquee-selection.vue.d.ts +13 -4
- package/dist/vue/components/selection-layer.vue.d.ts +15 -5
- package/dist/vue/components/text-selection.vue.d.ts +51 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +89 -32
- package/dist/vue/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -329,36 +329,38 @@ function mergeAdjacentRects(textRuns) {
|
|
|
329
329
|
function createTextSelectionHandler(opts) {
|
|
330
330
|
return {
|
|
331
331
|
onPointerDown: (point, evt, modeId) => {
|
|
332
|
+
var _a;
|
|
333
|
+
if (evt.target === evt.currentTarget) {
|
|
334
|
+
(_a = opts.onEmptySpaceClick) == null ? void 0 : _a.call(opts, modeId);
|
|
335
|
+
}
|
|
332
336
|
if (!opts.isEnabled(modeId)) return;
|
|
333
|
-
opts.onClear();
|
|
337
|
+
opts.onClear(modeId);
|
|
334
338
|
const geo = opts.getGeometry();
|
|
335
339
|
if (geo) {
|
|
336
340
|
const g = glyphAt(geo, point);
|
|
337
341
|
if (g !== -1) {
|
|
338
|
-
opts.onBegin(g);
|
|
339
|
-
evt.stopImmediatePropagation();
|
|
342
|
+
opts.onBegin(g, modeId);
|
|
340
343
|
}
|
|
341
344
|
}
|
|
342
345
|
},
|
|
343
|
-
onPointerMove: (point,
|
|
346
|
+
onPointerMove: (point, _evt, modeId) => {
|
|
344
347
|
if (!opts.isEnabled(modeId)) return;
|
|
345
348
|
const geo = opts.getGeometry();
|
|
346
349
|
if (geo) {
|
|
347
350
|
const g = glyphAt(geo, point);
|
|
348
351
|
opts.setCursor(g !== -1 ? "text" : null);
|
|
349
352
|
if (opts.isSelecting() && g !== -1) {
|
|
350
|
-
opts.onUpdate(g);
|
|
351
|
-
evt.stopImmediatePropagation();
|
|
353
|
+
opts.onUpdate(g, modeId);
|
|
352
354
|
}
|
|
353
355
|
}
|
|
354
356
|
},
|
|
355
357
|
onPointerUp: (_point, _evt, modeId) => {
|
|
356
358
|
if (!opts.isEnabled(modeId)) return;
|
|
357
|
-
opts.onEnd();
|
|
359
|
+
opts.onEnd(modeId);
|
|
358
360
|
},
|
|
359
361
|
onHandlerActiveEnd: (modeId) => {
|
|
360
362
|
if (!opts.isEnabled(modeId)) return;
|
|
361
|
-
opts.onClear();
|
|
363
|
+
opts.onClear(modeId);
|
|
362
364
|
}
|
|
363
365
|
};
|
|
364
366
|
}
|
|
@@ -368,12 +370,13 @@ function createMarqueeSelectionHandler(opts) {
|
|
|
368
370
|
let last = null;
|
|
369
371
|
return {
|
|
370
372
|
onPointerDown: (pos, evt, modeId) => {
|
|
371
|
-
var _a;
|
|
373
|
+
var _a, _b;
|
|
372
374
|
if (!opts.isEnabled(modeId)) return;
|
|
375
|
+
if ((_a = opts.isTextSelecting) == null ? void 0 : _a.call(opts)) return;
|
|
373
376
|
start = pos;
|
|
374
377
|
last = { origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } };
|
|
375
|
-
opts.onBegin(pos);
|
|
376
|
-
(
|
|
378
|
+
opts.onBegin(pos, modeId);
|
|
379
|
+
(_b = evt.setPointerCapture) == null ? void 0 : _b.call(evt);
|
|
377
380
|
},
|
|
378
381
|
onPointerMove: (pos, _evt, modeId) => {
|
|
379
382
|
if (!start || !opts.isEnabled(modeId)) return;
|
|
@@ -383,7 +386,7 @@ function createMarqueeSelectionHandler(opts) {
|
|
|
383
386
|
origin: { x: Math.min(start.x, x), y: Math.min(start.y, y) },
|
|
384
387
|
size: { width: Math.abs(x - start.x), height: Math.abs(y - start.y) }
|
|
385
388
|
};
|
|
386
|
-
opts.onChange(last);
|
|
389
|
+
opts.onChange(last, modeId);
|
|
387
390
|
},
|
|
388
391
|
onPointerUp: (_pos, evt, modeId) => {
|
|
389
392
|
var _a;
|
|
@@ -391,9 +394,9 @@ function createMarqueeSelectionHandler(opts) {
|
|
|
391
394
|
if (last && start) {
|
|
392
395
|
const dragPx = Math.max(last.size.width, last.size.height) * scale;
|
|
393
396
|
if (dragPx > minDragPx) {
|
|
394
|
-
opts.onEnd(last);
|
|
397
|
+
opts.onEnd(last, modeId);
|
|
395
398
|
} else {
|
|
396
|
-
opts.onCancel();
|
|
399
|
+
opts.onCancel(modeId);
|
|
397
400
|
}
|
|
398
401
|
}
|
|
399
402
|
start = null;
|
|
@@ -405,7 +408,7 @@ function createMarqueeSelectionHandler(opts) {
|
|
|
405
408
|
if (!opts.isEnabled(modeId)) return;
|
|
406
409
|
start = null;
|
|
407
410
|
last = null;
|
|
408
|
-
opts.onCancel();
|
|
411
|
+
opts.onCancel(modeId);
|
|
409
412
|
(_a = evt.releasePointerCapture) == null ? void 0 : _a.call(evt);
|
|
410
413
|
}
|
|
411
414
|
};
|
|
@@ -417,11 +420,14 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
417
420
|
this.enabledModesPerDoc = /* @__PURE__ */ new Map();
|
|
418
421
|
this.selecting = /* @__PURE__ */ new Map();
|
|
419
422
|
this.anchor = /* @__PURE__ */ new Map();
|
|
420
|
-
this.marqueeEnabled = /* @__PURE__ */ new Map();
|
|
421
423
|
this.marqueePage = /* @__PURE__ */ new Map();
|
|
422
424
|
this.pageCallbacks = /* @__PURE__ */ new Map();
|
|
423
425
|
this.menuPlacement$ = createScopedEmitter((documentId, placement) => ({ documentId, placement }));
|
|
424
|
-
this.selChange$ = createScopedEmitter((documentId, selection) => ({
|
|
426
|
+
this.selChange$ = createScopedEmitter((documentId, selection) => ({
|
|
427
|
+
documentId,
|
|
428
|
+
selection,
|
|
429
|
+
modeId: this.interactionManagerCapability.forDocument(documentId).getActiveMode()
|
|
430
|
+
}));
|
|
425
431
|
this.textRetrieved$ = createScopedEmitter(
|
|
426
432
|
(documentId, text) => ({ documentId, text })
|
|
427
433
|
);
|
|
@@ -429,19 +435,41 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
429
435
|
(documentId, text) => ({ documentId, text }),
|
|
430
436
|
{ cache: false }
|
|
431
437
|
);
|
|
432
|
-
this.beginSelection$ = createScopedEmitter(
|
|
433
|
-
|
|
434
|
-
|
|
438
|
+
this.beginSelection$ = createScopedEmitter(
|
|
439
|
+
(documentId, data) => ({
|
|
440
|
+
documentId,
|
|
441
|
+
page: data.page,
|
|
442
|
+
index: data.index,
|
|
443
|
+
modeId: data.modeId
|
|
444
|
+
}),
|
|
445
|
+
{ cache: false }
|
|
446
|
+
);
|
|
447
|
+
this.endSelection$ = createScopedEmitter((documentId, data) => ({ documentId, modeId: data.modeId }), { cache: false });
|
|
448
|
+
this.marqueeChange$ = createScopedEmitter(
|
|
449
|
+
(documentId, data) => ({
|
|
450
|
+
documentId,
|
|
451
|
+
pageIndex: data.pageIndex,
|
|
452
|
+
rect: data.rect,
|
|
453
|
+
modeId: data.modeId
|
|
454
|
+
}),
|
|
435
455
|
{ cache: false }
|
|
436
456
|
);
|
|
437
|
-
this.marqueeChange$ = createScopedEmitter((documentId, data) => ({ documentId, pageIndex: data.pageIndex, rect: data.rect }), {
|
|
438
|
-
cache: false
|
|
439
|
-
});
|
|
440
457
|
this.marqueeEnd$ = createScopedEmitter(
|
|
441
|
-
(documentId, data) => ({
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
458
|
+
(documentId, data) => ({
|
|
459
|
+
documentId,
|
|
460
|
+
pageIndex: data.pageIndex,
|
|
461
|
+
rect: data.rect,
|
|
462
|
+
modeId: data.modeId
|
|
463
|
+
}),
|
|
464
|
+
{ cache: false }
|
|
465
|
+
);
|
|
466
|
+
this.emptySpaceClick$ = createScopedEmitter(
|
|
467
|
+
(documentId, data) => ({
|
|
468
|
+
documentId,
|
|
469
|
+
pageIndex: data.pageIndex,
|
|
470
|
+
modeId: data.modeId
|
|
471
|
+
}),
|
|
472
|
+
{ cache: false }
|
|
445
473
|
);
|
|
446
474
|
this.viewportCapability = null;
|
|
447
475
|
this.scrollCapability = null;
|
|
@@ -474,16 +502,26 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
474
502
|
}
|
|
475
503
|
/* ── life-cycle ────────────────────────────────────────── */
|
|
476
504
|
onDocumentLoadingStarted(documentId) {
|
|
505
|
+
var _a;
|
|
477
506
|
this.dispatch(initSelectionState(documentId, initialSelectionDocumentState));
|
|
507
|
+
const marqueeEnabled = ((_a = this.config.marquee) == null ? void 0 : _a.enabled) !== false;
|
|
478
508
|
this.enabledModesPerDoc.set(
|
|
479
509
|
documentId,
|
|
480
|
-
/* @__PURE__ */ new Map([
|
|
510
|
+
/* @__PURE__ */ new Map([
|
|
511
|
+
[
|
|
512
|
+
"pointerMode",
|
|
513
|
+
{
|
|
514
|
+
enableSelection: true,
|
|
515
|
+
showSelectionRects: true,
|
|
516
|
+
enableMarquee: marqueeEnabled,
|
|
517
|
+
showMarqueeRects: true
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
])
|
|
481
521
|
);
|
|
482
522
|
this.pageCallbacks.set(documentId, /* @__PURE__ */ new Map());
|
|
483
523
|
this.selecting.set(documentId, false);
|
|
484
524
|
this.anchor.set(documentId, void 0);
|
|
485
|
-
const marqueeConfig = this.config.marquee;
|
|
486
|
-
this.marqueeEnabled.set(documentId, (marqueeConfig == null ? void 0 : marqueeConfig.enabled) !== false);
|
|
487
525
|
}
|
|
488
526
|
onDocumentClosed(documentId) {
|
|
489
527
|
this.dispatch(cleanupSelectionState(documentId));
|
|
@@ -491,7 +529,6 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
491
529
|
this.pageCallbacks.delete(documentId);
|
|
492
530
|
this.selecting.delete(documentId);
|
|
493
531
|
this.anchor.delete(documentId);
|
|
494
|
-
this.marqueeEnabled.delete(documentId);
|
|
495
532
|
this.marqueePage.delete(documentId);
|
|
496
533
|
this.selChange$.clearScope(documentId);
|
|
497
534
|
this.textRetrieved$.clearScope(documentId);
|
|
@@ -501,6 +538,7 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
501
538
|
this.menuPlacement$.clearScope(documentId);
|
|
502
539
|
this.marqueeChange$.clearScope(documentId);
|
|
503
540
|
this.marqueeEnd$.clearScope(documentId);
|
|
541
|
+
this.emptySpaceClick$.clearScope(documentId);
|
|
504
542
|
}
|
|
505
543
|
async initialize() {
|
|
506
544
|
}
|
|
@@ -513,6 +551,7 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
513
551
|
this.menuPlacement$.clear();
|
|
514
552
|
this.marqueeChange$.clear();
|
|
515
553
|
this.marqueeEnd$.clear();
|
|
554
|
+
this.emptySpaceClick$.clear();
|
|
516
555
|
super.destroy();
|
|
517
556
|
}
|
|
518
557
|
/* ── capability exposed to UI / other plugins ─────────── */
|
|
@@ -532,13 +571,12 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
532
571
|
getState: (docId) => this.getDocumentState(getDocId(docId)),
|
|
533
572
|
enableForMode: (modeId, options, docId) => {
|
|
534
573
|
var _a;
|
|
535
|
-
return (_a = this.enabledModesPerDoc.get(getDocId(docId))) == null ? void 0 : _a.set(modeId, {
|
|
574
|
+
return (_a = this.enabledModesPerDoc.get(getDocId(docId))) == null ? void 0 : _a.set(modeId, { ...options });
|
|
536
575
|
},
|
|
537
576
|
isEnabledForMode: (modeId, docId) => {
|
|
538
577
|
var _a;
|
|
539
578
|
return ((_a = this.enabledModesPerDoc.get(getDocId(docId))) == null ? void 0 : _a.has(modeId)) ?? false;
|
|
540
579
|
},
|
|
541
|
-
// Marquee selection
|
|
542
580
|
setMarqueeEnabled: (enabled, docId) => this.setMarqueeEnabled(getDocId(docId), enabled),
|
|
543
581
|
isMarqueeEnabled: (docId) => this.isMarqueeEnabled(getDocId(docId)),
|
|
544
582
|
// Document-scoped operations
|
|
@@ -551,7 +589,9 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
551
589
|
onEndSelection: this.endSelection$.onGlobal,
|
|
552
590
|
// Marquee selection events
|
|
553
591
|
onMarqueeChange: this.marqueeChange$.onGlobal,
|
|
554
|
-
onMarqueeEnd: this.marqueeEnd$.onGlobal
|
|
592
|
+
onMarqueeEnd: this.marqueeEnd$.onGlobal,
|
|
593
|
+
// Empty space click event
|
|
594
|
+
onEmptySpaceClick: this.emptySpaceClick$.onGlobal
|
|
555
595
|
};
|
|
556
596
|
}
|
|
557
597
|
createSelectionScope(documentId) {
|
|
@@ -574,7 +614,8 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
574
614
|
onBeginSelection: this.beginSelection$.forScope(documentId),
|
|
575
615
|
onEndSelection: this.endSelection$.forScope(documentId),
|
|
576
616
|
onMarqueeChange: this.marqueeChange$.forScope(documentId),
|
|
577
|
-
onMarqueeEnd: this.marqueeEnd$.forScope(documentId)
|
|
617
|
+
onMarqueeEnd: this.marqueeEnd$.forScope(documentId),
|
|
618
|
+
onEmptySpaceClick: this.emptySpaceClick$.forScope(documentId)
|
|
578
619
|
};
|
|
579
620
|
}
|
|
580
621
|
getDocumentState(documentId) {
|
|
@@ -620,13 +661,18 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
620
661
|
});
|
|
621
662
|
const textHandler = createTextSelectionHandler({
|
|
622
663
|
getGeometry: () => this.getDocumentState(documentId).geometry[pageIndex],
|
|
623
|
-
isEnabled: (modeId) =>
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
664
|
+
isEnabled: (modeId) => {
|
|
665
|
+
const config = enabledModes == null ? void 0 : enabledModes.get(modeId);
|
|
666
|
+
if (!config) return false;
|
|
667
|
+
return config.enableSelection !== false;
|
|
668
|
+
},
|
|
669
|
+
onBegin: (g, modeId) => this.beginSelection(documentId, pageIndex, g, modeId),
|
|
670
|
+
onUpdate: (g, modeId) => this.updateSelection(documentId, pageIndex, g, modeId),
|
|
671
|
+
onEnd: (modeId) => this.endSelection(documentId, modeId),
|
|
672
|
+
onClear: (modeId) => this.clearSelection(documentId, modeId),
|
|
628
673
|
isSelecting: () => this.selecting.get(documentId) ?? false,
|
|
629
|
-
setCursor: (cursor) => cursor ? interactionScope.setCursor("selection-text", cursor, 10) : interactionScope.removeCursor("selection-text")
|
|
674
|
+
setCursor: (cursor) => cursor ? interactionScope.setCursor("selection-text", cursor, 10) : interactionScope.removeCursor("selection-text"),
|
|
675
|
+
onEmptySpaceClick: (modeId) => this.emptySpaceClick$.emit(documentId, { pageIndex, modeId })
|
|
630
676
|
});
|
|
631
677
|
const unregisterHandlers = this.interactionManagerCapability.registerAlways({
|
|
632
678
|
scope: { type: "page", documentId, pageIndex },
|
|
@@ -640,8 +686,8 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
640
686
|
};
|
|
641
687
|
}
|
|
642
688
|
/**
|
|
643
|
-
* Register marquee selection on a page. Uses `
|
|
644
|
-
*
|
|
689
|
+
* Register marquee selection on a page. Uses `registerAlways` so any plugin
|
|
690
|
+
* can enable marquee selection for their mode via `enableForMode({ enableMarquee: true })`.
|
|
645
691
|
*/
|
|
646
692
|
registerMarqueeOnPage(opts) {
|
|
647
693
|
var _a;
|
|
@@ -678,29 +724,38 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
678
724
|
}
|
|
679
725
|
const pageSize = page.size;
|
|
680
726
|
const minDragPx = ((_a = this.config.marquee) == null ? void 0 : _a.minDragPx) ?? 5;
|
|
727
|
+
const shouldShowRect = () => {
|
|
728
|
+
var _a2;
|
|
729
|
+
const mode = this.interactionManagerCapability.forDocument(documentId).getActiveMode();
|
|
730
|
+
const config = (_a2 = this.enabledModesPerDoc.get(documentId)) == null ? void 0 : _a2.get(mode);
|
|
731
|
+
return (config == null ? void 0 : config.showMarqueeRects) !== false;
|
|
732
|
+
};
|
|
681
733
|
const marqueeHandler = createMarqueeSelectionHandler({
|
|
682
734
|
pageSize,
|
|
683
735
|
scale,
|
|
684
736
|
minDragPx,
|
|
685
|
-
isEnabled: () =>
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
onRectChange(rect);
|
|
737
|
+
isEnabled: (modeId) => {
|
|
738
|
+
var _a2;
|
|
739
|
+
const config = (_a2 = this.enabledModesPerDoc.get(documentId)) == null ? void 0 : _a2.get(modeId);
|
|
740
|
+
return (config == null ? void 0 : config.enableMarquee) === true;
|
|
690
741
|
},
|
|
691
|
-
|
|
692
|
-
|
|
742
|
+
isTextSelecting: () => this.selecting.get(documentId) ?? false,
|
|
743
|
+
onBegin: (pos, modeId) => this.beginMarquee(documentId, pageIndex, pos, modeId),
|
|
744
|
+
onChange: (rect, modeId) => {
|
|
745
|
+
this.updateMarquee(documentId, pageIndex, rect, modeId);
|
|
746
|
+
onRectChange(shouldShowRect() ? rect : null);
|
|
747
|
+
},
|
|
748
|
+
onEnd: (rect, modeId) => {
|
|
749
|
+
this.endMarquee(documentId, pageIndex, rect, modeId);
|
|
693
750
|
onRectChange(null);
|
|
694
751
|
},
|
|
695
|
-
onCancel: () => {
|
|
696
|
-
this.cancelMarquee(documentId);
|
|
752
|
+
onCancel: (modeId) => {
|
|
753
|
+
this.cancelMarquee(documentId, modeId);
|
|
697
754
|
onRectChange(null);
|
|
698
755
|
}
|
|
699
756
|
});
|
|
700
|
-
const unregisterHandlers = this.interactionManagerCapability.
|
|
701
|
-
documentId,
|
|
702
|
-
pageIndex,
|
|
703
|
-
modeId: "pointerMode",
|
|
757
|
+
const unregisterHandlers = this.interactionManagerCapability.registerAlways({
|
|
758
|
+
scope: { type: "page", documentId, pageIndex },
|
|
704
759
|
handlers: marqueeHandler
|
|
705
760
|
});
|
|
706
761
|
return unregisterHandlers;
|
|
@@ -726,21 +781,33 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
726
781
|
isTopVisible: rectTopInView >= 0 && rectTopInView < vpMetrics.clientHeight
|
|
727
782
|
};
|
|
728
783
|
}
|
|
784
|
+
emitMenuPlacement(documentId, placement) {
|
|
785
|
+
this.menuPlacement$.emit(documentId, placement);
|
|
786
|
+
if (placement) {
|
|
787
|
+
this.interactionManagerCapability.claimPageActivity(
|
|
788
|
+
documentId,
|
|
789
|
+
"selection-menu",
|
|
790
|
+
placement.pageIndex
|
|
791
|
+
);
|
|
792
|
+
} else {
|
|
793
|
+
this.interactionManagerCapability.releasePageActivity(documentId, "selection-menu");
|
|
794
|
+
}
|
|
795
|
+
}
|
|
729
796
|
recalculateMenuPlacement(documentId) {
|
|
730
797
|
const docState = this.state.documents[documentId];
|
|
731
798
|
if (!docState) return;
|
|
732
799
|
if (docState.selecting || docState.selection === null) {
|
|
733
|
-
this.
|
|
800
|
+
this.emitMenuPlacement(documentId, null);
|
|
734
801
|
return;
|
|
735
802
|
}
|
|
736
803
|
const bounds = selectBoundingRectsForAllPages(docState);
|
|
737
804
|
if (bounds.length === 0) {
|
|
738
|
-
this.
|
|
805
|
+
this.emitMenuPlacement(documentId, null);
|
|
739
806
|
return;
|
|
740
807
|
}
|
|
741
808
|
const tail = bounds[bounds.length - 1];
|
|
742
809
|
if (!this.viewportCapability || !this.scrollCapability) {
|
|
743
|
-
this.
|
|
810
|
+
this.emitMenuPlacement(documentId, {
|
|
744
811
|
pageIndex: tail.page,
|
|
745
812
|
rect: tail.rect,
|
|
746
813
|
spaceAbove: 0,
|
|
@@ -759,7 +826,7 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
759
826
|
const headMetrics = this.getPlacementMetrics(documentId, head.page, head.rect, vpMetrics);
|
|
760
827
|
if (tailMetrics) {
|
|
761
828
|
if (tailMetrics.isBottomVisible && tailMetrics.spaceBelow > this.menuHeight) {
|
|
762
|
-
this.
|
|
829
|
+
this.emitMenuPlacement(documentId, {
|
|
763
830
|
...tailMetrics,
|
|
764
831
|
suggestTop: false,
|
|
765
832
|
isVisible: true
|
|
@@ -769,7 +836,7 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
769
836
|
}
|
|
770
837
|
if (headMetrics) {
|
|
771
838
|
if (headMetrics.isTopVisible) {
|
|
772
|
-
this.
|
|
839
|
+
this.emitMenuPlacement(documentId, {
|
|
773
840
|
...headMetrics,
|
|
774
841
|
suggestTop: true,
|
|
775
842
|
isVisible: true
|
|
@@ -778,14 +845,14 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
778
845
|
}
|
|
779
846
|
}
|
|
780
847
|
if (tailMetrics && tailMetrics.isBottomVisible) {
|
|
781
|
-
this.
|
|
848
|
+
this.emitMenuPlacement(documentId, {
|
|
782
849
|
...tailMetrics,
|
|
783
850
|
suggestTop: false,
|
|
784
851
|
isVisible: true
|
|
785
852
|
});
|
|
786
853
|
return;
|
|
787
854
|
}
|
|
788
|
-
this.
|
|
855
|
+
this.emitMenuPlacement(documentId, null);
|
|
789
856
|
}
|
|
790
857
|
notifyPage(documentId, pageIndex) {
|
|
791
858
|
var _a, _b;
|
|
@@ -794,7 +861,7 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
794
861
|
const docState = this.getDocumentState(documentId);
|
|
795
862
|
const mode = this.interactionManagerCapability.forDocument(documentId).getActiveMode();
|
|
796
863
|
const modeConfig = (_b = this.enabledModesPerDoc.get(documentId)) == null ? void 0 : _b.get(mode);
|
|
797
|
-
const shouldShowRects = modeConfig && modeConfig.showRects !== false;
|
|
864
|
+
const shouldShowRects = modeConfig && (modeConfig.showSelectionRects ?? modeConfig.showRects) !== false;
|
|
798
865
|
if (shouldShowRects) {
|
|
799
866
|
callback({
|
|
800
867
|
rects: selectRectsForPage(docState, pageIndex),
|
|
@@ -829,29 +896,29 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
829
896
|
return this.getNewPageGeometryAndCache(documentId, pageIdx);
|
|
830
897
|
}
|
|
831
898
|
/* ── selection state updates ───────────────────────────── */
|
|
832
|
-
beginSelection(documentId, page, index) {
|
|
899
|
+
beginSelection(documentId, page, index, modeId) {
|
|
833
900
|
this.selecting.set(documentId, true);
|
|
834
901
|
this.anchor.set(documentId, { page, index });
|
|
835
902
|
this.dispatch(startSelection(documentId));
|
|
836
|
-
this.beginSelection$.emit(documentId, { page, index });
|
|
903
|
+
this.beginSelection$.emit(documentId, { page, index, modeId });
|
|
837
904
|
this.recalculateMenuPlacement(documentId);
|
|
838
905
|
}
|
|
839
|
-
endSelection(documentId) {
|
|
906
|
+
endSelection(documentId, modeId) {
|
|
840
907
|
this.selecting.set(documentId, false);
|
|
841
908
|
this.anchor.set(documentId, void 0);
|
|
842
909
|
this.dispatch(endSelection(documentId));
|
|
843
|
-
this.endSelection$.emit(documentId);
|
|
910
|
+
this.endSelection$.emit(documentId, { modeId });
|
|
844
911
|
this.recalculateMenuPlacement(documentId);
|
|
845
912
|
}
|
|
846
|
-
clearSelection(documentId) {
|
|
913
|
+
clearSelection(documentId, _modeId) {
|
|
847
914
|
this.selecting.set(documentId, false);
|
|
848
915
|
this.anchor.set(documentId, void 0);
|
|
849
916
|
this.dispatch(clearSelection(documentId));
|
|
850
917
|
this.selChange$.emit(documentId, null);
|
|
851
|
-
this.
|
|
918
|
+
this.emitMenuPlacement(documentId, null);
|
|
852
919
|
this.notifyAllPages(documentId);
|
|
853
920
|
}
|
|
854
|
-
updateSelection(documentId, page, index) {
|
|
921
|
+
updateSelection(documentId, page, index, modeId) {
|
|
855
922
|
if (!this.selecting.get(documentId) || !this.anchor.get(documentId)) return;
|
|
856
923
|
const a = this.anchor.get(documentId);
|
|
857
924
|
const forward = page > a.page || page === a.page && index >= a.index;
|
|
@@ -927,29 +994,40 @@ const _SelectionPlugin = class _SelectionPlugin extends BasePlugin {
|
|
|
927
994
|
}, ignore);
|
|
928
995
|
}
|
|
929
996
|
/* ── marquee selection state updates ─────────────────────── */
|
|
930
|
-
beginMarquee(documentId, pageIndex, _startPos) {
|
|
997
|
+
beginMarquee(documentId, pageIndex, _startPos, _modeId) {
|
|
931
998
|
this.marqueePage.set(documentId, pageIndex);
|
|
932
999
|
}
|
|
933
|
-
updateMarquee(documentId, pageIndex, rect) {
|
|
934
|
-
this.marqueeChange$.emit(documentId, { pageIndex, rect });
|
|
1000
|
+
updateMarquee(documentId, pageIndex, rect, modeId) {
|
|
1001
|
+
this.marqueeChange$.emit(documentId, { pageIndex, rect, modeId });
|
|
935
1002
|
}
|
|
936
|
-
endMarquee(documentId, pageIndex, rect) {
|
|
937
|
-
this.marqueeEnd$.emit(documentId, { pageIndex, rect });
|
|
938
|
-
this.marqueeChange$.emit(documentId, { pageIndex, rect: null });
|
|
1003
|
+
endMarquee(documentId, pageIndex, rect, modeId) {
|
|
1004
|
+
this.marqueeEnd$.emit(documentId, { pageIndex, rect, modeId });
|
|
1005
|
+
this.marqueeChange$.emit(documentId, { pageIndex, rect: null, modeId });
|
|
939
1006
|
this.marqueePage.delete(documentId);
|
|
940
1007
|
}
|
|
941
|
-
cancelMarquee(documentId) {
|
|
1008
|
+
cancelMarquee(documentId, modeId) {
|
|
942
1009
|
const pageIndex = this.marqueePage.get(documentId);
|
|
943
1010
|
if (pageIndex !== void 0) {
|
|
944
|
-
this.marqueeChange$.emit(documentId, { pageIndex, rect: null });
|
|
1011
|
+
this.marqueeChange$.emit(documentId, { pageIndex, rect: null, modeId });
|
|
945
1012
|
this.marqueePage.delete(documentId);
|
|
946
1013
|
}
|
|
947
1014
|
}
|
|
1015
|
+
/** @deprecated — shim for backward compat; delegates to pointerMode config */
|
|
948
1016
|
setMarqueeEnabled(documentId, enabled) {
|
|
949
|
-
this.
|
|
1017
|
+
const modes = this.enabledModesPerDoc.get(documentId);
|
|
1018
|
+
if (!modes) return;
|
|
1019
|
+
const current = modes.get("pointerMode");
|
|
1020
|
+
if (current) {
|
|
1021
|
+
current.enableMarquee = enabled;
|
|
1022
|
+
} else if (enabled) {
|
|
1023
|
+
modes.set("pointerMode", { enableMarquee: true });
|
|
1024
|
+
}
|
|
950
1025
|
}
|
|
1026
|
+
/** @deprecated — shim for backward compat; reads pointerMode config */
|
|
951
1027
|
isMarqueeEnabled(documentId) {
|
|
952
|
-
|
|
1028
|
+
var _a;
|
|
1029
|
+
const config = (_a = this.enabledModesPerDoc.get(documentId)) == null ? void 0 : _a.get("pointerMode");
|
|
1030
|
+
return (config == null ? void 0 : config.enableMarquee) !== false;
|
|
953
1031
|
}
|
|
954
1032
|
};
|
|
955
1033
|
_SelectionPlugin.id = "selection";
|