mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 16:25:51 +01:00
global link map WIP
This commit is contained in:
@@ -233,6 +233,8 @@ class Note extends AbstractEntity {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("POJO update", pojo);
|
||||
|
||||
sql.upsert("note_contents", "noteId", pojo);
|
||||
|
||||
const hash = utils.hash(this.noteId + "|" + pojo.content.toString());
|
||||
|
||||
@@ -63,6 +63,11 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
const dto = note.dto;
|
||||
dto.content = this.getTypeWidget().getContent();
|
||||
|
||||
// for read only notes
|
||||
if (dto.content === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
protectedSessionHolder.touchProtectedSessionIfNecessary(note);
|
||||
|
||||
await server.put('notes/' + noteId, dto, this.componentId);
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
import TypeWidget from "./type_widget.js";
|
||||
import libraryLoader from "../../services/library_loader.js";
|
||||
import server from "../../services/server.js";
|
||||
import attributeService from "../../services/attributes.js";
|
||||
|
||||
const TPL = `<div class="note-detail-global-link-map note-detail-printable">
|
||||
const TPL = `<div class="note-detail-global-link-map note-detail-printable" style="position: relative;">
|
||||
<style>
|
||||
.type-special .note-detail, .note-detail-global-link-map {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.map-switcher {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background-color: var(--accented-background-color);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.map-switcher .bx {
|
||||
font-size: x-large;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="btn-group btn-group-sm map-switcher" role="group">
|
||||
<button type="button" class="btn btn-secondary" title="Link Map" data-type="link"><span class="bx bx-network-chart"></span></button>
|
||||
<button type="button" class="btn btn-secondary" title="Tree map" data-type="tree"><span class="bx bx-sitemap"></span></button>
|
||||
</div>
|
||||
|
||||
<div class="link-map-container"></div>
|
||||
</div>`;
|
||||
@@ -22,6 +40,12 @@ export default class GlobalLinkMapTypeWidget extends TypeWidget {
|
||||
|
||||
window.addEventListener('resize', () => this.setFullHeight(), false);
|
||||
|
||||
this.$widget.find(".map-switcher button").on("click", async e => {
|
||||
const type = $(e.target).closest("button").attr("data-type");
|
||||
|
||||
await attributeService.setLabel(this.noteId, 'mapType', type);
|
||||
});
|
||||
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
@@ -47,6 +71,8 @@ export default class GlobalLinkMapTypeWidget extends TypeWidget {
|
||||
async doRefresh(note) {
|
||||
this.$widget.show();
|
||||
|
||||
this.mapType = this.note.getLabelValue("mapType") === "tree" ? "tree" : "link";
|
||||
|
||||
this.setFullHeight();
|
||||
|
||||
await libraryLoader.requireLibrary(libraryLoader.FORCE_GRAPH);
|
||||
@@ -268,4 +294,8 @@ export default class GlobalLinkMapTypeWidget extends TypeWidget {
|
||||
setTimeout(() => this.graph.zoomToFit(400, zoomPadding), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
this.$container.html('');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,9 +328,10 @@ class ConsistencyChecks {
|
||||
({noteId, type, mime}) => {
|
||||
if (this.autoFix) {
|
||||
const note = becca.getNote(noteId);
|
||||
note.setContent(getBlankContent(false, type, mime));
|
||||
const blankContent = getBlankContent(false, type, mime);
|
||||
note.setContent(blankContent);
|
||||
|
||||
logFix(`Note ${noteId} content was set to empty string since it was null even though it is not deleted`);
|
||||
logFix(`Note ${noteId} content was set to "${blankContent}" since it was null even though it is not deleted`);
|
||||
} else {
|
||||
logError(`Note ${noteId} content is null even though it is not deleted`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user