mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
Compare commits
7 Commits
v0.46.3-be
...
v0.46.4-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12b468d3dc | ||
|
|
6f901e6852 | ||
|
|
09e9ac4d00 | ||
|
|
a33ac65fdf | ||
|
|
f8fb071a6f | ||
|
|
a654078e56 | ||
|
|
fba68681aa |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.46.2-beta",
|
||||
"version": "0.46.3-beta",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "trilium",
|
||||
"productName": "Trilium Notes",
|
||||
"description": "Trilium Notes",
|
||||
"version": "0.46.3-beta",
|
||||
"version": "0.46.4-beta",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "electron.js",
|
||||
"bin": {
|
||||
|
||||
@@ -28,6 +28,16 @@ const TPL = `
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-4">
|
||||
<label for="heading-style">Heading style</label>
|
||||
<select class="form-control" id="heading-style">
|
||||
<option value="plain">Plain</option>
|
||||
<option value="markdown">Markdown-style</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Zooming can be controlled with CTRL+- and CTRL+= shortcuts as well.</p>
|
||||
|
||||
@@ -78,6 +88,7 @@ export default class ApperanceOptions {
|
||||
this.$themeSelect = $("#theme-select");
|
||||
this.$zoomFactorSelect = $("#zoom-factor-select");
|
||||
this.$nativeTitleBarSelect = $("#native-title-bar-select");
|
||||
this.$headingStyle = $("#heading-style");
|
||||
this.$mainFontSize = $("#main-font-size");
|
||||
this.$treeFontSize = $("#tree-font-size");
|
||||
this.$detailFontSize = $("#detail-font-size");
|
||||
@@ -86,11 +97,7 @@ export default class ApperanceOptions {
|
||||
this.$themeSelect.on('change', () => {
|
||||
const newTheme = this.$themeSelect.val();
|
||||
|
||||
for (const clazz of Array.from(this.$body[0].classList)) { // create copy to safely iterate over while removing classes
|
||||
if (clazz.startsWith("theme-")) {
|
||||
this.$body.removeClass(clazz);
|
||||
}
|
||||
}
|
||||
this.toggleBodyClass("theme-", newTheme);
|
||||
|
||||
const noteId = $(this).find(":selected").attr("data-note-id");
|
||||
|
||||
@@ -100,8 +107,6 @@ export default class ApperanceOptions {
|
||||
libraryLoader.requireCss(`api/notes/download/${noteId}`);
|
||||
}
|
||||
|
||||
this.$body.addClass("theme-" + newTheme);
|
||||
|
||||
server.put('options/theme/' + newTheme);
|
||||
});
|
||||
|
||||
@@ -113,6 +118,14 @@ export default class ApperanceOptions {
|
||||
server.put('options/nativeTitleBarVisible/' + nativeTitleBarVisible);
|
||||
});
|
||||
|
||||
this.$headingStyle.on('change', () => {
|
||||
const newHeadingStyle = this.$headingStyle.val();
|
||||
|
||||
this.toggleBodyClass("heading-style-", newHeadingStyle);
|
||||
|
||||
server.put('options/headingStyle/' + newHeadingStyle);
|
||||
});
|
||||
|
||||
this.$mainFontSize.on('change', async () => {
|
||||
await server.put('options/mainFontSize/' + this.$mainFontSize.val());
|
||||
|
||||
@@ -132,6 +145,16 @@ export default class ApperanceOptions {
|
||||
});
|
||||
}
|
||||
|
||||
toggleBodyClass(prefix, value) {
|
||||
for (const clazz of Array.from(this.$body[0].classList)) { // create copy to safely iterate over while removing classes
|
||||
if (clazz.startsWith(prefix)) {
|
||||
this.$body.removeClass(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
this.$body.addClass(prefix + value);
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
const themes = [
|
||||
{ val: 'white', title: 'White' },
|
||||
@@ -159,6 +182,8 @@ export default class ApperanceOptions {
|
||||
|
||||
this.$nativeTitleBarSelect.val(options.nativeTitleBarVisible === 'true' ? 'show' : 'hide');
|
||||
|
||||
this.$headingStyle.val(options.headingStyle);
|
||||
|
||||
this.$mainFontSize.val(options.mainFontSize);
|
||||
this.$treeFontSize.val(options.treeFontSize);
|
||||
this.$detailFontSize.val(options.detailFontSize);
|
||||
|
||||
@@ -254,22 +254,39 @@ class NoteShort {
|
||||
return noteAttributeCache.attributes[this.noteId];
|
||||
}
|
||||
|
||||
getAllNotePaths() {
|
||||
getAllNotePaths(encounteredNoteIds = null) {
|
||||
if (this.noteId === 'root') {
|
||||
return [['root']];
|
||||
}
|
||||
|
||||
if (!encounteredNoteIds) {
|
||||
encounteredNoteIds = new Set();
|
||||
}
|
||||
|
||||
encounteredNoteIds.add(this.noteId);
|
||||
|
||||
const parentNotes = this.getParentNotes();
|
||||
let paths;
|
||||
|
||||
if (parentNotes.length === 1) { // optimization for the most common case
|
||||
paths = parentNotes[0].getAllNotePaths();
|
||||
if (encounteredNoteIds.has(parentNotes[0].noteId)) {
|
||||
return [];
|
||||
}
|
||||
else {
|
||||
paths = parentNotes[0].getAllNotePaths(encounteredNoteIds);
|
||||
}
|
||||
}
|
||||
else {
|
||||
paths = [];
|
||||
|
||||
for (const parentNote of parentNotes) {
|
||||
paths.push(...parentNote.getAllNotePaths());
|
||||
if (encounteredNoteIds.has(parentNote.noteId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const newSet = new Set(encounteredNoteIds);
|
||||
|
||||
paths.push(...parentNote.getAllNotePaths(newSet));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ function isHoistedNode(node) {
|
||||
}
|
||||
|
||||
async function checkNoteAccess(notePath, tabContext) {
|
||||
// notePath argument can contain only noteId which is not good when hoisted since
|
||||
// then we need to check the whole note path
|
||||
const resolvedNotePath = await treeService.resolveNotePath(notePath);
|
||||
const resolvedNotePath = await treeService.resolveNotePath(notePath, tabContext.hoistedNoteId);
|
||||
|
||||
if (!resolvedNotePath) {
|
||||
console.log("Cannot activate " + notePath);
|
||||
@@ -37,7 +35,7 @@ async function checkNoteAccess(notePath, tabContext) {
|
||||
|
||||
const hoistedNoteId = tabContext.hoistedNoteId;
|
||||
|
||||
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
|
||||
if (!resolvedNotePath.includes(hoistedNoteId)) {
|
||||
const confirmDialog = await import('../dialogs/confirm.js');
|
||||
|
||||
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
|
||||
|
||||
@@ -37,7 +37,7 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
||||
path.push('root');
|
||||
}
|
||||
|
||||
const effectivePath = [];
|
||||
const effectivePathSegments = [];
|
||||
let childNoteId = null;
|
||||
let i = 0;
|
||||
|
||||
@@ -81,7 +81,7 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
||||
const pathToRoot = someNotePath.split("/").reverse().slice(1);
|
||||
|
||||
for (const noteId of pathToRoot) {
|
||||
effectivePath.push(noteId);
|
||||
effectivePathSegments.push(noteId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,11 +89,23 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
||||
}
|
||||
}
|
||||
|
||||
effectivePath.push(parentNoteId);
|
||||
effectivePathSegments.push(parentNoteId);
|
||||
childNoteId = parentNoteId;
|
||||
}
|
||||
|
||||
return effectivePath.reverse();
|
||||
effectivePathSegments.reverse();
|
||||
|
||||
if (effectivePathSegments.includes(hoistedNoteId)) {
|
||||
return effectivePathSegments;
|
||||
}
|
||||
else {
|
||||
const note = await treeCache.getNote(getNoteIdFromNotePath(notePath));
|
||||
|
||||
const someNotePathSegments = getSomeNotePathSegments(note, hoistedNoteId);
|
||||
|
||||
// if there isn't actually any note path with hoisted note then return the original resolved note path
|
||||
return someNotePathSegments.includes(hoistedNoteId) ? someNotePathSegments : effectivePathSegments;
|
||||
}
|
||||
}
|
||||
|
||||
function getSomeNotePathSegments(note, hoistedNotePath = 'root') {
|
||||
|
||||
@@ -88,7 +88,7 @@ export default class NotePathsWidget extends TabAwareWidget {
|
||||
.find('a')
|
||||
.addClass("no-tooltip-preview");
|
||||
|
||||
const comments = [];
|
||||
const icons = [];
|
||||
|
||||
if (this.notePath === notePath) {
|
||||
$noteLink.addClass("path-current");
|
||||
@@ -98,23 +98,23 @@ export default class NotePathsWidget extends TabAwareWidget {
|
||||
$noteLink.addClass("path-in-hoisted-subtree");
|
||||
}
|
||||
else {
|
||||
comments.push("outside of hoisting");
|
||||
icons.push(`<span class="bx bx-trending-up" title="This path is outside of hoisted note and you would have to unhoist."></span>`);
|
||||
}
|
||||
|
||||
if (notePathRecord.isArchived) {
|
||||
$noteLink.addClass("path-archived");
|
||||
|
||||
comments.push("archived");
|
||||
icons.push(`<span class="bx bx-archive" title="Archived"></span>`);
|
||||
}
|
||||
|
||||
if (notePathRecord.isSearch) {
|
||||
$noteLink.addClass("path-search");
|
||||
|
||||
comments.push("search");
|
||||
icons.push(`<span class="bx bx-search" title="Search"></span>`);
|
||||
}
|
||||
|
||||
if (comments.length > 0) {
|
||||
$noteLink.append(` (${comments.join(', ')})`);
|
||||
if (icons.length > 0) {
|
||||
$noteLink.append(` ${icons.join(' ')}`);
|
||||
}
|
||||
|
||||
this.$notePathList.append($noteLink);
|
||||
|
||||
@@ -994,8 +994,6 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
const nextNode = activeNode ? (activeNode.getNextSibling() || activeNode.getPrevSibling() || activeNode.getParent()) : null;
|
||||
const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;
|
||||
|
||||
console.log(activeNotePath, activeNodeFocused);
|
||||
|
||||
const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null;
|
||||
const activeNoteId = activeNode ? activeNode.data.noteId : null;
|
||||
|
||||
@@ -1117,6 +1115,10 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
|
||||
if (node) {
|
||||
node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
||||
|
||||
if (activeNodeFocused) {
|
||||
node.setFocus(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// this is used when original note has been deleted and we want to move the focus to the note above/below
|
||||
|
||||
@@ -49,15 +49,16 @@ const TPL = `
|
||||
}
|
||||
|
||||
.note-detail-editable-text h2 { font-size: 1.8em; }
|
||||
.note-detail-editable-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-editable-text h3 { font-size: 1.6em; }
|
||||
.note-detail-editable-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-editable-text h4 { font-size: 1.4em; }
|
||||
.note-detail-editable-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-editable-text h5 { font-size: 1.2em; }
|
||||
.note-detail-editable-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-editable-text h6 { font-size: 1.1em; }
|
||||
.note-detail-editable-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||||
|
||||
body.heading-style-markdown .note-detail-editable-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-editable-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-editable-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-editable-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-editable-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||||
|
||||
.note-detail-editable-text-editor {
|
||||
padding-top: 10px;
|
||||
|
||||
@@ -14,16 +14,11 @@ const TPL = `
|
||||
.note-detail-readonly-text h5 { font-size: 1.2em; }
|
||||
.note-detail-readonly-text h6 { font-size: 1.1em; }
|
||||
|
||||
.note-detail-readonly-text h2 { font-size: 1.8em; }
|
||||
.note-detail-readonly-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-readonly-text h3 { font-size: 1.6em; }
|
||||
.note-detail-readonly-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-readonly-text h4 { font-size: 1.4em; }
|
||||
.note-detail-readonly-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-readonly-text h5 { font-size: 1.2em; }
|
||||
.note-detail-readonly-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
|
||||
.note-detail-readonly-text h6 { font-size: 1.1em; }
|
||||
.note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-readonly-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-readonly-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-readonly-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-readonly-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
|
||||
body.heading-style-markdown .note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||||
|
||||
.note-detail-readonly-text {
|
||||
padding-left: 22px;
|
||||
|
||||
@@ -40,7 +40,8 @@ const ALLOWED_OPTIONS = new Set([
|
||||
'nativeTitleBarVisible',
|
||||
'attributeListExpanded',
|
||||
'promotedAttributesExpanded',
|
||||
'similarNotesExpanded'
|
||||
'similarNotesExpanded',
|
||||
'headingStyle'
|
||||
]);
|
||||
|
||||
function getOptions() {
|
||||
|
||||
@@ -19,6 +19,7 @@ function index(req, res) {
|
||||
res.render(view, {
|
||||
csrfToken: csrfToken,
|
||||
theme: options.theme,
|
||||
headingStyle: options.headingStyle,
|
||||
mainFontSize: parseInt(options.mainFontSize),
|
||||
treeFontSize: parseInt(options.treeFontSize),
|
||||
detailFontSize: parseInt(options.detailFontSize),
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = { buildDate:"2021-03-08T23:11:11+01:00", buildRevision: "f27370d44f08afaa22d4cd86cba489584f9c878b" };
|
||||
module.exports = { buildDate:"2021-03-10T23:35:12+01:00", buildRevision: "6f901e6852c33ba0dae6c70efb9f65e5b0028995" };
|
||||
|
||||
@@ -61,7 +61,7 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
|
||||
|
||||
const content = note.getContent();
|
||||
|
||||
if (!["text", "code"].includes(note.type)
|
||||
if (["text", "code"].includes(note.type)
|
||||
// if the note has already content we're not going to overwrite it with template's one
|
||||
&& (!content || content.trim().length === 0)
|
||||
&& templateNote.isStringNote()) {
|
||||
|
||||
@@ -84,7 +84,8 @@ const defaultOptions = [
|
||||
{ name: 'attributeListExpanded', value: 'false', isSynced: false },
|
||||
{ name: 'promotedAttributesExpanded', value: 'true', isSynced: true },
|
||||
{ name: 'similarNotesExpanded', value: 'true', isSynced: true },
|
||||
{ name: 'debugModeEnabled', value: 'false', isSynced: false }
|
||||
{ name: 'debugModeEnabled', value: 'false', isSynced: false },
|
||||
{ name: 'headingStyle', value: 'markdown', isSynced: true },
|
||||
];
|
||||
|
||||
function initStartupOptions() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<title>Trilium Notes</title>
|
||||
</head>
|
||||
<body class="desktop theme-<%= theme %>" style="--main-font-size: <%= mainFontSize %>%; --tree-font-size: <%= treeFontSize %>%; --detail-font-size: <%= detailFontSize %>%;">
|
||||
<body class="desktop theme-<%= theme %> heading-style-<%= headingStyle %>" style="--main-font-size: <%= mainFontSize %>%; --tree-font-size: <%= treeFontSize %>%; --detail-font-size: <%= detailFontSize %>%;">
|
||||
<noscript>Trilium requires JavaScript to be enabled.</noscript>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="mobile theme-<%= theme %>">
|
||||
<body class="mobile theme-<%= theme %> heading-style-<%= headingStyle %>">
|
||||
<noscript>Trilium requires JavaScript to be enabled.</noscript>
|
||||
|
||||
<div id="toast-container" class="d-flex flex-column justify-content-center align-items-center"></div>
|
||||
|
||||
Reference in New Issue
Block a user