@embedpdf/plugin-form 3.0.0-next.12 → 3.0.0-next.14
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/contract/host.d.cts +1 -1
- package/dist/contract/host.d.ts +1 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +3 -3
- package/dist/contract.d.ts +3 -3
- package/dist/contract.js.map +1 -1
- package/dist/index.cjs +65 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -27
- package/dist/index.d.ts +3 -27
- package/dist/index.js +65 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/scripting.d.cts +1 -1
- package/dist/scripting.d.ts +1 -1
- package/dist/{types-NGRZjJNj.d.ts → types-Bpc32Qmx.d.cts} +56 -4
- package/dist/types-C1uIIYfn.cjs.map +1 -1
- package/dist/{types-CnUW7z1W.d.cts → types-DRirhZKr.d.ts} +56 -4
- package/dist/types-DkQmmcTG.js.map +1 -1
- package/package.json +9 -9
package/dist/contract/host.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FormHostCapability, c as FormToken } from "../types-
|
|
1
|
+
import { a as FormHostCapability, c as FormToken } from "../types-Bpc32Qmx.cjs";
|
|
2
2
|
export { type FormHostCapability, FormToken };
|
package/dist/contract/host.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FormHostCapability, c as FormToken } from "../types-
|
|
1
|
+
import { a as FormHostCapability, c as FormToken } from "../types-DRirhZKr.js";
|
|
2
2
|
export { type FormHostCapability, FormToken };
|
package/dist/contract.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.cjs","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\nexport type {
|
|
1
|
+
{"version":3,"file":"contract.cjs","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n WidgetHit,\n} from './types';\nexport type {\n FormFieldDTO,\n FormFieldPatch,\n FormFieldRef,\n WidgetAppearance,\n} from '@embedpdf/engine-core/runtime';\n"],"mappings":";;AAMA,MAAa,0CAAYA,CAAAA,CAAAA"}
|
package/dist/contract.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as FillItem, b as WidgetHit, d as PlacedField, f as WidgetActivationResult, i as FormCommitStatus, l as FormUiEffect, n as FormCapability, o as FormPluginOptions, r as FormCommitResult, s as FormState, t as FormAction, u as PlaceFieldInput, v as Box, y as FieldKey } from "./types-Bpc32Qmx.cjs";
|
|
2
2
|
import { CapabilityToken } from "@embedpdf/core";
|
|
3
|
-
import { FormFieldDTO, FormFieldPatch, WidgetAppearance } from "@embedpdf/engine-core/runtime";
|
|
3
|
+
import { FormFieldDTO, FormFieldPatch, FormFieldRef, WidgetAppearance } from "@embedpdf/engine-core/runtime";
|
|
4
4
|
//#region src/contract.d.ts
|
|
5
5
|
declare const FormToken: CapabilityToken<FormCapability>;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance };
|
|
7
|
+
export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormFieldRef, type FormPluginOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance, type WidgetHit };
|
|
8
8
|
//# sourceMappingURL=contract.d.cts.map
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as FillItem, b as WidgetHit, d as PlacedField, f as WidgetActivationResult, i as FormCommitStatus, l as FormUiEffect, n as FormCapability, o as FormPluginOptions, r as FormCommitResult, s as FormState, t as FormAction, u as PlaceFieldInput, v as Box, y as FieldKey } from "./types-DRirhZKr.js";
|
|
2
2
|
import { CapabilityToken } from "@embedpdf/core";
|
|
3
|
-
import { FormFieldDTO, FormFieldPatch, WidgetAppearance } from "@embedpdf/engine-core/runtime";
|
|
3
|
+
import { FormFieldDTO, FormFieldPatch, FormFieldRef, WidgetAppearance } from "@embedpdf/engine-core/runtime";
|
|
4
4
|
//#region src/contract.d.ts
|
|
5
5
|
declare const FormToken: CapabilityToken<FormCapability>;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormPluginOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance };
|
|
7
|
+
export { type Box, type FieldKey, type FillItem, type FormAction, type FormCapability, type FormCommitResult, type FormCommitStatus, type FormFieldDTO, type FormFieldPatch, type FormFieldRef, type FormPluginOptions, type FormState, FormToken, type FormUiEffect, type PlaceFieldInput, type PlacedField, type WidgetActivationResult, type WidgetAppearance, type WidgetHit };
|
|
8
8
|
//# sourceMappingURL=contract.d.ts.map
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n} from './types';\nexport type {
|
|
1
|
+
{"version":3,"file":"contract.js","names":["FormHostToken"],"sources":["../src/contract.ts"],"sourcesContent":["/** Public form capability protocol without the form engine implementation. */\nimport type { CapabilityToken } from '@embedpdf/core';\n\nimport { FormToken as FormHostToken } from './types';\nimport type { FormCapability } from './types';\n\nexport const FormToken = FormHostToken as unknown as CapabilityToken<FormCapability>;\nexport type {\n Box,\n FieldKey,\n FillItem,\n FormAction,\n FormCapability,\n FormCommitResult,\n FormCommitStatus,\n FormPluginOptions,\n FormState,\n FormUiEffect,\n PlacedField,\n PlaceFieldInput,\n WidgetActivationResult,\n WidgetHit,\n} from './types';\nexport type {\n FormFieldDTO,\n FormFieldPatch,\n FormFieldRef,\n WidgetAppearance,\n} from '@embedpdf/engine-core/runtime';\n"],"mappings":";;AAMA,MAAa,YAAYA"}
|
package/dist/index.cjs
CHANGED
|
@@ -198,6 +198,29 @@ const fieldForWidget = (model, annotObjectNumber) => {
|
|
|
198
198
|
const i = model.byWidget[annotObjectNumber];
|
|
199
199
|
return i === void 0 ? null : model.snapshot?.fields[i] ?? null;
|
|
200
200
|
};
|
|
201
|
+
const contains = (b, p) => p.x >= b.x && p.x <= b.x + b.width && p.y >= b.y && p.y <= b.y + b.height;
|
|
202
|
+
/**
|
|
203
|
+
* The widget under a content-space point, from the model's loaded geometry
|
|
204
|
+
* for that page (null when the page's geometry has not arrived, or nothing
|
|
205
|
+
* is there). Nested widgets resolve to the smallest containing box.
|
|
206
|
+
*/
|
|
207
|
+
const widgetAt = (model, pageObjectNumber, point) => {
|
|
208
|
+
const geom = model.geom[pageObjectNumber];
|
|
209
|
+
if (!geom) return null;
|
|
210
|
+
let best = null;
|
|
211
|
+
for (const [key, box] of Object.entries(geom)) {
|
|
212
|
+
if (!contains(box, point)) continue;
|
|
213
|
+
const annotObjectNumber = Number(key);
|
|
214
|
+
const field = fieldForWidget(model, annotObjectNumber);
|
|
215
|
+
if (!field) continue;
|
|
216
|
+
if (!best || box.width * box.height < best.box.width * best.box.height) best = {
|
|
217
|
+
annotObjectNumber,
|
|
218
|
+
field,
|
|
219
|
+
box
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return best;
|
|
223
|
+
};
|
|
201
224
|
//#endregion
|
|
202
225
|
//#region src/core/fill-items.ts
|
|
203
226
|
const ZERO_BOX = {
|
|
@@ -211,7 +234,7 @@ const ZERO_BOX = {
|
|
|
211
234
|
* caller: the page projection reads the model's widget geometry; a consumer
|
|
212
235
|
* that already owns a live box (the annotation plane's RenderItem) passes it —
|
|
213
236
|
* or nothing, when only the semantics matter. Null for families with no fill
|
|
214
|
-
* control (
|
|
237
|
+
* control (unknown: rendered by the annotation plane only).
|
|
215
238
|
*/
|
|
216
239
|
function projectWidget(model, field, annotObjectNumber, box = ZERO_BOX) {
|
|
217
240
|
const key = fieldKeyOf(field);
|
|
@@ -274,6 +297,11 @@ function projectWidget(model, field, annotObjectNumber, box = ZERO_BOX) {
|
|
|
274
297
|
...base,
|
|
275
298
|
control: "button"
|
|
276
299
|
};
|
|
300
|
+
case "signature": return {
|
|
301
|
+
...base,
|
|
302
|
+
control: "signature",
|
|
303
|
+
signed: field.valueEntry.kind !== "none"
|
|
304
|
+
};
|
|
277
305
|
default: return null;
|
|
278
306
|
}
|
|
279
307
|
}
|
|
@@ -414,6 +442,26 @@ function createFormCapability(ctx, options = {}) {
|
|
|
414
442
|
geomLoading.delete(pon);
|
|
415
443
|
});
|
|
416
444
|
};
|
|
445
|
+
const widgetAt$1 = (pon, point) => {
|
|
446
|
+
const m = model();
|
|
447
|
+
ensureGeom(pon);
|
|
448
|
+
if (m.geom[pon]) return widgetAt(m, pon, point);
|
|
449
|
+
if (!annotationHost) return null;
|
|
450
|
+
let best = null;
|
|
451
|
+
for (const item of annotationHost.pageItems(pon)) {
|
|
452
|
+
if (!item.subtype.startsWith("widget") || item.ref?.kind !== "objectNumber") continue;
|
|
453
|
+
const box = item.box;
|
|
454
|
+
if (!(point.x >= box.x && point.x <= box.x + box.width && point.y >= box.y && point.y <= box.y + box.height)) continue;
|
|
455
|
+
const field = fieldForWidget(m, item.ref.annotObjectNumber);
|
|
456
|
+
if (!field) continue;
|
|
457
|
+
if (!best || box.width * box.height < best.box.width * best.box.height) best = {
|
|
458
|
+
annotObjectNumber: item.ref.annotObjectNumber,
|
|
459
|
+
field,
|
|
460
|
+
box
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
return best;
|
|
464
|
+
};
|
|
417
465
|
const fuseFill = (item, fillable) => item === null || fillable || item.disabled ? item : {
|
|
418
466
|
...item,
|
|
419
467
|
disabled: true
|
|
@@ -762,6 +810,7 @@ function createFormCapability(ctx, options = {}) {
|
|
|
762
810
|
ensureGeom,
|
|
763
811
|
field: (key) => fieldByKey(model(), key),
|
|
764
812
|
fieldForWidget: (annotObjectNumber) => fieldForWidget(model(), annotObjectNumber),
|
|
813
|
+
widgetAt: widgetAt$1,
|
|
765
814
|
setText: (key, value) => write(key, {
|
|
766
815
|
type: "text",
|
|
767
816
|
value
|
|
@@ -980,6 +1029,10 @@ function registerFormEffects(ctx) {
|
|
|
980
1029
|
refresh();
|
|
981
1030
|
return;
|
|
982
1031
|
}
|
|
1032
|
+
if (event.type === "document.versioned" || event.type === "signature.completed") {
|
|
1033
|
+
refresh();
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
983
1036
|
if (!event.type.startsWith("form.") || !("origin" in event)) return;
|
|
984
1037
|
const structural = STRUCTURAL.has(event.type);
|
|
985
1038
|
if (event.origin.kind !== "remote" && !structural) return;
|
|
@@ -1064,6 +1117,17 @@ const FORM_TOOLS = [
|
|
|
1064
1117
|
fontSize: 12
|
|
1065
1118
|
},
|
|
1066
1119
|
cursor: "crosshair"
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
id: "form-signature",
|
|
1123
|
+
family: "signature",
|
|
1124
|
+
visualKind: "widget-box",
|
|
1125
|
+
clickCreate: {
|
|
1126
|
+
width: 160,
|
|
1127
|
+
height: 48
|
|
1128
|
+
},
|
|
1129
|
+
defaults: FIELD_CHROME,
|
|
1130
|
+
cursor: "crosshair"
|
|
1067
1131
|
}
|
|
1068
1132
|
];
|
|
1069
1133
|
const FORM_TOOL_BY_ID = new Map(FORM_TOOLS.map((t) => [t.id, t]));
|