@embedpdf/plugin-annotation 3.0.0-next.4 → 3.0.0-next.6

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,7 @@
1
1
  let _embedpdf_core = require("@embedpdf/core");
2
2
  let _embedpdf_plugin_interaction = require("@embedpdf/plugin-interaction");
3
3
  let _embedpdf_engine_core_runtime = require("@embedpdf/engine-core/runtime");
4
+ let _embedpdf_plugin_selection = require("@embedpdf/plugin-selection");
4
5
  let _embedpdf_core_annotation = require("@embedpdf/core-annotation");
5
6
  let _embedpdf_core_geometry = require("@embedpdf/core-geometry");
6
7
  //#region src/types.ts
@@ -2487,6 +2488,26 @@ function createAnnotationCapability(ctx, config = {}) {
2487
2488
  finishCreationDraft: () => apply({ t: "finishCreationDraft" }),
2488
2489
  finishInkDraft: () => apply({ t: "finishInkDraft" }),
2489
2490
  cancelCreationDraft: () => apply({ t: "cancel" }),
2491
+ markupFromSelection: (subtype, preset) => {
2492
+ const selection = ctx.tryGet(_embedpdf_plugin_selection.SelectionToken);
2493
+ if (!selection || !selection.hasSelection()) return false;
2494
+ const snapshot = selection.snapshot();
2495
+ let created = false;
2496
+ for (const page of snapshot.pages) {
2497
+ if (!page.segments.length) continue;
2498
+ apply({
2499
+ t: "createMarkup",
2500
+ subtype,
2501
+ pon: page.pon,
2502
+ quads: page.segments.map((s) => s.quad),
2503
+ preset,
2504
+ flags: preset ? registry.get(preset)?.flags : void 0
2505
+ });
2506
+ created = true;
2507
+ }
2508
+ if (created) selection.clear();
2509
+ return created;
2510
+ },
2490
2511
  createMarkup: (subtype, pon, quads, preset) => apply({
2491
2512
  t: "createMarkup",
2492
2513
  subtype,
@@ -2746,4 +2767,4 @@ Object.defineProperty(exports, "widgetAppearanceFromProps", {
2746
2767
  }
2747
2768
  });
2748
2769
 
2749
- //# sourceMappingURL=capability-CYbikyob.cjs.map
2770
+ //# sourceMappingURL=capability-BMBwSdaY.cjs.map