You've already forked obsidian-visualiser
Add gitea content searching and fix lots of things
This commit is contained in:
@@ -9,6 +9,7 @@ import { normalizeUri } from 'micromark-util-sanitize-uri'
|
||||
import { type Properties, type Element } from 'hast'
|
||||
import { type Link } from 'mdast'
|
||||
import { isRelative } from 'ufo'
|
||||
import type { CanvasEdge, CanvasGroup, CanvasNode } from '~/types/canvas'
|
||||
|
||||
export default defineTransformer({
|
||||
name: 'canvas',
|
||||
@@ -36,6 +37,8 @@ export default defineTransformer({
|
||||
})
|
||||
}
|
||||
}));
|
||||
|
||||
rawContent.groups = getGroups(rawContent);
|
||||
|
||||
return {
|
||||
_id,
|
||||
@@ -43,7 +46,18 @@ export default defineTransformer({
|
||||
_type: 'canvas',
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function contains(group: CanvasNode, node: CanvasNode): boolean
|
||||
{
|
||||
return group.x < node.x && group.y < node.y && group.x + group.width > node.x + node.width && group.y + group.height > node.y + node.height;
|
||||
}
|
||||
function getGroups(content: { nodes: CanvasNode[], edges: CanvasEdge[] }): CanvasGroup[]
|
||||
{
|
||||
const groups = content.nodes.filter(e => e.type === "group");
|
||||
|
||||
return groups.map(group => { return { name: group.label!, nodes: [group.id, ...content.nodes.filter(node => node.type !== "group" && contains(group, node)).map(e => e.id)] }} );
|
||||
}
|
||||
|
||||
async function importPlugins(plugins: Record<string, false | MarkdownPlugin> = {}) {
|
||||
const resolvedPlugins: Record<string, false | MarkdownPlugin & { instance: any }> = {}
|
||||
|
||||
Reference in New Issue
Block a user