@embedpdf/plugin-annotation 3.0.0-next.17 → 3.0.0-next.19

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { widgetAppearanceOf } from "./authoring.cjs";
2
- import { $ as Color, A as AnnotationResources, At as AnnotationState, B as AnnotationTool, Bt as ResolvedGhost, C as AnnotationPatch, Ct as StampPlacement, D as AnnotationRef, Dt as ThreadDeleteResult, E as AnnotationProperty, Et as TextItem, F as AnnotationSelectionChangedEvent, Ft as AnnotationToolInput, G as ArmedStampInfo, Gt as ToolDefaultsFor, H as AnnotationTransfer, Ht as SelectionAuthoring, I as AnnotationSettings, It as DEFAULT_TOOLS, J as AttachmentFileSource, Jt as TextSelection, K as ArmedStampPreview, Kt as Face, L as AnnotationStampsApi, Lt as GhostPolicy, M as AnnotationRotationAnchor, Mt as AnnotationToken, N as AnnotationSelectionAnchor, Nt as ARMED_STAMP_TOOL_ID, O as AnnotationReorderedEvent, Ot as ToolDefaults, P as AnnotationSelectionApi, Pt as AnnotationToolDef, Q as ClickCreate, R as AnnotationSubtype, Rt as InkAuthoringOptions, S as AnnotationOption, St as StampInput, T as AnnotationProperties, Tt as TextAlign, U as AnnotationUpdatedEvent, Ut as StampSourceSpec, V as AnnotationToolsApi, Vt as ResolvedTool, W as AnnotationWriteFailedEvent, Wt as ToolAuthoringKind, X as BlendMode, Y as Behavior, Z as ChromeSettings, _ as AnnotationHoverChangedEvent, _t as MarkupSubtype, a as AnnotationBundle, at as EditableKind, b as AnnotationImportResult, bt as ReviewStatus, c as AnnotationCreatedEvent, ct as FilePickerProvider, d as AnnotationDraftApi, dt as HandleRole, et as CommentThread, f as AnnotationDraftChangedEvent, ft as ImageGhost, g as AnnotationFlags, gt as LinkNavItem, h as AnnotationFilter, ht as LineStyle, i as AnnotationAnchor, it as CreationDraft, j as AnnotationResyncedEvent, jt as annotationState, k as AnnotationResourceRole, kt as ToolDefaultsChangedEvent, l as AnnotationDeletedEvent, lt as FilePromptRequest, m as AnnotationExportSelection, mt as LineEndings, n as AfterCreateSettings, nt as CommentThreadReview, o as AnnotationCapability, ot as EditableKinds, p as AnnotationEditingChangedEvent, pt as LineEnding, q as AttachmentContent, qt as TextFormat, r as Annotation, rt as CommentsApi, s as AnnotationConfig, st as FieldValues, t as ANNOTATION_DEFAULTS, tt as CommentThreadChangedEvent, u as AnnotationDraft, ut as FlagKey, v as AnnotationImportDrop, vt as MeasurementIntent, w as AnnotationPosition, wt as StampPreviewProvider, x as AnnotationLinksApi, xt as SnapSettings, y as AnnotationImportOptions, yt as PdfLinkTarget, z as AnnotationTextApi, zt as PromptSourceSpec } from "./contract-GPTUCoul.cjs";
3
- import { f as AnnotationModel, n as AnnotationHostCapability } from "./host-contract-C4o5ns9R.cjs";
2
+ import { $ as Color, A as AnnotationResources, At as AnnotationState, B as AnnotationTool, Bt as ResolvedGhost, C as AnnotationPatch, Ct as StampPlacement, D as AnnotationRef, Dt as ThreadDeleteResult, E as AnnotationProperty, Et as TextItem, F as AnnotationSelectionChangedEvent, Ft as AnnotationToolInput, G as ArmedStampInfo, Gt as ToolDefaultsFor, H as AnnotationTransfer, Ht as SelectionAuthoring, I as AnnotationSettings, It as DEFAULT_TOOLS, J as AttachmentFileSource, Jt as TextSelection, K as ArmedStampPreview, Kt as Face, L as AnnotationStampsApi, Lt as GhostPolicy, M as AnnotationRotationAnchor, Mt as AnnotationToken, N as AnnotationSelectionAnchor, Nt as ARMED_STAMP_TOOL_ID, O as AnnotationReorderedEvent, Ot as ToolDefaults, P as AnnotationSelectionApi, Pt as AnnotationToolDef, Q as ClickCreate, R as AnnotationSubtype, Rt as InkAuthoringOptions, S as AnnotationOption, St as StampInput, T as AnnotationProperties, Tt as TextAlign, U as AnnotationUpdatedEvent, Ut as StampSourceSpec, V as AnnotationToolsApi, Vt as ResolvedTool, W as AnnotationWriteFailedEvent, Wt as ToolAuthoringKind, X as BlendMode, Y as Behavior, Z as ChromeSettings, _ as AnnotationHoverChangedEvent, _t as MarkupSubtype, a as AnnotationBundle, at as EditableKind, b as AnnotationImportResult, bt as ReviewStatus, c as AnnotationCreatedEvent, ct as FilePickerProvider, d as AnnotationDraftApi, dt as HandleRole, et as CommentThread, f as AnnotationDraftChangedEvent, ft as ImageGhost, g as AnnotationFlags, gt as LinkNavItem, h as AnnotationFilter, ht as LineStyle, i as AnnotationAnchor, it as CreationDraft, j as AnnotationResyncedEvent, jt as annotationState, k as AnnotationResourceRole, kt as ToolDefaultsChangedEvent, l as AnnotationDeletedEvent, lt as FilePromptRequest, m as AnnotationExportSelection, mt as LineEndings, n as AfterCreateSettings, nt as CommentThreadReview, o as AnnotationCapability, ot as EditableKinds, p as AnnotationEditingChangedEvent, pt as LineEnding, q as AttachmentContent, qt as TextFormat, r as Annotation, rt as CommentsApi, s as AnnotationConfig, st as FieldValues, t as ANNOTATION_DEFAULTS, tt as CommentThreadChangedEvent, u as AnnotationDraft, ut as FlagKey, v as AnnotationImportDrop, vt as MeasurementIntent, w as AnnotationPosition, wt as StampPreviewProvider, x as AnnotationLinksApi, xt as SnapSettings, y as AnnotationImportOptions, yt as PdfLinkTarget, z as AnnotationTextApi, zt as PromptSourceSpec } from "./contract-CX4PcAoR.cjs";
3
+ import { f as AnnotationModel, n as AnnotationHostCapability } from "./host-contract-lQ1quQNY.cjs";
4
4
  import { MIN_DRAG, Placement, gesturePlacement, kindNamed, propertiesOf, resolveClickPlacement } from "@embedpdf/core-annotation";
