@embedpdf/plugin-annotation 2.10.0 → 2.10.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.js CHANGED
@@ -4443,7 +4443,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
4443
4443
  return context.changes;
4444
4444
  }
4445
4445
  registerPageHandlers(documentId, pageIndex, scale, callbacks) {
4446
- var _a;
4446
+ var _a, _b;
4447
4447
  const docState = this.getCoreDocument(documentId);
4448
4448
  const page = (_a = docState == null ? void 0 : docState.document) == null ? void 0 : _a.pages[pageIndex];
4449
4449
  if (!page) return () => {
@@ -4453,7 +4453,7 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
4453
4453
  const unregisterFns = [];
4454
4454
  const effectivePageRotation = ((page.rotation ?? 0) + ((docState == null ? void 0 : docState.rotation) ?? 0)) % 4;
4455
4455
  for (const tool of this.state.tools) {
4456
- const factory = tool.pointerHandler;
4456
+ const factory = tool.pointerHandler ?? (((_b = tool.defaults) == null ? void 0 : _b.type) ? _AnnotationPlugin.defaultHandlerFactories.get(tool.defaults.type) : void 0);
4457
4457
  if (!factory) continue;
4458
4458
  const context = {
4459
4459
  pageIndex,
@@ -4464,10 +4464,10 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
4464
4464
  // Pass through services
4465
4465
  onPreview: (state) => callbacks.onPreview(tool.id, state),
4466
4466
  onCommit: (annotation, ctx) => {
4467
- var _a2, _b, _c;
4467
+ var _a2, _b2, _c;
4468
4468
  const editAfterCreate = ((_a2 = tool.behavior) == null ? void 0 : _a2.editAfterCreate) ?? false;
4469
4469
  this.createAnnotation(pageIndex, annotation, ctx, documentId, { editAfterCreate });
4470
- if ((_b = tool.behavior) == null ? void 0 : _b.deactivateToolAfterCreate) {
4470
+ if ((_b2 = tool.behavior) == null ? void 0 : _b2.deactivateToolAfterCreate) {
4471
4471
  this.setActiveTool(null, documentId);
4472
4472
  }
4473
4473
  if (((_c = tool.behavior) == null ? void 0 : _c.selectAfterCreate) || editAfterCreate) {
@@ -6178,6 +6178,18 @@ const _AnnotationPlugin = class _AnnotationPlugin extends BasePlugin {
6178
6178
  }
6179
6179
  };
6180
6180
  _AnnotationPlugin.id = "annotation";
6181
+ _AnnotationPlugin.defaultHandlerFactories = /* @__PURE__ */ new Map([
6182
+ [PdfAnnotationSubtype.CIRCLE, circleHandlerFactory],
6183
+ [PdfAnnotationSubtype.SQUARE, squareHandlerFactory],
6184
+ [PdfAnnotationSubtype.STAMP, stampHandlerFactory],
6185
+ [PdfAnnotationSubtype.POLYGON, polygonHandlerFactory],
6186
+ [PdfAnnotationSubtype.POLYLINE, polylineHandlerFactory],
6187
+ [PdfAnnotationSubtype.LINE, lineHandlerFactory],
6188
+ [PdfAnnotationSubtype.INK, inkHandlerFactory],
6189
+ [PdfAnnotationSubtype.FREETEXT, freeTextHandlerFactory],
6190
+ [PdfAnnotationSubtype.TEXT, textHandlerFactory],
6191
+ [PdfAnnotationSubtype.LINK, linkHandlerFactory]
6192
+ ]);
6181
6193
  let AnnotationPlugin = _AnnotationPlugin;
6182
6194
  function resolveInteractionProp(prop, annotation, defaultValue) {
6183
6195
  if (prop === void 0) return defaultValue;