From 1c0b55e42279d9325afab6c5e9b00ab25b135c04 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 29 Aug 2019 23:08:30 +0200 Subject: [PATCH] fixes to link parsing and tweaks --- src/public/javascripts/services/link_map.js | 6 +++++- src/public/javascripts/widgets/link_map.js | 10 ++++++++++ src/public/javascripts/widgets/note_revisions.js | 10 ++++++++++ src/services/notes.js | 4 ++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/public/javascripts/services/link_map.js b/src/public/javascripts/services/link_map.js index 22f18e49e..5eec78c7f 100644 --- a/src/public/javascripts/services/link_map.js +++ b/src/public/javascripts/services/link_map.js @@ -65,7 +65,7 @@ export default class LinkMap { graph, // param explanation here: https://github.com/dhotson/springy/issues/58 400.0, // Spring stiffness - 400.0, // Node repulsion + 200.0, // Node repulsion 0.15 // Damping ); @@ -79,6 +79,10 @@ export default class LinkMap { const note = notes.find(n => n.noteId === noteId); + if (!note) { + return null; + } + const $noteBox = $("
") .addClass("note-box") .prop("id", noteBoxId); diff --git a/src/public/javascripts/widgets/link_map.js b/src/public/javascripts/widgets/link_map.js index e85eada7a..2897fc1cb 100644 --- a/src/public/javascripts/widgets/link_map.js +++ b/src/public/javascripts/widgets/link_map.js @@ -43,6 +43,16 @@ class LinkMapWidget extends StandardWidget { this.linkMapService.cleanup(); } } + + syncDataReceived(syncData) { + if (syncData.find(sd => sd.entityName === 'attributes' && sd.noteId === this.ctx.note.noteId)) { + // no need to invalidate attributes since the Attribute class listens to this as well + // (and is guaranteed to run first) + if (this.linkMapService) { + this.linkMapService.loadNotesAndRelations(); + } + } + } } export default LinkMapWidget; \ No newline at end of file diff --git a/src/public/javascripts/widgets/note_revisions.js b/src/public/javascripts/widgets/note_revisions.js index 7b7cb38a7..9fa3e8718 100644 --- a/src/public/javascripts/widgets/note_revisions.js +++ b/src/public/javascripts/widgets/note_revisions.js @@ -9,6 +9,16 @@ const TPL = ` class NoteRevisionsWidget extends StandardWidget { getWidgetTitle() { return "Note revisions"; } + getHeaderActions() { + const $showFullButton = $("").append("show dialog").addClass('widget-header-action'); + $showFullButton.click(async () => { + const attributesDialog = await import("../dialogs/note_revisions.js"); + attributesDialog.showDialog(); + }); + + return [$showFullButton]; + } + async doRenderBody() { const revisionItems = await server.get(`notes/${this.ctx.note.noteId}/revisions`); diff --git a/src/services/notes.js b/src/services/notes.js index d9611c2e9..374b06f21 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -214,7 +214,7 @@ function findImageLinks(content, foundLinks) { while (match = re.exec(content)) { foundLinks.push({ - type: 'image-link', + name: 'image-link', value: match[1] }); } @@ -244,7 +244,7 @@ function findRelationMapLinks(content, foundLinks) { for (const note of obj.notes) { foundLinks.push({ - type: 'relation-map-link', + name: 'relation-map-link', value: note.noteId }) }