mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 12:55:19 +00:00
fix share links
This commit is contained in:
parent
85d7b1e098
commit
cfff416e18
1 changed files with 3 additions and 4 deletions
|
|
@ -8,7 +8,7 @@ import { autoPlacement, computePosition, offset, shift, VirtualElement } from "@
|
||||||
import { Link2Icon } from "@radix-ui/react-icons";
|
import { Link2Icon } from "@radix-ui/react-icons";
|
||||||
import { EditorView, SelectionRange } from "@uiw/react-codemirror";
|
import { EditorView, SelectionRange } from "@uiw/react-codemirror";
|
||||||
import { useCallback, useEffect, useRef } from "react";
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
import { resolveServerPath } from "../../api/(client)/client";
|
import { useDomain } from "@/hooks/useDomain";
|
||||||
|
|
||||||
interface ContextMenuProps {
|
interface ContextMenuProps {
|
||||||
view: EditorView;
|
view: EditorView;
|
||||||
|
|
@ -28,6 +28,7 @@ export const EditorContextMenu = ({
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const captureEvent = useCaptureEvent();
|
const captureEvent = useCaptureEvent();
|
||||||
|
const domain = useDomain();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selection.empty) {
|
if (selection.empty) {
|
||||||
|
|
@ -104,9 +105,7 @@ export const EditorContextMenu = ({
|
||||||
const from = toLineAndColumn(selection.from);
|
const from = toLineAndColumn(selection.from);
|
||||||
const to = toLineAndColumn(selection.to);
|
const to = toLineAndColumn(selection.to);
|
||||||
|
|
||||||
// @note: we need to resolve the server path for /browse since
|
const basePath = `${window.location.origin}/${domain}/browse`;
|
||||||
// we aren't using <Link /> (which normally does this for us).
|
|
||||||
const basePath = `${window.location.origin}${resolveServerPath('/browse')}`;
|
|
||||||
const url = createPathWithQueryParams(`${basePath}/${repoName}@${revisionName}/-/blob/${path}`,
|
const url = createPathWithQueryParams(`${basePath}/${repoName}@${revisionName}/-/blob/${path}`,
|
||||||
['highlightRange', `${from?.line}:${from?.column},${to?.line}:${to?.column}`],
|
['highlightRange', `${from?.line}:${from?.column},${to?.line}:${to?.column}`],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue