@tobyt/expo-pdf-markup 1.0.1 → 1.1.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/CHANGELOG.md +19 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationGeometry.kt +2 -2
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationHitTester.kt +1 -1
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationModel.kt +2 -1
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationRenderer.kt +36 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/AnnotationSerializer.kt +3 -1
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ContinuousPdfView.kt +72 -4
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ExpoPdfMarkupModule.kt +8 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ExpoPdfMarkupView.kt +9 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/TouchInterceptPolicy.kt +20 -0
- package/build/ExpoPdfMarkup.types.d.ts +27 -2
- 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 +34 -5
- package/build/ExpoPdfMarkupView.web.js.map +1 -1
- package/build/web/annotationUtils.d.ts.map +1 -1
- package/build/web/annotationUtils.js +14 -0
- package/build/web/annotationUtils.js.map +1 -1
- package/ios/AnnotationModels.swift +1 -0
- package/ios/AnnotationSerializer.swift +20 -0
- package/ios/ExpoPdfMarkupModule.swift +8 -0
- package/ios/ExpoPdfMarkupView+Move.swift +1 -1
- package/ios/ExpoPdfMarkupView.swift +6 -0
- package/ios/StampPDFAnnotation.swift +100 -0
- package/ios/Tests/AnnotationSerializerTests.swift +63 -0
- package/ios/Tests/StampPDFAnnotationTests.swift +128 -0
- package/package.json +3 -3
- package/src/ExpoPdfMarkup.types.ts +34 -1
- package/src/ExpoPdfMarkupView.web.tsx +40 -2
- package/src/web/annotationUtils.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @tobyt/expo-pdf-markup
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3f4fa8c: Android: fix touch-interception lifecycle in the PDF view. The view previously called `requestDisallowInterceptTouchEvent(true)` on every touch event and never released it, and in-progress gestures were never reset when interrupted. This could leave stale touch state on ancestor views shared with sibling screens (e.g. list rows behind the PDF screen becoming unresponsive to taps after navigating back, especially after locking/unlocking the device), and caused unnecessary gesture-handler contention while scrolling.
|
|
8
|
+
|
|
9
|
+
Now the parent intercept hold is requested on `ACTION_DOWN` and released on the final `ACTION_UP`/`ACTION_CANCEL` (held across multi-touch pinch), and all in-progress gestures (ink stroke, highlight/underline drag, annotation move, fling) are cancelled and the hold released when the window loses focus (device lock) or the view detaches. Note: an ink stroke interrupted by a device lock is discarded rather than committed.
|
|
10
|
+
|
|
11
|
+
## 1.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 24c58b8: Add `stamp` annotations for placing consumer-defined text glyphs (e.g. emoji) onto a PDF. New `StampAnnotation` type, `'stamp'` annotation mode, and `stampText`/`stampSize` props let apps arm a stamp (from their own picker UI) and tap to place it; stamps support move and eraser like other bounds-based annotations. A new `StampDefinition` type is exported as a convenience shape for organizing a custom stamp set. Image-backed stamps were intentionally left out — a stored local file path can go stale (app reinstall, cache eviction) and silently break previously-placed stamps, so this stays text-only for now.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 850b4f9: Routine dependency maintenance: upgrade to the latest Expo SDK 55 patch release. Bumps `expo` (55.0.5 → 55.0.26) and `react-native` (0.83.2 → 0.83.6) in the module, and `expo`, `expo-asset`, `expo-font`, `react-native`, `react`, `react-dom` to their SDK 55.0.26-compatible versions in the example app. No runtime behavior changes.
|
|
20
|
+
- 95b8c0d: Routine dependency maintenance: patch/minor bumps for transitive and dev dependencies (`@babel/plugin-transform-modules-systemjs`, `@xmldom/xmldom`, `lodash`, `node-forge`, `flatted`, `picomatch`, `yaml`, `brace-expansion`, `shell-quote`, `markdown-it`, `linkify-it`, `form-data`, `hasown`, `ws`), example app `react`/`react-dom`/`@types/react`, and CI Actions (`checkout`, `setup-node`, `upload-pages-artifact`, `deploy-pages`). No runtime behavior changes.
|
|
21
|
+
|
|
3
22
|
## 1.0.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ object AnnotationGeometry {
|
|
|
4
4
|
|
|
5
5
|
fun outlineBounds(annotation: AnnotationModel): AnnotationBounds? = when (annotation.type) {
|
|
6
6
|
"ink" -> outlineBoundsForInk(annotation)
|
|
7
|
-
"highlight", "underline", "freeText", "text" -> annotation.bounds
|
|
7
|
+
"highlight", "underline", "freeText", "text", "stamp" -> annotation.bounds
|
|
8
8
|
else -> null
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -39,7 +39,7 @@ object AnnotationGeometry {
|
|
|
39
39
|
}
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
"highlight", "underline", "freeText", "text" -> {
|
|
42
|
+
"highlight", "underline", "freeText", "text", "stamp" -> {
|
|
43
43
|
val bounds = annotation.bounds ?: return annotation
|
|
44
44
|
annotation.copy(
|
|
45
45
|
bounds =
|
|
@@ -20,7 +20,7 @@ object AnnotationHitTester {
|
|
|
20
20
|
if (hitTestInk(point, annotation, tolerance)) return annotation
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
"highlight", "underline", "freeText", "text" -> {
|
|
23
|
+
"highlight", "underline", "freeText", "text", "stamp" -> {
|
|
24
24
|
val bounds = annotation.bounds ?: continue
|
|
25
25
|
if (bounds.contains(point)) return annotation
|
|
26
26
|
}
|
|
@@ -19,7 +19,8 @@ data class AnnotationModel(
|
|
|
19
19
|
val contents: String? = null,
|
|
20
20
|
val fontSize: Float? = null,
|
|
21
21
|
val fontFamily: String? = null,
|
|
22
|
-
val createdAt: Double? = null
|
|
22
|
+
val createdAt: Double? = null,
|
|
23
|
+
val text: String? = null
|
|
23
24
|
)
|
|
24
25
|
|
|
25
26
|
data class AnnotationsData(
|
|
@@ -6,6 +6,7 @@ import android.graphics.Canvas
|
|
|
6
6
|
import android.graphics.DashPathEffect
|
|
7
7
|
import android.graphics.Paint
|
|
8
8
|
import android.graphics.Path
|
|
9
|
+
import android.graphics.RectF
|
|
9
10
|
import android.graphics.Typeface
|
|
10
11
|
|
|
11
12
|
object AnnotationRenderer {
|
|
@@ -48,6 +49,14 @@ object AnnotationRenderer {
|
|
|
48
49
|
pageHeight,
|
|
49
50
|
context
|
|
50
51
|
)
|
|
52
|
+
|
|
53
|
+
"stamp" -> drawStamp(
|
|
54
|
+
canvas,
|
|
55
|
+
annotation,
|
|
56
|
+
pageYOffset,
|
|
57
|
+
renderScale,
|
|
58
|
+
pageHeight
|
|
59
|
+
)
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
62
|
}
|
|
@@ -172,6 +181,33 @@ object AnnotationRenderer {
|
|
|
172
181
|
canvas.drawText(text, left, top + paint.textSize, paint)
|
|
173
182
|
}
|
|
174
183
|
|
|
184
|
+
private fun drawStamp(
|
|
185
|
+
canvas: Canvas,
|
|
186
|
+
annotation: AnnotationModel,
|
|
187
|
+
pageYOffset: Float,
|
|
188
|
+
renderScale: Float,
|
|
189
|
+
pageHeight: Int
|
|
190
|
+
) {
|
|
191
|
+
val bounds = annotation.bounds ?: return
|
|
192
|
+
val text = annotation.text ?: return
|
|
193
|
+
val left = bounds.x * renderScale
|
|
194
|
+
val top = (pageHeight - bounds.y - bounds.height) * renderScale + pageYOffset
|
|
195
|
+
val right = left + bounds.width * renderScale
|
|
196
|
+
val bottom = top + bounds.height * renderScale
|
|
197
|
+
val rect = RectF(left, top, right, bottom)
|
|
198
|
+
|
|
199
|
+
val paint = Paint().apply {
|
|
200
|
+
color = AnnotationSerializer.colorFromHex(annotation.color)
|
|
201
|
+
textSize = rect.height() * 0.7f
|
|
202
|
+
textAlign = Paint.Align.CENTER
|
|
203
|
+
isAntiAlias = true
|
|
204
|
+
}
|
|
205
|
+
// Paint has no built-in middle-baseline; offset by (ascent + descent) / 2 to
|
|
206
|
+
// vertically center the glyph within rect.
|
|
207
|
+
val baselineY = rect.centerY() - (paint.descent() + paint.ascent()) / 2f
|
|
208
|
+
canvas.drawText(text, rect.centerX(), baselineY, paint)
|
|
209
|
+
}
|
|
210
|
+
|
|
175
211
|
/** Resolve a typeface the same way React Native text does when available, so
|
|
176
212
|
* expo-font loaded families are measured and rendered consistently with the
|
|
177
213
|
* rest of the app. */
|
|
@@ -77,7 +77,8 @@ object AnnotationSerializer {
|
|
|
77
77
|
contents = if (obj.has("contents")) obj.getString("contents") else null,
|
|
78
78
|
fontSize = optFloat(obj, "fontSize"),
|
|
79
79
|
fontFamily = if (obj.has("fontFamily")) obj.getString("fontFamily") else null,
|
|
80
|
-
createdAt = if (obj.has("createdAt")) obj.optDouble("createdAt") else null
|
|
80
|
+
createdAt = if (obj.has("createdAt")) obj.optDouble("createdAt") else null,
|
|
81
|
+
text = if (obj.has("text")) obj.getString("text") else null
|
|
81
82
|
)
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -125,6 +126,7 @@ object AnnotationSerializer {
|
|
|
125
126
|
model.fontSize?.let { obj.put("fontSize", it.toDouble()) }
|
|
126
127
|
model.fontFamily?.let { obj.put("fontFamily", it) }
|
|
127
128
|
model.createdAt?.let { obj.put("createdAt", it) }
|
|
129
|
+
model.text?.let { obj.put("text", it) }
|
|
128
130
|
return obj
|
|
129
131
|
}
|
|
130
132
|
|
|
@@ -78,6 +78,8 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
78
78
|
var annotationColor: String = "#000000"
|
|
79
79
|
var annotationLineWidth: Float = 2f
|
|
80
80
|
var annotationFontFamily: String? = null
|
|
81
|
+
var stampText: String? = null
|
|
82
|
+
var stampSize: Float = 48f
|
|
81
83
|
var onAnnotationsChangedListener: (() -> Unit)? = null
|
|
82
84
|
|
|
83
85
|
// Ink drawing state
|
|
@@ -246,6 +248,13 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
251
|
+
// Hold off parent interception (e.g. gesture-handler root, scroll
|
|
252
|
+
// containers) for the duration of each gesture only; leaving it set
|
|
253
|
+
// permanently can strand ancestors shared with sibling screens.
|
|
254
|
+
TouchInterceptPolicy.disallowInterceptFor(event.actionMasked)?.let {
|
|
255
|
+
parent?.requestDisallowInterceptTouchEvent(it)
|
|
256
|
+
}
|
|
257
|
+
|
|
249
258
|
// Always let scale detector handle pinch zoom
|
|
250
259
|
scaleDetector.onTouchEvent(event)
|
|
251
260
|
|
|
@@ -290,16 +299,54 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
290
299
|
return true
|
|
291
300
|
}
|
|
292
301
|
|
|
302
|
+
"stamp" -> {
|
|
303
|
+
if (event.action == MotionEvent.ACTION_UP && event.pointerCount == 1) {
|
|
304
|
+
handleStampTap(event)
|
|
305
|
+
}
|
|
306
|
+
gestureDetector.onTouchEvent(event)
|
|
307
|
+
return true
|
|
308
|
+
}
|
|
309
|
+
|
|
293
310
|
else -> {
|
|
294
311
|
// "none" mode — normal scroll/zoom
|
|
295
312
|
gestureDetector.onTouchEvent(event)
|
|
296
313
|
}
|
|
297
314
|
}
|
|
298
315
|
|
|
299
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
300
316
|
return true
|
|
301
317
|
}
|
|
302
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Cancels any in-progress gesture (ink stroke, drag, move, fling) and
|
|
321
|
+
* releases the parent touch-intercept hold. Needed when the gesture is
|
|
322
|
+
* interrupted without a final ACTION_UP/ACTION_CANCEL — device lock
|
|
323
|
+
* (window focus loss) or view teardown — so that no stale touch state
|
|
324
|
+
* survives on this view or its ancestors. An interrupted ink stroke is
|
|
325
|
+
* discarded rather than committed.
|
|
326
|
+
*/
|
|
327
|
+
fun cancelActiveGestures() {
|
|
328
|
+
isDrawingInk = false
|
|
329
|
+
currentInkPoints.clear()
|
|
330
|
+
inkScreenPath.reset()
|
|
331
|
+
isDragging = false
|
|
332
|
+
dragStartPoint = null
|
|
333
|
+
dragCurrentPoint = null
|
|
334
|
+
clearMovePreview()
|
|
335
|
+
scroller.forceFinished(true)
|
|
336
|
+
parent?.requestDisallowInterceptTouchEvent(false)
|
|
337
|
+
invalidate()
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
|
|
341
|
+
super.onWindowFocusChanged(hasWindowFocus)
|
|
342
|
+
if (!hasWindowFocus) cancelActiveGestures()
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
override fun onDetachedFromWindow() {
|
|
346
|
+
cancelActiveGestures()
|
|
347
|
+
super.onDetachedFromWindow()
|
|
348
|
+
}
|
|
349
|
+
|
|
303
350
|
// --- Ink mode ---
|
|
304
351
|
|
|
305
352
|
private fun handleInkTouch(event: MotionEvent) {
|
|
@@ -311,7 +358,6 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
311
358
|
val pt = AnnotationPoint(event.x, event.y)
|
|
312
359
|
currentInkPoints.add(pt)
|
|
313
360
|
inkScreenPath.moveTo(event.x, event.y)
|
|
314
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
315
361
|
}
|
|
316
362
|
|
|
317
363
|
MotionEvent.ACTION_MOVE -> {
|
|
@@ -375,7 +421,6 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
375
421
|
isDragging = true
|
|
376
422
|
dragStartPoint = AnnotationPoint(event.x, event.y)
|
|
377
423
|
dragCurrentPoint = dragStartPoint
|
|
378
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
379
424
|
}
|
|
380
425
|
|
|
381
426
|
MotionEvent.ACTION_MOVE -> {
|
|
@@ -467,7 +512,6 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
467
512
|
movingAnnotation = hit
|
|
468
513
|
movingPreviewAnnotation = hit
|
|
469
514
|
moveStartPdfPoint = pdfTouch.point
|
|
470
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
471
515
|
invalidate()
|
|
472
516
|
}
|
|
473
517
|
}
|
|
@@ -574,6 +618,30 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
574
618
|
)
|
|
575
619
|
}
|
|
576
620
|
|
|
621
|
+
// --- Stamp mode ---
|
|
622
|
+
|
|
623
|
+
private fun handleStampTap(event: MotionEvent) {
|
|
624
|
+
val text = stampText ?: return
|
|
625
|
+
val pdfTouch = screenToPdfPoint(event.x, event.y) ?: return
|
|
626
|
+
val half = stampSize / 2f
|
|
627
|
+
val annotation = AnnotationModel(
|
|
628
|
+
id = UUID.randomUUID().toString(),
|
|
629
|
+
type = "stamp",
|
|
630
|
+
page = pdfTouch.pageIndex,
|
|
631
|
+
color = annotationColor,
|
|
632
|
+
bounds = AnnotationBounds(
|
|
633
|
+
pdfTouch.point.x - half,
|
|
634
|
+
pdfTouch.point.y - half,
|
|
635
|
+
stampSize,
|
|
636
|
+
stampSize
|
|
637
|
+
),
|
|
638
|
+
text = text,
|
|
639
|
+
createdAt = System.currentTimeMillis() / 1000.0
|
|
640
|
+
)
|
|
641
|
+
annotations = annotations + annotation
|
|
642
|
+
onAnnotationsChangedListener?.invoke()
|
|
643
|
+
}
|
|
644
|
+
|
|
577
645
|
// --- Helpers ---
|
|
578
646
|
|
|
579
647
|
private fun pageIndexAtContentY(contentY: Float): Int {
|
|
@@ -84,6 +84,14 @@ class ExpoPdfMarkupModule : Module() {
|
|
|
84
84
|
view.setAnnotationFontFamily(font)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
Prop("stampText") { view: ExpoPdfMarkupView, value: String? ->
|
|
88
|
+
view.setStampText(value)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Prop("stampSize") { view: ExpoPdfMarkupView, value: Double? ->
|
|
92
|
+
view.setStampSize(value)
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
Prop("useJsTextDialog") { view: ExpoPdfMarkupView, use: Boolean? ->
|
|
88
96
|
view.useJsTextDialog = use ?: false
|
|
89
97
|
}
|
|
@@ -135,6 +135,14 @@ class ExpoPdfMarkupView(context: Context, appContext: AppContext) : ExpoView(con
|
|
|
135
135
|
pdfView.annotationFontFamily = font
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
fun setStampText(value: String?) {
|
|
139
|
+
pdfView.stampText = value
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fun setStampSize(value: Double?) {
|
|
143
|
+
pdfView.stampSize = value?.toFloat() ?: 48f
|
|
144
|
+
}
|
|
145
|
+
|
|
138
146
|
private fun emitAnnotationsChanged() {
|
|
139
147
|
val data = AnnotationsData(version = 1, annotations = pdfView.annotations)
|
|
140
148
|
val json = AnnotationSerializer.serialize(data)
|
|
@@ -193,6 +201,7 @@ class ExpoPdfMarkupView(context: Context, appContext: AppContext) : ExpoView(con
|
|
|
193
201
|
|
|
194
202
|
override fun onDetachedFromWindow() {
|
|
195
203
|
super.onDetachedFromWindow()
|
|
204
|
+
pdfView.cancelActiveGestures()
|
|
196
205
|
// Save the successfully-loaded source before close() so we can reload on re-attach.
|
|
197
206
|
// (currentSource is always null after loadPdf() because close() resets it there.)
|
|
198
207
|
sourceToReloadOnAttach = lastLoadedSource
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package dev.terhoeven.expopdfmarkup
|
|
2
|
+
|
|
3
|
+
import android.view.MotionEvent
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Decides whether the parent's touch interception should be disallowed for a
|
|
7
|
+
* given masked motion action, or left unchanged (null).
|
|
8
|
+
*
|
|
9
|
+
* The disallow flag is held for the whole gesture: requested on the initial
|
|
10
|
+
* ACTION_DOWN and released only on the final ACTION_UP or ACTION_CANCEL.
|
|
11
|
+
* ACTION_POINTER_DOWN/ACTION_POINTER_UP (extra fingers during pinch zoom)
|
|
12
|
+
* must not release it mid-gesture.
|
|
13
|
+
*/
|
|
14
|
+
object TouchInterceptPolicy {
|
|
15
|
+
fun disallowInterceptFor(actionMasked: Int): Boolean? = when (actionMasked) {
|
|
16
|
+
MotionEvent.ACTION_DOWN -> true
|
|
17
|
+
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> false
|
|
18
|
+
else -> null
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -52,12 +52,33 @@ export type TextAnnotation = {
|
|
|
52
52
|
fontFamily?: string;
|
|
53
53
|
createdAt?: number;
|
|
54
54
|
};
|
|
55
|
-
export type
|
|
55
|
+
export type StampAnnotation = {
|
|
56
|
+
id: string;
|
|
57
|
+
type: 'stamp';
|
|
58
|
+
page: number;
|
|
59
|
+
/** Colour applied to the text glyph, as a CSS colour string (e.g. `'#FF0000'`). Has no visible effect on full-colour emoji. */
|
|
60
|
+
color: string;
|
|
61
|
+
bounds: AnnotationBounds;
|
|
62
|
+
/** A glyph or short string to render (e.g. an emoji, or a plain character like `'f'`). */
|
|
63
|
+
text: string;
|
|
64
|
+
createdAt?: number;
|
|
65
|
+
};
|
|
66
|
+
export type Annotation = InkAnnotation | HighlightAnnotation | UnderlineAnnotation | TextAnnotation | StampAnnotation;
|
|
56
67
|
export type AnnotationsData = {
|
|
57
68
|
version: 1;
|
|
58
69
|
annotations: Annotation[];
|
|
59
70
|
};
|
|
60
|
-
export type AnnotationMode = 'none' | 'ink' | 'highlight' | 'underline' | 'text' | 'eraser' | 'move';
|
|
71
|
+
export type AnnotationMode = 'none' | 'ink' | 'highlight' | 'underline' | 'text' | 'stamp' | 'eraser' | 'move';
|
|
72
|
+
/**
|
|
73
|
+
* Recommended shape for describing a consumer-defined stamp set (e.g. domain-specific glyphs).
|
|
74
|
+
* Purely a convenience type for organizing your own stamp picker UI — never sent to native;
|
|
75
|
+
* extract `text` to set as the `stampText` prop before placement.
|
|
76
|
+
*/
|
|
77
|
+
export type StampDefinition = {
|
|
78
|
+
id: string;
|
|
79
|
+
label: string;
|
|
80
|
+
text: string;
|
|
81
|
+
};
|
|
61
82
|
export type TextInputRequest = {
|
|
62
83
|
mode: 'create' | 'edit';
|
|
63
84
|
page: number;
|
|
@@ -86,6 +107,10 @@ export type ExpoPdfMarkupViewProps = {
|
|
|
86
107
|
* - Web: CSS font family (`"Georgia, serif"`) or `undefined` for `sans-serif`
|
|
87
108
|
*/
|
|
88
109
|
annotationFontFamily?: string;
|
|
110
|
+
/** Glyph or short string for the next stamp to place. Required for the `'stamp'` tool to place anything on tap. */
|
|
111
|
+
stampText?: string;
|
|
112
|
+
/** Side length, in PDF points, of the square bounding box for newly placed stamps. Defaults to 48. */
|
|
113
|
+
stampSize?: number;
|
|
89
114
|
/** Fired when the visible page changes. */
|
|
90
115
|
onPageChanged?: (event: {
|
|
91
116
|
nativeEvent: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPdfMarkup.types.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAA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,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPdfMarkup.types.js","sourceRoot":"","sources":["../src/ExpoPdfMarkup.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type AnnotationPoint = { x: number; y: number };\n\nexport type AnnotationBounds = { x: number; y: number; width: number; height: number };\n\nexport type InkAnnotation = {\n id: string;\n type: 'ink';\n page: number;\n color: string;\n lineWidth: number;\n paths: AnnotationPoint[][];\n createdAt?: number;\n};\n\nexport type HighlightAnnotation = {\n id: string;\n type: 'highlight';\n page: number;\n color: string;\n alpha?: number;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type UnderlineAnnotation = {\n id: string;\n type: 'underline';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type TextAnnotation = {\n id: string;\n type: 'text' | 'freeText';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n contents?: string;\n fontSize?: number;\n /**\n * Font family for the text annotation. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: family name (`\"serif\"`, `\"monospace\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n fontFamily?: string;\n createdAt?: number;\n};\n\nexport type
|
|
1
|
+
{"version":3,"file":"ExpoPdfMarkup.types.js","sourceRoot":"","sources":["../src/ExpoPdfMarkup.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type AnnotationPoint = { x: number; y: number };\n\nexport type AnnotationBounds = { x: number; y: number; width: number; height: number };\n\nexport type InkAnnotation = {\n id: string;\n type: 'ink';\n page: number;\n color: string;\n lineWidth: number;\n paths: AnnotationPoint[][];\n createdAt?: number;\n};\n\nexport type HighlightAnnotation = {\n id: string;\n type: 'highlight';\n page: number;\n color: string;\n alpha?: number;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type UnderlineAnnotation = {\n id: string;\n type: 'underline';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n createdAt?: number;\n};\n\nexport type TextAnnotation = {\n id: string;\n type: 'text' | 'freeText';\n page: number;\n color: string;\n bounds: AnnotationBounds;\n contents?: string;\n fontSize?: number;\n /**\n * Font family for the text annotation. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: family name (`\"serif\"`, `\"monospace\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n fontFamily?: string;\n createdAt?: number;\n};\n\nexport type StampAnnotation = {\n id: string;\n type: 'stamp';\n page: number;\n /** Colour applied to the text glyph, as a CSS colour string (e.g. `'#FF0000'`). Has no visible effect on full-colour emoji. */\n color: string;\n bounds: AnnotationBounds;\n /** A glyph or short string to render (e.g. an emoji, or a plain character like `'f'`). */\n text: string;\n createdAt?: number;\n};\n\nexport type Annotation =\n | InkAnnotation\n | HighlightAnnotation\n | UnderlineAnnotation\n | TextAnnotation\n | StampAnnotation;\n\nexport type AnnotationsData = {\n version: 1;\n annotations: Annotation[];\n};\n\nexport type AnnotationMode =\n | 'none'\n | 'ink'\n | 'highlight'\n | 'underline'\n | 'text'\n | 'stamp'\n | 'eraser'\n | 'move';\n\n/**\n * Recommended shape for describing a consumer-defined stamp set (e.g. domain-specific glyphs).\n * Purely a convenience type for organizing your own stamp picker UI — never sent to native;\n * extract `text` to set as the `stampText` prop before placement.\n */\nexport type StampDefinition = {\n id: string;\n label: string;\n text: string;\n};\n\nexport type TextInputRequest = {\n mode: 'create' | 'edit';\n page: number;\n point: AnnotationPoint;\n currentText?: string;\n};\n\nexport type ExpoPdfMarkupViewProps = {\n /** Absolute local file path of the PDF to display. */\n source: string;\n /** 0-based page number to display. Can be used to restore scroll position on orientation change. */\n page?: number;\n /** Background colour shown behind the PDF pages. */\n backgroundColor?: string;\n /** Serialised {@link AnnotationsData} JSON string to load when the document opens. */\n annotations?: string;\n /** Active annotation tool. Defaults to `'none'` (view-only). */\n annotationMode?: AnnotationMode;\n /** Colour applied to new annotations, as a CSS colour string (e.g. `'#FF0000'`). */\n annotationColor?: string;\n /** Stroke width in points applied to new ink annotations. */\n annotationLineWidth?: number;\n /**\n * Default font family for new text annotations. Platform-specific:\n * - iOS: PostScript name (`\"Georgia\"`, `\"Courier\"`) or `undefined` for system font (San Francisco)\n * - Android: React Native / Expo font family name (`\"Montserrat-Regular\"`, `\"serif\"`) or `undefined` for default sans-serif\n * - Web: CSS font family (`\"Georgia, serif\"`) or `undefined` for `sans-serif`\n */\n annotationFontFamily?: string;\n /** Glyph or short string for the next stamp to place. Required for the `'stamp'` tool to place anything on tap. */\n stampText?: string;\n /** Side length, in PDF points, of the square bounding box for newly placed stamps. Defaults to 48. */\n stampSize?: number;\n /** Fired when the visible page changes. */\n onPageChanged?: (event: {\n nativeEvent: { page: number; pageCount: number; pageWidth: number; pageHeight: number };\n }) => void;\n /** Fired once the document has finished loading. */\n onLoadComplete?: (event: { nativeEvent: { pageCount: number } }) => void;\n /** Fired when the document fails to load. */\n onError?: (event: { nativeEvent: { message: string } }) => void;\n /** Fired after annotations are created or edited. `annotations` is a serialised {@link AnnotationsData} JSON string. */\n onAnnotationsChanged?: (event: { nativeEvent: { annotations: string } }) => void;\n /**\n * Optional async callback for the text annotation tool. When provided, this is called instead of\n * the native platform dialog (UIAlertController / AlertDialog) when the user taps to place a text\n * annotation. When editing an existing text annotation, `request.currentText` is populated and\n * `request.mode` is `'edit'`. Return the text string to create/update the annotation, or `null`\n * to cancel.\n */\n onTextInputRequested?: (request: TextInputRequest) => Promise<string | null>;\n style?: StyleProp<ViewStyle>;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPdfMarkupView.web.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAGV,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAuB/B,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;
|
|
1
|
+
{"version":3,"file":"ExpoPdfMarkupView.web.d.ts","sourceRoot":"","sources":["../src/ExpoPdfMarkupView.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAGV,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAuB/B,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;AAoYD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAqWtE"}
|
|
@@ -18,7 +18,7 @@ export function setPdfJsWorkerSrc(url) {
|
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
const MIN_ZOOM = 1;
|
|
20
20
|
const MAX_ZOOM = 5;
|
|
21
|
-
function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotationColor, annotationLineWidth, zoomLevel, onAnnotationAdded, onAnnotationRemoved, onAnnotationUpdated, onTextInputRequested, containerRef, }) {
|
|
21
|
+
function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotationColor, annotationLineWidth, stampText, stampSize, zoomLevel, onAnnotationAdded, onAnnotationRemoved, onAnnotationUpdated, onTextInputRequested, containerRef, }) {
|
|
22
22
|
const pdfCanvasRef = React.useRef(null);
|
|
23
23
|
const annotCanvasRef = React.useRef(null);
|
|
24
24
|
const pageRef = React.useRef(null);
|
|
@@ -194,7 +194,10 @@ function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotatio
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
function handlePointerUp(e) {
|
|
197
|
-
if (!pointerDownRef.current &&
|
|
197
|
+
if (!pointerDownRef.current &&
|
|
198
|
+
annotationMode !== 'text' &&
|
|
199
|
+
annotationMode !== 'eraser' &&
|
|
200
|
+
annotationMode !== 'stamp')
|
|
198
201
|
return;
|
|
199
202
|
pointerDownRef.current = false;
|
|
200
203
|
const pt = getCanvasPoint(e);
|
|
@@ -280,9 +283,35 @@ function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotatio
|
|
|
280
283
|
if (hit)
|
|
281
284
|
onAnnotationRemoved(hit.id);
|
|
282
285
|
}
|
|
286
|
+
else if (annotationMode === 'stamp') {
|
|
287
|
+
if (!stampText)
|
|
288
|
+
return;
|
|
289
|
+
const pdfPoint = canvasToPdf(pt.x, pt.y, scale, pdfHeight);
|
|
290
|
+
const half = stampSize / 2;
|
|
291
|
+
onAnnotationAdded({
|
|
292
|
+
id: newAnnotationId(),
|
|
293
|
+
type: 'stamp',
|
|
294
|
+
page: pageIndex,
|
|
295
|
+
color: annotationColor,
|
|
296
|
+
bounds: {
|
|
297
|
+
x: pdfPoint.x - half,
|
|
298
|
+
y: pdfPoint.y - half,
|
|
299
|
+
width: stampSize,
|
|
300
|
+
height: stampSize,
|
|
301
|
+
},
|
|
302
|
+
text: stampText,
|
|
303
|
+
createdAt: Date.now(),
|
|
304
|
+
});
|
|
305
|
+
}
|
|
283
306
|
}
|
|
284
307
|
const pointerEvents = annotationMode === 'none' ? 'none' : 'auto';
|
|
285
|
-
const cursor = annotationMode === 'move'
|
|
308
|
+
const cursor = annotationMode === 'move'
|
|
309
|
+
? 'grab'
|
|
310
|
+
: annotationMode === 'eraser'
|
|
311
|
+
? 'not-allowed'
|
|
312
|
+
: annotationMode === 'stamp'
|
|
313
|
+
? 'copy'
|
|
314
|
+
: 'crosshair';
|
|
286
315
|
return (<div ref={containerRef} style={{ position: 'relative', width: cssWidth, height: cssHeight, margin: '0 auto' }}>
|
|
287
316
|
<canvas ref={pdfCanvasRef} style={{
|
|
288
317
|
position: 'absolute',
|
|
@@ -307,7 +336,7 @@ function PageView({ doc, pageIndex, meta, annotations, annotationMode, annotatio
|
|
|
307
336
|
// Main component
|
|
308
337
|
// ---------------------------------------------------------------------------
|
|
309
338
|
export default function ExpoPdfMarkupView(props) {
|
|
310
|
-
const { source, page: propPage, backgroundColor = '#f0f0f0', annotations: annotationsProp, annotationMode = 'none', annotationColor = '#FF0000', annotationLineWidth = 2, annotationFontFamily, onPageChanged, onLoadComplete, onError, onAnnotationsChanged, onTextInputRequested, style, } = props;
|
|
339
|
+
const { source, page: propPage, backgroundColor = '#f0f0f0', annotations: annotationsProp, annotationMode = 'none', annotationColor = '#FF0000', annotationLineWidth = 2, annotationFontFamily, stampText, stampSize = 48, onPageChanged, onLoadComplete, onError, onAnnotationsChanged, onTextInputRequested, style, } = props;
|
|
311
340
|
const scrollContainerRef = React.useRef(null);
|
|
312
341
|
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
313
342
|
const [doc, setDoc] = React.useState(null);
|
|
@@ -579,7 +608,7 @@ export default function ExpoPdfMarkupView(props) {
|
|
|
579
608
|
<div style={{ zoom: zoomLevel }}>
|
|
580
609
|
{doc &&
|
|
581
610
|
pageMetas.map((meta, i) => (<React.Fragment key={i}>
|
|
582
|
-
<PageView doc={doc} pageIndex={i} meta={meta} annotations={annotations} annotationMode={annotationMode} annotationColor={annotationColor} annotationLineWidth={annotationLineWidth} zoomLevel={zoomLevel} onAnnotationAdded={handleAnnotationAdded} onAnnotationRemoved={handleAnnotationRemoved} onAnnotationUpdated={handleAnnotationUpdated} onTextInputRequested={handleTextInputRequested} containerRef={(el) => {
|
|
611
|
+
<PageView doc={doc} pageIndex={i} meta={meta} annotations={annotations} annotationMode={annotationMode} annotationColor={annotationColor} annotationLineWidth={annotationLineWidth} stampText={stampText} stampSize={stampSize} zoomLevel={zoomLevel} onAnnotationAdded={handleAnnotationAdded} onAnnotationRemoved={handleAnnotationRemoved} onAnnotationUpdated={handleAnnotationUpdated} onTextInputRequested={handleTextInputRequested} containerRef={(el) => {
|
|
583
612
|
pageContainerRefs.current[i] = el;
|
|
584
613
|
}}/>
|
|
585
614
|
{i < pageMetas.length - 1 && <div style={{ height: 8 }} aria-hidden/>}
|