diff --git a/package.json b/package.json index c67a694b3..bf134ad96 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,10 @@ "url": "https://github.com/zadam/trilium.git" }, "scripts": { - "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev node ./src/www", - "start-server-no-dir": "cross-env TRILIUM_ENV=dev node ./src/www", - "start-electron": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev electron --inspect=5858 .", - "start-electron-no-dir": "cross-env TRILIUM_ENV=dev electron --inspect=5858 .", + "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 node ./src/www", + "start-server-no-dir": "cross-env TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 node ./src/www", + "start-electron": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .", + "start-electron-no-dir": "cross-env TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .", "switch-server": "rm -rf ./node_modules/better-sqlite3 && npm install", "switch-electron": "rm -rf ./node_modules/better-sqlite3 && npm install && ./node_modules/.bin/electron-rebuild", "build-api-docs": "./bin/build-api-docs.sh", diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index 08c7da919..8f760cc95 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -477,13 +477,13 @@ export default class TabManager extends Component { this.openAndActivateEmptyTab(); } - async removeAllTabsCommand() { + async closeAllTabsCommand() { for (const ntxIdToRemove of this.mainNoteContexts.map(nc => nc.ntxId)) { await this.removeNoteContext(ntxIdToRemove); } } - async removeAllTabsExceptForThisCommand({ntxId}) { + async closeOtherTabsCommand({ntxId}) { for (const ntxIdToRemove of this.mainNoteContexts.map(nc => nc.ntxId)) { if (ntxIdToRemove !== ntxId) { await this.removeNoteContext(ntxIdToRemove); @@ -491,6 +491,10 @@ export default class TabManager extends Component { } } + async closeTabCommand({ntxId}) { + await this.removeNoteContext(ntxId); + } + async moveTabToNewWindowCommand({ntxId}) { const {notePath, hoistedNoteId} = this.getNoteContextById(ntxId); diff --git a/src/public/app/services/note_content_renderer.js b/src/public/app/services/note_content_renderer.js index 0a509af31..2fb805799 100644 --- a/src/public/app/services/note_content_renderer.js +++ b/src/public/app/services/note_content_renderer.js @@ -7,6 +7,7 @@ import openService from "./open.js"; import froca from "./froca.js"; import utils from "./utils.js"; import linkService from "./link.js"; +import treeService from "./tree.js"; let idCounter = 1; @@ -31,6 +32,17 @@ async function getRenderedContent(note, options = {}) { renderMathInElement($renderedContent[0], {trust: true}); } + + const getNoteIdFromLink = el => treeService.getNoteIdFromNotePath($(el).attr('href')); + const referenceLinks = $renderedContent.find("a.reference-link"); + const noteIdsToPrefetch = referenceLinks.map(el => getNoteIdFromLink(el)); + await froca.getNotes(noteIdsToPrefetch); + + for (const el of referenceLinks) { + const noteId = getNoteIdFromLink(el); + + await linkService.loadReferenceLinkTitle(noteId, $(el)); + } } else { await renderChildrenList($renderedContent, note); diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 4f6825c94..01f1ce23b 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -460,7 +460,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) { const files = [...dataTransfer.files]; // chrome has issue that dataTransfer.files empties after async operation - const importService = await import('../services/import'); + const importService = await import('../services/import.js'); importService.uploadFiles(node.data.noteId, files, { safeImport: true, diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index a401157fc..41249650a 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -262,9 +262,10 @@ export default class TabRowWidget extends BasicWidget { x: e.pageX, y: e.pageY, items: [ - {title: "Move this tab to a new window", command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"}, - {title: "Close all tabs", command: "removeAllTabs", uiIcon: "bx bx-x"}, - {title: "Close all tabs except for this", command: "removeAllTabsExceptForThis", uiIcon: "bx bx-x"}, + {title: "Close", command: "closeTab", uiIcon: "bx bx-x"}, + {title: "Close other tabs", command: "closeOtherTabs", uiIcon: "bx bx-x"}, + {title: "Close all tabs", command: "closeAllTabs", uiIcon: "bx bx-x"}, + {title: "Move this tab to a new window", command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"} ], selectMenuItemHandler: ({command}) => { this.triggerCommand(command, {ntxId}); diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.js index 450bc6ded..133d66065 100644 --- a/src/public/app/widgets/toc.js +++ b/src/public/app/widgets/toc.js @@ -126,7 +126,7 @@ export default class TocWidget extends RightPanelWidget { getToc(html) { // Regular expression for headings