@embedpdf/plugin-form 3.2.0 → 3.3.0

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
@@ -582,8 +582,16 @@ function fieldsWithChangedValues(previous, next) {
582
582
  });
583
583
  }
584
584
  const valueEntryOf = (field) => "valueEntry" in field ? field.valueEntry : null;
585
- /** Whether a widget shows on screen: its `hidden` and `noView` flags hide it. */
586
- const shownOnScreen = (row) => !row.hidden && !row.noView;
585
+ /**
586
+ * Whether a widget's box has an area. One of no size is how a PDF keeps a field that shows
587
+ * nowhere: the field of a document timestamp, an invisible signature.
588
+ */
589
+ const hasArea = (row) => row.rect.width > 0 && row.rect.height > 0;
590
+ /**
591
+ * Whether a widget shows on screen: its `hidden` and `noView` flags hide it, and a box of no
592
+ * size has nothing to show. What doesn't show gets no control, and Tab doesn't stop at it.
593
+ */
594
+ const shownOnScreen = (row) => !row.hidden && !row.noView && hasArea(row);
587
595
  /** The widgets one page shows, from the form's widget rows. */
588
596
  function pageWidgetsOf(index, pageObjectNumber) {
589
597
  const widgets = {};
@@ -3083,7 +3091,8 @@ function createInterchange(ctx, services) {
3083
3091
  * its records and edits them with its tools: select, move, resize, restyle,
3084
3092
  * reorder, delete. Each edit comes back here as the form's ops, in the same
3085
3093
  * change as the rest of it. While the tool fills, nothing is lent, and the
3086
- * form layer draws and fills every widget.
3094
+ * form layer draws and fills every widget. A widget of no size is never lent:
3095
+ * nobody can see it, so nobody should be able to select it by hand.
3087
3096
  */
3088
3097
  const objectNumberOf = (ref) => ref.kind === "objectNumber" ? ref.objectNumber : -1;
3089
3098
  function createWidgetLender(ctx, { fields, design, pictures, looks }, copyOps) {
@@ -3092,8 +3101,8 @@ function createWidgetLender(ctx, { fields, design, pictures, looks }, copyOps) {
3092
3101
  fields.get().snapshot,
3093
3102
  fields.view().snapshot
3094
3103
  ], (lending, confirmed, shown) => lending && confirmed && shown ? {
3095
- confirmed: confirmed.widgets,
3096
- shown: shown.widgets
3104
+ confirmed: confirmed.widgets.filter(hasArea),
3105
+ shown: shown.widgets.filter(hasArea)
3097
3106
  } : null);
3098
3107
  /**
3099
3108
  * Deleted widgets, as the form's ops: a widget leaves its field