5
5
  import { annotationKey } from "@embedpdf/core";
6
6
  //#region src/annotation.plugin.d.ts
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { widgetAppearanceOf } from "./authoring.js";
2
- import { $ as Color, A as AnnotationResources, At as AnnotationState, B as AnnotationTool, Bt as ResolvedGhost, C as AnnotationPatch, Ct as StampPlacement, D as AnnotationRef, Dt as ThreadDeleteResult, E as AnnotationProperty, Et as TextItem, F as AnnotationSelectionChangedEvent, Ft as AnnotationToolInput, G as ArmedStampInfo, Gt as ToolDefaultsFor, H as AnnotationTransfer, Ht as SelectionAuthoring, I as AnnotationSettings, It as DEFAULT_TOOLS, J as AttachmentFileSource, Jt as TextSelection, K as ArmedStampPreview, Kt as Face, L as AnnotationStampsApi, Lt as GhostPolicy, M as AnnotationRotationAnchor, Mt as AnnotationToken, N as AnnotationSelectionAnchor, Nt as ARMED_STAMP_TOOL_ID, O as AnnotationReorderedEvent, Ot as ToolDefaults, P as AnnotationSelectionApi, Pt as AnnotationToolDef, Q as ClickCreate, R as AnnotationSubtype, Rt as InkAuthoringOptions, S as AnnotationOption, St as StampInput, T as AnnotationProperties, Tt as TextAlign, U as AnnotationUpdatedEvent, Ut as StampSourceSpec, V as AnnotationToolsApi, Vt as ResolvedTool, W as AnnotationWriteFailedEvent, Wt as ToolAuthoringKind, X as BlendMode, Y as Behavior, Z as ChromeSettings, _ as AnnotationHoverChangedEvent, _t as MarkupSubtype, a as AnnotationBundle, at as EditableKind, b as AnnotationImportResult, bt as ReviewStatus, c as AnnotationCreatedEvent, ct as FilePickerProvider, d as AnnotationDraftApi, dt as HandleRole, et as CommentThread, f as AnnotationDraftChangedEvent, ft as ImageGhost, g as AnnotationFlags, gt as LinkNavItem, h as AnnotationFilter, ht as LineStyle, i as AnnotationAnchor, it as CreationDraft, j as AnnotationResyncedEvent, jt as annotationState, k as AnnotationResourceRole, kt as ToolDefaultsChangedEvent, l as AnnotationDeletedEvent, lt as FilePromptRequest, m as AnnotationExportSelection, mt as LineEndings, n as AfterCreateSettings, nt as CommentThreadReview, o as AnnotationCapability, ot as EditableKinds, p as AnnotationEditingChangedEvent, pt as LineEnding, q as AttachmentContent, qt as TextFormat, r as Annotation, rt as CommentsApi, s as AnnotationConfig, st as FieldValues, t as ANNOTATION_DEFAULTS, tt as CommentThreadChangedEvent, u as AnnotationDraft, ut as FlagKey, v as AnnotationImportDrop, vt as MeasurementIntent, w as AnnotationPosition, wt as StampPreviewProvider, x as AnnotationLinksApi, xt as SnapSettings, y as AnnotationImportOptions, yt as PdfLinkTarget, z as AnnotationTextApi, zt as PromptSourceSpec } from "./contract-BkjSlY96.js";
3
- import { f as AnnotationModel, n as AnnotationHostCapability } from "./host-contract-Cqp5sPYD.js";
2
+ import { $ as Color, A as AnnotationResources, At as AnnotationState, B as AnnotationTool, Bt as ResolvedGhost, C as AnnotationPatch, Ct as StampPlacement, D as AnnotationRef, Dt as ThreadDeleteResult, E as AnnotationProperty, Et as TextItem, F as AnnotationSelectionChangedEvent, Ft as AnnotationToolInput, G as ArmedStampInfo, Gt as ToolDefaultsFor, H as AnnotationTransfer, Ht as SelectionAuthoring, I as AnnotationSettings, It as DEFAULT_TOOLS, J as AttachmentFileSource, Jt as TextSelection, K as ArmedStampPreview, Kt as Face, L as AnnotationStampsApi, Lt as GhostPolicy, M as AnnotationRotationAnchor, Mt as AnnotationToken, N as AnnotationSelectionAnchor, Nt as ARMED_STAMP_TOOL_ID, O as AnnotationReorderedEvent, Ot as ToolDefaults, P as AnnotationSelectionApi, Pt as AnnotationToolDef, Q as ClickCreate, R as AnnotationSubtype, Rt as InkAuthoringOptions, S as AnnotationOption, St as StampInput, T as AnnotationProperties, Tt as TextAlign, U as AnnotationUpdatedEvent, Ut as StampSourceSpec, V as AnnotationToolsApi, Vt as ResolvedTool, W as AnnotationWriteFailedEvent, Wt as ToolAuthoringKind, X as BlendMode, Y as Behavior, Z as ChromeSettings, _ as AnnotationHoverChangedEvent, _t as MarkupSubtype, a as AnnotationBundle, at as EditableKind, b as AnnotationImportResult, bt as ReviewStatus, c as AnnotationCreatedEvent, ct as FilePickerProvider, d as AnnotationDraftApi, dt as HandleRole, et as CommentThread, f as AnnotationDraftChangedEvent, ft as ImageGhost, g as AnnotationFlags, gt as LinkNavItem, h as AnnotationFilter, ht as LineStyle, i as AnnotationAnchor, it as CreationDraft, j as AnnotationResyncedEvent, jt as annotationState, k as AnnotationResourceRole, kt as ToolDefaultsChangedEvent, l as AnnotationDeletedEvent, lt as FilePromptRequest, m as AnnotationExportSelection, mt as LineEndings, n as AfterCreateSettings, nt as CommentThreadReview, o as AnnotationCapability, ot as EditableKinds, p as AnnotationEditingChangedEvent, pt as LineEnding, q as AttachmentContent, qt as TextFormat, r as Annotation, rt as CommentsApi, s as AnnotationConfig, st as FieldValues, t as ANNOTATION_DEFAULTS, tt as CommentThreadChangedEvent, u as AnnotationDraft, ut as FlagKey, v as AnnotationImportDrop, vt as MeasurementIntent, w as AnnotationPosition, wt as StampPreviewProvider, x as AnnotationLinksApi, xt as SnapSettings, y as AnnotationImportOptions, yt as PdfLinkTarget, z as AnnotationTextApi, zt as PromptSourceSpec } from "./contract-D6a0ANBk.js";
3
+ import { f as AnnotationModel, n as AnnotationHostCapability } from "./host-contract-PNwb5DEw.js";
4
4
  import { annotationKey } from "@embedpdf/core";
