glitchgrab 1.16.0 → 1.17.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/README.md +12 -0
- package/dist/index.js +48 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,6 +146,18 @@ function FeedbackWidget() {
|
|
|
146
146
|
|
|
147
147
|
Note: `openReportDialog()` requires a `<ReportButton>` to be mounted somewhere in the component tree. It triggers the same modal with screenshot capture.
|
|
148
148
|
|
|
149
|
+
## Keyboard Shortcuts
|
|
150
|
+
|
|
151
|
+
Once `GlitchgrabProvider` is mounted, these shortcuts work globally:
|
|
152
|
+
|
|
153
|
+
| Shortcut | Action |
|
|
154
|
+
|----------|--------|
|
|
155
|
+
| `Cmd+Shift+G` / `Ctrl+Shift+G` | Open the report dialog |
|
|
156
|
+
| `Cmd+V` / `Ctrl+V` (dialog open) | Paste a screenshot from clipboard |
|
|
157
|
+
| `Escape` | Close the dialog |
|
|
158
|
+
|
|
159
|
+
No configuration needed — shortcuts are active as long as the provider is in the tree.
|
|
160
|
+
|
|
149
161
|
## Fetching Reports by User
|
|
150
162
|
|
|
151
163
|
### React hook (recommended)
|
package/dist/index.js
CHANGED
|
@@ -446,11 +446,15 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
446
446
|
function useIsDark() {
|
|
447
447
|
if (typeof window === "undefined") return true;
|
|
448
448
|
try {
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
449
|
+
for (const el of [document.body, document.documentElement]) {
|
|
450
|
+
const bg = getComputedStyle(el).backgroundColor;
|
|
451
|
+
const match = bg.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);
|
|
452
|
+
if (match) {
|
|
453
|
+
const alpha = match[4] !== void 0 ? parseFloat(match[4]) : 1;
|
|
454
|
+
if (alpha < 0.05) continue;
|
|
455
|
+
const [r, g, b] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
456
|
+
return (r * 299 + g * 587 + b * 114) / 1e3 < 128;
|
|
457
|
+
}
|
|
454
458
|
}
|
|
455
459
|
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
456
460
|
} catch (e) {
|
|
@@ -672,6 +676,30 @@ function ReportDialog({
|
|
|
672
676
|
document.addEventListener("keydown", handleEsc);
|
|
673
677
|
return () => document.removeEventListener("keydown", handleEsc);
|
|
674
678
|
}, [isOpen, previewOpen]);
|
|
679
|
+
(0, import_react.useEffect)(() => {
|
|
680
|
+
if (!isOpen) return;
|
|
681
|
+
const handlePaste = (e) => {
|
|
682
|
+
var _a;
|
|
683
|
+
try {
|
|
684
|
+
const items = (_a = e.clipboardData) == null ? void 0 : _a.items;
|
|
685
|
+
if (!items) return;
|
|
686
|
+
for (let i = 0; i < items.length; i++) {
|
|
687
|
+
if (items[i].type.startsWith("image/")) {
|
|
688
|
+
const file = items[i].getAsFile();
|
|
689
|
+
if (!file) continue;
|
|
690
|
+
const reader = new FileReader();
|
|
691
|
+
reader.onload = () => setScreenshot(reader.result);
|
|
692
|
+
reader.readAsDataURL(file);
|
|
693
|
+
e.preventDefault();
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
} catch (e2) {
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
window.addEventListener("paste", handlePaste);
|
|
701
|
+
return () => window.removeEventListener("paste", handlePaste);
|
|
702
|
+
}, [isOpen]);
|
|
675
703
|
const handleClose = () => {
|
|
676
704
|
setIsOpen(false);
|
|
677
705
|
setStep(1);
|
|
@@ -1081,7 +1109,7 @@ function ReportDialog({
|
|
|
1081
1109
|
background: "none",
|
|
1082
1110
|
cursor: "pointer"
|
|
1083
1111
|
},
|
|
1084
|
-
children: "Upload
|
|
1112
|
+
children: "Upload or paste (\u2318V)"
|
|
1085
1113
|
}
|
|
1086
1114
|
),
|
|
1087
1115
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1469,6 +1497,20 @@ function GlitchgrabProviderInner({
|
|
|
1469
1497
|
window.dispatchEvent(new CustomEvent("glitchgrab:open-report", { detail: options }));
|
|
1470
1498
|
}
|
|
1471
1499
|
}, []);
|
|
1500
|
+
(0, import_react2.useEffect)(() => {
|
|
1501
|
+
try {
|
|
1502
|
+
if (typeof window === "undefined") return;
|
|
1503
|
+
const handleKeyDown = (e) => {
|
|
1504
|
+
if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "g") {
|
|
1505
|
+
e.preventDefault();
|
|
1506
|
+
openReportDialog();
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1510
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1511
|
+
} catch (e) {
|
|
1512
|
+
}
|
|
1513
|
+
}, [openReportDialog]);
|
|
1472
1514
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1473
1515
|
GlitchgrabContext.Provider,
|
|
1474
1516
|
{
|