You've already forked obsidian-visualiser
Progressing on CanvasEditor
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { hasPermissions } from "#shared/auth.util";
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import { explorerContentTable } from '~/db/schema';
|
||||
import { project } from '~/schemas/project';
|
||||
import { project, type ProjectItem } from '~/schemas/project';
|
||||
import { parsePath } from "#shared/general.utils";
|
||||
import { eq, getTableColumns, sql } from "drizzle-orm";
|
||||
import type { ExploreContent } from "~/types/content";
|
||||
import type { ExploreContent, TreeItem } from "~/types/content";
|
||||
import type { TreeItemEditable } from "~/pages/explore/edit/index.vue";
|
||||
|
||||
export default defineEventHandler(async (e) => {
|
||||
@@ -47,14 +47,14 @@ export default defineEventHandler(async (e) => {
|
||||
const path = [item.parent, parsePath(item.name === '' ? item.title : item.name)].filter(e => !!e).join('/');
|
||||
|
||||
tx.insert(explorerContentTable).values({
|
||||
path: item.path,
|
||||
path: item.path || path,
|
||||
owner: user.id,
|
||||
title: item.title,
|
||||
type: item.type,
|
||||
navigable: item.navigable,
|
||||
private: item.private,
|
||||
order: item.order,
|
||||
content: item.content ?? old.content,
|
||||
content: item.content ?? old?.content ?? null,
|
||||
}).onConflictDoUpdate({
|
||||
set: {
|
||||
path: path,
|
||||
@@ -64,12 +64,12 @@ export default defineEventHandler(async (e) => {
|
||||
private: item.private,
|
||||
order: item.order,
|
||||
timestamp: new Date(),
|
||||
content: item.content ?? old.content,
|
||||
content: item.content ?? old?.content ?? null,
|
||||
},
|
||||
target: explorerContentTable.path,
|
||||
}).run();
|
||||
|
||||
if(item.path !== path)
|
||||
if(item.path !== path && !old)
|
||||
{
|
||||
tx.update(explorerContentTable).set({ content: sql`replace(${explorerContentTable.content}, ${sql.placeholder('old')}, ${sql.placeholder('new')})` }).prepare().run({ 'old': item.path, 'new': path });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user