The free and privacy-friendly screen recorder with no limits 🎥
JavaScript annotationannotation-toolaudiocamerachrome-extensiondesigneditorffmpegjavascriptproductivityrecorderscreen-capturescreen-recorderscreencasttensorflowvideo
Better shortcuts
Alyssa Xa2a32e75d853
diff --git a/src/manifest.json b/src/manifest.jsonindex 3ec403f..e7efb86 100755--- a/src/manifest.json+++ b/src/manifest.json@@ -84,6 +84,21 @@"default": "Alt+Shift+M"},"description": "Pause/Resume recording"+ },+ "stop-recording": {+ "description": "Stop recording"+ },+ "toggle-drawing-mode": {+ "description": "Toggle drawing mode"+ },+ "toggle-blur-mode": {+ "description": "Toggle blur mode"+ },+ "toggle-hide-ui": {+ "description": "Toggle hide UI"+ },+ "toggle-cursor-mode": {+ "description": "Toggle cursor options"}},"permissions": [diff --git a/src/pages/Background/listeners/onCommandListener.js b/src/pages/Background/listeners/onCommandListener.jsindex 5ab6e4b..8989cd4 100644--- a/src/pages/Background/listeners/onCommandListener.js+++ b/src/pages/Background/listeners/onCommandListener.js@@ -4,6 +4,7 @@ import { sendMessageTab, getCurrentTab } from "../tabManagement";export const onCommandListener = () => {chrome.commands.onCommand.addListener(async (command) => {const activeTab = await getCurrentTab();+ if (!activeTab || !activeTab.id) return;if (command === "start-recording") {// Validate if it's possible to inject into content@@ -46,6 +47,16 @@ export const onCommandListener = () => {sendMessageTab(activeTab.id, { type: "cancel-recording" });} else if (command === "pause-recording") {sendMessageTab(activeTab.id, { type: "pause-recording" });+ } else if (command === "stop-recording") {+ sendMessageTab(activeTab.id, { type: "stop-recording-tab" });+ } else if (command === "toggle-drawing-mode") {+ sendMessageTab(activeTab.id, { type: "toggle-drawing-mode" });+ } else if (command === "toggle-blur-mode") {+ sendMessageTab(activeTab.id, { type: "toggle-blur-mode" });+ } else if (command === "toggle-hide-ui") {+ sendMessageTab(activeTab.id, { type: "toggle-hide-ui" });+ } else if (command === "toggle-cursor-mode") {+ sendMessageTab(activeTab.id, { type: "toggle-cursor-mode" });}});};diff --git a/src/pages/Content/context/ContentState.jsx b/src/pages/Content/context/ContentState.jsxindex a618c03..0ae70c3 100644--- a/src/pages/Content/context/ContentState.jsx+++ b/src/pages/Content/context/ContentState.jsx@@ -16,6 +16,20 @@ export const contentStateRef = { current: null };export let setContentState = () => {};export let setTimer = () => {};+const CURSOR_EFFECTS = ["target", "highlight", "spotlight"];++const normalizeCursorEffects = (effects) => {+ if (!Array.isArray(effects)) return [];+ return effects.filter((effect) => CURSOR_EFFECTS.includes(effect));+};++const deriveCursorMode = (effects, fallbackMode) => {+ if (effects.length === 0) return "none";+ if (effects.length === 1) return effects[0];+ if (fallbackMode && effects.includes(fallbackMode)) return fallbackMode;+ return effects[0] || "none";+};+const ContentState = (props) => {const [timer, setTimerInternal] = React.useState(0);const CLOUD_FEATURES_ENABLED =@@ -714,6 +728,7 @@ const ContentState = (props) => {resumeRecording: resumeRecording,dismissRecording: dismissRecording,startStreaming: startStreaming,+ setToolbarMode: null,openModal: null,openToast: null,timeWarning: false,@@ -775,7 +790,11 @@ const ContentState = (props) => {askMicrophone: true,recordingShortcut: "⌥⇧W",recordingShortcut: "⌥⇧D",+ toggleDrawingModeShortcut: "",+ toggleBlurModeShortcut: "",+ toggleCursorModeShortcut: "",cursorMode: "none",+ cursorEffects: [],shape: "rectangle",shapeFill: false,pushToTalk: false,@@ -1035,6 +1054,32 @@ const ContentState = (props) => {recording: Boolean(changes.recording.newValue),}));}+ if (changes.cursorEffects) {+ const nextEffects = normalizeCursorEffects(+ changes.cursorEffects.newValue+ );+ const fallbackMode =+ changes.cursorMode?.newValue ||+ contentStateRef.current?.cursorMode ||+ "none";+ const nextMode = deriveCursorMode(nextEffects, fallbackMode);+ setContentState((prev) => ({+ ...prev,+ cursorEffects: nextEffects,+ cursorMode: nextMode,+ }));+ } else if (changes.cursorMode) {+ const mode = changes.cursorMode.newValue || "none";+ const fallbackEffects = mode !== "none" ? [mode] : [];+ setContentState((prev) => ({+ ...prev,+ cursorMode: mode,+ cursorEffects:+ Array.isArray(prev.cursorEffects) && prev.cursorEffects.length > 0+ ? prev.cursorEffects+ : fallbackEffects,+ }));+ }if (changes.paused ||changes.recording ||diff --git a/src/pages/Content/context/messaging/handlers.js b/src/pages/Content/context/messaging/handlers.jsindex 0b60d9d..7586d56 100644--- a/src/pages/Content/context/messaging/handlers.js+++ b/src/pages/Content/context/messaging/handlers.js@@ -71,15 +71,63 @@ export const setupHandlers = () => {registerMessage("stop-recording-tab", () => {const state = getState();if (!state.recording) return;+ state.stopRecording();+ });- chrome.storage.local.set({ recording: false });+ registerMessage("toggle-drawing-mode", () => {+ const nextDrawingMode = !contentStateRef.current.drawingMode;setContentState((prev) => ({...prev,- recording: false,- paused: false,- showExtension: false,- showPopup: true,+ drawingMode: nextDrawingMode,+ blurMode: nextDrawingMode ? false : prev.blurMode,+ }));+ chrome.storage.local.set({+ drawingMode: nextDrawingMode,+ blurMode: nextDrawingMode ? false : contentStateRef.current.blurMode,+ });+ });++ registerMessage("toggle-blur-mode", () => {+ const nextBlurMode = !contentStateRef.current.blurMode;+ setContentState((prev) => ({+ ...prev,+ blurMode: nextBlurMode,+ drawingMode: nextBlurMode ? false : prev.drawingMode,}));+ chrome.storage.local.set({+ blurMode: nextBlurMode,+ drawingMode: nextBlurMode ? false : contentStateRef.current.drawingMode,+ });+ });++ registerMessage("toggle-hide-ui", () => {+ const nextHideUI = !contentStateRef.current.hideUI;+ setContentState((prev) => ({+ ...prev,+ hideUI: nextHideUI,+ hideToolbar: nextHideUI ? true : prev.hideToolbar,+ hideUIAlerts: nextHideUI ? true : prev.hideUIAlerts,+ }));+ chrome.storage.local.set({+ hideUI: nextHideUI,+ ...(nextHideUI+ ? { hideToolbar: true, hideUIAlerts: true }+ : {}),+ });+ });++ registerMessage("toggle-cursor-mode", () => {+ const state = getState();+ const nextMode =+ contentStateRef.current.cursorMode === "none" ? "cursor" : "";+ if (state?.setToolbarMode) {+ state.setToolbarMode(nextMode);+ } else {+ setContentState((prev) => ({+ ...prev,+ toolbarMode: nextMode,+ }));+ }});registerMessage("recording-ended", async () => {@@ -159,11 +207,23 @@ export const setupHandlers = () => {const cancelRecordingCommand = message.commands.find((command) => command.name === "cancel-recording");+ const toggleDrawingModeCommand = message.commands.find(+ (command) => command.name === "toggle-drawing-mode"+ );+ const toggleBlurModeCommand = message.commands.find(+ (command) => command.name === "toggle-blur-mode"+ );+ const toggleCursorModeCommand = message.commands.find(+ (command) => command.name === "toggle-cursor-mode"+ );setContentState((prev) => ({...prev,recordingShortcut: startRecordingCommand.shortcut,dismissRecordingShortcut: cancelRecordingCommand.shortcut,+ toggleDrawingModeShortcut: toggleDrawingModeCommand?.shortcut || "",+ toggleBlurModeShortcut: toggleBlurModeCommand?.shortcut || "",+ toggleCursorModeShortcut: toggleCursorModeCommand?.shortcut || "",}));});diff --git a/src/pages/Content/context/utils/updateFromStorage.js b/src/pages/Content/context/utils/updateFromStorage.jsindex bb2a1f5..e38659f 100644--- a/src/pages/Content/context/utils/updateFromStorage.js+++ b/src/pages/Content/context/utils/updateFromStorage.js@@ -1,6 +1,20 @@import { setContentState } from "../ContentState";import { checkRecording } from "./checkRecording";+const CURSOR_EFFECTS = ["target", "highlight", "spotlight"];++const normalizeCursorEffects = (effects) => {+ if (!Array.isArray(effects)) return [];+ return effects.filter((effect) => CURSOR_EFFECTS.includes(effect));+};++const deriveCursorMode = (effects, fallbackMode) => {+ if (effects.length === 0) return "none";+ if (effects.length === 1) return effects[0];+ if (fallbackMode && effects.includes(fallbackMode)) return fallbackMode;+ return effects[0] || "none";+};+export const updateFromStorage = (check = true, id = null) => {chrome.storage.local.get([@@ -30,6 +44,7 @@ export const updateFromStorage = (check = true, id = null) => {"pendingRecording","askForPermissions","cursorMode",+ "cursorEffects","pushToTalk","askMicrophone","offscreenRecording",@@ -63,6 +78,19 @@ export const updateFromStorage = (check = true, id = null) => {"hasSubscribedBefore",],(result) => {+ const storedEffects = normalizeCursorEffects(result.cursorEffects);+ const hasStoredEffects = Array.isArray(result.cursorEffects);+ const legacyMode =+ result.cursorMode !== undefined && result.cursorMode !== null+ ? result.cursorMode+ : "none";+ const cursorEffects = hasStoredEffects+ ? storedEffects+ : legacyMode !== "none"+ ? [legacyMode]+ : [];+ const cursorMode = deriveCursorMode(cursorEffects, legacyMode);+setContentState((prevContentState) => ({...prevContentState,audioInput:@@ -173,10 +201,11 @@ export const updateFromStorage = (check = true, id = null) => {result.askForPermissions !== null? result.askForPermissions: prevContentState.askForPermissions,- cursorMode:- result.cursorMode !== undefined && result.cursorMode !== null- ? result.cursorMode- : prevContentState.cursorMode,+ cursorMode: cursorMode || prevContentState.cursorMode,+ cursorEffects:+ cursorEffects.length > 0 || hasStoredEffects+ ? cursorEffects+ : prevContentState.cursorEffects,pushToTalk:result.pushToTalk !== undefined && result.pushToTalk !== null? result.pushToTalk@@ -299,6 +328,13 @@ export const updateFromStorage = (check = true, id = null) => {chrome.storage.local.set({ backupSetup: false });}+ if (!hasStoredEffects && legacyMode) {+ chrome.storage.local.set({+ cursorEffects: cursorEffects,+ cursorMode: cursorMode,+ });+ }+if (result.backgroundEffectsActive) {chrome.runtime.sendMessage({ type: "backgroundEffectsActive" });}diff --git a/src/pages/Content/shortcuts/Shortcuts.jsx b/src/pages/Content/shortcuts/Shortcuts.jsxindex 92fd8aa..737b2df 100644--- a/src/pages/Content/shortcuts/Shortcuts.jsx+++ b/src/pages/Content/shortcuts/Shortcuts.jsx@@ -1,9 +1,8 @@-import React, { useState, useEffect, useContext, useRef } from "react";--import { useHotkeys } from "react-hotkeys-hook";+import React, { useEffect, useContext, useRef } from "react";// Contextimport { contentStateContext } from "../context/ContentState";+import { undoCanvas, redoCanvas, saveCanvas } from "../canvas/modules/History";const Shortcuts = ({ shortcuts }) => {const [contentState, setContentState] = useContext(contentStateContext);@@ -33,7 +32,242 @@ const Shortcuts = ({ shortcuts }) => {drawingMode: !prevContentState.drawingMode,}));});- */+ */++ // In-app shortcuts (number keys) for Screenity tools.+ // 1: select, 2: pen, 3: highlighter, 4: eraser, 5: color picker+ // 6: text, 7: shape (rectangle), 8: arrow, 9: image, 0: clear+ // Cursor effects: 0 clears, 1 target, 2 highlight, 3 spotlight+ useEffect(() => {+ const getDeepActiveElement = () => {+ let active = document.activeElement;+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {+ active = active.shadowRoot.activeElement;+ }+ return active;+ };++ const isEditableElement = (element) => {+ if (!element) return false;+ if (element.isContentEditable) return true;+ const tag = element.tagName ? element.tagName.toLowerCase() : "";+ return tag === "input" || tag === "textarea" || tag === "select";+ };++ const isTextEditingActive = () => {+ const state = contentStateRef.current;+ if (state?.tool !== "text") return false;+ const activeObj = state?.canvas?.getActiveObject?.();+ return Boolean(activeObj && activeObj.isEditing);+ };++ const shouldHandleShortcut = (event) => {+ const state = contentStateRef.current;+ if (!state?.drawingMode && !state?.blurMode) return false;+ if (event.altKey || event.ctrlKey || event.metaKey) return false;++ const active = getDeepActiveElement();+ if (isEditableElement(active)) return false;+ if (isTextEditingActive()) return false;++ return true;+ };++ const getDigitKey = (event) => {+ if (event.code && event.code.startsWith("Digit")) {+ return event.code.replace("Digit", "");+ }+ if (event.code && event.code.startsWith("Numpad")) {+ return event.code.replace("Numpad", "");+ }+ if (event.key >= "0" && event.key <= "9") {+ return event.key;+ }+ return null;+ };++ const setTool = (tool, nextShape) => {+ setContentState((prev) => ({+ ...prev,+ tool,+ ...(nextShape ? nextShape : {}),+ }));+ };++ const clearDrawings = () => {+ const state = contentStateRef.current;+ if (!state?.canvas) return;+ state.canvas.clear();+ state.canvas.renderAll();+ state.canvas.requestRenderAll();+ saveCanvas(state, setContentState);+ };++ const clearBlurMasks = () => {+ const blurredElements = document.querySelectorAll(".screenity-blur");+ blurredElements.forEach((element) => {+ element.classList.remove("screenity-blur");+ });+ };++ const getShadowRoot = () =>+ contentStateRef.current?.shadowRef?.shadowRoot || null;++ const toggleColorPicker = () => {+ const shadowRoot = getShadowRoot();+ const trigger = shadowRoot+ ? shadowRoot.querySelector("[data-color-trigger]")+ : document.querySelector("[data-color-trigger]");+ if (trigger) {+ trigger.click();+ }+ };++ const openImagePicker = () => {+ const shadowRoot = getShadowRoot();+ const fileInput = shadowRoot+ ? shadowRoot.querySelector("[data-image-upload=\"true\"]")+ : document.querySelector("[data-image-upload=\"true\"]");+ if (fileInput) {+ fileInput.click();+ }+ };++ const deriveCursorMode = (effects, fallback) => {+ if (effects.length === 0) return "none";+ if (effects.length === 1) return effects[0];+ return fallback || effects[0] || "none";+ };++ const clearCursorEffects = () => {+ setContentState((prev) => ({+ ...prev,+ cursorEffects: [],+ cursorMode: "none",+ }));+ chrome.storage.local.set({+ cursorEffects: [],+ cursorMode: "none",+ });+ };++ const toggleCursorEffect = (effect) => {+ const state = contentStateRef.current;+ const current = Array.isArray(state.cursorEffects)+ ? state.cursorEffects+ : [];+ const next = current.includes(effect)+ ? current.filter((item) => item !== effect)+ : [...current, effect];+ const nextMode = deriveCursorMode(next, effect);++ setContentState((prev) => ({+ ...prev,+ cursorEffects: next,+ cursorMode: nextMode,+ }));+ chrome.storage.local.set({+ cursorEffects: next,+ cursorMode: nextMode,+ });+ };++ const handleKeyDown = (event) => {+ const state = contentStateRef.current;+ if (state?.drawingMode && (event.ctrlKey || event.metaKey)) {+ const key = event.key.toLowerCase();+ if (key === "z" && !event.shiftKey) {+ event.preventDefault();+ event.stopPropagation();+ event.stopImmediatePropagation();+ undoCanvas(state, setContentState);+ return;+ }+ if (+ (key === "z" && event.shiftKey) ||+ key === "y"+ ) {+ event.preventDefault();+ event.stopPropagation();+ event.stopImmediatePropagation();+ redoCanvas(state, setContentState);+ return;+ }+ }++ if (!shouldHandleShortcut(event)) return;+ const digitKey = getDigitKey(event);+ if (!digitKey) return;++ let handled = true;+ if (state?.drawingMode) {+ switch (digitKey) {+ case "1":+ setTool("select");+ break;+ case "2":+ setTool("pen");+ break;+ case "3":+ setTool("highlighter");+ break;+ case "4":+ setTool("eraser");+ break;+ case "5":+ toggleColorPicker();+ break;+ case "6":+ setTool("text");+ break;+ case "7":+ setTool("shape", { shape: "rectangle", shapeFill: false });+ break;+ case "8":+ setTool("arrow");+ break;+ case "9":+ openImagePicker();+ break;+ case "0":+ clearDrawings();+ break;+ default:+ handled = false;+ }+ } else {+ switch (digitKey) {+ case "0":+ if (state?.blurMode) {+ clearBlurMasks();+ }+ clearCursorEffects();+ break;+ case "1":+ toggleCursorEffect("target");+ break;+ case "2":+ toggleCursorEffect("highlight");+ break;+ case "3":+ toggleCursorEffect("spotlight");+ break;+ default:+ handled = false;+ }+ }+ if (handled) {+ event.preventDefault();+ event.stopPropagation();+ event.stopImmediatePropagation();+ }+ };++ document.addEventListener("keydown", handleKeyDown, true);+ return () => {+ document.removeEventListener("keydown", handleKeyDown, true);+ };+ }, []);// Push to talk (while Alt/Option + Shift + J key is pressed enable microphone, disable on key up)useEffect(() => {diff --git a/src/pages/Content/toolbar/components/RadialMenu.jsx b/src/pages/Content/toolbar/components/RadialMenu.jsxindex 0b67972..cf8fd0b 100644--- a/src/pages/Content/toolbar/components/RadialMenu.jsx+++ b/src/pages/Content/toolbar/components/RadialMenu.jsx@@ -1,7 +1,6 @@import React, { useEffect, useState } from "react";import * as Popover from "@radix-ui/react-popover";-import * as Tooltip from "@radix-ui/react-tooltip";// Iconsimport { EyeDropperIcon } from "./SVG";@@ -24,18 +23,8 @@ const RadialMenu = (props) => {const [fullwheel, setFullWheel] = useState(false);const [open, setOpen] = useState(false);const [eyeDropperActive, setEyeDropperActive] = useState(false);- const [override, setOverride] = useState("");const [renderColorWheel, setRenderColorWheel] = useState(false);- useEffect(() => {- // Check if hideUI is set- if (contentState.hideUI) {- setOverride("override");- } else {- setOverride("");- }- }, [contentState.hideUI]);-// Colors in menuconst [colors, setColors] = useState([{ color: "#FED252", label: "Yellow" },@@ -93,34 +82,16 @@ const RadialMenu = (props) => {return (<Popover.Root open={open} onOpenChange={() => setOpen(!open)}>- <Popover.Trigger as="div" ref={ref}>- <Tooltip.Provider>- <Tooltip.Root delayDuration={700}>- <Tooltip.Trigger asChild>- <div className="ToolbarButton" component="div" ref={buttonRef}>- <div- className="ColorPicker"- style={{ backgroundColor: contentState.color }}- ></div>- </div>- </Tooltip.Trigger>- <Tooltip.Portal- container={- document.getElementsByClassName("screenity-shadow-dom")[0]- }- >- <Tooltip.Content- className={"TooltipContent" + " " + override}- style={{- display: override === "override" ? "none" : "block",- }}- >- Color and stroke- </Tooltip.Content>- </Tooltip.Portal>- </Tooltip.Root>- </Tooltip.Provider>- </Popover.Trigger>+ <TooltipWrap content="Color and stroke" shortcut={props.shortcut}>+ <Popover.Trigger as="div" ref={ref} data-color-trigger="true">+ <div className="ToolbarButton" component="div" ref={buttonRef}>+ <div+ className="ColorPicker"+ style={{ backgroundColor: contentState.color }}+ ></div>+ </div>+ </Popover.Trigger>+ </TooltipWrap><Popover.Portal forceMount container={ref.current}><Popover.Content avoidCollisions={false} asChild onOpenAutoFocus><divdiff --git a/src/pages/Content/toolbar/components/ToolTrigger.jsx b/src/pages/Content/toolbar/components/ToolTrigger.jsxindex 1a8c8aa..9ba9feb 100644--- a/src/pages/Content/toolbar/components/ToolTrigger.jsx+++ b/src/pages/Content/toolbar/components/ToolTrigger.jsx@@ -9,7 +9,7 @@ const ToolTrigger = (props) => {const resume = props.resume ? " resume" : "";return (- <TooltipWrap content={props.content}>+ <TooltipWrap content={props.content} shortcut={props.shortcut}>{props.type === "button" ? (<Toolbar.ButtonclassName={"ToolbarButton" + grab + resume}diff --git a/src/pages/Content/toolbar/components/TooltipWrap.jsx b/src/pages/Content/toolbar/components/TooltipWrap.jsxindex cc70205..025e075 100644--- a/src/pages/Content/toolbar/components/TooltipWrap.jsx+++ b/src/pages/Content/toolbar/components/TooltipWrap.jsx@@ -9,6 +9,10 @@ const TooltipWrap = (props) => {const [contentState, setContentState] = useContext(contentStateContext);const classname = props.name ? props.name : "";const [override, setOverride] = useState("");+ const content =+ props.shortcut && props.content+ ? `${props.content} (${props.shortcut})`+ : props.content;useEffect(() => {// Check if hideUI is set@@ -46,7 +50,7 @@ const TooltipWrap = (props) => {display: override === "override" ? "none" : "block",}}>- {props.content}+ {content}</Tooltip.Content></Tooltip.Portal></Tooltip.Root>diff --git a/src/pages/Content/toolbar/layout/BlurToolbar.jsx b/src/pages/Content/toolbar/layout/BlurToolbar.jsxindex edab07d..effcdf9 100644--- a/src/pages/Content/toolbar/layout/BlurToolbar.jsx+++ b/src/pages/Content/toolbar/layout/BlurToolbar.jsx@@ -28,6 +28,7 @@ const BlurToolbar = (props) => {<ToolTriggertype="button"content={chrome.i18n.getMessage("clearBlurredElementsTooltip")}+ shortcut="0"onClick={() => {// Remove class screenity-blur from all elementsconst blurredElements =diff --git a/src/pages/Content/toolbar/layout/CursorToolbar.jsx b/src/pages/Content/toolbar/layout/CursorToolbar.jsxindex a7ddd1e..46f7f69 100644--- a/src/pages/Content/toolbar/layout/CursorToolbar.jsx+++ b/src/pages/Content/toolbar/layout/CursorToolbar.jsx@@ -1,4 +1,4 @@-import React, { useState, useEffect, useContext } from "react";+import React, { useState, useEffect, useContext, useRef } from "react";import * as Toolbar from "@radix-ui/react-toolbar";import TooltipWrap from "../components/TooltipWrap";@@ -16,6 +16,85 @@ import {const CursorToolbar = (props) => {const [contentState, setContentState] = useContext(contentStateContext);+ const lastClickedEffectRef = useRef(contentState.cursorMode || "none");++ useEffect(() => {+ if (contentState.cursorMode) {+ lastClickedEffectRef.current = contentState.cursorMode;+ }+ }, [contentState.cursorMode]);++ const deriveCursorMode = (effects, fallback) => {+ if (effects.length === 0) return "none";+ if (effects.length === 1) return effects[0];+ if (fallback && effects.includes(fallback)) return fallback;+ return effects[0] || "none";+ };++ const applyCursorSelection = (effect, shiftKey) => {+ if (effect === "none") {+ lastClickedEffectRef.current = "none";+ setContentState((prev) => ({+ ...prev,+ cursorEffects: [],+ cursorMode: "none",+ }));+ if (!shiftKey) {+ props.setMode(false);+ }+ chrome.storage.local.set({+ cursorEffects: [],+ cursorMode: "none",+ });+ return;+ }++ const currentEffects = Array.isArray(contentState.cursorEffects)+ ? contentState.cursorEffects+ : [];++ let nextEffects = [];+ if (shiftKey) {+ if (currentEffects.includes(effect)) {+ nextEffects = currentEffects.filter((item) => item !== effect);+ } else {+ nextEffects = [...currentEffects, effect];+ }+ } else {+ nextEffects = [effect];+ }++ lastClickedEffectRef.current = effect;+ const nextMode = deriveCursorMode(+ nextEffects,+ lastClickedEffectRef.current+ );++ setContentState((prev) => ({+ ...prev,+ cursorEffects: nextEffects,+ cursorMode: nextMode,+ }));+ if (!shiftKey) {+ props.setMode(false);+ }+ chrome.storage.local.set({+ cursorEffects: nextEffects,+ cursorMode: nextMode,+ });+ };++ const handleClick = (effect) => (event) => {+ applyCursorSelection(effect, Boolean(event.shiftKey));+ };++ const cursorEffects = Array.isArray(contentState.cursorEffects)+ ? contentState.cursorEffects+ : [];+ const isDefault = cursorEffects.length === 0;+ const toggleValues = isDefault ? ["none"] : cursorEffects;+ const isEffectActive = (effect) =>+ effect === "none" ? isDefault : cursorEffects.includes(effect);return (<Toolbar.Root@@ -24,48 +103,65 @@ const CursorToolbar = (props) => {tabIndex="0"><Toolbar.ToggleGroup- type="single"+ type="multiple"className="ToolbarToggleGroup"- value={contentState.cursorMode}- onValueChange={(value) => {- if (value) {- setContentState((prevContentState) => ({- ...prevContentState,- cursorMode: value,- }));- props.setMode(false);-- chrome.storage.local.set({- cursorMode: value,- });- }- }}+ value={toggleValues}+ onValueChange={() => {}}>- <TooltipWrap content="Default">+ <TooltipWrap content="Default" shortcut="0"><div className="ToolbarToggleWrap">- <Toolbar.ToggleItem className="ToolbarToggleItem" value="none">+ <Toolbar.ToggleItem+ className="ToolbarToggleItem"+ value="none"+ data-state={isEffectActive("none") ? "on" : "off"}+ onClick={handleClick("none")}+ ><CursorIcon /></Toolbar.ToggleItem></div></TooltipWrap><Toolbar.Separator className="ToolbarSeparator" />- <TooltipWrap content={chrome.i18n.getMessage("highlightClicksTooltip")}>+ <TooltipWrap+ content={chrome.i18n.getMessage("highlightClicksTooltip")}+ shortcut="1"+ ><div className="ToolbarToggleWrap">- <Toolbar.ToggleItem className="ToolbarToggleItem" value="target">+ <Toolbar.ToggleItem+ className="ToolbarToggleItem"+ value="target"+ data-state={isEffectActive("target") ? "on" : "off"}+ onClick={handleClick("target")}+ ><TargetCursorIcon /></Toolbar.ToggleItem></div></TooltipWrap>- <TooltipWrap content={chrome.i18n.getMessage("highlightCursorTooltip")}>+ <TooltipWrap+ content={chrome.i18n.getMessage("highlightCursorTooltip")}+ shortcut="2"+ ><div className="ToolbarToggleWrap">- <Toolbar.ToggleItem className="ToolbarToggleItem" value="highlight">+ <Toolbar.ToggleItem+ className="ToolbarToggleItem"+ value="highlight"+ data-state={isEffectActive("highlight") ? "on" : "off"}+ onClick={handleClick("highlight")}+ ><HighlightCursorIcon /></Toolbar.ToggleItem></div></TooltipWrap>- <TooltipWrap content={chrome.i18n.getMessage("spotlightCursorTooltip")}>+ <TooltipWrap+ content={chrome.i18n.getMessage("spotlightCursorTooltip")}+ shortcut="3"+ ><div className="ToolbarToggleWrap">- <Toolbar.ToggleItem className="ToolbarToggleItem" value="spotlight">+ <Toolbar.ToggleItem+ className="ToolbarToggleItem"+ value="spotlight"+ data-state={isEffectActive("spotlight") ? "on" : "off"}+ onClick={handleClick("spotlight")}+ ><SpotlightCursorIcon /></Toolbar.ToggleItem></div>diff --git a/src/pages/Content/toolbar/layout/DrawingToolbar.jsx b/src/pages/Content/toolbar/layout/DrawingToolbar.jsxindex 4e94c47..f790029 100644--- a/src/pages/Content/toolbar/layout/DrawingToolbar.jsx+++ b/src/pages/Content/toolbar/layout/DrawingToolbar.jsx@@ -121,6 +121,7 @@ const DrawingToolbar = (props) => {type="toggle"value="select"content={chrome.i18n.getMessage("selectToolTooltip")}+ shortcut="1"><TransformIcon /></ToolTrigger>@@ -128,6 +129,7 @@ const DrawingToolbar = (props) => {type="toggle"value="pen"content={chrome.i18n.getMessage("penToolTooltip")}+ shortcut="2"><DrawIcon /></ToolTrigger>@@ -135,6 +137,7 @@ const DrawingToolbar = (props) => {type="toggle"value="highlighter"content={chrome.i18n.getMessage("highlighterToolTooltip")}+ shortcut="3"><HighlighterIcon /></ToolTrigger>@@ -142,14 +145,16 @@ const DrawingToolbar = (props) => {type="toggle"value="eraser"content={chrome.i18n.getMessage("eraserToolTooltip")}+ shortcut="4"><EraserIcon /></ToolTrigger>- <RadialMenu />+ <RadialMenu shortcut="5" /><ToolTriggertype="toggle"value="text"content={chrome.i18n.getMessage("textToolTooltip")}+ shortcut="6"><TextIcon /></ToolTrigger>@@ -158,6 +163,7 @@ const DrawingToolbar = (props) => {type="toggle"value="shape"content={chrome.i18n.getMessage("shapeToolTooltip")}+ shortcut="7">{contentState.shape === "rectangle" && contentState.shapeFill ? (<RectangleFilledIcon />@@ -177,6 +183,7 @@ const DrawingToolbar = (props) => {type="toggle"value="arrow"content={chrome.i18n.getMessage("arrowToolTooltip")}+ shortcut="8"><ArrowIcon /></ToolTrigger>@@ -184,6 +191,7 @@ const DrawingToolbar = (props) => {type="button"value="image"content={chrome.i18n.getMessage("imageToolTooltip")}+ shortcut="9"onClick={(e) => imageFileInput.current.click()}><ImageIcon />@@ -193,6 +201,7 @@ const DrawingToolbar = (props) => {accept="image/*"style={{ display: "none" }}ref={imageFileInput}+ data-image-upload="true"onChange={handleImageChange}/></ToolTrigger>@@ -217,6 +226,7 @@ const DrawingToolbar = (props) => {<ToolTriggertype="button"content={chrome.i18n.getMessage("clearCanvasTooltip")}+ shortcut="0"disabled={contentState.canvas? contentState.canvas.getObjects().length === 0diff --git a/src/pages/Content/toolbar/layout/ToolbarWrap.jsx b/src/pages/Content/toolbar/layout/ToolbarWrap.jsxindex afbc941..75bd89e 100644--- a/src/pages/Content/toolbar/layout/ToolbarWrap.jsx+++ b/src/pages/Content/toolbar/layout/ToolbarWrap.jsx@@ -47,6 +47,7 @@ const ToolbarWrap = () => {const [contentState, setContentState, t, setT] =useContext(contentStateContext);const [mode, setMode] = React.useState("");+ const modeRef = React.useRef(mode);const [hovering, setHovering] = React.useState(false);const DragRef = React.useRef(null);const ToolbarRef = React.useRef(null);@@ -61,6 +62,18 @@ const ToolbarWrap = () => {const [visuallyHidden, setVisuallyHidden] = useState(false);const timeRef = React.useRef("");+ useEffect(() => {+ modeRef.current = mode;+ }, [mode]);++ useEffect(() => {+ setContentState((prev) => ({+ ...prev,+ setToolbarMode: setMode,+ toolbarMode: mode,+ }));+ }, [mode, setContentState]);+useEffect(() => {if (contentState.toolbarHover && contentState.hideUI) {setTransparent("ToolbarTransparent");@@ -313,6 +326,21 @@ const ToolbarWrap = () => {}}, [contentState.drawingMode, contentState.blurMode, contentState.openToast]);+ useEffect(() => {+ let nextMode = modeRef.current;+ if (contentState.drawingMode) {+ nextMode = "draw";+ } else if (contentState.blurMode) {+ nextMode = "blur";+ } else if (modeRef.current === "draw" || modeRef.current === "blur") {+ nextMode = "";+ }++ if (nextMode !== modeRef.current) {+ setMode(nextMode);+ }+ }, [contentState.drawingMode, contentState.blurMode]);+useEffect(() => {if (mode === "draw") {setContentState((prevContentState) => ({@@ -540,6 +568,7 @@ const ToolbarWrap = () => {type="mode"content={chrome.i18n.getMessage("toggleDrawingToolsTooltip")}value="draw"+ shortcut={contentState.toggleDrawingModeShortcut}>{mode === "draw" && <CloseButtonToolbar />}{mode !== "draw" && <DrawIcon />}@@ -551,6 +580,7 @@ const ToolbarWrap = () => {type="mode"content={chrome.i18n.getMessage("toggleBlurToolTooltip")}value="blur"+ shortcut={contentState.toggleBlurModeShortcut}>{mode === "blur" && <CloseButtonToolbar />}{mode !== "blur" && <BlurIcon />}@@ -563,6 +593,7 @@ const ToolbarWrap = () => {type="mode"content={chrome.i18n.getMessage("toggleCursorOptionsTooltip")}value="cursor"+ shortcut={contentState.toggleCursorModeShortcut}>{contentState.cursorMode === "target" && <TargetCursorIcon />}{contentState.cursorMode === "highlight" && (diff --git a/src/pages/Content/utils/BlurTool.jsx b/src/pages/Content/utils/BlurTool.jsxindex 6cf14a6..cfc36ba 100644--- a/src/pages/Content/utils/BlurTool.jsx+++ b/src/pages/Content/utils/BlurTool.jsx@@ -14,6 +14,7 @@ const BlurTool = () => {const hoveredElementRef = useRef(null);const blurModeRef = useRef(null);const [showOutline, setShowOutline] = useState(false);+ const [outlineRect, setOutlineRect] = useState(null);useEffect(() => {blurModeRef.current = contentState.blurMode;@@ -31,9 +32,23 @@ const BlurTool = () => {}, [contentState.showExtension]);useLayoutEffect(() => {+ const updateOutline = (target) => {+ if (!target) return;+ hoveredElementRef.current = target;+ const rect = target.getBoundingClientRect();+ setOutlineRect({+ top: rect.top + window.scrollY,+ left: rect.left + window.scrollX,+ width: target.offsetWidth,+ height: target.offsetHeight,+ });+ setShowOutline(true);+ };+const handleMouseMove = (event) => {if (!blurModeRef.current) {setShowOutline(false);+ setOutlineRect(null);return;}const target = event.target;@@ -41,16 +56,18 @@ const BlurTool = () => {!target.classList.contains("screenity-outline") &&!target.closest("#screenity-ui #screenity-ui *")) {- hoveredElementRef.current = target;- setShowOutline(true);+ updateOutline(target);document.body.style.cursor = "pointer";} else {document.body.style.cursor = "auto";+ setShowOutline(false);+ setOutlineRect(null);}};const handleMouseOut = () => {setShowOutline(false);+ setOutlineRect(null);};const handleMouseDown = (event) => {@@ -87,6 +104,7 @@ const BlurTool = () => {const handleMouseUp = (event) => {if (!blurModeRef.current) {setShowOutline(false);+ setOutlineRect(null);return;}@@ -98,37 +116,38 @@ const BlurTool = () => {event.stopPropagation();};- document.body.addEventListener("mouseover", handleMouseMove, true);+ const handleScroll = () => {+ if (!blurModeRef.current || !hoveredElementRef.current) return;+ updateOutline(hoveredElementRef.current);+ };++ document.body.addEventListener("mousemove", handleMouseMove, true);document.body.addEventListener("mousedown", handleMouseDown, true);document.body.addEventListener("mouseout", handleMouseOut, true);document.body.addEventListener("mouseup", handleMouseUp, true);document.body.addEventListener("click", handleElementClick, true);+ document.addEventListener("scroll", handleScroll, true);return () => {- document.body.removeEventListener("mouseover", handleMouseMove);- document.body.removeEventListener("mousedown", handleMouseDown);- document.body.removeEventListener("mouseout", handleMouseOut);- document.body.removeEventListener("mouseup", handleMouseUp);- document.body.removeEventListener("click", handleElementClick);+ document.body.removeEventListener("mousemove", handleMouseMove, true);+ document.body.removeEventListener("mousedown", handleMouseDown, true);+ document.body.removeEventListener("mouseout", handleMouseOut, true);+ document.body.removeEventListener("mouseup", handleMouseUp, true);+ document.body.removeEventListener("click", handleElementClick, true);+ document.removeEventListener("scroll", handleScroll, true);};}, []);return (<div>- {showOutline && (+ {showOutline && outlineRect && (<divclassName="screenity-outline"style={{- top:- hoveredElementRef.current.getBoundingClientRect().top +- window.scrollY +- "px",- left:- hoveredElementRef.current.getBoundingClientRect().left +- window.scrollX +- "px",- width: hoveredElementRef.current.offsetWidth + "px",- height: hoveredElementRef.current.offsetHeight + "px",+ top: outlineRect.top + "px",+ left: outlineRect.left + "px",+ width: outlineRect.width + "px",+ height: outlineRect.height + "px",}}></div>)}diff --git a/src/pages/Content/utils/CursorModes.jsx b/src/pages/Content/utils/CursorModes.jsxindex 877a640..96c5a3c 100644--- a/src/pages/Content/utils/CursorModes.jsx+++ b/src/pages/Content/utils/CursorModes.jsx@@ -5,29 +5,37 @@ import { contentStateContext } from "../context/ContentState";const CursorModes = () => {const [contentState, setContentState] = useContext(contentStateContext);- const modeRef = useRef(null);- const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });+ const effectsRef = useRef(new Set());useEffect(() => {- modeRef.current = contentState.cursorMode;- }, [contentState.cursorMode]);+ const nextEffects = Array.isArray(contentState.cursorEffects)+ ? contentState.cursorEffects+ : [];+ effectsRef.current = new Set(nextEffects);+ }, [contentState.cursorEffects]);const mouseDownHandler = (e) => {- if (modeRef.current === "target") {- document.querySelector(".cursor-click-target").style.transform =+ if (effectsRef.current.has("target")) {+ const target = document.querySelector(".cursor-click-target");+ if (!target) return;+ target.style.transform ="translate(-50%, -50%) scale(1)";- document.querySelector(".cursor-click-target").style.opacity = "1";+ target.style.opacity = "1";}};const mouseUpHandler = (e) => {- if (modeRef.current === "target") {- document.querySelector(".cursor-click-target").style.transform =+ if (effectsRef.current.has("target")) {+ const target = document.querySelector(".cursor-click-target");+ if (!target) return;+ target.style.transform ="translate(-50%, -50%) scale(0)";- document.querySelector(".cursor-click-target").style.opacity = "0";+ target.style.opacity = "0";window.setTimeout(() => {- document.querySelector(".cursor-click-target").style.transform =+ const targetReset = document.querySelector(".cursor-click-target");+ if (!targetReset) return;+ targetReset.style.transform ="translate(-50%, -50%) scale(1)";}, 350);}@@ -44,21 +52,35 @@ const CursorModes = () => {const scrollTop = window.scrollY;const scrollLeft = window.scrollX;- const cursorElement =- modeRef.current === "target"- ? document.querySelector(".cursor-click-target")- : modeRef.current === "highlight"- ? document.querySelector(".cursor-highlight")- : document.querySelector(".spotlight");+ if (effectsRef.current.has("target")) {+ const target = document.querySelector(".cursor-click-target");+ if (target) {+ target.style.top = lastMouseRef.current.y + scrollTop + "px";+ target.style.left = lastMouseRef.current.x + scrollLeft + "px";+ }+ }++ if (effectsRef.current.has("highlight")) {+ const highlight = document.querySelector(".cursor-highlight");+ if (highlight) {+ highlight.style.top = lastMouseRef.current.y + scrollTop + "px";+ highlight.style.left = lastMouseRef.current.x + scrollLeft + "px";+ }+ }- if (cursorElement) {- cursorElement.style.top = lastMouseRef.current.y + scrollTop + "px";- cursorElement.style.left = lastMouseRef.current.x + scrollLeft + "px";+ if (effectsRef.current.has("spotlight")) {+ const spotlight = document.querySelector(".spotlight");+ if (spotlight) {+ spotlight.style.top = lastMouseRef.current.y + scrollTop + "px";+ spotlight.style.left = lastMouseRef.current.x + scrollLeft + "px";+ }}};const mouseMoveHandler = (e) => {- setLastMousePosition({ x: e.clientX, y: e.clientY });+ const next = { x: e.clientX, y: e.clientY };+ lastMouseRef.current = next;+ setLastMousePosition(next);updateCursorPosition();};@@ -88,7 +110,9 @@ const CursorModes = () => {style={{display: "block",visibility:- contentState.cursorMode === "highlight" ? "visible" : "hidden",+ contentState.cursorEffects?.includes("highlight")+ ? "visible"+ : "hidden",position: "absolute",top: 0,left: 0,@@ -108,7 +132,9 @@ const CursorModes = () => {style={{display: "block",visibility:- contentState.cursorMode === "target" ? "visible" : "hidden",+ contentState.cursorEffects?.includes("target")+ ? "visible"+ : "hidden",position: "absolute",top: 0,opacity: 0,@@ -130,9 +156,11 @@ const CursorModes = () => {className="spotlight"style={{position: "absolute",- display: contentState.cursorMode === "spotlight" ? "block" : "none",- top: mousePosition.y + "px",- left: mousePosition.x + "px",+ display: contentState.cursorEffects?.includes("spotlight")+ ? "block"+ : "none",+ top: lastMousePosition.y + "px",+ left: lastMousePosition.x + "px",width: "100px",height: "100px",borderRadius: "50%",