mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
feat(obsidian): persist FMG-to-note association with fmg-id in frontmatter
When a user selects or creates a note for a burg/marker, the system now automatically links them together by adding/updating the note's frontmatter. **How it works:** 1. **When saving a note**: - Adds `fmg-id: burg123` to frontmatter - Updates `x:` and `y:` coordinates - Preserves existing frontmatter fields 2. **When creating a new note**: - Template includes fmg-id from the start - Uses the proper elementId (e.g., "burg123") 3. **Next time you edit**: - System finds note instantly by fmg-id - No need to search by coordinates again - Permanent two-way link established **Changes:** - obsidian-notes-editor.js: - Pass elementId and coordinates to showMarkdownEditor() - updateFrontmatterWithFmgData() injects fmg-id on save - Automatically updates coordinates to keep in sync - obsidian-bridge.js: - generateNoteTemplate() accepts elementId parameter - Uses elementId for fmg-id instead of element.id Users no longer need to manually match notes - once linked, the association is permanent in the note's frontmatter.
This commit is contained in:
parent
28cf8db82d
commit
154145a518
3 changed files with 49 additions and 10 deletions
|
|
@ -343,13 +343,13 @@ const ObsidianBridge = (() => {
|
|||
}
|
||||
|
||||
// Generate note template for FMG element
|
||||
function generateNoteTemplate(element, type) {
|
||||
function generateNoteTemplate(element, type, elementId) {
|
||||
const {x, y} = element;
|
||||
const lat = pack.cells.lat?.[element.cell] || 0;
|
||||
const lon = pack.cells.lon?.[element.cell] || 0;
|
||||
|
||||
const frontmatter = {
|
||||
"fmg-id": element.id || `${type}${element.i}`,
|
||||
"fmg-id": elementId || element.id || `${type}${element.i}`,
|
||||
"fmg-type": type,
|
||||
coordinates: {x, y, lat, lon},
|
||||
tags: [type],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue