mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
support for cssClass label on note
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const Entity = require('./entity');
|
||||
const Attribute = require('./attribute');
|
||||
const protectedSessionService = require('../services/protected_session');
|
||||
const repository = require('../services/repository');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
@@ -131,6 +132,37 @@ class Note extends Entity {
|
||||
return attributes.find(attr => attr.type === 'label' && attr.name === name);
|
||||
}
|
||||
|
||||
async getLabelValue(name) {
|
||||
const label = await this.getLabel(name);
|
||||
|
||||
return label ? label.value : null;
|
||||
}
|
||||
|
||||
async setLabel(name, value = "") {
|
||||
let label = await this.getLabel(name);
|
||||
|
||||
if (!label) {
|
||||
label = new Attribute({
|
||||
noteId: this.noteId,
|
||||
type: 'label',
|
||||
name: name
|
||||
});
|
||||
}
|
||||
|
||||
label.value = value;
|
||||
|
||||
await label.save();
|
||||
}
|
||||
|
||||
async removeLabel(name) {
|
||||
const label = await this.getLabel(name);
|
||||
|
||||
if (label) {
|
||||
label.isDeleted = true;
|
||||
await label.save();
|
||||
}
|
||||
}
|
||||
|
||||
async getRevisions() {
|
||||
return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user