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
This commit is contained in:
Philip Okugbe
2024-08-31 19:11:07 +01:00
committed by GitHub
parent 77b541ec71
commit 38e9eef2dc
26 changed files with 1440 additions and 799 deletions

View File

@ -5,11 +5,11 @@ declare global {
}
export function getAppUrl(): string {
let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
if (import.meta.env.DEV) {
return appUrl || "http://localhost:3000";
}
// if (import.meta.env.DEV) {
// return appUrl || "http://localhost:3000";
//}
return `${window.location.protocol}//${window.location.host}`;
}
@ -20,9 +20,10 @@ export function getBackendUrl(): string {
export function getCollaborationUrl(): string {
const COLLAB_PATH = "/collab";
const url = process.env.APP_URL || getAppUrl();
const wsProtocol = getAppUrl().startsWith("https") ? "wss" : "ws";
return `${wsProtocol}://${getAppUrl().split("://")[1]}${COLLAB_PATH}`;
const wsProtocol = url.startsWith("https") ? "wss" : "ws";
return `${wsProtocol}://${url.split("://")[1]}${COLLAB_PATH}`;
}
export function getAvatarUrl(avatarUrl: string) {

View File

@ -44,3 +44,11 @@ export const formatBytes = (
return `${adjustedSize.toFixed(precision)} ${units[adjustedUnitIndex]}`;
};
export async function svgStringToFile(
svgString: string,
fileName: string,
): Promise<File> {
const blob = new Blob([svgString], { type: "image/svg+xml" });
return new File([blob], fileName, { type: "image/svg+xml" });
}