Added link sharing functionality

This commit is contained in:
AloeSapling 2025-08-21 14:25:03 +02:00
parent d0ff06dd1d
commit a6f8c98242
3 changed files with 11 additions and 1 deletions

BIN
bun.lockb Normal file → Executable file

Binary file not shown.

View file

@ -6,6 +6,8 @@ import { initManageLinks } from "./manageLinks.ts";
import { initManageTemplates } from "./manageTemplates.ts";
import UIManager from "./uiManager.ts";
import "@placecharity/framework-types"
const DUMMY_DATA = {
whoami: "BlueMarble",
schemaVersion: "",

View file

@ -90,7 +90,15 @@ function exportToggle(id: number){
exportTemplateIndexes.push(id)
}
function shareTemplate(id: number){
dataManager.getExportableData([id], []) // make link from this data
try{
const string = JSON.stringify(dataManager.getExportableData([id], []));
const windowURL = window.location.origin + window.location.pathname;
const searchParams = new URLSearchParams();
searchParams.set("bmShare", string);
navigator.clipboard.writeText(windowURL+searchParams.toString());
window.charity.lib.sonner.toast.success("Share link copied to clipboard")
}
catch{ window.charity.lib.sonner.toast.error("Creating share link failed") }
}
function deleteTemplate(id: number){