@tobyt/expo-pdf-markup 2.0.0 → 2.1.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/CHANGELOG.md +15 -0
- package/README.md +58 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationModel.kt +12 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationSerializer.kt +92 -15
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationsChangeEmitter.kt +31 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ExpoPdfMarkupModule.kt +4 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ExpoPdfMarkupView.kt +10 -13
- package/build/ExpoPdfMarkup.types.d.ts +24 -0
- package/build/ExpoPdfMarkup.types.d.ts.map +1 -1
- package/build/ExpoPdfMarkup.types.js.map +1 -1
- package/build/ExpoPdfMarkupView.web.d.ts.map +1 -1
- package/build/ExpoPdfMarkupView.web.js +5 -5
- package/build/ExpoPdfMarkupView.web.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/parseAnnotations.d.ts +11 -0
- package/build/parseAnnotations.d.ts.map +1 -0
- package/build/parseAnnotations.js +49 -0
- package/build/parseAnnotations.js.map +1 -0
- package/build/web/annotationUtils.d.ts +12 -3
- package/build/web/annotationUtils.d.ts.map +1 -1
- package/build/web/annotationUtils.js +57 -12
- package/build/web/annotationUtils.js.map +1 -1
- package/fixtures/annotations-v1-array.json +124 -0
- package/fixtures/ink-cleanup-expected-array.json +95 -0
- package/fixtures/ink-cleanup-expected-object.json +95 -0
- package/fixtures/ink-cleanup-input.json +99 -0
- package/ios/AnnotationModels.swift +159 -0
- package/ios/AnnotationSerializer.swift +4 -2
- package/ios/ExpoPdfMarkupModule.swift +4 -0
- package/ios/ExpoPdfMarkupView.swift +8 -2
- package/ios/Tests/AnnotationCoordinateTests.swift +87 -0
- package/ios/Tests/AnnotationSerializerTests.swift +158 -1
- package/ios/Tests/BookModeTests.swift +11 -7
- package/ios/Tests/ExpoPdfMarkupViewTests.swift +122 -0
- package/package.json +40 -25
- package/src/ExpoPdfMarkup.types.ts +26 -0
- package/src/ExpoPdfMarkupView.web.tsx +5 -4
- package/src/index.ts +1 -0
- package/src/parseAnnotations.ts +52 -0
- package/src/web/annotationUtils.ts +70 -11
- package/docs/agents/domain.md +0 -51
- package/docs/agents/issue-tracker.md +0 -46
- package/docs/agents/triage-labels.md +0 -15
- package/tsconfig.test.json +0 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseAnnotations } from '../parseAnnotations';
|
|
1
2
|
// ---------------------------------------------------------------------------
|
|
2
3
|
// Coordinate transforms
|
|
3
4
|
// ---------------------------------------------------------------------------
|
|
@@ -288,26 +289,70 @@ export function drawAnnotationsOnCanvas(ctx, annotations, pageIndex, meta, optio
|
|
|
288
289
|
// ---------------------------------------------------------------------------
|
|
289
290
|
// Serialization
|
|
290
291
|
// ---------------------------------------------------------------------------
|
|
291
|
-
|
|
292
|
+
/** Forgiving variant of the public parser: malformed input becomes an empty set. */
|
|
293
|
+
export function parseAnnotationsOrEmpty(json) {
|
|
292
294
|
if (!json)
|
|
293
295
|
return { version: 1, annotations: [] };
|
|
296
|
+
let data;
|
|
294
297
|
try {
|
|
295
|
-
|
|
296
|
-
if (!Array.isArray(data?.annotations))
|
|
297
|
-
return { version: 1, annotations: [] };
|
|
298
|
-
// Deduplicate by id — last wins
|
|
299
|
-
const seen = new Map();
|
|
300
|
-
for (const a of data.annotations) {
|
|
301
|
-
seen.set(a.id, a);
|
|
302
|
-
}
|
|
303
|
-
return { version: 1, annotations: Array.from(seen.values()) };
|
|
298
|
+
data = parseAnnotations(json);
|
|
304
299
|
}
|
|
305
300
|
catch {
|
|
306
301
|
return { version: 1, annotations: [] };
|
|
307
302
|
}
|
|
303
|
+
// Deduplicate by id — last wins
|
|
304
|
+
const seen = new Map();
|
|
305
|
+
for (const a of data.annotations) {
|
|
306
|
+
seen.set(a.id, a);
|
|
307
|
+
}
|
|
308
|
+
return { version: 1, annotations: Array.from(seen.values()) };
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Round a coordinate to the nearest 0.1 pt, matching the iOS and Android writers:
|
|
312
|
+
* scale by 10 in double precision, round half away from zero, divide by 10.
|
|
313
|
+
* Negative zero becomes zero so it is written as `0`.
|
|
314
|
+
*/
|
|
315
|
+
function roundInkCoordinate(value) {
|
|
316
|
+
const scaled = value * 10;
|
|
317
|
+
const rounded = Math.sign(scaled) * Math.round(Math.abs(scaled));
|
|
318
|
+
return rounded / 10 + 0;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Round each ink point to 0.1 pt and drop consecutive duplicates (compared after
|
|
322
|
+
* rounding). A stroke that collapses to one point keeps two identical points so it
|
|
323
|
+
* still draws as a dot; strokes that started with fewer points are left that short.
|
|
324
|
+
*/
|
|
325
|
+
function cleanUpInkStroke(stroke) {
|
|
326
|
+
const cleaned = [];
|
|
327
|
+
for (const point of stroke) {
|
|
328
|
+
const rounded = { x: roundInkCoordinate(point.x), y: roundInkCoordinate(point.y) };
|
|
329
|
+
const previous = cleaned[cleaned.length - 1];
|
|
330
|
+
if (previous && previous.x === rounded.x && previous.y === rounded.y)
|
|
331
|
+
continue;
|
|
332
|
+
cleaned.push(rounded);
|
|
333
|
+
}
|
|
334
|
+
if (stroke.length >= 2 && cleaned.length === 1) {
|
|
335
|
+
cleaned.push({ ...cleaned[0] });
|
|
336
|
+
}
|
|
337
|
+
return cleaned;
|
|
308
338
|
}
|
|
309
|
-
|
|
310
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Write an annotation set. Ink points are cleaned up here, and only here: in memory
|
|
341
|
+
* they keep full precision. Bounds and every non-ink field are written unchanged.
|
|
342
|
+
*/
|
|
343
|
+
export function serializeAnnotations(data, { inkPointFormat = 'object' } = {}) {
|
|
344
|
+
const writeStroke = (stroke) => {
|
|
345
|
+
const cleaned = cleanUpInkStroke(stroke);
|
|
346
|
+
return inkPointFormat === 'array'
|
|
347
|
+
? cleaned.map((p) => [p.x, p.y])
|
|
348
|
+
: cleaned;
|
|
349
|
+
};
|
|
350
|
+
return JSON.stringify({
|
|
351
|
+
...data,
|
|
352
|
+
annotations: data.annotations.map((annotation) => annotation.type === 'ink'
|
|
353
|
+
? { ...annotation, paths: (annotation.paths ?? []).map(writeStroke) }
|
|
354
|
+
: annotation),
|
|
355
|
+
});
|
|
311
356
|
}
|
|
312
357
|
export function newAnnotationId() {
|
|
313
358
|
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotationUtils.js","sourceRoot":"","sources":["../../src/web/annotationUtils.ts"],"names":[],"mappings":"AAQA,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E,iEAAiE;AACjE,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,OAAe,EACf,KAAa,EACb,UAAkB;IAElB,OAAO;QACL,CAAC,EAAE,OAAO,GAAG,KAAK;QAClB,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,KAAK;KAChC,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,IAAY,EACZ,KAAa,EACb,UAAkB;IAElB,OAAO;QACL,CAAC,EAAE,IAAI,GAAG,KAAK;QACf,CAAC,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,KAAK;KAC/B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAwB,EACxB,KAAa,EACb,UAAkB;IAElB,OAAO;QACL,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,KAAK;QACnB,CAAC,EAAE,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK;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AC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAoB,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QAC9E,gCAAgC;QAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAqB;IACxD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC7E,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type {\n Annotation,\n AnnotationBounds,\n AnnotationPoint,\n AnnotationsData,\n} from '../ExpoPdfMarkup.types';\nimport type { PdfPageMeta } from './types';\n\n// ---------------------------------------------------------------------------\n// Coordinate transforms\n// ---------------------------------------------------------------------------\n\n/** Convert canvas pixel coords → PDF user-space coords (y-up) */\nexport function canvasToPdf(\n canvasX: number,\n canvasY: number,\n scale: number,\n pageHeight: number\n): AnnotationPoint {\n return {\n x: canvasX / scale,\n y: pageHeight - canvasY / scale,\n };\n}\n\n/** Convert PDF user-space coords (y-up) → canvas pixel coords */\nexport function pdfToCanvas(\n pdfX: number,\n pdfY: number,\n scale: number,\n pageHeight: number\n): { x: number; y: number } {\n return {\n x: pdfX * scale,\n y: (pageHeight - pdfY) * scale,\n };\n}\n\n/**\n * Convert a PDF bounds rect (y-up, y = bottom edge) → canvas rect (y-down, y = top edge).\n * All values are in CSS pixels (not physical pixels).\n */\nexport function pdfBoundsToCanvas(\n bounds: AnnotationBounds,\n scale: number,\n pageHeight: number\n): { x: number; y: number; width: number; height: number } {\n return {\n x: bounds.x * scale,\n y: (pageHeight - bounds.y - bounds.height) * scale,\n width: bounds.width * scale,\n height: bounds.height * scale,\n };\n}\n\n/**\n * Convert a canvas drag rect (minX/Y, maxX/Y in CSS pixels) → PDF bounds (y-up).\n * `bounds.y` is the bottom edge in PDF space, consistent with iOS/Android.\n */\nexport function canvasRectToPdfBounds(\n minX: number,\n minY: number,\n maxX: number,\n maxY: number,\n scale: number,\n pageHeight: number\n): AnnotationBounds {\n return {\n x: minX / scale,\n y: pageHeight - maxY / scale,\n width: (maxX - minX) / scale,\n height: (maxY - minY) / scale,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hit testing (ported from AnnotationHitTester.kt)\n// ---------------------------------------------------------------------------\n\nexport function distanceToSegment(\n point: AnnotationPoint,\n a: AnnotationPoint,\n b: AnnotationPoint\n): number {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const lenSq = dx * dx + dy * dy;\n if (lenSq === 0) {\n const px = point.x - a.x;\n const py = point.y - a.y;\n return Math.sqrt(px * px + py * py);\n }\n let t = ((point.x - a.x) * dx + (point.y - a.y) * dy) / lenSq;\n t = Math.max(0, Math.min(1, t));\n const projX = a.x + t * dx;\n const projY = a.y + t * dy;\n const ex = point.x - projX;\n const ey = point.y - projY;\n return Math.sqrt(ex * ex + ey * ey);\n}\n\nfunction boundsContains(bounds: AnnotationBounds, point: AnnotationPoint): boolean {\n return (\n point.x >= bounds.x &&\n point.x <= bounds.x + bounds.width &&\n point.y >= bounds.y &&\n point.y <= bounds.y + bounds.height\n );\n}\n\nexport function getAnnotationOutlineBounds(annotation: Annotation): AnnotationBounds | null {\n if (annotation.type !== 'ink') {\n return annotation.bounds;\n }\n\n const paths = annotation.paths ?? [];\n let minX = Number.POSITIVE_INFINITY;\n let minY = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let maxY = Number.NEGATIVE_INFINITY;\n\n for (const stroke of paths) {\n for (const point of stroke) {\n minX = Math.min(minX, point.x);\n minY = Math.min(minY, point.y);\n maxX = Math.max(maxX, point.x);\n maxY = Math.max(maxY, point.y);\n }\n }\n\n if (!Number.isFinite(minX) || !Number.isFinite(minY)) {\n return null;\n }\n\n const padding = Math.max(annotation.lineWidth ?? 2, 10);\n return {\n x: minX - padding,\n y: minY - padding,\n width: maxX - minX + padding * 2,\n height: maxY - minY + padding * 2,\n };\n}\n\nexport function clampAnnotationTranslation(\n annotation: Annotation,\n deltaX: number,\n deltaY: number,\n pageWidth: number,\n pageHeight: number\n): AnnotationPoint {\n const bounds = getAnnotationOutlineBounds(annotation);\n if (!bounds) {\n return { x: deltaX, y: deltaY };\n }\n\n const minDeltaX = -bounds.x;\n const maxDeltaX = pageWidth - (bounds.x + bounds.width);\n const minDeltaY = -bounds.y;\n const maxDeltaY = pageHeight - (bounds.y + bounds.height);\n\n return {\n x: Math.min(Math.max(deltaX, minDeltaX), maxDeltaX),\n y: Math.min(Math.max(deltaY, minDeltaY), maxDeltaY),\n };\n}\n\nexport function translateAnnotation(\n annotation: Annotation,\n deltaX: number,\n deltaY: number\n): Annotation {\n if (deltaX === 0 && deltaY === 0) {\n return annotation;\n }\n\n if (annotation.type === 'ink') {\n return {\n ...annotation,\n paths: (annotation.paths ?? []).map((stroke) =>\n stroke.map((point) => ({\n x: point.x + deltaX,\n y: point.y + deltaY,\n }))\n ),\n };\n }\n\n return {\n ...annotation,\n bounds: {\n ...annotation.bounds,\n x: annotation.bounds.x + deltaX,\n y: annotation.bounds.y + deltaY,\n },\n };\n}\n\n/** Return the topmost annotation hit at pdfPoint on pageIndex, or null. */\nexport function hitTestAnnotation(\n pdfPoint: AnnotationPoint,\n annotations: Annotation[],\n pageIndex: number\n): Annotation | null {\n const onPage = annotations.filter((a) => a.page === pageIndex);\n for (let i = onPage.length - 1; i >= 0; i--) {\n const annotation = onPage[i];\n if (!annotation) continue;\n if (annotation.type === 'ink') {\n const tolerance = Math.max(annotation.lineWidth ?? 2, 10);\n const paths = annotation.paths ?? [];\n for (const stroke of paths) {\n const first = stroke[0];\n if (stroke.length === 1 && first) {\n const dx = pdfPoint.x - first.x;\n const dy = pdfPoint.y - first.y;\n if (Math.sqrt(dx * dx + dy * dy) <= tolerance) return annotation;\n }\n for (let j = 0; j < stroke.length - 1; j++) {\n const from = stroke[j];\n const to = stroke[j + 1];\n if (from && to && distanceToSegment(pdfPoint, from, to) <= tolerance) {\n return annotation;\n }\n }\n }\n } else {\n const bounds = annotation.bounds;\n if (bounds && boundsContains(bounds, pdfPoint)) return annotation;\n }\n }\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Canvas drawing (mirrors AnnotationRenderer.kt)\n// ---------------------------------------------------------------------------\n\n/**\n * Draw all annotations for pageIndex onto ctx.\n * meta.scale is CSS-pixels-per-PDF-point; canvas backing = CSS * devicePixelRatio,\n * but the caller should have called ctx.scale(dpr, dpr) so we work in CSS pixels here.\n */\nexport function drawAnnotationsOnCanvas(\n ctx: CanvasRenderingContext2D,\n annotations: Annotation[],\n pageIndex: number,\n meta: PdfPageMeta,\n options: {\n highlightAnnotations?: boolean;\n highlightColor?: string;\n previewAnnotationId?: string | null;\n previewAnnotation?: Annotation | null;\n } = {}\n): void {\n const { scale, pdfHeight } = meta;\n const pageAnnotations = annotations\n .filter((annotation) => annotation.page === pageIndex)\n .map((annotation) =>\n options.previewAnnotationId === annotation.id && options.previewAnnotation\n ? options.previewAnnotation\n : annotation\n )\n .filter((annotation) => annotation.page === pageIndex);\n\n for (const annotation of pageAnnotations) {\n switch (annotation.type) {\n case 'ink': {\n const paths = annotation.paths ?? [];\n ctx.save();\n ctx.strokeStyle = annotation.color;\n ctx.lineWidth = (annotation.lineWidth ?? 2) * scale;\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n for (const stroke of paths) {\n if (stroke.length === 0) continue;\n ctx.beginPath();\n for (let i = 0; i < stroke.length; i++) {\n const point = stroke[i];\n if (!point) continue;\n const { x, y } = pdfToCanvas(point.x, point.y, scale, pdfHeight);\n if (i === 0) ctx.moveTo(x, y);\n else ctx.lineTo(x, y);\n }\n ctx.stroke();\n }\n ctx.restore();\n break;\n }\n case 'highlight': {\n const bounds = annotation.bounds;\n if (!bounds) break;\n const rect = pdfBoundsToCanvas(bounds, scale, pdfHeight);\n ctx.save();\n ctx.globalAlpha = annotation.alpha ?? 0.5;\n ctx.fillStyle = annotation.color;\n ctx.fillRect(rect.x, rect.y, rect.width, rect.height);\n ctx.restore();\n break;\n }\n case 'underline': {\n const bounds = annotation.bounds;\n if (!bounds) break;\n // Underline sits at the bottom of bounds (PDF y = bounds.y = bottom edge)\n const left = bounds.x * scale;\n const bottom = (pdfHeight - bounds.y) * scale;\n const right = left + bounds.width * scale;\n ctx.save();\n ctx.strokeStyle = annotation.color;\n ctx.lineWidth = scale;\n ctx.beginPath();\n ctx.moveTo(left, bottom);\n ctx.lineTo(right, bottom);\n ctx.stroke();\n ctx.restore();\n break;\n }\n case 'text':\n case 'freeText': {\n const bounds = annotation.bounds;\n const text = annotation.contents;\n if (!bounds || !text) break;\n const fontSize = (annotation.fontSize ?? 16) * scale;\n ctx.save();\n ctx.fillStyle = annotation.color;\n ctx.font = `${fontSize}px ${annotation.fontFamily ?? 'sans-serif'}`;\n const canvasTop = (pdfHeight - bounds.y - bounds.height) * scale;\n ctx.fillText(text, bounds.x * scale, canvasTop + fontSize);\n ctx.restore();\n break;\n }\n case 'stamp': {\n const bounds = annotation.bounds;\n if (!bounds || !annotation.text) break;\n const rect = pdfBoundsToCanvas(bounds, scale, pdfHeight);\n ctx.save();\n ctx.fillStyle = annotation.color;\n ctx.font = `${rect.height * 0.7}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText(annotation.text, rect.x + rect.width / 2, rect.y + rect.height / 2);\n ctx.restore();\n break;\n }\n }\n }\n\n if (!options.highlightAnnotations) {\n return;\n }\n\n for (const annotation of pageAnnotations) {\n const bounds = getAnnotationOutlineBounds(annotation);\n if (!bounds) continue;\n const rect = pdfBoundsToCanvas(bounds, scale, pdfHeight);\n ctx.save();\n ctx.strokeStyle = options.highlightColor ?? '#0A84FF';\n ctx.lineWidth = 1.5;\n ctx.setLineDash([6, 4]);\n ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);\n ctx.restore();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Serialization\n// ---------------------------------------------------------------------------\n\nexport function parseAnnotations(json?: string): AnnotationsData {\n if (!json) return { version: 1, annotations: [] };\n try {\n const data = JSON.parse(json) as AnnotationsData;\n if (!Array.isArray(data?.annotations)) return { version: 1, annotations: [] };\n // Deduplicate by id — last wins\n const seen = new Map<string, Annotation>();\n for (const a of data.annotations) {\n seen.set(a.id, a);\n }\n return { version: 1, annotations: Array.from(seen.values()) };\n } catch {\n return { version: 1, annotations: [] };\n }\n}\n\nexport function serializeAnnotations(data: AnnotationsData): string {\n return JSON.stringify(data);\n}\n\nexport function newAnnotationId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return Math.random().toString(36).slice(2) + Date.now().toString(36);\n}\n"]}
|
|
1
|
+
{"version":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U,oBAAoB,CAClC,IAAqB,EACrB,EAAE,cAAc,GAAG,QAAQ,KAAuB,EAAE;IAEpD,MAAM,WAAW,GAAG,CAAC,MAAyB,EAA8C,EAAE;QAC5F,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,cAAc,KAAK,OAAO;YAC/B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAwB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,CAAC,CAAC,OAAO,CAAC;IACd,CAAC,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,GAAG,IAAI;QACP,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/C,UAAU,CAAC,IAAI,KAAK,KAAK;YACvB,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACrE,CAAC,CAAC,UAAU,CACf;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC7E,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type {\n Annotation,\n AnnotationBounds,\n AnnotationPoint,\n AnnotationPointArray,\n AnnotationsData,\n InkPointFormat,\n} from '../ExpoPdfMarkup.types';\nimport { parseAnnotations } from '../parseAnnotations';\nimport type { PdfPageMeta } from './types';\n\n// ---------------------------------------------------------------------------\n// Coordinate transforms\n// ---------------------------------------------------------------------------\n\n/** Convert canvas pixel coords → PDF user-space coords (y-up) */\nexport function canvasToPdf(\n canvasX: number,\n canvasY: number,\n scale: number,\n pageHeight: number\n): AnnotationPoint {\n return {\n x: canvasX / scale,\n y: pageHeight - canvasY / scale,\n };\n}\n\n/** Convert PDF user-space coords (y-up) → canvas pixel coords */\nexport function pdfToCanvas(\n pdfX: number,\n pdfY: number,\n scale: number,\n pageHeight: number\n): { x: number; y: number } {\n return {\n x: pdfX * scale,\n y: (pageHeight - pdfY) * scale,\n };\n}\n\n/**\n * Convert a PDF bounds rect (y-up, y = bottom edge) → canvas rect (y-down, y = top edge).\n * All values are in CSS pixels (not physical pixels).\n */\nexport function pdfBoundsToCanvas(\n bounds: AnnotationBounds,\n scale: number,\n pageHeight: number\n): { x: number; y: number; width: number; height: number } {\n return {\n x: bounds.x * scale,\n y: (pageHeight - bounds.y - bounds.height) * scale,\n width: bounds.width * scale,\n height: bounds.height * scale,\n };\n}\n\n/**\n * Convert a canvas drag rect (minX/Y, maxX/Y in CSS pixels) → PDF bounds (y-up).\n * `bounds.y` is the bottom edge in PDF space, consistent with iOS/Android.\n */\nexport function canvasRectToPdfBounds(\n minX: number,\n minY: number,\n maxX: number,\n maxY: number,\n scale: number,\n pageHeight: number\n): AnnotationBounds {\n return {\n x: minX / scale,\n y: pageHeight - maxY / scale,\n width: (maxX - minX) / scale,\n height: (maxY - minY) / scale,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hit testing (ported from AnnotationHitTester.kt)\n// ---------------------------------------------------------------------------\n\nexport function distanceToSegment(\n point: AnnotationPoint,\n a: AnnotationPoint,\n b: AnnotationPoint\n): number {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const lenSq = dx * dx + dy * dy;\n if (lenSq === 0) {\n const px = point.x - a.x;\n const py = point.y - a.y;\n return Math.sqrt(px * px + py * py);\n }\n let t = ((point.x - a.x) * dx + (point.y - a.y) * dy) / lenSq;\n t = Math.max(0, Math.min(1, t));\n const projX = a.x + t * dx;\n const projY = a.y + t * dy;\n const ex = point.x - projX;\n const ey = point.y - projY;\n return Math.sqrt(ex * ex + ey * ey);\n}\n\nfunction boundsContains(bounds: AnnotationBounds, point: AnnotationPoint): boolean {\n return (\n point.x >= bounds.x &&\n point.x <= bounds.x + bounds.width &&\n point.y >= bounds.y &&\n point.y <= bounds.y + bounds.height\n );\n}\n\nexport function getAnnotationOutlineBounds(annotation: Annotation): AnnotationBounds | null {\n if (annotation.type !== 'ink') {\n return annotation.bounds;\n }\n\n const paths = annotation.paths ?? [];\n let minX = Number.POSITIVE_INFINITY;\n let minY = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let maxY = Number.NEGATIVE_INFINITY;\n\n for (const stroke of paths) {\n for (const point of stroke) {\n minX = Math.min(minX, point.x);\n minY = Math.min(minY, point.y);\n maxX = Math.max(maxX, point.x);\n maxY = Math.max(maxY, point.y);\n }\n }\n\n if (!Number.isFinite(minX) || !Number.isFinite(minY)) {\n return null;\n }\n\n const padding = Math.max(annotation.lineWidth ?? 2, 10);\n return {\n x: minX - padding,\n y: minY - padding,\n width: maxX - minX + padding * 2,\n height: maxY - minY + padding * 2,\n };\n}\n\nexport function clampAnnotationTranslation(\n annotation: Annotation,\n deltaX: number,\n deltaY: number,\n pageWidth: number,\n pageHeight: number\n): AnnotationPoint {\n const bounds = getAnnotationOutlineBounds(annotation);\n if (!bounds) {\n return { x: deltaX, y: deltaY };\n }\n\n const minDeltaX = -bounds.x;\n const maxDeltaX = pageWidth - (bounds.x + bounds.width);\n const minDeltaY = -bounds.y;\n const maxDeltaY = pageHeight - (bounds.y + bounds.height);\n\n return {\n x: Math.min(Math.max(deltaX, minDeltaX), maxDeltaX),\n y: Math.min(Math.max(deltaY, minDeltaY), maxDeltaY),\n };\n}\n\nexport function translateAnnotation(\n annotation: Annotation,\n deltaX: number,\n deltaY: number\n): Annotation {\n if (deltaX === 0 && deltaY === 0) {\n return annotation;\n }\n\n if (annotation.type === 'ink') {\n return {\n ...annotation,\n paths: (annotation.paths ?? []).map((stroke) =>\n stroke.map((point) => ({\n x: point.x + deltaX,\n y: point.y + deltaY,\n }))\n ),\n };\n }\n\n return {\n ...annotation,\n bounds: {\n ...annotation.bounds,\n x: annotation.bounds.x + deltaX,\n y: annotation.bounds.y + deltaY,\n },\n };\n}\n\n/** Return the topmost annotation hit at pdfPoint on pageIndex, or null. */\nexport function hitTestAnnotation(\n pdfPoint: AnnotationPoint,\n annotations: Annotation[],\n pageIndex: number\n): Annotation | null {\n const onPage = annotations.filter((a) => a.page === pageIndex);\n for (let i = onPage.length - 1; i >= 0; i--) {\n const annotation = onPage[i];\n if (!annotation) continue;\n if (annotation.type === 'ink') {\n const tolerance = Math.max(annotation.lineWidth ?? 2, 10);\n const paths = annotation.paths ?? [];\n for (const stroke of paths) {\n const first = stroke[0];\n if (stroke.length === 1 && first) {\n const dx = pdfPoint.x - first.x;\n const dy = pdfPoint.y - first.y;\n if (Math.sqrt(dx * dx + dy * dy) <= tolerance) return annotation;\n }\n for (let j = 0; j < stroke.length - 1; j++) {\n const from = stroke[j];\n const to = stroke[j + 1];\n if (from && to && distanceToSegment(pdfPoint, from, to) <= tolerance) {\n return annotation;\n }\n }\n }\n } else {\n const bounds = annotation.bounds;\n if (bounds && boundsContains(bounds, pdfPoint)) return annotation;\n }\n }\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Canvas drawing (mirrors AnnotationRenderer.kt)\n// ---------------------------------------------------------------------------\n\n/**\n * Draw all annotations for pageIndex onto ctx.\n * meta.scale is CSS-pixels-per-PDF-point; canvas backing = CSS * devicePixelRatio,\n * but the caller should have called ctx.scale(dpr, dpr) so we work in CSS pixels here.\n */\nexport function drawAnnotationsOnCanvas(\n ctx: CanvasRenderingContext2D,\n annotations: Annotation[],\n pageIndex: number,\n meta: PdfPageMeta,\n options: {\n highlightAnnotations?: boolean;\n highlightColor?: string;\n previewAnnotationId?: string | null;\n previewAnnotation?: Annotation | null;\n } = {}\n): void {\n const { scale, pdfHeight } = meta;\n const pageAnnotations = annotations\n .filter((annotation) => annotation.page === pageIndex)\n .map((annotation) =>\n options.previewAnnotationId === annotation.id && options.previewAnnotation\n ? options.previewAnnotation\n : annotation\n )\n .filter((annotation) => annotation.page === pageIndex);\n\n for (const annotation of pageAnnotations) {\n switch (annotation.type) {\n case 'ink': {\n const paths = annotation.paths ?? [];\n ctx.save();\n ctx.strokeStyle = annotation.color;\n ctx.lineWidth = (annotation.lineWidth ?? 2) * scale;\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n for (const stroke of paths) {\n if (stroke.length === 0) continue;\n ctx.beginPath();\n for (let i = 0; i < stroke.length; i++) {\n const point = stroke[i];\n if (!point) continue;\n const { x, y } = pdfToCanvas(point.x, point.y, scale, pdfHeight);\n if (i === 0) ctx.moveTo(x, y);\n else ctx.lineTo(x, y);\n }\n ctx.stroke();\n }\n ctx.restore();\n break;\n }\n case 'highlight': {\n const bounds = annotation.bounds;\n if (!bounds) break;\n const rect = pdfBoundsToCanvas(bounds, scale, pdfHeight);\n ctx.save();\n ctx.globalAlpha = annotation.alpha ?? 0.5;\n ctx.fillStyle = annotation.color;\n ctx.fillRect(rect.x, rect.y, rect.width, rect.height);\n ctx.restore();\n break;\n }\n case 'underline': {\n const bounds = annotation.bounds;\n if (!bounds) break;\n // Underline sits at the bottom of bounds (PDF y = bounds.y = bottom edge)\n const left = bounds.x * scale;\n const bottom = (pdfHeight - bounds.y) * scale;\n const right = left + bounds.width * scale;\n ctx.save();\n ctx.strokeStyle = annotation.color;\n ctx.lineWidth = scale;\n ctx.beginPath();\n ctx.moveTo(left, bottom);\n ctx.lineTo(right, bottom);\n ctx.stroke();\n ctx.restore();\n break;\n }\n case 'text':\n case 'freeText': {\n const bounds = annotation.bounds;\n const text = annotation.contents;\n if (!bounds || !text) break;\n const fontSize = (annotation.fontSize ?? 16) * scale;\n ctx.save();\n ctx.fillStyle = annotation.color;\n ctx.font = `${fontSize}px ${annotation.fontFamily ?? 'sans-serif'}`;\n const canvasTop = (pdfHeight - bounds.y - bounds.height) * scale;\n ctx.fillText(text, bounds.x * scale, canvasTop + fontSize);\n ctx.restore();\n break;\n }\n case 'stamp': {\n const bounds = annotation.bounds;\n if (!bounds || !annotation.text) break;\n const rect = pdfBoundsToCanvas(bounds, scale, pdfHeight);\n ctx.save();\n ctx.fillStyle = annotation.color;\n ctx.font = `${rect.height * 0.7}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText(annotation.text, rect.x + rect.width / 2, rect.y + rect.height / 2);\n ctx.restore();\n break;\n }\n }\n }\n\n if (!options.highlightAnnotations) {\n return;\n }\n\n for (const annotation of pageAnnotations) {\n const bounds = getAnnotationOutlineBounds(annotation);\n if (!bounds) continue;\n const rect = pdfBoundsToCanvas(bounds, scale, pdfHeight);\n ctx.save();\n ctx.strokeStyle = options.highlightColor ?? '#0A84FF';\n ctx.lineWidth = 1.5;\n ctx.setLineDash([6, 4]);\n ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);\n ctx.restore();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Serialization\n// ---------------------------------------------------------------------------\n\n/** Forgiving variant of the public parser: malformed input becomes an empty set. */\nexport function parseAnnotationsOrEmpty(json?: string): AnnotationsData {\n if (!json) return { version: 1, annotations: [] };\n let data: AnnotationsData;\n try {\n data = parseAnnotations(json);\n } catch {\n return { version: 1, annotations: [] };\n }\n // Deduplicate by id — last wins\n const seen = new Map<string, Annotation>();\n for (const a of data.annotations) {\n seen.set(a.id, a);\n }\n return { version: 1, annotations: Array.from(seen.values()) };\n}\n\n/**\n * Round a coordinate to the nearest 0.1 pt, matching the iOS and Android writers:\n * scale by 10 in double precision, round half away from zero, divide by 10.\n * Negative zero becomes zero so it is written as `0`.\n */\nfunction roundInkCoordinate(value: number): number {\n const scaled = value * 10;\n const rounded = Math.sign(scaled) * Math.round(Math.abs(scaled));\n return rounded / 10 + 0;\n}\n\n/**\n * Round each ink point to 0.1 pt and drop consecutive duplicates (compared after\n * rounding). A stroke that collapses to one point keeps two identical points so it\n * still draws as a dot; strokes that started with fewer points are left that short.\n */\nfunction cleanUpInkStroke(stroke: AnnotationPoint[]): AnnotationPoint[] {\n const cleaned: AnnotationPoint[] = [];\n for (const point of stroke) {\n const rounded = { x: roundInkCoordinate(point.x), y: roundInkCoordinate(point.y) };\n const previous = cleaned[cleaned.length - 1];\n if (previous && previous.x === rounded.x && previous.y === rounded.y) continue;\n cleaned.push(rounded);\n }\n if (stroke.length >= 2 && cleaned.length === 1) {\n cleaned.push({ ...cleaned[0]! });\n }\n return cleaned;\n}\n\nexport type SerializeOptions = {\n /** How ink points are written; defaults to object form. */\n inkPointFormat?: InkPointFormat;\n};\n\n/**\n * Write an annotation set. Ink points are cleaned up here, and only here: in memory\n * they keep full precision. Bounds and every non-ink field are written unchanged.\n */\nexport function serializeAnnotations(\n data: AnnotationsData,\n { inkPointFormat = 'object' }: SerializeOptions = {}\n): string {\n const writeStroke = (stroke: AnnotationPoint[]): (AnnotationPoint | AnnotationPointArray)[] => {\n const cleaned = cleanUpInkStroke(stroke);\n return inkPointFormat === 'array'\n ? cleaned.map((p): AnnotationPointArray => [p.x, p.y])\n : cleaned;\n };\n return JSON.stringify({\n ...data,\n annotations: data.annotations.map((annotation) =>\n annotation.type === 'ink'\n ? { ...annotation, paths: (annotation.paths ?? []).map(writeStroke) }\n : annotation\n ),\n });\n}\n\nexport function newAnnotationId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return Math.random().toString(36).slice(2) + Date.now().toString(36);\n}\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"annotations": [
|
|
4
|
+
{
|
|
5
|
+
"id": "shared-ink",
|
|
6
|
+
"type": "ink",
|
|
7
|
+
"color": "#CC2244",
|
|
8
|
+
"lineWidth": 3,
|
|
9
|
+
"paths": [
|
|
10
|
+
[
|
|
11
|
+
[40, 100],
|
|
12
|
+
{
|
|
13
|
+
"x": 120,
|
|
14
|
+
"y": 160
|
|
15
|
+
},
|
|
16
|
+
[180, 130]
|
|
17
|
+
]
|
|
18
|
+
],
|
|
19
|
+
"page": 0,
|
|
20
|
+
"createdAt": 1741340000
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "shared-highlight",
|
|
24
|
+
"type": "highlight",
|
|
25
|
+
"color": "#FFCC00",
|
|
26
|
+
"alpha": 0.5,
|
|
27
|
+
"bounds": {
|
|
28
|
+
"x": 60,
|
|
29
|
+
"y": 300,
|
|
30
|
+
"width": 180,
|
|
31
|
+
"height": 24
|
|
32
|
+
},
|
|
33
|
+
"page": 0,
|
|
34
|
+
"createdAt": 1741340001
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "shared-underline",
|
|
38
|
+
"type": "underline",
|
|
39
|
+
"color": "#2244CC",
|
|
40
|
+
"bounds": {
|
|
41
|
+
"x": 80,
|
|
42
|
+
"y": 380,
|
|
43
|
+
"width": 160,
|
|
44
|
+
"height": 20
|
|
45
|
+
},
|
|
46
|
+
"page": 0,
|
|
47
|
+
"createdAt": 1741340002
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "shared-text",
|
|
51
|
+
"type": "text",
|
|
52
|
+
"color": "#114422",
|
|
53
|
+
"bounds": {
|
|
54
|
+
"x": 100,
|
|
55
|
+
"y": 450,
|
|
56
|
+
"width": 240,
|
|
57
|
+
"height": 40
|
|
58
|
+
},
|
|
59
|
+
"contents": "Shared note",
|
|
60
|
+
"fontSize": 16,
|
|
61
|
+
"fontFamily": "Helvetica",
|
|
62
|
+
"page": 0,
|
|
63
|
+
"createdAt": 1741340003
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "shared-free-text",
|
|
67
|
+
"type": "freeText",
|
|
68
|
+
"color": "#442211",
|
|
69
|
+
"bounds": {
|
|
70
|
+
"x": 100,
|
|
71
|
+
"y": 520,
|
|
72
|
+
"width": 240,
|
|
73
|
+
"height": 40
|
|
74
|
+
},
|
|
75
|
+
"contents": "Visible page",
|
|
76
|
+
"fontSize": 18,
|
|
77
|
+
"fontFamily": "Helvetica",
|
|
78
|
+
"page": 0,
|
|
79
|
+
"createdAt": 1741340004
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "shared-music",
|
|
83
|
+
"type": "stamp",
|
|
84
|
+
"color": "#332299",
|
|
85
|
+
"bounds": {
|
|
86
|
+
"x": 20,
|
|
87
|
+
"y": 700,
|
|
88
|
+
"width": 48,
|
|
89
|
+
"height": 48
|
|
90
|
+
},
|
|
91
|
+
"text": "♫",
|
|
92
|
+
"page": 0,
|
|
93
|
+
"createdAt": 1741340005
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "shared-star",
|
|
97
|
+
"type": "stamp",
|
|
98
|
+
"color": "#BB5500",
|
|
99
|
+
"bounds": {
|
|
100
|
+
"x": 270,
|
|
101
|
+
"y": 700,
|
|
102
|
+
"width": 48,
|
|
103
|
+
"height": 48
|
|
104
|
+
},
|
|
105
|
+
"text": "★",
|
|
106
|
+
"page": 0,
|
|
107
|
+
"createdAt": 1741340006
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "shared-emoji",
|
|
111
|
+
"type": "stamp",
|
|
112
|
+
"color": "#222222",
|
|
113
|
+
"bounds": {
|
|
114
|
+
"x": 530,
|
|
115
|
+
"y": 700,
|
|
116
|
+
"width": 48,
|
|
117
|
+
"height": 48
|
|
118
|
+
},
|
|
119
|
+
"text": "🎵",
|
|
120
|
+
"page": 0,
|
|
121
|
+
"createdAt": 1741340007
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"annotations": [
|
|
4
|
+
{
|
|
5
|
+
"id": "cleanup-ink",
|
|
6
|
+
"type": "ink",
|
|
7
|
+
"color": "#CC2244",
|
|
8
|
+
"lineWidth": 3,
|
|
9
|
+
"paths": [
|
|
10
|
+
[
|
|
11
|
+
[307.7, 462.6],
|
|
12
|
+
[1.8, 12.3],
|
|
13
|
+
[100, 100],
|
|
14
|
+
[0, -1.3],
|
|
15
|
+
[0.1, 2.7]
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
[50, 60],
|
|
19
|
+
[50, 60]
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
[5, 5],
|
|
23
|
+
[5, 5]
|
|
24
|
+
],
|
|
25
|
+
[[10.1, 21]],
|
|
26
|
+
[]
|
|
27
|
+
],
|
|
28
|
+
"page": 0,
|
|
29
|
+
"createdAt": 1741340000
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "cleanup-ink-fractional-width",
|
|
33
|
+
"type": "ink",
|
|
34
|
+
"color": "#2244CC",
|
|
35
|
+
"lineWidth": 2.5,
|
|
36
|
+
"paths": [
|
|
37
|
+
[
|
|
38
|
+
[200.1, 301],
|
|
39
|
+
[200.2, 300.9],
|
|
40
|
+
[200.1, 301]
|
|
41
|
+
]
|
|
42
|
+
],
|
|
43
|
+
"page": 1,
|
|
44
|
+
"createdAt": 1741340001
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "cleanup-highlight",
|
|
48
|
+
"type": "highlight",
|
|
49
|
+
"color": "#FFCC00",
|
|
50
|
+
"alpha": 0.25,
|
|
51
|
+
"bounds": { "x": 60.125, "y": 300.875, "width": 180.5, "height": 24.25 },
|
|
52
|
+
"page": 0,
|
|
53
|
+
"createdAt": 1741340002
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "cleanup-underline",
|
|
57
|
+
"type": "underline",
|
|
58
|
+
"color": "#2244CC",
|
|
59
|
+
"bounds": { "x": 80.0625, "y": 380.375, "width": 160.25, "height": 20.5 },
|
|
60
|
+
"page": 0,
|
|
61
|
+
"createdAt": 1741340003
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "cleanup-text",
|
|
65
|
+
"type": "text",
|
|
66
|
+
"color": "#114422",
|
|
67
|
+
"bounds": { "x": 100.125, "y": 450.75, "width": 240.375, "height": 40.5 },
|
|
68
|
+
"contents": "Unrounded note",
|
|
69
|
+
"fontSize": 16.5,
|
|
70
|
+
"fontFamily": "Helvetica",
|
|
71
|
+
"page": 0,
|
|
72
|
+
"createdAt": 1741340004
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "cleanup-free-text",
|
|
76
|
+
"type": "freeText",
|
|
77
|
+
"color": "#442211",
|
|
78
|
+
"bounds": { "x": 100.0625, "y": 520.875, "width": 240.25, "height": 40.25 },
|
|
79
|
+
"contents": "Unrounded free text",
|
|
80
|
+
"fontSize": 18.5,
|
|
81
|
+
"fontFamily": "Helvetica",
|
|
82
|
+
"page": 0,
|
|
83
|
+
"createdAt": 1741340005
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "cleanup-stamp",
|
|
87
|
+
"type": "stamp",
|
|
88
|
+
"color": "#332299",
|
|
89
|
+
"bounds": { "x": 20.125, "y": 700.875, "width": 48.5, "height": 48.5 },
|
|
90
|
+
"text": "♫",
|
|
91
|
+
"page": 0,
|
|
92
|
+
"createdAt": 1741340006
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"annotations": [
|
|
4
|
+
{
|
|
5
|
+
"id": "cleanup-ink",
|
|
6
|
+
"type": "ink",
|
|
7
|
+
"color": "#CC2244",
|
|
8
|
+
"lineWidth": 3,
|
|
9
|
+
"paths": [
|
|
10
|
+
[
|
|
11
|
+
{ "x": 307.7, "y": 462.6 },
|
|
12
|
+
{ "x": 1.8, "y": 12.3 },
|
|
13
|
+
{ "x": 100, "y": 100 },
|
|
14
|
+
{ "x": 0, "y": -1.3 },
|
|
15
|
+
{ "x": 0.1, "y": 2.7 }
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
{ "x": 50, "y": 60 },
|
|
19
|
+
{ "x": 50, "y": 60 }
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
{ "x": 5, "y": 5 },
|
|
23
|
+
{ "x": 5, "y": 5 }
|
|
24
|
+
],
|
|
25
|
+
[{ "x": 10.1, "y": 21 }],
|
|
26
|
+
[]
|
|
27
|
+
],
|
|
28
|
+
"page": 0,
|
|
29
|
+
"createdAt": 1741340000
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "cleanup-ink-fractional-width",
|
|
33
|
+
"type": "ink",
|
|
34
|
+
"color": "#2244CC",
|
|
35
|
+
"lineWidth": 2.5,
|
|
36
|
+
"paths": [
|
|
37
|
+
[
|
|
38
|
+
{ "x": 200.1, "y": 301 },
|
|
39
|
+
{ "x": 200.2, "y": 300.9 },
|
|
40
|
+
{ "x": 200.1, "y": 301 }
|
|
41
|
+
]
|
|
42
|
+
],
|
|
43
|
+
"page": 1,
|
|
44
|
+
"createdAt": 1741340001
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "cleanup-highlight",
|
|
48
|
+
"type": "highlight",
|
|
49
|
+
"color": "#FFCC00",
|
|
50
|
+
"alpha": 0.25,
|
|
51
|
+
"bounds": { "x": 60.125, "y": 300.875, "width": 180.5, "height": 24.25 },
|
|
52
|
+
"page": 0,
|
|
53
|
+
"createdAt": 1741340002
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "cleanup-underline",
|
|
57
|
+
"type": "underline",
|
|
58
|
+
"color": "#2244CC",
|
|
59
|
+
"bounds": { "x": 80.0625, "y": 380.375, "width": 160.25, "height": 20.5 },
|
|
60
|
+
"page": 0,
|
|
61
|
+
"createdAt": 1741340003
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "cleanup-text",
|
|
65
|
+
"type": "text",
|
|
66
|
+
"color": "#114422",
|
|
67
|
+
"bounds": { "x": 100.125, "y": 450.75, "width": 240.375, "height": 40.5 },
|
|
68
|
+
"contents": "Unrounded note",
|
|
69
|
+
"fontSize": 16.5,
|
|
70
|
+
"fontFamily": "Helvetica",
|
|
71
|
+
"page": 0,
|
|
72
|
+
"createdAt": 1741340004
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "cleanup-free-text",
|
|
76
|
+
"type": "freeText",
|
|
77
|
+
"color": "#442211",
|
|
78
|
+
"bounds": { "x": 100.0625, "y": 520.875, "width": 240.25, "height": 40.25 },
|
|
79
|
+
"contents": "Unrounded free text",
|
|
80
|
+
"fontSize": 18.5,
|
|
81
|
+
"fontFamily": "Helvetica",
|
|
82
|
+
"page": 0,
|
|
83
|
+
"createdAt": 1741340005
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "cleanup-stamp",
|
|
87
|
+
"type": "stamp",
|
|
88
|
+
"color": "#332299",
|
|
89
|
+
"bounds": { "x": 20.125, "y": 700.875, "width": 48.5, "height": 48.5 },
|
|
90
|
+
"text": "♫",
|
|
91
|
+
"page": 0,
|
|
92
|
+
"createdAt": 1741340006
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"annotations": [
|
|
4
|
+
{
|
|
5
|
+
"id": "cleanup-ink",
|
|
6
|
+
"type": "ink",
|
|
7
|
+
"color": "#CC2244",
|
|
8
|
+
"lineWidth": 3,
|
|
9
|
+
"paths": [
|
|
10
|
+
[
|
|
11
|
+
{ "x": 307.6921296296296, "y": 462.6087962962961 },
|
|
12
|
+
{ "x": 307.6921296296296, "y": 462.6087962962961 },
|
|
13
|
+
{ "x": 307.7049, "y": 462.5501 },
|
|
14
|
+
{ "x": 1.75, "y": 12.25 },
|
|
15
|
+
{ "x": 100.04, "y": 99.96 },
|
|
16
|
+
{ "x": -0.04, "y": -1.25 },
|
|
17
|
+
{ "x": -0.04, "y": -1.25 },
|
|
18
|
+
{ "x": 0.05, "y": 2.675 }
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
{ "x": 50.01, "y": 60.02 },
|
|
22
|
+
{ "x": 50.03, "y": 59.98 },
|
|
23
|
+
{ "x": 49.96, "y": 60.04 }
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
{ "x": 5, "y": 5 },
|
|
27
|
+
{ "x": 5, "y": 5 }
|
|
28
|
+
],
|
|
29
|
+
[{ "x": 10.123, "y": 20.987 }],
|
|
30
|
+
[]
|
|
31
|
+
],
|
|
32
|
+
"page": 0,
|
|
33
|
+
"createdAt": 1741340000
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "cleanup-ink-fractional-width",
|
|
37
|
+
"type": "ink",
|
|
38
|
+
"color": "#2244CC",
|
|
39
|
+
"lineWidth": 2.5,
|
|
40
|
+
"paths": [
|
|
41
|
+
[
|
|
42
|
+
{ "x": 200.123456, "y": 300.987654 },
|
|
43
|
+
{ "x": 200.16, "y": 300.94 },
|
|
44
|
+
{ "x": 200.14, "y": 301.01 }
|
|
45
|
+
]
|
|
46
|
+
],
|
|
47
|
+
"page": 1,
|
|
48
|
+
"createdAt": 1741340001
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "cleanup-highlight",
|
|
52
|
+
"type": "highlight",
|
|
53
|
+
"color": "#FFCC00",
|
|
54
|
+
"alpha": 0.25,
|
|
55
|
+
"bounds": { "x": 60.125, "y": 300.875, "width": 180.5, "height": 24.25 },
|
|
56
|
+
"page": 0,
|
|
57
|
+
"createdAt": 1741340002
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "cleanup-underline",
|
|
61
|
+
"type": "underline",
|
|
62
|
+
"color": "#2244CC",
|
|
63
|
+
"bounds": { "x": 80.0625, "y": 380.375, "width": 160.25, "height": 20.5 },
|
|
64
|
+
"page": 0,
|
|
65
|
+
"createdAt": 1741340003
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "cleanup-text",
|
|
69
|
+
"type": "text",
|
|
70
|
+
"color": "#114422",
|
|
71
|
+
"bounds": { "x": 100.125, "y": 450.75, "width": 240.375, "height": 40.5 },
|
|
72
|
+
"contents": "Unrounded note",
|
|
73
|
+
"fontSize": 16.5,
|
|
74
|
+
"fontFamily": "Helvetica",
|
|
75
|
+
"page": 0,
|
|
76
|
+
"createdAt": 1741340004
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "cleanup-free-text",
|
|
80
|
+
"type": "freeText",
|
|
81
|
+
"color": "#442211",
|
|
82
|
+
"bounds": { "x": 100.0625, "y": 520.875, "width": 240.25, "height": 40.25 },
|
|
83
|
+
"contents": "Unrounded free text",
|
|
84
|
+
"fontSize": 18.5,
|
|
85
|
+
"fontFamily": "Helvetica",
|
|
86
|
+
"page": 0,
|
|
87
|
+
"createdAt": 1741340005
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "cleanup-stamp",
|
|
91
|
+
"type": "stamp",
|
|
92
|
+
"color": "#332299",
|
|
93
|
+
"bounds": { "x": 20.125, "y": 700.875, "width": 48.5, "height": 48.5 },
|
|
94
|
+
"text": "♫",
|
|
95
|
+
"page": 0,
|
|
96
|
+
"createdAt": 1741340006
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|