react-screenshots 0.5.1 → 0.5.10
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/electron/assets/{index.72e90af8.css → index.95e77ee2.css} +1 -1
- package/electron/assets/index.c68b977f.js +14 -0
- package/electron/electron.html +2 -2
- package/lib/react-screenshots.cjs.js +4 -4
- package/lib/react-screenshots.es.js +160 -108
- package/lib/style.css +1 -1
- package/lib/types/ScreenshotsBackground/index.d.ts +3 -2
- package/lib/types/ScreenshotsButton/index.d.ts +3 -2
- package/lib/types/ScreenshotsCanvas/index.d.ts +1 -1
- package/lib/types/ScreenshotsColor/index.d.ts +3 -2
- package/lib/types/ScreenshotsMagnifier/index.d.ts +3 -2
- package/lib/types/ScreenshotsOperations/index.d.ts +4 -3
- package/lib/types/ScreenshotsOption/index.d.ts +3 -2
- package/lib/types/ScreenshotsSize/index.d.ts +3 -2
- package/lib/types/ScreenshotsSizeColor/index.d.ts +3 -2
- package/lib/types/ScreenshotsTextarea/index.d.ts +3 -2
- package/lib/types/composeImage.d.ts +10 -0
- package/lib/types/exports.d.ts +1 -1
- package/package.json +7 -7
- package/electron/assets/index.77e4c335.js +0 -14
- package/lib/types/Screenshots/index.d.ts +0 -13
- package/lib/types/imageToBlob.d.ts +0 -5
|
@@ -29,26 +29,36 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
import React, { useContext, useCallback, useState, useRef, useLayoutEffect, useEffect, forwardRef, useImperativeHandle, cloneElement } from "react";
|
|
32
|
+
import React, { useContext, useCallback, memo, useState, useRef, useLayoutEffect, useEffect, forwardRef, useImperativeHandle, cloneElement } from "react";
|
|
33
33
|
import { createPortal } from "react-dom";
|
|
34
|
-
var
|
|
35
|
-
function
|
|
34
|
+
var HistoryItemType;
|
|
35
|
+
(function(HistoryItemType2) {
|
|
36
|
+
HistoryItemType2[HistoryItemType2["Edit"] = 0] = "Edit";
|
|
37
|
+
HistoryItemType2[HistoryItemType2["Source"] = 1] = "Source";
|
|
38
|
+
})(HistoryItemType || (HistoryItemType = {}));
|
|
39
|
+
function composeImage({ image, width, height, history, bounds }) {
|
|
36
40
|
return new Promise((resolve, reject) => {
|
|
37
|
-
if (!image.complete) {
|
|
38
|
-
return reject(new Error("image is not fully loaded"));
|
|
39
|
-
}
|
|
40
41
|
const $canvas = document.createElement("canvas");
|
|
41
|
-
const targetWidth = width * window.devicePixelRatio;
|
|
42
|
-
const targetHeight = height * window.devicePixelRatio;
|
|
42
|
+
const targetWidth = bounds.width * window.devicePixelRatio;
|
|
43
|
+
const targetHeight = bounds.height * window.devicePixelRatio;
|
|
43
44
|
$canvas.width = targetWidth;
|
|
44
45
|
$canvas.height = targetHeight;
|
|
45
46
|
const ctx = $canvas.getContext("2d");
|
|
46
47
|
if (!ctx) {
|
|
47
48
|
return reject(new Error("convert image to blob fail"));
|
|
48
49
|
}
|
|
50
|
+
const rx = image.naturalWidth / width;
|
|
51
|
+
const ry = image.naturalHeight / height;
|
|
49
52
|
ctx.imageSmoothingEnabled = true;
|
|
50
53
|
ctx.imageSmoothingQuality = "low";
|
|
51
|
-
ctx.
|
|
54
|
+
ctx.setTransform(window.devicePixelRatio, 0, 0, window.devicePixelRatio, 0, 0);
|
|
55
|
+
ctx.clearRect(0, 0, bounds.width, bounds.height);
|
|
56
|
+
ctx.drawImage(image, bounds.x * rx, bounds.y * ry, bounds.width * rx, bounds.height * ry, 0, 0, bounds.width, bounds.height);
|
|
57
|
+
history.stack.slice(0, history.index + 1).forEach((item) => {
|
|
58
|
+
if (item.type === HistoryItemType.Source) {
|
|
59
|
+
item.draw(ctx, item);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
52
62
|
$canvas.toBlob((blob) => {
|
|
53
63
|
if (!blob) {
|
|
54
64
|
return reject(new Error("canvas toBlob fail"));
|
|
@@ -57,6 +67,7 @@ function imageToBlob(image, { width, height }) {
|
|
|
57
67
|
}, "image/png");
|
|
58
68
|
});
|
|
59
69
|
}
|
|
70
|
+
var iconfont = "";
|
|
60
71
|
var screenshots = "";
|
|
61
72
|
const zhCN = {
|
|
62
73
|
magnifier_position_label: "\u5750\u6807",
|
|
@@ -130,7 +141,7 @@ var index$9 = "";
|
|
|
130
141
|
var _jsxFileName$l = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsMagnifier/index.tsx";
|
|
131
142
|
const magnifierWidth = 100;
|
|
132
143
|
const magnifierHeight = 80;
|
|
133
|
-
|
|
144
|
+
var ScreenshotsMagnifier = memo(function ScreenshotsMagnifier2({
|
|
134
145
|
x,
|
|
135
146
|
y
|
|
136
147
|
}) {
|
|
@@ -247,7 +258,7 @@ function ScreenshotsMagnifier({
|
|
|
247
258
|
columnNumber: 9
|
|
248
259
|
}
|
|
249
260
|
}, "RGB: #", rgb)));
|
|
250
|
-
}
|
|
261
|
+
});
|
|
251
262
|
function getBoundsByPoints$2({ x: x1, y: y1 }, { x: x2, y: y2 }, width, height) {
|
|
252
263
|
if (x1 > x2) {
|
|
253
264
|
[x1, x2] = [x2, x1];
|
|
@@ -276,7 +287,7 @@ function getBoundsByPoints$2({ x: x1, y: y1 }, { x: x2, y: y2 }, width, height)
|
|
|
276
287
|
}
|
|
277
288
|
var index$8 = "";
|
|
278
289
|
var _jsxFileName$k = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsBackground/index.tsx";
|
|
279
|
-
|
|
290
|
+
var ScreenshotsBackground = memo(function ScreenshotsBackground2() {
|
|
280
291
|
const {
|
|
281
292
|
url,
|
|
282
293
|
image,
|
|
@@ -401,7 +412,7 @@ function ScreenshotsBackground() {
|
|
|
401
412
|
columnNumber: 31
|
|
402
413
|
}
|
|
403
414
|
}));
|
|
404
|
-
}
|
|
415
|
+
});
|
|
405
416
|
function useCursor() {
|
|
406
417
|
const { cursor } = useStore();
|
|
407
418
|
const { setCursor } = useDispatcher();
|
|
@@ -454,11 +465,6 @@ function useEmiter() {
|
|
|
454
465
|
reset
|
|
455
466
|
};
|
|
456
467
|
}
|
|
457
|
-
var HistoryItemType;
|
|
458
|
-
(function(HistoryItemType2) {
|
|
459
|
-
HistoryItemType2[HistoryItemType2["Edit"] = 0] = "Edit";
|
|
460
|
-
HistoryItemType2[HistoryItemType2["Source"] = 1] = "Source";
|
|
461
|
-
})(HistoryItemType || (HistoryItemType = {}));
|
|
462
468
|
function useHistory() {
|
|
463
469
|
const { history } = useStore();
|
|
464
470
|
const { setHistory } = useDispatcher();
|
|
@@ -715,8 +721,9 @@ var ResizePoints;
|
|
|
715
721
|
ResizePoints2["Move"] = "move";
|
|
716
722
|
})(ResizePoints || (ResizePoints = {}));
|
|
717
723
|
const resizePoints = [ResizePoints.ResizeTop, ResizePoints.ResizetopRight, ResizePoints.ResizeRight, ResizePoints.ResizeRightBottom, ResizePoints.ResizeBottom, ResizePoints.ResizeBottomLeft, ResizePoints.ResizeLeft, ResizePoints.ResizeLeftTop];
|
|
718
|
-
var ScreenshotsCanvas = forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
724
|
+
var ScreenshotsCanvas = memo(forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
719
725
|
const {
|
|
726
|
+
url,
|
|
720
727
|
image,
|
|
721
728
|
width,
|
|
722
729
|
height
|
|
@@ -732,23 +739,19 @@ var ScreenshotsCanvas = forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
|
732
739
|
const canvasRef = useRef(null);
|
|
733
740
|
const ctxRef = useRef(null);
|
|
734
741
|
const draw2 = useCallback(() => {
|
|
735
|
-
if (!
|
|
742
|
+
if (!bounds || !ctxRef.current) {
|
|
736
743
|
return;
|
|
737
744
|
}
|
|
738
|
-
const rx = image.naturalWidth / width;
|
|
739
|
-
const ry = image.naturalHeight / height;
|
|
740
745
|
const ctx = ctxRef.current;
|
|
741
746
|
ctx.imageSmoothingEnabled = true;
|
|
742
747
|
ctx.imageSmoothingQuality = "low";
|
|
743
|
-
ctx.setTransform(window.devicePixelRatio, 0, 0, window.devicePixelRatio, 0, 0);
|
|
744
748
|
ctx.clearRect(0, 0, bounds.width, bounds.height);
|
|
745
|
-
ctx.drawImage(image, bounds.x * rx, bounds.y * ry, bounds.width * rx, bounds.height * ry, 0, 0, bounds.width, bounds.height);
|
|
746
749
|
history.stack.slice(0, history.index + 1).forEach((item) => {
|
|
747
750
|
if (item.type === HistoryItemType.Source) {
|
|
748
751
|
item.draw(ctx, item);
|
|
749
752
|
}
|
|
750
753
|
});
|
|
751
|
-
}, [
|
|
754
|
+
}, [bounds, ctxRef, history]);
|
|
752
755
|
const onMouseDown = useCallback((e, resizeOrMove) => {
|
|
753
756
|
if (e.button !== 0 || !bounds) {
|
|
754
757
|
return;
|
|
@@ -823,39 +826,54 @@ var ScreenshotsCanvas = forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
|
823
826
|
};
|
|
824
827
|
}, [updateBounds, operation, emiter]);
|
|
825
828
|
useImperativeHandle(ref, () => ctxRef.current);
|
|
826
|
-
if (!bounds) {
|
|
827
|
-
return null;
|
|
828
|
-
}
|
|
829
829
|
return /* @__PURE__ */ React.createElement("div", {
|
|
830
830
|
className: "screenshots-canvas",
|
|
831
831
|
style: {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
height: bounds.height
|
|
832
|
+
width: (bounds == null ? void 0 : bounds.width) || 0,
|
|
833
|
+
height: (bounds == null ? void 0 : bounds.height) || 0,
|
|
834
|
+
transform: bounds ? `translate(${bounds.x}px, ${bounds.y}px)` : "none"
|
|
836
835
|
},
|
|
837
836
|
__self: this,
|
|
838
837
|
__source: {
|
|
839
838
|
fileName: _jsxFileName$j,
|
|
840
|
-
lineNumber:
|
|
841
|
-
columnNumber:
|
|
839
|
+
lineNumber: 173,
|
|
840
|
+
columnNumber: 7
|
|
842
841
|
}
|
|
843
|
-
}, /* @__PURE__ */ React.createElement("
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
842
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
843
|
+
className: "screenshots-canvas-body",
|
|
844
|
+
__self: this,
|
|
845
|
+
__source: {
|
|
846
|
+
fileName: _jsxFileName$j,
|
|
847
|
+
lineNumber: 181,
|
|
848
|
+
columnNumber: 9
|
|
849
|
+
}
|
|
850
|
+
}, /* @__PURE__ */ React.createElement("img", {
|
|
851
|
+
className: "screenshots-canvas-image",
|
|
852
|
+
src: url,
|
|
847
853
|
style: {
|
|
848
|
-
width
|
|
849
|
-
height
|
|
854
|
+
width,
|
|
855
|
+
height,
|
|
856
|
+
transform: bounds ? `translate(${-bounds.x}px, ${-bounds.y}px)` : "none"
|
|
850
857
|
},
|
|
851
858
|
__self: this,
|
|
852
859
|
__source: {
|
|
853
860
|
fileName: _jsxFileName$j,
|
|
854
|
-
lineNumber:
|
|
855
|
-
columnNumber:
|
|
861
|
+
lineNumber: 183,
|
|
862
|
+
columnNumber: 11
|
|
856
863
|
}
|
|
857
|
-
}), /* @__PURE__ */ React.createElement("
|
|
858
|
-
|
|
864
|
+
}), /* @__PURE__ */ React.createElement("canvas", {
|
|
865
|
+
ref: canvasRef,
|
|
866
|
+
className: "screenshots-canvas-panel",
|
|
867
|
+
width: (bounds == null ? void 0 : bounds.width) || 0,
|
|
868
|
+
height: (bounds == null ? void 0 : bounds.height) || 0,
|
|
869
|
+
__self: this,
|
|
870
|
+
__source: {
|
|
871
|
+
fileName: _jsxFileName$j,
|
|
872
|
+
lineNumber: 192,
|
|
873
|
+
columnNumber: 11
|
|
874
|
+
}
|
|
875
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
876
|
+
className: "screenshots-canvas-mask",
|
|
859
877
|
style: {
|
|
860
878
|
cursor
|
|
861
879
|
},
|
|
@@ -863,8 +881,8 @@ var ScreenshotsCanvas = forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
|
863
881
|
__self: this,
|
|
864
882
|
__source: {
|
|
865
883
|
fileName: _jsxFileName$j,
|
|
866
|
-
lineNumber:
|
|
867
|
-
columnNumber:
|
|
884
|
+
lineNumber: 199,
|
|
885
|
+
columnNumber: 9
|
|
868
886
|
}
|
|
869
887
|
}), borders.map((border) => {
|
|
870
888
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -873,8 +891,8 @@ var ScreenshotsCanvas = forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
|
873
891
|
__self: this,
|
|
874
892
|
__source: {
|
|
875
893
|
fileName: _jsxFileName$j,
|
|
876
|
-
lineNumber:
|
|
877
|
-
columnNumber:
|
|
894
|
+
lineNumber: 207,
|
|
895
|
+
columnNumber: 18
|
|
878
896
|
}
|
|
879
897
|
});
|
|
880
898
|
}), resizePoints.map((resizePoint) => {
|
|
@@ -885,12 +903,12 @@ var ScreenshotsCanvas = forwardRef(function ScreenshotsCanvas2(props, ref) {
|
|
|
885
903
|
__self: this,
|
|
886
904
|
__source: {
|
|
887
905
|
fileName: _jsxFileName$j,
|
|
888
|
-
lineNumber:
|
|
889
|
-
columnNumber:
|
|
906
|
+
lineNumber: 211,
|
|
907
|
+
columnNumber: 13
|
|
890
908
|
}
|
|
891
909
|
});
|
|
892
910
|
}));
|
|
893
|
-
});
|
|
911
|
+
}));
|
|
894
912
|
function useCall() {
|
|
895
913
|
const dispatcher = useDispatcher();
|
|
896
914
|
const call = useCallback((funcName, ...args) => {
|
|
@@ -925,11 +943,12 @@ var Placement;
|
|
|
925
943
|
Placement2["Bottom"] = "bottom";
|
|
926
944
|
Placement2["Top"] = "top";
|
|
927
945
|
})(Placement || (Placement = {}));
|
|
928
|
-
|
|
946
|
+
var ScreenshotsOption = memo(function ScreenshotsOption2({
|
|
929
947
|
open,
|
|
930
948
|
content,
|
|
931
949
|
children
|
|
932
950
|
}) {
|
|
951
|
+
var _a, _b;
|
|
933
952
|
const childrenRef = useRef(null);
|
|
934
953
|
const popoverRef = useRef(null);
|
|
935
954
|
const contentRef = useRef(null);
|
|
@@ -1004,8 +1023,7 @@ function ScreenshotsOption({
|
|
|
1004
1023
|
className: "screenshots-option",
|
|
1005
1024
|
style: {
|
|
1006
1025
|
visibility: position ? "visible" : "hidden",
|
|
1007
|
-
|
|
1008
|
-
top: position == null ? void 0 : position.y
|
|
1026
|
+
transform: `translate(${(_a = position == null ? void 0 : position.x) != null ? _a : 0}px, ${(_b = position == null ? void 0 : position.y) != null ? _b : 0}px)`
|
|
1009
1027
|
},
|
|
1010
1028
|
"data-placement": placement,
|
|
1011
1029
|
__self: this,
|
|
@@ -1019,7 +1037,7 @@ function ScreenshotsOption({
|
|
|
1019
1037
|
__self: this,
|
|
1020
1038
|
__source: {
|
|
1021
1039
|
fileName: _jsxFileName$i,
|
|
1022
|
-
lineNumber:
|
|
1040
|
+
lineNumber: 120,
|
|
1023
1041
|
columnNumber: 13
|
|
1024
1042
|
}
|
|
1025
1043
|
}, content), /* @__PURE__ */ React.createElement("div", {
|
|
@@ -1030,14 +1048,14 @@ function ScreenshotsOption({
|
|
|
1030
1048
|
__self: this,
|
|
1031
1049
|
__source: {
|
|
1032
1050
|
fileName: _jsxFileName$i,
|
|
1033
|
-
lineNumber:
|
|
1051
|
+
lineNumber: 121,
|
|
1034
1052
|
columnNumber: 13
|
|
1035
1053
|
}
|
|
1036
1054
|
})), getPopoverEl()));
|
|
1037
|
-
}
|
|
1055
|
+
});
|
|
1038
1056
|
var index$5 = "";
|
|
1039
1057
|
var _jsxFileName$h = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsButton/index.tsx";
|
|
1040
|
-
|
|
1058
|
+
var ScreenshotsButton = memo(function ScreenshotsButton2({
|
|
1041
1059
|
title,
|
|
1042
1060
|
icon,
|
|
1043
1061
|
checked,
|
|
@@ -1086,27 +1104,39 @@ function ScreenshotsButton({
|
|
|
1086
1104
|
columnNumber: 9
|
|
1087
1105
|
}
|
|
1088
1106
|
})));
|
|
1089
|
-
}
|
|
1107
|
+
});
|
|
1090
1108
|
var _jsxFileName$g = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Ok/index.tsx";
|
|
1091
1109
|
function Ok() {
|
|
1092
|
-
const
|
|
1110
|
+
const {
|
|
1111
|
+
image,
|
|
1112
|
+
width,
|
|
1113
|
+
height,
|
|
1114
|
+
history,
|
|
1115
|
+
bounds,
|
|
1116
|
+
lang
|
|
1117
|
+
} = useStore();
|
|
1093
1118
|
const canvasContextRef = useCanvasContextRef();
|
|
1094
1119
|
const [, historyDispatcher] = useHistory();
|
|
1095
1120
|
const call = useCall();
|
|
1096
|
-
const [bounds] = useBounds();
|
|
1097
1121
|
const reset = useReset();
|
|
1098
1122
|
const onClick = useCallback(() => {
|
|
1099
1123
|
historyDispatcher.clearSelect();
|
|
1100
1124
|
setTimeout(() => {
|
|
1101
|
-
if (!canvasContextRef.current) {
|
|
1125
|
+
if (!canvasContextRef.current || !image || !bounds) {
|
|
1102
1126
|
return;
|
|
1103
1127
|
}
|
|
1104
|
-
|
|
1128
|
+
composeImage({
|
|
1129
|
+
image,
|
|
1130
|
+
width,
|
|
1131
|
+
height,
|
|
1132
|
+
history,
|
|
1133
|
+
bounds
|
|
1134
|
+
}).then((blob) => {
|
|
1105
1135
|
call("onOk", blob, bounds);
|
|
1106
1136
|
reset();
|
|
1107
|
-
}
|
|
1137
|
+
});
|
|
1108
1138
|
});
|
|
1109
|
-
}, [canvasContextRef, historyDispatcher,
|
|
1139
|
+
}, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset]);
|
|
1110
1140
|
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
1111
1141
|
title: lang.operation_ok_title,
|
|
1112
1142
|
icon: "icon-ok",
|
|
@@ -1114,7 +1144,7 @@ function Ok() {
|
|
|
1114
1144
|
__self: this,
|
|
1115
1145
|
__source: {
|
|
1116
1146
|
fileName: _jsxFileName$g,
|
|
1117
|
-
lineNumber:
|
|
1147
|
+
lineNumber: 36,
|
|
1118
1148
|
columnNumber: 10
|
|
1119
1149
|
}
|
|
1120
1150
|
});
|
|
@@ -1142,24 +1172,36 @@ function Cancel() {
|
|
|
1142
1172
|
}
|
|
1143
1173
|
var _jsxFileName$e = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Save/index.tsx";
|
|
1144
1174
|
function Save() {
|
|
1145
|
-
const
|
|
1175
|
+
const {
|
|
1176
|
+
image,
|
|
1177
|
+
width,
|
|
1178
|
+
height,
|
|
1179
|
+
history,
|
|
1180
|
+
bounds,
|
|
1181
|
+
lang
|
|
1182
|
+
} = useStore();
|
|
1146
1183
|
const canvasContextRef = useCanvasContextRef();
|
|
1147
1184
|
const [, historyDispatcher] = useHistory();
|
|
1148
|
-
const [bounds] = useBounds();
|
|
1149
1185
|
const call = useCall();
|
|
1150
1186
|
const reset = useReset();
|
|
1151
1187
|
const onClick = useCallback(() => {
|
|
1152
1188
|
historyDispatcher.clearSelect();
|
|
1153
1189
|
setTimeout(() => {
|
|
1154
|
-
if (!canvasContextRef.current) {
|
|
1190
|
+
if (!canvasContextRef.current || !image || !bounds) {
|
|
1155
1191
|
return;
|
|
1156
1192
|
}
|
|
1157
|
-
|
|
1193
|
+
composeImage({
|
|
1194
|
+
image,
|
|
1195
|
+
width,
|
|
1196
|
+
height,
|
|
1197
|
+
history,
|
|
1198
|
+
bounds
|
|
1199
|
+
}).then((blob) => {
|
|
1158
1200
|
call("onSave", blob, bounds);
|
|
1159
1201
|
reset();
|
|
1160
|
-
}
|
|
1202
|
+
});
|
|
1161
1203
|
});
|
|
1162
|
-
}, [canvasContextRef, historyDispatcher, bounds, call, reset]);
|
|
1204
|
+
}, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset]);
|
|
1163
1205
|
return /* @__PURE__ */ React.createElement(ScreenshotsButton, {
|
|
1164
1206
|
title: lang.operation_save_title,
|
|
1165
1207
|
icon: "icon-save",
|
|
@@ -1167,7 +1209,7 @@ function Save() {
|
|
|
1167
1209
|
__self: this,
|
|
1168
1210
|
__source: {
|
|
1169
1211
|
fileName: _jsxFileName$e,
|
|
1170
|
-
lineNumber:
|
|
1212
|
+
lineNumber: 36,
|
|
1171
1213
|
columnNumber: 10
|
|
1172
1214
|
}
|
|
1173
1215
|
});
|
|
@@ -1214,7 +1256,7 @@ function Undo() {
|
|
|
1214
1256
|
}
|
|
1215
1257
|
var index$4 = "";
|
|
1216
1258
|
var _jsxFileName$b = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsSize/index.tsx";
|
|
1217
|
-
|
|
1259
|
+
var ScreenshotsSize = memo(function ScreenshotsSize2({
|
|
1218
1260
|
value,
|
|
1219
1261
|
onChange
|
|
1220
1262
|
}) {
|
|
@@ -1256,7 +1298,7 @@ function ScreenshotsSize({
|
|
|
1256
1298
|
}
|
|
1257
1299
|
}));
|
|
1258
1300
|
}));
|
|
1259
|
-
}
|
|
1301
|
+
});
|
|
1260
1302
|
function useCanvasMousedown(onMousedown) {
|
|
1261
1303
|
const emiter = useEmiter();
|
|
1262
1304
|
useEffect(() => {
|
|
@@ -1457,7 +1499,7 @@ function Mosaic() {
|
|
|
1457
1499
|
}
|
|
1458
1500
|
var index$3 = "";
|
|
1459
1501
|
var _jsxFileName$9 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsColor/index.tsx";
|
|
1460
|
-
|
|
1502
|
+
var ScreenshotsColor = memo(function ScreenshotsColor2({
|
|
1461
1503
|
value,
|
|
1462
1504
|
onChange
|
|
1463
1505
|
}) {
|
|
@@ -1490,10 +1532,10 @@ function ScreenshotsColor({
|
|
|
1490
1532
|
}
|
|
1491
1533
|
});
|
|
1492
1534
|
}));
|
|
1493
|
-
}
|
|
1535
|
+
});
|
|
1494
1536
|
var index$2 = "";
|
|
1495
1537
|
var _jsxFileName$8 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsSizeColor/index.tsx";
|
|
1496
|
-
|
|
1538
|
+
var ScreenshotsSizeColor = memo(function ScreenshotsSizeColor2({
|
|
1497
1539
|
size,
|
|
1498
1540
|
color,
|
|
1499
1541
|
onSizeChange,
|
|
@@ -1504,7 +1546,7 @@ function ScreenshotsSizeColor({
|
|
|
1504
1546
|
__self: this,
|
|
1505
1547
|
__source: {
|
|
1506
1548
|
fileName: _jsxFileName$8,
|
|
1507
|
-
lineNumber:
|
|
1549
|
+
lineNumber: 20,
|
|
1508
1550
|
columnNumber: 5
|
|
1509
1551
|
}
|
|
1510
1552
|
}, /* @__PURE__ */ React.createElement(ScreenshotsSize, {
|
|
@@ -1513,7 +1555,7 @@ function ScreenshotsSizeColor({
|
|
|
1513
1555
|
__self: this,
|
|
1514
1556
|
__source: {
|
|
1515
1557
|
fileName: _jsxFileName$8,
|
|
1516
|
-
lineNumber:
|
|
1558
|
+
lineNumber: 21,
|
|
1517
1559
|
columnNumber: 7
|
|
1518
1560
|
}
|
|
1519
1561
|
}), /* @__PURE__ */ React.createElement(ScreenshotsColor, {
|
|
@@ -1522,11 +1564,11 @@ function ScreenshotsSizeColor({
|
|
|
1522
1564
|
__self: this,
|
|
1523
1565
|
__source: {
|
|
1524
1566
|
fileName: _jsxFileName$8,
|
|
1525
|
-
lineNumber:
|
|
1567
|
+
lineNumber: 22,
|
|
1526
1568
|
columnNumber: 7
|
|
1527
1569
|
}
|
|
1528
1570
|
}));
|
|
1529
|
-
}
|
|
1571
|
+
});
|
|
1530
1572
|
const hiddenTextareaStyle = `
|
|
1531
1573
|
min-width: 0 !important;
|
|
1532
1574
|
width: 0 !important;
|
|
@@ -1597,7 +1639,7 @@ function calculateNodeSize(textarea, value, maxWidth, maxHeight) {
|
|
|
1597
1639
|
}
|
|
1598
1640
|
var index$1 = "";
|
|
1599
1641
|
var _jsxFileName$7 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsTextarea/index.tsx";
|
|
1600
|
-
|
|
1642
|
+
var ScreenshotsTextarea = memo(function ScreenshotsTextarea2({
|
|
1601
1643
|
x,
|
|
1602
1644
|
y,
|
|
1603
1645
|
maxWidth,
|
|
@@ -1646,15 +1688,14 @@ function ScreenshotsTextarea({
|
|
|
1646
1688
|
ref: textareaRef,
|
|
1647
1689
|
className: "screenshots-textarea",
|
|
1648
1690
|
style: {
|
|
1649
|
-
left: x,
|
|
1650
|
-
top: y,
|
|
1651
1691
|
color,
|
|
1652
1692
|
width,
|
|
1653
1693
|
height,
|
|
1654
1694
|
maxWidth,
|
|
1655
1695
|
maxHeight,
|
|
1656
1696
|
fontSize: size,
|
|
1657
|
-
lineHeight: `${size}px
|
|
1697
|
+
lineHeight: `${size}px`,
|
|
1698
|
+
transform: `translate(${x}px, ${y}px)`
|
|
1658
1699
|
},
|
|
1659
1700
|
value,
|
|
1660
1701
|
onChange: (e) => onChange && onChange(e.target.value),
|
|
@@ -1666,7 +1707,7 @@ function ScreenshotsTextarea({
|
|
|
1666
1707
|
columnNumber: 5
|
|
1667
1708
|
}
|
|
1668
1709
|
}), getPopoverEl());
|
|
1669
|
-
}
|
|
1710
|
+
});
|
|
1670
1711
|
function useDrawSelect(onDrawSelect) {
|
|
1671
1712
|
const emiter = useEmiter();
|
|
1672
1713
|
useEffect(() => {
|
|
@@ -2838,7 +2879,8 @@ var OperationButtons = [Rectangle, Ellipse, Arrow, Brush, Text, Mosaic, "|", Und
|
|
|
2838
2879
|
var index = "";
|
|
2839
2880
|
var _jsxFileName$1 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsOperations/index.tsx";
|
|
2840
2881
|
const ScreenshotsOperationsCtx = React.createContext(null);
|
|
2841
|
-
|
|
2882
|
+
var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
|
|
2883
|
+
var _a, _b;
|
|
2842
2884
|
const {
|
|
2843
2885
|
width,
|
|
2844
2886
|
height
|
|
@@ -2901,8 +2943,7 @@ function ScreenshotsOperations() {
|
|
|
2901
2943
|
className: "screenshots-operations",
|
|
2902
2944
|
style: {
|
|
2903
2945
|
visibility: position ? "visible" : "hidden",
|
|
2904
|
-
|
|
2905
|
-
top: position == null ? void 0 : position.y
|
|
2946
|
+
transform: `translate(${(_a = position == null ? void 0 : position.x) != null ? _a : 0}px, ${(_b = position == null ? void 0 : position.y) != null ? _b : 0}px)`
|
|
2906
2947
|
},
|
|
2907
2948
|
onDoubleClick,
|
|
2908
2949
|
onContextMenu,
|
|
@@ -2917,7 +2958,7 @@ function ScreenshotsOperations() {
|
|
|
2917
2958
|
__self: this,
|
|
2918
2959
|
__source: {
|
|
2919
2960
|
fileName: _jsxFileName$1,
|
|
2920
|
-
lineNumber:
|
|
2961
|
+
lineNumber: 87,
|
|
2921
2962
|
columnNumber: 9
|
|
2922
2963
|
}
|
|
2923
2964
|
}, OperationButtons.map((OperationButton, index2) => {
|
|
@@ -2928,7 +2969,7 @@ function ScreenshotsOperations() {
|
|
|
2928
2969
|
__self: this,
|
|
2929
2970
|
__source: {
|
|
2930
2971
|
fileName: _jsxFileName$1,
|
|
2931
|
-
lineNumber:
|
|
2972
|
+
lineNumber: 90,
|
|
2932
2973
|
columnNumber: 22
|
|
2933
2974
|
}
|
|
2934
2975
|
});
|
|
@@ -2938,13 +2979,13 @@ function ScreenshotsOperations() {
|
|
|
2938
2979
|
__self: this,
|
|
2939
2980
|
__source: {
|
|
2940
2981
|
fileName: _jsxFileName$1,
|
|
2941
|
-
lineNumber:
|
|
2982
|
+
lineNumber: 92,
|
|
2942
2983
|
columnNumber: 22
|
|
2943
2984
|
}
|
|
2944
2985
|
});
|
|
2945
2986
|
}
|
|
2946
2987
|
}))));
|
|
2947
|
-
}
|
|
2988
|
+
});
|
|
2948
2989
|
function useGetLoadedImage(url) {
|
|
2949
2990
|
const [image, setImage] = useState(null);
|
|
2950
2991
|
useEffect(() => {
|
|
@@ -3035,24 +3076,35 @@ function Screenshots(_a) {
|
|
|
3035
3076
|
return;
|
|
3036
3077
|
}
|
|
3037
3078
|
if (bounds && canvasContextRef.current) {
|
|
3038
|
-
|
|
3079
|
+
composeImage({
|
|
3080
|
+
image,
|
|
3081
|
+
width,
|
|
3082
|
+
height,
|
|
3083
|
+
history,
|
|
3084
|
+
bounds
|
|
3085
|
+
}).then((blob) => {
|
|
3039
3086
|
call("onOk", blob, bounds);
|
|
3040
3087
|
reset();
|
|
3041
|
-
}, "image/png");
|
|
3042
|
-
} else {
|
|
3043
|
-
const blob = await imageToBlob(image, {
|
|
3044
|
-
width,
|
|
3045
|
-
height
|
|
3046
3088
|
});
|
|
3047
|
-
|
|
3089
|
+
} else {
|
|
3090
|
+
const targetBounds = {
|
|
3048
3091
|
x: 0,
|
|
3049
3092
|
y: 0,
|
|
3050
3093
|
width,
|
|
3051
3094
|
height
|
|
3095
|
+
};
|
|
3096
|
+
composeImage({
|
|
3097
|
+
image,
|
|
3098
|
+
width,
|
|
3099
|
+
height,
|
|
3100
|
+
history,
|
|
3101
|
+
bounds: targetBounds
|
|
3102
|
+
}).then((blob) => {
|
|
3103
|
+
call("onOk", blob, targetBounds);
|
|
3104
|
+
reset();
|
|
3052
3105
|
});
|
|
3053
|
-
reset();
|
|
3054
3106
|
}
|
|
3055
|
-
}, [image, bounds, width, height, call]);
|
|
3107
|
+
}, [image, history, bounds, width, height, call]);
|
|
3056
3108
|
const onContextMenu = useCallback((e) => {
|
|
3057
3109
|
if (e.button !== 2) {
|
|
3058
3110
|
return;
|
|
@@ -3072,7 +3124,7 @@ function Screenshots(_a) {
|
|
|
3072
3124
|
__self: this,
|
|
3073
3125
|
__source: {
|
|
3074
3126
|
fileName: _jsxFileName,
|
|
3075
|
-
lineNumber:
|
|
3127
|
+
lineNumber: 142,
|
|
3076
3128
|
columnNumber: 5
|
|
3077
3129
|
}
|
|
3078
3130
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -3086,14 +3138,14 @@ function Screenshots(_a) {
|
|
|
3086
3138
|
__self: this,
|
|
3087
3139
|
__source: {
|
|
3088
3140
|
fileName: _jsxFileName,
|
|
3089
|
-
lineNumber:
|
|
3141
|
+
lineNumber: 143,
|
|
3090
3142
|
columnNumber: 7
|
|
3091
3143
|
}
|
|
3092
3144
|
}, /* @__PURE__ */ React.createElement(ScreenshotsBackground, {
|
|
3093
3145
|
__self: this,
|
|
3094
3146
|
__source: {
|
|
3095
3147
|
fileName: _jsxFileName,
|
|
3096
|
-
lineNumber:
|
|
3148
|
+
lineNumber: 149,
|
|
3097
3149
|
columnNumber: 9
|
|
3098
3150
|
}
|
|
3099
3151
|
}), /* @__PURE__ */ React.createElement(ScreenshotsCanvas, {
|
|
@@ -3101,14 +3153,14 @@ function Screenshots(_a) {
|
|
|
3101
3153
|
__self: this,
|
|
3102
3154
|
__source: {
|
|
3103
3155
|
fileName: _jsxFileName,
|
|
3104
|
-
lineNumber:
|
|
3156
|
+
lineNumber: 150,
|
|
3105
3157
|
columnNumber: 9
|
|
3106
3158
|
}
|
|
3107
3159
|
}), /* @__PURE__ */ React.createElement(ScreenshotsOperations, {
|
|
3108
3160
|
__self: this,
|
|
3109
3161
|
__source: {
|
|
3110
3162
|
fileName: _jsxFileName,
|
|
3111
|
-
lineNumber:
|
|
3163
|
+
lineNumber: 151,
|
|
3112
3164
|
columnNumber: 9
|
|
3113
3165
|
}
|
|
3114
3166
|
})));
|