mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 02:05:53 +01:00
small refactorings and fixes
This commit is contained in:
@@ -147,7 +147,7 @@ export default class RevisionsDialog extends BasicWidget {
|
||||
for (const item of this.revisionItems) {
|
||||
this.$list.append(
|
||||
$('<a class="dropdown-item" tabindex="0">')
|
||||
.text(`${item.dateLastEdited.substr(0, 16)} (${item.contentLength} bytes)`)
|
||||
.text(`${item.dateLastEdited.substr(0, 16)} (${utils.formatSize(item.contentLength)})`)
|
||||
.attr('data-revision-id', item.revisionId)
|
||||
.attr('title', `This revision was last edited on ${item.dateLastEdited}`)
|
||||
);
|
||||
@@ -259,7 +259,7 @@ export default class RevisionsDialog extends BasicWidget {
|
||||
))
|
||||
.append($("<tr>").append(
|
||||
$("<th>").text("File size:"),
|
||||
$("<td>").text(`${revisionItem.contentLength} bytes`)
|
||||
$("<td>").text(utils.formatSize(revisionItem.contentLength))
|
||||
));
|
||||
|
||||
if (fullRevision.content) {
|
||||
|
||||
@@ -42,7 +42,7 @@ export default class FindInCode {
|
||||
// Find and highlight matches
|
||||
// Find and highlight matches
|
||||
// XXX Using \\b and not using the unicode flag probably doesn't
|
||||
// work with non ascii alphabets, findAndReplace uses a more
|
||||
// work with non-ASCII alphabets, findAndReplace uses a more
|
||||
// complicated regexp, see
|
||||
// https://github.com/ckeditor/ckeditor5/blob/b95e2faf817262ac0e1e21993d9c0bde3f1be594/packages/ckeditor5-find-and-replace/src/utils.js#L145
|
||||
const wholeWordChar = wholeWord ? "\\b" : "";
|
||||
@@ -166,8 +166,6 @@ export default class FindInCode {
|
||||
}
|
||||
});
|
||||
}
|
||||
// Restore the highlightSelectionMatches setting
|
||||
codeEditor.setOption("highlightSelectionMatches", this.oldHighlightSelectionMatches);
|
||||
this.findResult = null;
|
||||
|
||||
codeEditor.focus();
|
||||
|
||||
@@ -125,18 +125,15 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
async refreshWithNote(note) {
|
||||
const attributes = note.getAttributes();
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
this.$widget.show();
|
||||
|
||||
this.$fileNoteId.text(note.noteId);
|
||||
this.$fileName.text(attributeMap.originalFileName || "?");
|
||||
this.$fileName.text(note.getLabelValue('originalFileName') || "?");
|
||||
this.$fileType.text(note.mime);
|
||||
|
||||
const blob = await this.note.getBlob();
|
||||
|
||||
this.$fileSize.text(utils.formatNoteSize(blob.contentLength));
|
||||
this.$fileSize.text(utils.formatSize(blob.contentLength));
|
||||
|
||||
// open doesn't work for protected notes since it works through a browser which isn't in protected session
|
||||
this.$openButton.toggle(!note.isProtected);
|
||||
|
||||
@@ -111,15 +111,12 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
async refreshWithNote(note) {
|
||||
const attributes = note.getAttributes();
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
this.$widget.show();
|
||||
|
||||
const blob = await this.note.getBlob();
|
||||
|
||||
this.$fileName.text(attributeMap.originalFileName || "?");
|
||||
this.$fileSize.text(`${blob.contentLength} bytes`);
|
||||
this.$fileName.text(note.getLabelValue('originalFileName') || "?");
|
||||
this.$fileSize.text(utils.formatSize(blob.contentLength));
|
||||
this.$fileType.text(note.mime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
|
||||
this.$subTreeSize.empty().append($('<span class="bx bx-loader bx-spin"></span>'));
|
||||
|
||||
const noteSizeResp = await server.get(`stats/note-size/${this.noteId}`);
|
||||
this.$noteSize.text(utils.formatNoteSize(noteSizeResp.noteSize));
|
||||
this.$noteSize.text(utils.formatSize(noteSizeResp.noteSize));
|
||||
|
||||
const subTreeResp = await server.get(`stats/subtree-size/${this.noteId}`);
|
||||
|
||||
if (subTreeResp.subTreeNoteCount > 1) {
|
||||
this.$subTreeSize.text(`(subtree size: ${utils.formatNoteSize(subTreeResp.subTreeSize)} in ${subTreeResp.subTreeNoteCount} notes)`);
|
||||
this.$subTreeSize.text(`(subtree size: ${utils.formatSize(subTreeResp.subTreeSize)} in ${subTreeResp.subTreeNoteCount} notes)`);
|
||||
}
|
||||
else {
|
||||
this.$subTreeSize.text("");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import NoteContextAwareWidget from "../note_context_aware_widget.js";
|
||||
import AttributeDetailWidget from "../attribute_widgets/attribute_detail.js";
|
||||
import AttributeEditorWidget from "../attribute_widgets/attribute_editor.js";
|
||||
import attributeService from "../../services/attributes.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="attribute-list">
|
||||
|
||||
@@ -84,15 +84,11 @@ export default class TocWidget extends RightPanelWidget {
|
||||
}
|
||||
|
||||
async refreshWithNote(note) {
|
||||
/*The reason for adding tocPreviousVisible is to record whether the previous state of the toc is hidden or displayed,
|
||||
* and then let it be displayed/hidden at the initial time. If there is no such value,
|
||||
* when the right panel needs to display highlighttext but not toc, every time the note content is changed,
|
||||
/*The reason for adding tocPreviousVisible is to record whether the previous state of the toc is hidden or displayed,
|
||||
* and then let it be displayed/hidden at the initial time. If there is no such value,
|
||||
* when the right panel needs to display highlighttext but not toc, every time the note content is changed,
|
||||
* toc will appear and then close immediately, because getToc(html) function will consume time*/
|
||||
if (this.noteContext.viewScope.tocPreviousVisible ==true){
|
||||
this.toggleInt(true);
|
||||
}else{
|
||||
this.toggleInt(false);
|
||||
}
|
||||
this.toggleInt(!!this.noteContext.viewScope.tocPreviousVisible);
|
||||
|
||||
const tocLabel = note.getLabel('toc');
|
||||
|
||||
@@ -112,10 +108,10 @@ export default class TocWidget extends RightPanelWidget {
|
||||
this.$toc.html($toc);
|
||||
if (["", "show"].includes(tocLabel?.value) || headingCount >= options.getInt('minTocHeadings')){
|
||||
this.toggleInt(true);
|
||||
this.noteContext.viewScope.tocPreviousVisible=true;
|
||||
this.noteContext.viewScope.tocPreviousVisible=true;
|
||||
}else{
|
||||
this.toggleInt(false);
|
||||
this.noteContext.viewScope.tocPreviousVisible=false;
|
||||
this.noteContext.viewScope.tocPreviousVisible=false;
|
||||
}
|
||||
|
||||
this.triggerCommand("reEvaluateRightPaneVisibility");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import AbstractTextTypeWidget from "./abstract_text_type_widget.js";
|
||||
import treeService from "../../services/tree.js";
|
||||
import libraryLoader from "../../services/library_loader.js";
|
||||
|
||||
const TPL = `
|
||||
|
||||
Reference in New Issue
Block a user