Skip to content

Commit

Permalink
fix: 修复快捷键导致的链接丢失问题
Browse files Browse the repository at this point in the history
  • Loading branch information
moshangqi committed Dec 22, 2023
1 parent 98ebe5f commit 7467865
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
19 changes: 2 additions & 17 deletions src/components/SuperSideBar/impl/ClipAssistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ function ClipContent() {

const onClipPage = async () => {
const html = await backgroundBridge.clip.clipPage();
console.log(html);
await addLinkWhenEmpty();
editorRef.current?.appendContent(html);
editorRef.current?.insertBreakLine();
Expand Down Expand Up @@ -263,39 +262,25 @@ function ClipContent() {
}, [selectSavePosition]);

useEffect(() => {
const onStartSelectArea = () => {
const div = document.querySelector(`#${ClipSelectAreaId}`);
(div as HTMLDivElement)?.click();
};
const onStartScreenOcr = () => {
const div = document.querySelector(`#${ClipScreenOcrId}`);
(div as HTMLDivElement)?.click();
};
const onStartCollectLink = () => {
const div = document.querySelector(`#${ClipCollectLinkId}`);
(div as HTMLDivElement)?.click();
};

const onMessage = (e: any) => {
if (e.data.key !== ClipAssistantMessageKey) {
return;
}
switch (e.data.action) {
case ClipAssistantMessageActions.addContent: {
addLinkWhenEmpty();
editorRef.current?.appendContent(e.data?.data);
break;
}
case ClipAssistantMessageActions.startSelectArea: {
onStartSelectArea();
break;
}
case ClipAssistantMessageActions.startScreenOcr: {
onStartScreenOcr();
break;
}
case ClipAssistantMessageActions.startCollectLink: {
onStartCollectLink();
break;
}
default: {
break;
}
Expand Down
2 changes: 0 additions & 2 deletions src/isomorphic/event/clipAssistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ export enum ClipAssistantMessageActions {
*/
ready = 'ready',
addContent = 'addContent',
startSelectArea = 'startSelectArea',
startScreenOcr = 'startScreenOcr',
startCollectLink = 'startCollectLink',
}
2 changes: 1 addition & 1 deletion src/pages/sidePanel/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare const Tracert: any;
const MiniWidth = 416;

function App() {
const [sidePanelIsReady, setSidePanelIsReady] = useState(true);
const [sidePanelIsReady, setSidePanelIsReady] = useState(false);
const { forceUpdate } = useForceUpdate();
const disableRef = useRef(window.innerWidth < MiniWidth);

Expand Down

0 comments on commit 7467865

Please sign in to comment.