mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
fixes, separation of notefull from noteshort
This commit is contained in:
@@ -23,9 +23,9 @@ class AttributesWidget extends StandardWidget {
|
||||
return [$showFullButton];
|
||||
}
|
||||
|
||||
async refreshWithNote() {
|
||||
const attributes = await this.tabContext.attributes.getAttributes();
|
||||
const ownedAttributes = attributes.filter(attr => attr.noteId === this.tabContext.note.noteId);
|
||||
async refreshWithNote(note) {
|
||||
const attributes = await note.getAttributes();
|
||||
const ownedAttributes = note.getOwnedAttributes();
|
||||
|
||||
if (attributes.length === 0) {
|
||||
this.$body.text("No attributes yet...");
|
||||
|
||||
@@ -36,16 +36,19 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
||||
this.typeWidgetPromises = {};
|
||||
|
||||
this.spacedUpdate = new SpacedUpdate(async () => {
|
||||
const note = this.tabContext.note;
|
||||
note.content = this.getTypeWidget().getContent();
|
||||
const {noteFull} = this.tabContext;
|
||||
const {noteId} = this.tabContext.note;
|
||||
|
||||
const resp = await server.put('notes/' + note.noteId, note.dto);
|
||||
const dto = note.dto;
|
||||
dto.content = noteFull.content = this.getTypeWidget().getContent();
|
||||
|
||||
const resp = await server.put('notes/' + noteId, dto);
|
||||
|
||||
// FIXME: minor - does not propagate to other tab contexts with this note though
|
||||
note.dateModified = resp.dateModified;
|
||||
note.utcDateModified = resp.utcDateModified;
|
||||
noteFull.dateModified = resp.dateModified;
|
||||
noteFull.utcDateModified = resp.utcDateModified;
|
||||
|
||||
this.trigger('noteChangesSaved', {noteId: note.noteId})
|
||||
this.trigger('noteChangesSaved', {noteId})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,7 +159,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
||||
let type = note.type;
|
||||
|
||||
if (type === 'text' && !disableAutoBook
|
||||
&& utils.isHtmlEmpty(note.content)
|
||||
&& utils.isHtmlEmpty(this.tabContext.noteFull.content)
|
||||
&& note.hasChildren()) {
|
||||
|
||||
type = 'book';
|
||||
|
||||
@@ -49,14 +49,16 @@ class NoteInfoWidget extends StandardWidget {
|
||||
const $type = this.$body.find(".note-info-type");
|
||||
const $mime = this.$body.find(".note-info-mime");
|
||||
|
||||
const {noteFull} = this.tabContext;
|
||||
|
||||
$noteId.text(note.noteId);
|
||||
$dateCreated
|
||||
.text(note.dateCreated)
|
||||
.attr("title", note.dateCreated);
|
||||
.text(noteFull.dateCreated)
|
||||
.attr("title", noteFull.dateCreated);
|
||||
|
||||
$dateModified
|
||||
.text(note.dateModified)
|
||||
.attr("title", note.dateCreated);
|
||||
.text(noteFull.dateModified)
|
||||
.attr("title", noteFull.dateCreated);
|
||||
|
||||
$type.text(note.type);
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
async refreshWithNote() {
|
||||
async refreshWithNote(note) {
|
||||
this.$container.empty();
|
||||
|
||||
const attributes = await this.tabContext.attributes.getAttributes();
|
||||
const attributes = await note.getAttributes();
|
||||
|
||||
const promoted = attributes.filter(attr =>
|
||||
(attr.type === 'label-definition' || attr.type === 'relation-definition')
|
||||
|
||||
@@ -75,7 +75,7 @@ export default class CodeTypeWidget extends TypeWidget {
|
||||
this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
|
||||
// we provide fallback
|
||||
this.codeEditor.setValue(note.content || "");
|
||||
this.codeEditor.setValue(this.tabContext.noteFull.content || "");
|
||||
|
||||
const info = CodeMirror.findModeByMIME(note.mime);
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ export default class FileTypeWidget extends TypeWidget {
|
||||
}
|
||||
|
||||
async doRefresh(note) {
|
||||
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
||||
const attributes = await note.getAttributes();
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
this.$widget.show();
|
||||
@@ -128,9 +128,9 @@ export default class FileTypeWidget extends TypeWidget {
|
||||
this.$fileSize.text(note.contentLength + " bytes");
|
||||
this.$fileType.text(note.mime);
|
||||
|
||||
if (note.content) {
|
||||
if (this.tabContext.noteFull.content) {
|
||||
this.$previewContent.show();
|
||||
this.$previewContent.text(note.content);
|
||||
this.$previewContent.text(this.tabContext.noteFull.content);
|
||||
}
|
||||
else {
|
||||
this.$previewContent.empty().hide();
|
||||
|
||||
@@ -123,7 +123,7 @@ class NoteDetailImage extends TypeWidget {
|
||||
}
|
||||
|
||||
async doRefresh(note) {
|
||||
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
||||
const attributes = await note.getAttributes();
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
this.$widget.show();
|
||||
@@ -132,7 +132,7 @@ class NoteDetailImage extends TypeWidget {
|
||||
this.$fileSize.text(note.contentLength + " bytes");
|
||||
this.$fileType.text(note.mime);
|
||||
|
||||
const imageHash = note.utcDateModified.replace(" ", "_");
|
||||
const imageHash = this.tabContext.noteFull.utcDateModified.replace(" ", "_");
|
||||
|
||||
this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}?${imageHash}`);
|
||||
}
|
||||
|
||||
@@ -254,9 +254,9 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
||||
}
|
||||
};
|
||||
|
||||
if (this.tabContext.note.content) {
|
||||
if (this.tabContext.noteFull.content) {
|
||||
try {
|
||||
this.mapData = JSON.parse(this.tabContext.note.content);
|
||||
this.mapData = JSON.parse(this.tabContext.noteFull.content);
|
||||
} catch (e) {
|
||||
console.log("Could not parse content: ", e);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export default class SearchTypeWidget extends TypeWidget {
|
||||
this.$component.show();
|
||||
|
||||
try {
|
||||
const json = JSON.parse(note.content);
|
||||
const json = JSON.parse(this.tabContext.noteFull.content);
|
||||
|
||||
this.$searchString.val(json.searchString);
|
||||
}
|
||||
|
||||
@@ -137,10 +137,10 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
}
|
||||
|
||||
async doRefresh(note) {
|
||||
this.textEditor.isReadOnly = await this.isReadOnly();
|
||||
this.textEditor.isReadOnly = await note.hasLabel('readOnly');
|
||||
|
||||
this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||
this.textEditor.setData(note.content);
|
||||
this.textEditor.setData(this.tabContext.noteFull.content);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -160,12 +160,6 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
&& !content.includes("<section")
|
||||
}
|
||||
|
||||
async isReadOnly() {
|
||||
const attributes = await this.tabContext.attributes.getAttributes();
|
||||
|
||||
return attributes.some(attr => attr.type === 'label' && attr.name === 'readOnly');
|
||||
}
|
||||
|
||||
focus() {
|
||||
this.$editor.trigger('focus');
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export default class TypeWidget extends TabAwareWidget {
|
||||
static getType() {}
|
||||
|
||||
/**
|
||||
* @param {NoteFull} note
|
||||
* @param {NoteShort} note
|
||||
*/
|
||||
doRefresh(note) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user