@embedpdf/core-annotation 3.0.0-next.15 → 3.0.0-next.16

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 CHANGED
@@ -3903,7 +3903,8 @@ const groupOf = (annotation) => annotation.reply?.type === "group" ? (0, _embedp
3903
3903
  * lockedContents — `/Contents` text cannot change; geometry still can
3904
3904
  * print — include when printing (carried for the print pipeline)
3905
3905
  * noZoom/noRotate — screen-anchored body (see anchor.ts)
3906
- * invisible — legacy: hide unknown subtypes with no handler
3906
+ * invisible — hides only a type that isn't standard; meaningless on
3907
+ * a standard annotation
3907
3908
  */
3908
3909
  /** The `/F` every freshly drawn annotation starts with: `print` set (Acrobat
3909
3910
  * parity — without it the annotation silently disappears when printed). */
@@ -3920,11 +3921,20 @@ const mergeFlags = (base, patch) => ({
3920
3921
  ...patch
3921
3922
  });
3922
3923
  /**
3923
- * On-screen visibility. `hidden` beats everything; `noView` hides unless
3924
- * `toggleNoView` and the annotation is engaged — the spec says hover/selection,
3925
- * and v1 uses selection (the model tracks no hover).
3924
+ * Does `invisible` leave this annotation unpainted? Only when its type isn't a
3925
+ * standard one, which no handler draws (ISO 32000-2 12.5.3); on a standard
3926
+ * annotation the flag means nothing. The engine's renderer and flatten follow
3927
+ * the same rule. A type the engine doesn't model but PDFium knows (Sound,
3928
+ * Screen, 3D…) is standard, and so is Projection, which PDFium doesn't know.
3926
3929
  */
3927
- const viewable = (flags, engaged = false) => !flags.hidden && (!flags.noView || flags.toggleNoView && engaged);
3930
+ const hiddenByInvisibleFlag = (annotation) => annotation.invisible && annotation.subtype === "unsupported" && annotation.rawSubtypeCode === _embedpdf_engine_core_runtime.PdfAnnotationSubtypeCode.UNKNOWN && annotation.rawSubtypeName !== "Projection";
3931
+ /**
3932
+ * On-screen visibility. `hidden` beats everything, and `invisible` hides a type
3933
+ * that isn't standard; `noView` hides unless `toggleNoView` and the annotation
3934
+ * is engaged — the spec says hover/selection, and v1 uses selection (the model
3935
+ * tracks no hover).
3936
+ */
3937
+ const viewable = (annotation, engaged = false) => !annotation.hidden && !hiddenByInvisibleFlag(annotation) && (!annotation.noView || annotation.toggleNoView && engaged);
3928
3938
  /** Any pointer interaction (click-to-select, hover). ReadOnly kills it. */
3929
3939
  const interactive = (flags) => !flags.hidden && !flags.noView && !flags.readOnly;
3930
3940
  /** Interaction gate for a concrete annotation: widget kinds ignore `readOnly`
@@ -8805,20 +8815,29 @@ function textBoxes(model, page, view) {
8805
8815
  const out = [];
8806
8816
  for (const id of model.order) {
8807
8817
  const record = model.byId[id];
8808
- if (record.annotation.page.objectNumber !== pageObjectNumber || shapeOf(record.annotation).kind !== "text-box") continue;
8818
+ if (record.annotation.page.objectNumber !== pageObjectNumber) continue;
8809
8819
  if (!viewable(record.annotation, model.selected.includes(id))) continue;
8810
8820
  if (!textIsLive(model, id)) continue;
8811
- const geometry = effGeom(model, id, view);
8812
- if (geometry.kind !== "text-box") continue;
8813
- out.push({
8814
- id,
8815
- box: geometry.box,
8816
- editing: model.editing === id,
8817
- rot: geomRotation(geometry)
8818
- });
8821
+ const box = textBoxOf(model, id, view);
8822
+ if (box) out.push(box);
8819
8823
  }
8820
8824
  return out;
8821
8825
  }
8826
+ /** One free text's box, live or baked: a renderer that draws the box itself
8827
+ * shows its text in every state, as no /AP image is drawn under it. `null`
8828
+ * for a record that isn't a text box. */
8829
+ function textBoxOf(model, id, view) {
8830
+ const record = model.byId[id];
8831
+ if (!record || shapeOf(record.annotation).kind !== "text-box") return null;
8832
+ const geometry = effGeom(model, id, view);
8833
+ if (geometry.kind !== "text-box") return null;
8834
+ return {
8835
+ id,
8836
+ box: geometry.box,
8837
+ editing: model.editing === id,
8838
+ rot: geomRotation(geometry)
8839
+ };
8840
+ }
8822
8841
  /** The currently selected annotations as render items (live gesture applied) —
8823
8842
  * cross-page, for selection-aware toolbars (style + line-ending editing). */
8824
8843
  function selectedItems(model, view) {
@@ -9890,6 +9909,7 @@ exports.straightenInkStroke = straightenInkStroke;
9890
9909
  exports.styleAt = styleAt;
9891
9910
  exports.styleOf = styleOf;
9892
9911
  exports.textBoxFamily = textBoxFamily;
9912
+ exports.textBoxOf = textBoxOf;
9893
9913
  exports.textBoxes = textBoxes;
9894
9914
  exports.textOf = textOf;
9895
9915
  exports.textPlateInset = textPlateInset;