mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
fix copy
This commit is contained in:
parent
7cfd9e5580
commit
86294c676a
3 changed files with 12 additions and 10 deletions
|
|
@ -16,6 +16,9 @@ const CodeButtonsOnHover = ({ diffRepr: text }: { diffRepr: string }) => {
|
|||
const [copyButtonState, setCopyButtonState] = useState(CopyButtonState.Copy)
|
||||
const inlineDiffService = useService('inlineDiffService')
|
||||
|
||||
const clipboardService = useService('clipboardService')
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (copyButtonState !== CopyButtonState.Copy) {
|
||||
setTimeout(() => {
|
||||
|
|
@ -25,15 +28,10 @@ const CodeButtonsOnHover = ({ diffRepr: text }: { diffRepr: string }) => {
|
|||
}, [copyButtonState])
|
||||
|
||||
const onCopy = useCallback(() => {
|
||||
navigator.clipboard.writeText(text).then(
|
||||
() => {
|
||||
setCopyButtonState(CopyButtonState.Copied)
|
||||
},
|
||||
() => {
|
||||
setCopyButtonState(CopyButtonState.Error)
|
||||
}
|
||||
)
|
||||
}, [text])
|
||||
clipboardService.writeText(text)
|
||||
.then(() => { setCopyButtonState(CopyButtonState.Copied) })
|
||||
.catch(() => { setCopyButtonState(CopyButtonState.Error) })
|
||||
}, [text, clipboardService])
|
||||
|
||||
return <>
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const Sidebar = () => {
|
|||
|
||||
// className='@@void-scope'
|
||||
return <div className='@@void-scope'>
|
||||
<div className={`flex flex-col h-screen w-full px-2 py-2`}>
|
||||
<div className={`flex flex-col w-full px-2 py-2`}>
|
||||
|
||||
{/* <span onClick={() => {
|
||||
const tabs = ['chat', 'settings', 'threadSelector']
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import { IFileService } from '../../../../platform/files/common/files.js';
|
|||
import { IInlineDiffsService } from './registerInlineDiffs.js';
|
||||
import { IModelService } from '../../../../editor/common/services/model.js';
|
||||
import { ISendLLMMessageService } from '../../../../platform/void/browser/llmMessageService.js';
|
||||
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
|
||||
|
||||
|
||||
// import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
|
||||
|
|
@ -69,6 +70,7 @@ export type ReactServicesType = {
|
|||
inlineDiffService: IInlineDiffsService;
|
||||
sendLLMMessageService: ISendLLMMessageService;
|
||||
contextViewService: IContextViewService;
|
||||
clipboardService: IClipboardService;
|
||||
}
|
||||
|
||||
// ---------- Define viewpane ----------
|
||||
|
|
@ -101,6 +103,7 @@ class VoidSidebarViewPane extends ViewPane {
|
|||
protected override renderBody(parent: HTMLElement): void {
|
||||
super.renderBody(parent);
|
||||
parent.style.overflow = 'auto'
|
||||
parent.style.userSelect = 'text'
|
||||
|
||||
// gets set immediately
|
||||
this.instantiationService.invokeFunction(accessor => {
|
||||
|
|
@ -113,6 +116,7 @@ class VoidSidebarViewPane extends ViewPane {
|
|||
inlineDiffService: accessor.get(IInlineDiffsService),
|
||||
sendLLMMessageService: accessor.get(ISendLLMMessageService),
|
||||
contextViewService: accessor.get(IContextViewService),
|
||||
clipboardService: accessor.get(IClipboardService),
|
||||
}
|
||||
mountFn(parent, services);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue