Files
docmost/apps/client/src/lib/config.ts
Philip Okugbe 38e9eef2dc feat: excalidraw integration (#214)
* update tiptap version

* excalidraw init

* cleanup

* better file handling and other fixes

* use different modal to fix excalidraw cursor position issue
* see https://github.com/excalidraw/excalidraw/issues/7312
* fix websocket in vite dev mode

* WIP

* add align attribute

* fix table

* menu icons

* Render image in excalidraw html
* add size to custom SVG components

* rewrite undefined font urls
2024-08-31 19:11:07 +01:00

48 lines
1.1 KiB
TypeScript

declare global {
interface Window {
CONFIG?: Record<string, string>;
}
}
export function getAppUrl(): string {
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
// if (import.meta.env.DEV) {
// return appUrl || "http://localhost:3000";
//}
return `${window.location.protocol}//${window.location.host}`;
}
export function getBackendUrl(): string {
return getAppUrl() + "/api";
}
export function getCollaborationUrl(): string {
const COLLAB_PATH = "/collab";
const url = process.env.APP_URL || getAppUrl();
const wsProtocol = url.startsWith("https") ? "wss" : "ws";
return `${wsProtocol}://${url.split("://")[1]}${COLLAB_PATH}`;
}
export function getAvatarUrl(avatarUrl: string) {
if (!avatarUrl) {
return null;
}
if (avatarUrl?.startsWith("http")) {
return avatarUrl;
}
return getBackendUrl() + "/attachments/img/avatar/" + avatarUrl;
}
export function getSpaceUrl(spaceSlug: string) {
return "/s/" + spaceSlug;
}
export function getFileUrl(src: string) {
return src?.startsWith("/files/") ? getBackendUrl() + src : src;
}