mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 23:35:50 +01:00
fixes, allowing conversion of note into an attachment
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import server from '../services/server.js';
|
||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||
import ws from "../services/ws.js";
|
||||
import options from "../services/options.js";
|
||||
import froca from "../services/froca.js";
|
||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||
import cssClassManager from "../services/css_class_manager.js";
|
||||
@@ -246,6 +245,27 @@ class FNote {
|
||||
return attachments.find(att => att.attachmentId === attachmentId);
|
||||
}
|
||||
|
||||
isEligibleForConversionToAttachment() {
|
||||
if (this.type !== 'image' || !this.isContentAvailable() || this.hasChildren() || this.getParentBranches().length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const targetRelations = this.getTargetRelations().filter(relation => relation.name === 'imageLink');
|
||||
|
||||
if (targetRelations.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parentNote = this.getParentNotes()[0]; // at this point note can have only one parent
|
||||
const referencingNote = targetRelations[0].getNote();
|
||||
|
||||
if (parentNote !== referencingNote || parentNote.type !== 'text' || !parentNote.isContentAvailable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [type] - (optional) attribute type to filter
|
||||
* @param {string} [name] - (optional) attribute name to filter
|
||||
|
||||
Reference in New Issue
Block a user