@embedpdf/plugin-annotation 2.14.0 → 2.14.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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/annotation-plugin.d.ts +25 -0
- package/dist/lib/helpers.d.ts +8 -0
- package/dist/lib/types.d.ts +21 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +27 -18
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +27 -18
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/annotation-container.d.ts +13 -1
- package/dist/shared/components/types.d.ts +12 -0
- package/dist/shared-preact/components/annotation-container.d.ts +13 -1
- package/dist/shared-preact/components/types.d.ts +12 -0
- package/dist/shared-react/components/annotation-container.d.ts +13 -1
- package/dist/shared-react/components/types.d.ts +12 -0
- package/dist/svelte/components/types.d.ts +12 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +31 -20
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/types.d.ts +12 -0
- package/dist/vue/components/annotation-container.vue.d.ts +12 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +57 -41
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/types.d.ts +12 -0
- package/package.json +12 -12
package/dist/vue/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
-
import { AnnotationPlugin, initialDocumentState, inferRotationCenterFromRects, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, LockModeType,
|
|
2
|
+
import { AnnotationPlugin, initialDocumentState, inferRotationCenterFromRects, generateCloudyRectanglePath, generateCloudyEllipsePath, patching, generateCloudyPolygonPath, LockModeType, hasNoViewFlag, hasHiddenFlag, resolveInteractionProp, getAnnotationsByPageIndex, getSelectedAnnotationIds, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
|
|
3
3
|
export * from "@embedpdf/plugin-annotation";
|
|
4
4
|
import { defineComponent, ref, watchEffect, openBlock, createElementBlock, normalizeStyle, createCommentVNode, toValue, watch, computed, shallowRef, toRaw, useSlots, createElementVNode, renderSlot, createBlock, Fragment, unref, normalizeProps, mergeProps, renderList, withCtx, resolveDynamicComponent, Teleport, toDisplayString, markRaw, provide, inject, onUnmounted, nextTick, createVNode, createSlots, guardReactiveProps, onMounted } from "vue";
|
|
5
5
|
import { getCounterRotation } from "@embedpdf/utils";
|
|
@@ -144,6 +144,8 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
144
144
|
lockAspectRatio: { type: Boolean, default: false },
|
|
145
145
|
vertexConfig: {},
|
|
146
146
|
selectionMenu: {},
|
|
147
|
+
structurallyLocked: { type: Boolean, default: false },
|
|
148
|
+
contentLocked: { type: Boolean, default: false },
|
|
147
149
|
outlineOffset: { default: 1 },
|
|
148
150
|
onDoubleClick: {},
|
|
149
151
|
onSelect: {},
|
|
@@ -317,7 +319,9 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
317
319
|
const menuContext = computed(() => ({
|
|
318
320
|
type: "annotation",
|
|
319
321
|
annotation: props.trackedAnnotation,
|
|
320
|
-
pageIndex: props.pageIndex
|
|
322
|
+
pageIndex: props.pageIndex,
|
|
323
|
+
structurallyLocked: props.structurallyLocked,
|
|
324
|
+
contentLocked: props.contentLocked
|
|
321
325
|
}));
|
|
322
326
|
const menuPlacement = computed(() => {
|
|
323
327
|
const effectiveAngle = ((annotationRotation.value + effectivePageRotation.value * 90) % 360 + 360) % 360;
|
|
@@ -4264,21 +4268,25 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4264
4268
|
},
|
|
4265
4269
|
{ immediate: true }
|
|
4266
4270
|
);
|
|
4267
|
-
const resolvedAnnotations = computed(
|
|
4268
|
-
|
|
4271
|
+
const resolvedAnnotations = computed(() => {
|
|
4272
|
+
void lockedMode.value;
|
|
4273
|
+
return annotations.value.map((annotation) => {
|
|
4269
4274
|
var _a;
|
|
4270
4275
|
const renderer = resolveRenderer(annotation);
|
|
4271
4276
|
if (!renderer) return null;
|
|
4277
|
+
if (hasNoViewFlag(annotation.object)) return null;
|
|
4278
|
+
if (hasHiddenFlag(annotation.object)) return null;
|
|
4272
4279
|
const tool = ((_a = annotationProvides.value) == null ? void 0 : _a.findToolForAnnotation(annotation.object)) ?? null;
|
|
4273
|
-
const
|
|
4274
|
-
const
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
+
const nonInteractive = annotationProvides.value ? !annotationProvides.value.isAnnotationInteractive(annotation.object) : false;
|
|
4281
|
+
const structurallyLocked = annotationProvides.value ? annotationProvides.value.isAnnotationStructurallyLocked(annotation.object) : false;
|
|
4282
|
+
const contentLocked = annotationProvides.value ? annotationProvides.value.isAnnotationContentLocked(annotation.object) : false;
|
|
4283
|
+
if (nonInteractive && renderer.hiddenWhenLocked) return null;
|
|
4284
|
+
return { annotation, renderer, tool, nonInteractive, structurallyLocked, contentLocked };
|
|
4285
|
+
}).filter((v) => v !== null);
|
|
4286
|
+
});
|
|
4287
|
+
const getFinalDraggable = (annotation, renderer, structurallyLocked) => {
|
|
4280
4288
|
var _a;
|
|
4281
|
-
if (
|
|
4289
|
+
if (structurallyLocked) return false;
|
|
4282
4290
|
const tool = (_a = annotationProvides.value) == null ? void 0 : _a.findToolForAnnotation(annotation.object);
|
|
4283
4291
|
const defaults = renderer.interactionDefaults;
|
|
4284
4292
|
const isEditing = editingId.value === annotation.object.id;
|
|
@@ -4289,9 +4297,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4289
4297
|
);
|
|
4290
4298
|
return renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
|
|
4291
4299
|
};
|
|
4292
|
-
const getResolvedResizable = (annotation, renderer,
|
|
4300
|
+
const getResolvedResizable = (annotation, renderer, structurallyLocked) => {
|
|
4293
4301
|
var _a, _b;
|
|
4294
|
-
if (
|
|
4302
|
+
if (structurallyLocked) return false;
|
|
4295
4303
|
const tool = (_a = annotationProvides.value) == null ? void 0 : _a.findToolForAnnotation(annotation.object);
|
|
4296
4304
|
return resolveInteractionProp(
|
|
4297
4305
|
tool == null ? void 0 : tool.interaction.isResizable,
|
|
@@ -4308,9 +4316,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4308
4316
|
((_b = renderer.interactionDefaults) == null ? void 0 : _b.lockAspectRatio) ?? false
|
|
4309
4317
|
);
|
|
4310
4318
|
};
|
|
4311
|
-
const getResolvedRotatable = (annotation, renderer,
|
|
4319
|
+
const getResolvedRotatable = (annotation, renderer, structurallyLocked) => {
|
|
4312
4320
|
var _a, _b;
|
|
4313
|
-
if (
|
|
4321
|
+
if (structurallyLocked) return false;
|
|
4314
4322
|
const tool = (_a = annotationProvides.value) == null ? void 0 : _a.findToolForAnnotation(annotation.object);
|
|
4315
4323
|
return resolveInteractionProp(
|
|
4316
4324
|
tool == null ? void 0 : tool.interaction.isRotatable,
|
|
@@ -4318,9 +4326,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4318
4326
|
((_b = renderer.interactionDefaults) == null ? void 0 : _b.isRotatable) ?? false
|
|
4319
4327
|
);
|
|
4320
4328
|
};
|
|
4321
|
-
const getSelectionMenu = (annotation, renderer,
|
|
4329
|
+
const getSelectionMenu = (annotation, renderer, nonInteractive) => {
|
|
4322
4330
|
var _a;
|
|
4323
|
-
if (
|
|
4331
|
+
if (nonInteractive) return void 0;
|
|
4324
4332
|
if ((_a = renderer.hideSelectionMenu) == null ? void 0 : _a.call(renderer, annotation.object)) return void 0;
|
|
4325
4333
|
if (isMultiSelected.value) return void 0;
|
|
4326
4334
|
return props.selectionMenu;
|
|
@@ -4328,8 +4336,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4328
4336
|
const noopSelect = (e) => {
|
|
4329
4337
|
e.stopPropagation();
|
|
4330
4338
|
};
|
|
4331
|
-
const getOnSelect = (annotation, renderer,
|
|
4332
|
-
if (
|
|
4339
|
+
const getOnSelect = (annotation, renderer, nonInteractive) => {
|
|
4340
|
+
if (nonInteractive) return noopSelect;
|
|
4333
4341
|
if (renderer.selectOverride) {
|
|
4334
4342
|
const selectHelpers = {
|
|
4335
4343
|
defaultSelect: handleClick,
|
|
@@ -4452,8 +4460,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4452
4460
|
const allSelected = annotationProvides.value.getSelectedAnnotations();
|
|
4453
4461
|
return allSelected.every((ta) => ta.object.pageIndex === props.pageIndex);
|
|
4454
4462
|
});
|
|
4455
|
-
const getOnDoubleClick = (renderer, annotation,
|
|
4456
|
-
if (
|
|
4463
|
+
const getOnDoubleClick = (renderer, annotation, nonInteractive, contentLocked) => {
|
|
4464
|
+
if (nonInteractive || contentLocked) return void 0;
|
|
4457
4465
|
if (!renderer.onDoubleClick) return void 0;
|
|
4458
4466
|
return (e) => {
|
|
4459
4467
|
e.stopPropagation();
|
|
@@ -4465,9 +4473,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4465
4473
|
annotation.object.blendMode ?? renderer.defaultBlendMode ?? PdfBlendMode.Normal
|
|
4466
4474
|
);
|
|
4467
4475
|
};
|
|
4468
|
-
const getAppearance = (annotation, renderer,
|
|
4476
|
+
const getAppearance = (annotation, renderer, nonInteractive) => {
|
|
4469
4477
|
var _a, _b;
|
|
4470
|
-
if (
|
|
4478
|
+
if (nonInteractive && renderer.renderLocked) return void 0;
|
|
4471
4479
|
const tool = (_a = annotationProvides.value) == null ? void 0 : _a.findToolForAnnotation(annotation.object);
|
|
4472
4480
|
const useAP = ((_b = tool == null ? void 0 : tool.behavior) == null ? void 0 : _b.useAppearanceStream) ?? renderer.useAppearanceStream ?? true;
|
|
4473
4481
|
return useAP ? getAppearanceForAnnotation(annotation) : void 0;
|
|
@@ -4484,37 +4492,45 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4484
4492
|
});
|
|
4485
4493
|
return (_ctx, _cache) => {
|
|
4486
4494
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
4487
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(resolvedAnnotations.value, ({
|
|
4495
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(resolvedAnnotations.value, ({
|
|
4496
|
+
annotation,
|
|
4497
|
+
renderer,
|
|
4498
|
+
nonInteractive,
|
|
4499
|
+
structurallyLocked,
|
|
4500
|
+
contentLocked
|
|
4501
|
+
}) => {
|
|
4488
4502
|
var _a;
|
|
4489
4503
|
return openBlock(), createBlock(_sfc_main$Q, mergeProps({
|
|
4490
4504
|
key: annotation.object.id,
|
|
4491
4505
|
trackedAnnotation: annotation,
|
|
4492
|
-
isSelected:
|
|
4493
|
-
isEditing:
|
|
4494
|
-
isMultiSelected:
|
|
4495
|
-
isDraggable: getFinalDraggable(annotation, renderer,
|
|
4496
|
-
isResizable: getResolvedResizable(annotation, renderer,
|
|
4506
|
+
isSelected: nonInteractive ? false : allSelectedIds.value.includes(annotation.object.id),
|
|
4507
|
+
isEditing: nonInteractive ? false : editingId.value === annotation.object.id,
|
|
4508
|
+
isMultiSelected: nonInteractive ? false : isMultiSelected.value,
|
|
4509
|
+
isDraggable: getFinalDraggable(annotation, renderer, structurallyLocked),
|
|
4510
|
+
isResizable: getResolvedResizable(annotation, renderer, structurallyLocked),
|
|
4497
4511
|
lockAspectRatio: getResolvedLockAspectRatio(annotation, renderer),
|
|
4498
|
-
isRotatable: getResolvedRotatable(annotation, renderer,
|
|
4499
|
-
vertexConfig:
|
|
4500
|
-
selectionMenu: getSelectionMenu(annotation, renderer,
|
|
4501
|
-
|
|
4502
|
-
|
|
4512
|
+
isRotatable: getResolvedRotatable(annotation, renderer, structurallyLocked),
|
|
4513
|
+
vertexConfig: structurallyLocked ? void 0 : renderer.vertexConfig,
|
|
4514
|
+
selectionMenu: getSelectionMenu(annotation, renderer, nonInteractive),
|
|
4515
|
+
structurallyLocked,
|
|
4516
|
+
contentLocked,
|
|
4517
|
+
onSelect: getOnSelect(annotation, renderer, nonInteractive),
|
|
4518
|
+
onDoubleClick: getOnDoubleClick(renderer, annotation, nonInteractive, contentLocked),
|
|
4503
4519
|
zIndex: renderer.zIndex,
|
|
4504
4520
|
blendMode: getBlendMode(annotation, renderer),
|
|
4505
4521
|
style: (_a = renderer.containerStyle) == null ? void 0 : _a.call(renderer, annotation.object),
|
|
4506
|
-
appearance: getAppearance(annotation, renderer,
|
|
4522
|
+
appearance: getAppearance(annotation, renderer, nonInteractive)
|
|
4507
4523
|
}, { ref_for: true }, containerProps.value), createSlots({
|
|
4508
4524
|
default: withCtx(({ annotation: currentObject, appearanceActive }) => [
|
|
4509
|
-
(openBlock(), createBlock(resolveDynamicComponent(
|
|
4525
|
+
(openBlock(), createBlock(resolveDynamicComponent(nonInteractive && renderer.renderLocked ? renderer.renderLocked : renderer.component), {
|
|
4510
4526
|
annotation,
|
|
4511
4527
|
currentObject,
|
|
4512
|
-
isSelected:
|
|
4513
|
-
isEditing:
|
|
4528
|
+
isSelected: nonInteractive ? false : allSelectedIds.value.includes(annotation.object.id),
|
|
4529
|
+
isEditing: nonInteractive ? false : editingId.value === annotation.object.id,
|
|
4514
4530
|
scale: __props.scale,
|
|
4515
4531
|
pageIndex: __props.pageIndex,
|
|
4516
4532
|
documentId: __props.documentId,
|
|
4517
|
-
onClick:
|
|
4533
|
+
onClick: nonInteractive ? void 0 : getOnSelect(annotation, renderer, nonInteractive),
|
|
4518
4534
|
appearanceActive
|
|
4519
4535
|
}, null, 8, ["annotation", "currentObject", "isSelected", "isEditing", "scale", "pageIndex", "documentId", "onClick", "appearanceActive"]))
|
|
4520
4536
|
]),
|
|
@@ -4536,7 +4552,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4536
4552
|
]),
|
|
4537
4553
|
key: "0"
|
|
4538
4554
|
} : void 0
|
|
4539
|
-
]), 1040, ["trackedAnnotation", "isSelected", "isEditing", "isMultiSelected", "isDraggable", "isResizable", "lockAspectRatio", "isRotatable", "vertexConfig", "selectionMenu", "onSelect", "onDoubleClick", "zIndex", "blendMode", "style", "appearance"]);
|
|
4555
|
+
]), 1040, ["trackedAnnotation", "isSelected", "isEditing", "isMultiSelected", "isDraggable", "isResizable", "lockAspectRatio", "isRotatable", "vertexConfig", "selectionMenu", "structurallyLocked", "contentLocked", "onSelect", "onDoubleClick", "zIndex", "blendMode", "style", "appearance"]);
|
|
4540
4556
|
}), 128)),
|
|
4541
4557
|
allSelectedOnSamePage.value && selectedAnnotationsOnPage.value.length >= 2 ? (openBlock(), createBlock(_sfc_main$P, {
|
|
4542
4558
|
key: 0,
|