5
5
  import { MIN_DRAG, Placement, gesturePlacement, kindNamed, propertiesOf, resolveClickPlacement } from "@embedpdf/core-annotation";
6
6
  //#region src/annotation.plugin.d.ts
package/dist/index.js CHANGED
@@ -196,7 +196,7 @@ function createComments(ctx, { store, authority, events }, threads, crud) {
196
196
  const root = threads.rootRefOf(ref);
197
197
  const thread = threads.threadOf(ref);
198
198
  const members = threads.memberRefsOf(thread);
199
- const blocked = members.filter((ref) => !authority.canDelete(ref));
199
+ const blocked = authority.blockersOf(root);
200
200
  if (blocked.length > 0) {
201
201
  announce(root, "deleted");
202
202
  return {
@@ -232,7 +232,7 @@ function createComments(ctx, { store, authority, events }, threads, crud) {
232
232
  canDelete: (ref) => authority.canDelete(ref),
233
233
  canDeleteThread: (ref) => {
234
234
  const thread = threads.index().byMember.get(annotationKey$1(ref)) ?? null;
235
- return thread !== null && threads.memberRefsOf(thread).every(authority.canDelete);
235
+ return thread !== null && authority.canDelete(thread.root.ref);
236
236
  }
237
237
  } } };
238
238
  }
