Compare commits

..

9 Commits

Author SHA1 Message Date
zadam
ad8d35efe9 release 0.49.1-beta 2021-12-24 23:05:10 +01:00
zadam
0217b1c85d share pdf view is responsive 2021-12-24 22:46:55 +01:00
zadam
c0aa14f586 Merge remote-tracking branch 'origin/master' 2021-12-24 22:43:25 +01:00
zadam
b54cfab4ff share root itself is not shared, fixes #2468 2021-12-24 22:43:12 +01:00
Matt
a08985e7a6 Display PDF in shared notes (#2466)
* Add PDF rendering

* Cleanup
2021-12-24 22:36:31 +01:00
zadam
a789025025 don't show share switch for root and share root notes, #2465 2021-12-24 22:34:15 +01:00
zadam
3f307b117e fix webpack build 2021-12-24 22:18:05 +01:00
zadam
a232035d47 fix backlink count 2021-12-24 21:01:36 +01:00
zadam
9d38e9342d moved API docs button to the bottom of a code note 2021-12-24 20:40:27 +01:00
18 changed files with 91 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.49.0-beta",
"version": "0.49.1-beta",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {

View File

@@ -103,17 +103,19 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
async refreshWithNote(note) {
this.clearItems();
const targetRelationCount = note.getTargetRelations().length;
if (targetRelationCount === 0) {
// can't use froca since that would count only relations from loaded notes
const resp = await server.get(`notes/${this.noteId}/backlink-count`);
if (!resp || !resp.count) {
this.$ticker.hide();
return;
}
else {
this.$ticker.show();
this.$count.text(
`${targetRelationCount} backlink`
+ (targetRelationCount === 1 ? '' : 's')
);
}
this.$ticker.show();
this.$count.text(
`${resp.count} backlink`
+ (resp.count === 1 ? '' : 's')
);
}
clearItems() {
@@ -136,18 +138,22 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
await froca.getNotes(backlinks.map(bl => bl.noteId)); // prefetch all
for (const backlink of backlinks) {
this.$items.append(await linkService.createNoteLink(backlink.noteId, {
const $item = $("<div>");
$item.append(await linkService.createNoteLink(backlink.noteId, {
showNoteIcon: true,
showNotePath: true,
showTooltip: false
}));
if (backlink.relationName) {
this.$items.append($("<p>").text("relation: " + backlink.relationName));
$item.append($("<p>").text("relation: " + backlink.relationName));
}
else {
this.$items.append(...backlink.excerpts);
$item.append(...backlink.excerpts);
}
this.$items.append($item);
}
}
}

View File

@@ -18,7 +18,7 @@ const TPL = `
export default class SharedInfoWidget extends NoteContextAwareWidget {
isEnabled() {
return super.isEnabled() && this.note.hasAncestor('share');
return super.isEnabled() && this.noteId !== 'share' && this.note.hasAncestor('share');
}
doRender() {

View File

@@ -4,6 +4,10 @@ import server from "../services/server.js";
import utils from "../services/utils.js";
export default class SharedSwitchWidget extends SwitchWidget {
isEnabled() {
return super.isEnabled() && this.noteId !== 'root' && this.noteId !== 'share';
}
doRender() {
super.doRender();

View File

@@ -14,21 +14,11 @@ const TPL = `
position: relative;
}
.trilium-api-docs-button {
/*display: none;*/
position: absolute;
top: 10px;
right: 10px;
}
.note-detail-code-editor {
min-height: 50px;
}
</style>
<button class="btn bx bx-help-circle trilium-api-docs-button icon-button floating-button"
title="Open Trilium API docs"></button>
<div class="note-detail-code-editor"></div>
<div style="display: flex; justify-content: space-evenly;">
@@ -37,6 +27,13 @@ const TPL = `
Execute <kbd data-command="runActiveNote"></kbd>
</button>
<button class="no-print trilium-api-docs-button btn btn-sm"
title="Open Trilium API docs">
<span class="bx bx-help-circle"></span>
API docs
</button>
<button class="no-print save-to-note-button btn btn-sm">
<span class="bx bx-save"></span>

View File

@@ -52,6 +52,11 @@ pre {
word-wrap: anywhere;
}
iframe.pdf-view {
width: 100%;
height: 800px;
}
#menuButton {
display: none;
position: fixed;

View File

@@ -302,6 +302,21 @@ function uploadModifiedFile(req) {
note.setContent(fileContent);
}
function getBacklinkCount(req) {
const {noteId} = req.params;
const note = becca.getNote(noteId);
if (!note) {
return [404, "Not found"];
}
else {
return {
count: note.getTargetRelations().length
};
}
}
module.exports = {
getNote,
updateNote,
@@ -316,5 +331,6 @@ module.exports = {
duplicateSubtree,
eraseDeletedNotesNow,
getDeleteNotesPreview,
uploadModifiedFile
uploadModifiedFile,
getBacklinkCount
};

View File

@@ -220,6 +220,7 @@ function register(app) {
apiRoute(DELETE, '/api/notes/:noteId/revisions/:noteRevisionId', noteRevisionsApiRoute.eraseNoteRevision);
route(GET, '/api/notes/:noteId/revisions/:noteRevisionId/download', [auth.checkApiAuthOrElectron], noteRevisionsApiRoute.downloadNoteRevision);
apiRoute(PUT, '/api/notes/:noteId/restore-revision/:noteRevisionId', noteRevisionsApiRoute.restoreNoteRevision);
apiRoute(GET, '/api/notes/:noteId/backlink-count', notesApiRoute.getBacklinkCount);
apiRoute(POST, '/api/notes/relation-map', notesApiRoute.getRelationMap);
apiRoute(POST, '/api/notes/erase-deleted-notes-now', notesApiRoute.eraseDeletedNotesNow);
apiRoute(PUT, '/api/notes/:noteId/change-title', notesApiRoute.changeTitle);

View File

@@ -1 +1 @@
module.exports = { buildDate:"2021-12-23T23:03:21+01:00", buildRevision: "f0217cae5eb4bdac12efe1d15bf26dc128e7f854" };
module.exports = { buildDate:"2021-12-24T23:05:10+01:00", buildRevision: "0217b1c85de9a2824e7f07d07a357064c5803383" };

View File

@@ -59,6 +59,7 @@ async function createMainWindow() {
height: mainWindowState.height,
title: 'Trilium Notes',
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false,
spellcheck: spellcheckEnabled

View File

@@ -76,7 +76,12 @@ function getContent(note) {
content = `<img src="api/images/${note.noteId}/${note.title}?${note.utcDateModified}">`;
}
else if (note.type === 'file') {
content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download'">Download file</button>`;
if (note.mime === 'application/pdf') {
content = `<iframe class="pdf-view" src="api/notes/${note.noteId}/view"></iframe>`
}
else {
content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download'">Download file</button>`;
}
}
else if (note.type === 'book') {
content = getChildrenList(note);

View File

@@ -78,6 +78,26 @@ function register(router) {
res.send(note.getContent());
});
router.get('/share/api/notes/:noteId/view', (req, res, next) => {
const {noteId} = req.params;
const note = shaca.getNote(noteId);
if (!note) {
return res.status(404).send(`Not found`);
}
const utils = require("../services/utils");
const filename = utils.formatDownloadTitle(note.title, note.type, note.mime);
// res.setHeader('Content-Disposition', utils.getContentDisposition(filename));
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.setHeader('Content-Type', note.mime);
res.send(note.getContent());
});
}
module.exports = {

View File

@@ -41,6 +41,8 @@
<%- include('dialogs/delete_notes.ejs') %>
<script type="text/javascript">
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
window.baseApiUrl = 'api/';
window.device = "desktop";
window.glob = {

View File

@@ -105,6 +105,8 @@
<%- include('dialogs/confirm.ejs') %>
<script type="text/javascript">
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
window.baseApiUrl = 'api/';
window.device = "mobile";
window.glob = {

View File

@@ -189,6 +189,8 @@
</div>
<script type="text/javascript">
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
window.glob = {
sourceId: ''
};

View File

@@ -11,5 +11,5 @@ module.exports = {
filename: 'desktop.js'
},
devtool: 'source-map',
target: 'electron-main'
target: 'electron-renderer'
};

View File

@@ -11,5 +11,5 @@ module.exports = {
filename: 'mobile.js'
},
devtool: 'source-map',
target: 'electron-main'
target: 'electron-renderer'
};

View File

@@ -11,5 +11,5 @@ module.exports = {
filename: 'setup.js'
},
devtool: 'source-map',
target: 'electron-main'
target: 'electron-renderer'
};