@papyrus-sdk/ui-react-native 0.2.21 → 0.2.22
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.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,14 @@ interface ViewerProps {
|
|
|
11
11
|
removeClippedSubviews?: boolean;
|
|
12
12
|
useDedicatedAndroidPdfViewer?: boolean;
|
|
13
13
|
viewerMode?: PdfViewerMode;
|
|
14
|
+
onTextSelected?: (payload: {
|
|
15
|
+
text: string;
|
|
16
|
+
pageIndex: number;
|
|
17
|
+
}) => void;
|
|
18
|
+
onDefineSelection?: (payload: {
|
|
19
|
+
text: string;
|
|
20
|
+
pageIndex: number;
|
|
21
|
+
}) => void;
|
|
14
22
|
}
|
|
15
23
|
declare const Viewer: React.FC<ViewerProps>;
|
|
16
24
|
|
|
@@ -26,6 +34,14 @@ interface PageRendererProps {
|
|
|
26
34
|
horizontalPadding?: number;
|
|
27
35
|
spacing?: number;
|
|
28
36
|
onSelectionDragActiveChange?: (active: boolean) => void;
|
|
37
|
+
onTextSelected?: (payload: {
|
|
38
|
+
text: string;
|
|
39
|
+
pageIndex: number;
|
|
40
|
+
}) => void;
|
|
41
|
+
onDefineSelection?: (payload: {
|
|
42
|
+
text: string;
|
|
43
|
+
pageIndex: number;
|
|
44
|
+
}) => void;
|
|
29
45
|
gestureScrollLockActive?: boolean;
|
|
30
46
|
lastPinchEndedAt?: number | null;
|
|
31
47
|
requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ interface ViewerProps {
|
|
|
11
11
|
removeClippedSubviews?: boolean;
|
|
12
12
|
useDedicatedAndroidPdfViewer?: boolean;
|
|
13
13
|
viewerMode?: PdfViewerMode;
|
|
14
|
+
onTextSelected?: (payload: {
|
|
15
|
+
text: string;
|
|
16
|
+
pageIndex: number;
|
|
17
|
+
}) => void;
|
|
18
|
+
onDefineSelection?: (payload: {
|
|
19
|
+
text: string;
|
|
20
|
+
pageIndex: number;
|
|
21
|
+
}) => void;
|
|
14
22
|
}
|
|
15
23
|
declare const Viewer: React.FC<ViewerProps>;
|
|
16
24
|
|
|
@@ -26,6 +34,14 @@ interface PageRendererProps {
|
|
|
26
34
|
horizontalPadding?: number;
|
|
27
35
|
spacing?: number;
|
|
28
36
|
onSelectionDragActiveChange?: (active: boolean) => void;
|
|
37
|
+
onTextSelected?: (payload: {
|
|
38
|
+
text: string;
|
|
39
|
+
pageIndex: number;
|
|
40
|
+
}) => void;
|
|
41
|
+
onDefineSelection?: (payload: {
|
|
42
|
+
text: string;
|
|
43
|
+
pageIndex: number;
|
|
44
|
+
}) => void;
|
|
29
45
|
gestureScrollLockActive?: boolean;
|
|
30
46
|
lastPinchEndedAt?: number | null;
|
|
31
47
|
requestSelectionVerticalAutoscroll?: (absoluteY: number) => number;
|
package/dist/index.js
CHANGED
|
@@ -21632,6 +21632,7 @@ var import_react_native = require("react-native");
|
|
|
21632
21632
|
var import_react_native_gesture_handler = require("react-native-gesture-handler");
|
|
21633
21633
|
var import_react_native_svg = __toESM(require("react-native-svg"));
|
|
21634
21634
|
var import_core = require("@papyrus-sdk/core");
|
|
21635
|
+
var import_types = require("@papyrus-sdk/types");
|
|
21635
21636
|
var import_engine_native = require("@papyrus-sdk/engine-native");
|
|
21636
21637
|
|
|
21637
21638
|
// perf/mobilePerf.ts
|
|
@@ -22088,6 +22089,14 @@ var resolvePdfBasePageWidth = ({
|
|
|
22088
22089
|
horizontalPadding
|
|
22089
22090
|
}) => Math.max(0, viewportWidth - horizontalPadding * 2);
|
|
22090
22091
|
|
|
22092
|
+
// components/selectionEvent.ts
|
|
22093
|
+
var notifyTextSelection = (handler, payload) => {
|
|
22094
|
+
const text = payload.text.replace(/\s+/g, " ").trim();
|
|
22095
|
+
if (!text) return false;
|
|
22096
|
+
handler?.({ ...payload, text });
|
|
22097
|
+
return Boolean(handler);
|
|
22098
|
+
};
|
|
22099
|
+
|
|
22091
22100
|
// components/PageRenderer.tsx
|
|
22092
22101
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
22093
22102
|
var TEXT_MARKUP_TOOLS = /* @__PURE__ */ new Set([
|
|
@@ -22162,6 +22171,8 @@ var PageRenderer = ({
|
|
|
22162
22171
|
horizontalPadding = 16,
|
|
22163
22172
|
spacing = 24,
|
|
22164
22173
|
onSelectionDragActiveChange,
|
|
22174
|
+
onTextSelected,
|
|
22175
|
+
onDefineSelection,
|
|
22165
22176
|
gestureScrollLockActive = false,
|
|
22166
22177
|
lastPinchEndedAt = null,
|
|
22167
22178
|
requestSelectionVerticalAutoscroll
|
|
@@ -22507,6 +22518,17 @@ var PageRenderer = ({
|
|
|
22507
22518
|
return;
|
|
22508
22519
|
}
|
|
22509
22520
|
const selectedText = selection.text || "";
|
|
22521
|
+
const normalizedText = selectedText.replace(/\s+/g, " ").trim();
|
|
22522
|
+
if (normalizedText) {
|
|
22523
|
+
import_core.papyrusEvents.emit(import_types.PapyrusEventType.TEXT_SELECTED, {
|
|
22524
|
+
text: normalizedText,
|
|
22525
|
+
pageIndex
|
|
22526
|
+
});
|
|
22527
|
+
}
|
|
22528
|
+
notifyTextSelection(onTextSelected, {
|
|
22529
|
+
text: normalizedText,
|
|
22530
|
+
pageIndex
|
|
22531
|
+
});
|
|
22510
22532
|
logSelectionPerf("selection.ready", {
|
|
22511
22533
|
tool: activeTool,
|
|
22512
22534
|
sourceRectCount: selection.rects.length,
|
|
@@ -23442,6 +23464,20 @@ var PageRenderer = ({
|
|
|
23442
23464
|
}
|
|
23443
23465
|
],
|
|
23444
23466
|
children: [
|
|
23467
|
+
onDefineSelection ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
23468
|
+
import_react_native.Pressable,
|
|
23469
|
+
{
|
|
23470
|
+
onPress: (event) => {
|
|
23471
|
+
stopPressPropagation(event);
|
|
23472
|
+
onDefineSelection({
|
|
23473
|
+
text: selectionText,
|
|
23474
|
+
pageIndex
|
|
23475
|
+
});
|
|
23476
|
+
},
|
|
23477
|
+
style: [styles.selectionAction, styles.defineSelectionAction],
|
|
23478
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.defineSelectionText, children: "Definir" })
|
|
23479
|
+
}
|
|
23480
|
+
) : null,
|
|
23445
23481
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
23446
23482
|
import_react_native.Pressable,
|
|
23447
23483
|
{
|
|
@@ -23741,6 +23777,15 @@ var styles = import_react_native.StyleSheet.create({
|
|
|
23741
23777
|
justifyContent: "center",
|
|
23742
23778
|
marginRight: 10
|
|
23743
23779
|
},
|
|
23780
|
+
defineSelectionAction: {
|
|
23781
|
+
width: 58,
|
|
23782
|
+
paddingHorizontal: 6
|
|
23783
|
+
},
|
|
23784
|
+
defineSelectionText: {
|
|
23785
|
+
color: "#FFFFFF",
|
|
23786
|
+
fontSize: 11,
|
|
23787
|
+
fontWeight: "700"
|
|
23788
|
+
},
|
|
23744
23789
|
selectionActionLast: {
|
|
23745
23790
|
marginRight: 0
|
|
23746
23791
|
},
|
|
@@ -23772,7 +23817,7 @@ var styles = import_react_native.StyleSheet.create({
|
|
|
23772
23817
|
borderRadius: 3
|
|
23773
23818
|
}
|
|
23774
23819
|
});
|
|
23775
|
-
var arePageRendererPropsEqual = (previous, next) => previous.engine === next.engine && previous.pageIndex === next.pageIndex && previous.scale === next.scale && previous.PageViewComponent === next.PageViewComponent && previous.availableWidth === next.availableWidth && previous.pageViewportWidth === next.pageViewportWidth && previous.horizontalPadding === next.horizontalPadding && previous.spacing === next.spacing && previous.onSelectionDragActiveChange === next.onSelectionDragActiveChange && previous.gestureScrollLockActive === next.gestureScrollLockActive && previous.lastPinchEndedAt === next.lastPinchEndedAt && previous.requestSelectionVerticalAutoscroll === next.requestSelectionVerticalAutoscroll;
|
|
23820
|
+
var arePageRendererPropsEqual = (previous, next) => previous.engine === next.engine && previous.pageIndex === next.pageIndex && previous.scale === next.scale && previous.PageViewComponent === next.PageViewComponent && previous.availableWidth === next.availableWidth && previous.pageViewportWidth === next.pageViewportWidth && previous.horizontalPadding === next.horizontalPadding && previous.spacing === next.spacing && previous.onSelectionDragActiveChange === next.onSelectionDragActiveChange && previous.onTextSelected === next.onTextSelected && previous.onDefineSelection === next.onDefineSelection && previous.gestureScrollLockActive === next.gestureScrollLockActive && previous.lastPinchEndedAt === next.lastPinchEndedAt && previous.requestSelectionVerticalAutoscroll === next.requestSelectionVerticalAutoscroll;
|
|
23776
23821
|
var PageRenderer_default = (0, import_react.memo)(PageRenderer, arePageRendererPropsEqual);
|
|
23777
23822
|
|
|
23778
23823
|
// components/WebViewViewer.tsx
|
|
@@ -24926,7 +24971,9 @@ var Viewer = ({
|
|
|
24926
24971
|
maxToRenderPerBatch,
|
|
24927
24972
|
removeClippedSubviews,
|
|
24928
24973
|
useDedicatedAndroidPdfViewer,
|
|
24929
|
-
viewerMode
|
|
24974
|
+
viewerMode,
|
|
24975
|
+
onTextSelected,
|
|
24976
|
+
onDefineSelection
|
|
24930
24977
|
}) => {
|
|
24931
24978
|
const pageCount = (0, import_core4.useViewerStore)((state) => state.pageCount);
|
|
24932
24979
|
const currentPage = (0, import_core4.useViewerStore)((state) => state.currentPage);
|
|
@@ -26062,6 +26109,8 @@ var Viewer = ({
|
|
|
26062
26109
|
pageViewportWidth: columnWidth,
|
|
26063
26110
|
spacing: DOUBLE_PAGE_SPACING,
|
|
26064
26111
|
onSelectionDragActiveChange: setSelectionDragActive,
|
|
26112
|
+
onTextSelected,
|
|
26113
|
+
onDefineSelection,
|
|
26065
26114
|
gestureScrollLockActive,
|
|
26066
26115
|
lastPinchEndedAt,
|
|
26067
26116
|
requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
|
|
@@ -26078,6 +26127,8 @@ var Viewer = ({
|
|
|
26078
26127
|
pageViewportWidth: columnWidth,
|
|
26079
26128
|
spacing: DOUBLE_PAGE_SPACING,
|
|
26080
26129
|
onSelectionDragActiveChange: setSelectionDragActive,
|
|
26130
|
+
onTextSelected,
|
|
26131
|
+
onDefineSelection,
|
|
26081
26132
|
gestureScrollLockActive,
|
|
26082
26133
|
lastPinchEndedAt,
|
|
26083
26134
|
requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
|
|
@@ -26097,6 +26148,8 @@ var Viewer = ({
|
|
|
26097
26148
|
pageViewportWidth: documentSurfaceWidth,
|
|
26098
26149
|
spacing: CONTINUOUS_PAGE_SPACING,
|
|
26099
26150
|
onSelectionDragActiveChange: setSelectionDragActive,
|
|
26151
|
+
onTextSelected,
|
|
26152
|
+
onDefineSelection,
|
|
26100
26153
|
gestureScrollLockActive,
|
|
26101
26154
|
lastPinchEndedAt,
|
|
26102
26155
|
requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
|
|
@@ -26186,6 +26239,8 @@ var Viewer = ({
|
|
|
26186
26239
|
pageViewportWidth: documentSurfaceWidth,
|
|
26187
26240
|
spacing: 32,
|
|
26188
26241
|
onSelectionDragActiveChange: setSelectionDragActive,
|
|
26242
|
+
onTextSelected,
|
|
26243
|
+
onDefineSelection,
|
|
26189
26244
|
gestureScrollLockActive,
|
|
26190
26245
|
lastPinchEndedAt,
|
|
26191
26246
|
requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
|