Add WordCraft and DeckCraft office editors with protected server saves

This commit is contained in:
SantaSpeen committed 2026-10-22 19:25:22 +03:00
1 parent bc9709e500
commit 6e36b6c4b7
20 files changed
+582 -40

No files matched your search

+5 -1
View File
@@ -76,7 +76,11 @@ const currentView = computed(() => {
if (fileStore.req.isDir) {
return FileListing;
}
if (["gridcraft", "pdfcraft"].includes(String(route.query.craft)))
if (
["wordcraft", "gridcraft", "deckcraft", "pdfcraft"].includes(
String(route.query.craft)
)
)
return CraftEditor;
if (
route.query.edit === "true" &&
+22 -10
View File
@@ -99,6 +99,9 @@ const file = files.req,
: file?.path || "";
const currentPath = ref(sourcePath),
currentName = ref(sourcePath.split("/").pop() || "");
const nativeExtension = computed(
() => store.items.find((item) => item.id === id)?.extension || ""
);
const title = computed(
() => store.items.find((item) => item.id === id)?.name || id
);
@@ -116,6 +119,7 @@ interface Save {
path: string;
create: boolean;
revision: number;
requestId?: string;
}
const pending = ref<Save>();
const authExpired = ref(false);
@@ -204,10 +208,13 @@ async function persist() {
);
if (disposed) return;
success = true;
if (payload.requestId)
frame.value?.contentWindow?.postMessage(
{ type: id + ":saved", requestId: payload.requestId },
window.location.origin
);
authExpired.value = false;
if (
payload.path.toLowerCase().endsWith(id === "gridcraft" ? ".xlsx" : ".pdf")
) {
if (payload.path.toLowerCase().endsWith(nativeExtension.value)) {
tag = response.headers.get("ETag") || "";
currentPath.value = payload.path;
currentName.value = payload.name;
@@ -219,6 +226,11 @@ async function persist() {
}
} catch (failure) {
if (!disposed) {
if (payload.requestId)
frame.value?.contentWindow?.postMessage(
{ type: id + ":save-error", requestId: payload.requestId },
window.location.origin
);
if (failure instanceof StatusError && failure.status === 401)
authExpired.value = true;
error.value =
@@ -237,9 +249,7 @@ function confirmSaveAs() {
if (!pending.value) return;
const ext = pending.value.name.toLowerCase().endsWith(".pdf")
? ".pdf"
: id === "gridcraft"
? ".xlsx"
: ".pdf";
: nativeExtension.value;
const name = safeCraftName(newName.value, ext);
if (!name) {
error.value = t("addons.invalidName");
@@ -299,9 +309,7 @@ function receive(event: MessageEvent) {
}
const extension = message.name?.toLowerCase().endsWith(".pdf")
? ".pdf"
: id === "gridcraft"
? ".xlsx"
: ".pdf";
: nativeExtension.value;
const name = safeCraftName(message.name, extension);
if (!name) {
error.value = t("addons.invalidName");
@@ -311,9 +319,13 @@ function receive(event: MessageEvent) {
pending.value = {
bytes: message.bytes,
name,
path: currentPath.value,
path: create
? currentPath.value.slice(0, currentPath.value.lastIndexOf("/") + 1) +
name
: currentPath.value,
create,
revision,
requestId: message.requestId,
};
if (create) {
newName.value = name;