Obsidian theme developed

This commit is contained in:
KarimTamani
2025-05-30 19:50:54 +01:00
parent a6a09b7199
commit fdb168bfdd
40 changed files with 595 additions and 208 deletions
+4
View File
@@ -70,7 +70,11 @@ const useHighlightedEdges = (nodes: Node[], relationships: RelationshipType[], e
(edge.animated || edge.selected) &&
(edge.source === node.id || edge.target === node.id)
);
const newHighlightedEdgeIds = newHighlightedEdges.map((edge : Edge) => edge.id) ;
const previousHighlightedEdgeIds = node.data.highlightedEdges.map((edge : Edge) => edge.id) ;
if (areArraysEqual(previousHighlightedEdgeIds , newHighlightedEdgeIds))
return node ;
// Add the highlighted edges to the node's data
return {
...node,
+27 -2
View File
@@ -3,13 +3,15 @@ import { TableType } from "@/lib/schemas/table-schema";
import { Node, useReactFlow } from "@xyflow/react";
import { useEffect } from "react";
import { getDefaultTableOverlapping } from "@/utils/tables";
import hash from "object-hash";
import { compare } from "fast-json-patch";
export const useTableToNode = (tables: TableType[]): void => {
const { setNodes } = useReactFlow();
useEffect(() => {
const nodes = tables.map((table: TableType) => {
const tableNodes = tables.map((table: TableType) => {
return {
id: table.id,
type: "table",
@@ -29,7 +31,30 @@ export const useTableToNode = (tables: TableType[]): void => {
} as Node
})
setNodes(nodes);
setNodes((nodes) => {
return tableNodes.map((tableNode) => {
const node: Node | undefined = nodes.find((node: Node) => node.id == tableNode.id);
if (!node)
return tableNode;
else {
// const diff = compare(node.data.table as TableType, tableNode.data.table as TableType);
//console.log (diff)
const hashNode: string = hash(node.data.table as TableType);
const hashTableNode: string = hash(tableNode.data.table as TableType);
return hashNode == hashTableNode ? node : tableNode;
}
})
});
}, [tables])
}