@kne/react-pdf-sign 1.0.2 → 1.0.3
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/README.md +28 -26
- package/dist/index.js +18 -23
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +18 -23
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,24 +73,26 @@ const BaseExample = () => {
|
|
|
73
73
|
}}
|
|
74
74
|
/>
|
|
75
75
|
</Button>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
76
|
+
{pdfFile && (
|
|
77
|
+
<Button
|
|
78
|
+
onClick={() => {
|
|
79
|
+
const { size } = ref.current.getLocation();
|
|
80
|
+
signatureModal({
|
|
81
|
+
mask: (
|
|
82
|
+
<Flex justify="flex-end" align="flex-end" style={{ height: '100%', width: '100%', padding: '10px', boxSizing: 'border-box' }}>
|
|
83
|
+
签字日期: {new Date().toLocaleDateString()}
|
|
84
|
+
</Flex>
|
|
85
|
+
),
|
|
86
|
+
width: size.width,
|
|
87
|
+
height: size.height,
|
|
88
|
+
onSuccess: file => {
|
|
89
|
+
setSign(URL.createObjectURL(file));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}}>
|
|
93
|
+
添加签名
|
|
94
|
+
</Button>
|
|
95
|
+
)}
|
|
94
96
|
{pdfFile && sign && (
|
|
95
97
|
<Button
|
|
96
98
|
onClick={async () => {
|
|
@@ -187,15 +189,15 @@ const BaseExample = () => {
|
|
|
187
189
|
onClick={() => {
|
|
188
190
|
ref.current.setLocation({
|
|
189
191
|
size: {
|
|
190
|
-
width:
|
|
191
|
-
height:
|
|
192
|
-
x:
|
|
193
|
-
y:
|
|
192
|
+
width: 390,
|
|
193
|
+
height: 156,
|
|
194
|
+
x: 163,
|
|
195
|
+
y: 8
|
|
194
196
|
},
|
|
195
|
-
scaleX: 1,
|
|
196
|
-
scaleY: 1,
|
|
197
|
-
x:
|
|
198
|
-
y:
|
|
197
|
+
scaleX: 1.95,
|
|
198
|
+
scaleY: 1.95,
|
|
199
|
+
x: 163,
|
|
200
|
+
y: 8
|
|
199
201
|
});
|
|
200
202
|
}}>
|
|
201
203
|
设置签名位置
|
package/dist/index.js
CHANGED
|
@@ -199,7 +199,6 @@ const LocationLayer = withLocale(p => {
|
|
|
199
199
|
const [signatureImage] = useImage__default["default"](signature);
|
|
200
200
|
const groupRef = react.useRef();
|
|
201
201
|
const signRef = react.useRef();
|
|
202
|
-
const targetRef = react.useRef();
|
|
203
202
|
const transformerRef = react.useRef();
|
|
204
203
|
const computedSignLocation = () => {
|
|
205
204
|
const absolutePosition = signRef.current.absolutePosition();
|
|
@@ -211,8 +210,8 @@ const LocationLayer = withLocale(p => {
|
|
|
211
210
|
x: Math.round(absolutePosition.x),
|
|
212
211
|
y: Math.round(absolutePosition.y)
|
|
213
212
|
},
|
|
214
|
-
scaleX: Number(
|
|
215
|
-
scaleY: Number(
|
|
213
|
+
scaleX: Number(groupRef.current.attrs.scaleX.toFixed(2)),
|
|
214
|
+
scaleY: Number(groupRef.current.attrs.scaleY.toFixed(2)),
|
|
216
215
|
x: Math.round(groupRef.current.attrs.x),
|
|
217
216
|
y: Math.round(groupRef.current.attrs.y)
|
|
218
217
|
});
|
|
@@ -247,7 +246,7 @@ const LocationLayer = withLocale(p => {
|
|
|
247
246
|
}, []);
|
|
248
247
|
react.useEffect(() => {
|
|
249
248
|
if (isInit) {
|
|
250
|
-
transformerRef.current.nodes([
|
|
249
|
+
transformerRef.current.nodes([groupRef.current]);
|
|
251
250
|
}
|
|
252
251
|
}, [isInit]);
|
|
253
252
|
if (!(isInit && value)) {
|
|
@@ -263,22 +262,21 @@ const LocationLayer = withLocale(p => {
|
|
|
263
262
|
draggable: true,
|
|
264
263
|
ref: groupRef,
|
|
265
264
|
onDragEnd: computedSignLocation,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
})
|
|
265
|
+
scaleX: value.scaleX,
|
|
266
|
+
scaleY: value.scaleY,
|
|
267
|
+
onTransformEnd: computedSignLocation,
|
|
268
|
+
children: [signatureImage ? /*#__PURE__*/jsxRuntime.jsx(reactKonva.Image, {
|
|
269
|
+
width: width,
|
|
270
|
+
height: height,
|
|
271
|
+
image: signatureImage,
|
|
272
|
+
cornerRadius: 8,
|
|
273
|
+
ref: signRef
|
|
274
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
275
|
+
width: width,
|
|
276
|
+
height: height,
|
|
277
|
+
fill: "#f0f0f0",
|
|
278
|
+
cornerRadius: 8,
|
|
279
|
+
ref: signRef
|
|
282
280
|
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
|
|
283
281
|
text: signatureImage ? '' : placeholder,
|
|
284
282
|
fontSize: 16,
|
|
@@ -290,9 +288,6 @@ const LocationLayer = withLocale(p => {
|
|
|
290
288
|
height: height
|
|
291
289
|
})]
|
|
292
290
|
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Transformer, {
|
|
293
|
-
scaleX: value.scaleX,
|
|
294
|
-
scaleY: value.scaleY,
|
|
295
|
-
centeredScaling: true,
|
|
296
291
|
ref: transformerRef,
|
|
297
292
|
keepRatio: true,
|
|
298
293
|
flipEnabled: false,
|