@@ -1731,18 +1731,36 @@ function createAuthority(ctx, store) {
1731
1731
  const record = store.model().byId[annotationKey$1(ref)];
1732
1732
  return !!record && annotTransformable(record);
1733
1733
  };
1734
- const canDelete = (ref) => {
1735
- const record = store.model().byId[annotationKey$1(ref)];
1736
- return !!record && annotDeletable(record);
1737
- };
1734
+ /**
1735
+ * What keeps `ref` from being deleted; none when the delete goes through. Deleting an
1736
+ * annotation deletes what goes with it ({@link deletedWith}: its replies, review states,
1737
+ * grouped parts and popups), and the engine checks each of them. The annotation itself is
1738
+ * checked as anything deleted by hand is ({@link annotDeletable}); what goes with it is never
1739
+ * clicked itself, so only its lock and the session's right to delete it count: a review state
1740
+ * is hidden so that no viewer draws it, and it still goes with its thread.
1741
+ */
1742
+ const blockersOf = (ref) => {
1743
+ const model = store.model();
1744
+ const key = annotationKey$1(ref);
1745
+ if (!model.byId[key]) return [ref];
1746
+ return deletedWith(model.order.map((id) => model.byId[id]?.annotation).filter((annotation) => annotation?.page.objectNumber === ref.page.objectNumber), ref).filter((member) => {
1747
+ const memberRecord = model.byId[annotationKey$1(member.ref)];
1748
+ if (!memberRecord) return true;
1749
+ return annotationKey$1(member.ref) === key ? !annotDeletable(memberRecord) : !goesAlong(memberRecord);
1750
+ }).map((member) => member.ref);
1751
+ };
1752
+ const canDelete = (ref) => blockersOf(ref).length === 0;
1738
1753
  return {
1739
1754
  canRead,
1740
1755
  canCreate,
1741
1756
  canUpdate,
1742
1757
  canDelete,
1758
+ blockersOf,
1743
1759
  allowsMutation
1744
1760
  };
1745
1761
  }
1762
+ /** Deleted with the annotation it belongs to: unlocked, and the session's to delete. */
1763
+ const goesAlong = (record) => !record.annotation.locked && (record.authority?.delete ?? true);
1746
1764
  //#endregion
1747
1765
  //#region src/read/view.ts
1748
1766
  /**