mirror of
https://github.com/zadam/trilium.git
synced 2024-12-29 11:24:45 +08:00
excludeFromTreeMap generalized to excludeFromNoteMap
This commit is contained in:
parent
75fc9e2048
commit
a1ca538106
4 changed files with 13 additions and 5 deletions
|
@ -8,7 +8,7 @@ module.exports = () => {
|
|||
|
||||
for (const note of Object.values(becca.notes)) {
|
||||
if (note.hasLabel('calendarRoot')) {
|
||||
note.addLabel('excludeFromTreeMap', "", true);
|
||||
note.addLabel('excludeFromNoteMap', "", true);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -119,11 +119,15 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||
|
||||
let mapRootNoteId = this.getMapRootNoteId();
|
||||
const data = await this.loadNotesAndRelations(mapRootNoteId);
|
||||
|
||||
const nodeLinkRatio = data.nodes.length / data.links.length;
|
||||
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
|
||||
const charge = -20 / magnifiedRatio;
|
||||
const boundedCharge = Math.min(-3, charge);
|
||||
|
||||
this.graph.d3Force('link').distance(40);
|
||||
this.graph.d3Force('center').strength(0.2);
|
||||
this.graph.d3Force('charge').strength(-20 / Math.pow(nodeLinkRatio, 1.5));
|
||||
this.graph.d3Force('charge').strength(boundedCharge);
|
||||
this.graph.d3Force('charge').distanceMax(1000);
|
||||
|
||||
this.renderData(data);
|
||||
|
|
|
@ -26,10 +26,14 @@ function buildDescendantCountMap() {
|
|||
|
||||
function getLinkMap(req) {
|
||||
const mapRootNote = becca.getNote(req.params.noteId);
|
||||
// if the map root itself has ignore (journal typically) then there wouldn't be anything to display so
|
||||
// we'll just ignore it
|
||||
const ignoreExcludeFromNoteMap = mapRootNote.hasLabel('excludeFromNoteMap');
|
||||
|
||||
const noteIds = new Set();
|
||||
|
||||
const notes = mapRootNote.getSubtreeNotes(false)
|
||||
.filter(note => ignoreExcludeFromNoteMap || !note.hasLabel('excludeFromNoteMap'))
|
||||
.map(note => [
|
||||
note.noteId,
|
||||
note.isContentAvailable() ? note.title : '[protected]',
|
||||
|
@ -72,11 +76,11 @@ function getTreeMap(req) {
|
|||
const mapRootNote = becca.getNote(req.params.noteId);
|
||||
// if the map root itself has ignore (journal typically) then there wouldn't be anything to display so
|
||||
// we'll just ignore it
|
||||
const ignoreExcludeFromTreeMap = mapRootNote.hasLabel('excludeFromTreeMap');
|
||||
const ignoreExcludeFromNoteMap = mapRootNote.hasLabel('excludeFromNoteMap');
|
||||
const noteIds = new Set();
|
||||
|
||||
const notes = mapRootNote.getSubtreeNotes(false)
|
||||
.filter(note => ignoreExcludeFromTreeMap || !note.hasLabel('excludeFromTreeMap'))
|
||||
.filter(note => ignoreExcludeFromNoteMap || !note.hasLabel('excludeFromNoteMap'))
|
||||
.filter(note => {
|
||||
if (note.type !== 'image' || note.getChildNotes().length > 0) {
|
||||
return true;
|
||||
|
|
|
@ -47,7 +47,7 @@ const BUILTIN_ATTRIBUTES = [
|
|||
{ type: 'label', name: 'pageSize' },
|
||||
{ type: 'label', name: 'viewType' },
|
||||
{ type: 'label', name: 'mapRootNoteId' },
|
||||
{ type: 'label', name: 'excludeFromTreeMap' },
|
||||
{ type: 'label', name: 'excludeFromNoteMap' },
|
||||
|
||||
// relation names
|
||||
{ type: 'relation', name: 'runOnNoteCreation', isDangerous: true },
|
||||
|
|
Loading…
Reference in a new issue