From bb8fd2b054e09190e6642231f70e85e554808e02 Mon Sep 17 00:00:00 2001 From: contributor Date: Wed, 3 May 2023 16:19:28 +0300 Subject: [PATCH 01/16] zip export - set note title as document.title --- src/services/export/zip.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/export/zip.js b/src/services/export/zip.js index c58afca9f..6bbd1b6ed 100644 --- a/src/services/export/zip.js +++ b/src/services/export/zip.js @@ -248,6 +248,7 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) if (noteMeta.format === 'html') { if (!content.substr(0, 100).toLowerCase().includes(" element will make sure external links are openable - https://github.com/zadam/trilium/issues/1289#issuecomment-704066809 content = ` @@ -256,10 +257,11 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) + ${htmlTitle}
-

${utils.escapeHtml(title)}

+

${htmlTitle}

${content}
From 22587ee6b5f016646023647a341431edaf727c48 Mon Sep 17 00:00:00 2001 From: Nriver <6752679+Nriver@users.noreply.github.com> Date: Thu, 4 May 2023 14:57:33 +0800 Subject: [PATCH 02/16] customize search engine --- src/public/app/desktop.js | 21 +++++- .../widgets/type_widgets/content_widget.js | 2 + .../options/other/search_engine.js | 73 +++++++++++++++++++ src/routes/api/options.js | 4 +- 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 src/public/app/widgets/type_widgets/options/other/search_engine.js diff --git a/src/public/app/desktop.js b/src/public/app/desktop.js index e83f4477e..7b0da9e35 100644 --- a/src/public/app/desktop.js +++ b/src/public/app/desktop.js @@ -8,6 +8,7 @@ import contextMenu from "./menus/context_menu.js"; import DesktopLayout from "./layouts/desktop_layout.js"; import glob from "./services/glob.js"; import zoomService from './components/zoom.js'; +import options from "./services/options.js"; bundleService.getWidgetBundlesByParent().then(widgetBundles => { appContext.setLayout(new DesktopLayout(widgetBundles)); @@ -115,11 +116,27 @@ if (utils.isElectron()) { ? (`${params.selectionText.substr(0, 13)}…`) : params.selectionText; + // Read the search engine from the options and fallback to DuckDuckGo if the option is not set. + const customSearchEngineName = options.get("customSearchEngineName"); + const customSearchEngineUrl = options.get("customSearchEngineUrl"); + let searchEngineName; + let searchEngineUrl; + if (customSearchEngineName && customSearchEngineUrl) { + searchEngineName = customSearchEngineName; + searchEngineUrl = customSearchEngineUrl; + } else { + searchEngineName = "Duckduckgo"; + searchEngineUrl = "https://duckduckgo.com/?q={keyword}"; + } + + // Replace the placeholder with the real search keyword. + let searchUrl = searchEngineUrl.replace("{keyword}", encodeURIComponent(params.selectionText)); + items.push({ enabled: editFlags.canPaste, - title: `Search for "${shortenedSelection}" with DuckDuckGo`, + title: `Search for "${shortenedSelection}" with ${searchEngineName}`, uiIcon: "bx bx-search-alt", - handler: () => electron.shell.openExternal(`https://duckduckgo.com/?q=${encodeURIComponent(params.selectionText)}`) + handler: () => electron.shell.openExternal(searchUrl) }); } diff --git a/src/public/app/widgets/type_widgets/content_widget.js b/src/public/app/widgets/type_widgets/content_widget.js index d81fe550a..967c996e5 100644 --- a/src/public/app/widgets/type_widgets/content_widget.js +++ b/src/public/app/widgets/type_widgets/content_widget.js @@ -18,6 +18,7 @@ import PasswordOptions from "./options/password.js"; import EtapiOptions from "./options/etapi.js"; import BackupOptions from "./options/backup.js"; import SyncOptions from "./options/sync.js"; +import SearchEngineOptions from "./options/other/search_engine.js"; import TrayOptions from "./options/other/tray.js"; import NoteErasureTimeoutOptions from "./options/other/note_erasure_timeout.js"; import NoteRevisionsSnapshotIntervalOptions from "./options/other/note_revisions_snapshot_interval.js"; @@ -75,6 +76,7 @@ const CONTENT_WIDGETS = { _optionsBackup: [ BackupOptions ], _optionsSync: [ SyncOptions ], _optionsOther: [ + SearchEngineOptions, TrayOptions, NoteErasureTimeoutOptions, NoteRevisionsSnapshotIntervalOptions, diff --git a/src/public/app/widgets/type_widgets/options/other/search_engine.js b/src/public/app/widgets/type_widgets/options/other/search_engine.js new file mode 100644 index 000000000..fcbc7b5c2 --- /dev/null +++ b/src/public/app/widgets/type_widgets/options/other/search_engine.js @@ -0,0 +1,73 @@ +import OptionsWidget from "../options_widget.js"; + +const TPL = ` +
+ + +

Search Engine

+ +

Custom search engine requires both a name and a URL to be set. If either of these is not set, DuckDuckGo will be used as the default search engine.

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
`; + +const SEARCH_ENGINES = { + "Bing": "https://www.bing.com/search?q={keyword}", + "Baidu": "https://www.baidu.com/s?wd={keyword}", + "Duckduckgo": "https://duckduckgo.com/?q={keyword}", + "Google": "https://www.google.com/search?q={keyword}", +} + +export default class SearchEngineOptions extends OptionsWidget { + doRender() { + this.$widget = $(TPL); + + this.$form = this.$widget.find(".sync-setup-form"); + this.$predefinedSearchEngineSelect = this.$widget.find(".predefined-search-engine-select"); + this.$customSearchEngineName = this.$widget.find(".custom-search-engine-name"); + this.$customSearchEngineUrl = this.$widget.find(".custom-search-engine-url"); + + this.$predefinedSearchEngineSelect.on('change', () => { + const predefinedSearchEngine = this.$predefinedSearchEngineSelect.val(); + this.$customSearchEngineName[0].value = predefinedSearchEngine; + this.$customSearchEngineUrl[0].value = SEARCH_ENGINES[predefinedSearchEngine]; + }); + + this.$form.on('submit', () => { + this.updateMultipleOptions({ + 'customSearchEngineName': this.$customSearchEngineName.val(), + 'customSearchEngineUrl': this.$customSearchEngineUrl.val() + }); + }); + } + + async optionsLoaded(options) { + this.$predefinedSearchEngineSelect.val(""); + this.$customSearchEngineName[0].value = options.customSearchEngineName; + this.$customSearchEngineUrl[0].value = options.customSearchEngineUrl; + } +} diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 855672e9a..e98b1795f 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -61,7 +61,9 @@ const ALLOWED_OPTIONS = new Set([ 'downloadImagesAutomatically', 'minTocHeadings', 'checkForUpdates', - 'disableTray' + 'disableTray', + 'customSearchEngineName', + 'customSearchEngineUrl', ]); function getOptions() { From 8ce499e9581a397f061accf104b4528906782115 Mon Sep 17 00:00:00 2001 From: Nriver <6752679+Nriver@users.noreply.github.com> Date: Thu, 4 May 2023 16:20:09 +0800 Subject: [PATCH 03/16] add runtime check for search engine options --- .../app/widgets/type_widgets/options/other/search_engine.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/app/widgets/type_widgets/options/other/search_engine.js b/src/public/app/widgets/type_widgets/options/other/search_engine.js index fcbc7b5c2..081aa0aa8 100644 --- a/src/public/app/widgets/type_widgets/options/other/search_engine.js +++ b/src/public/app/widgets/type_widgets/options/other/search_engine.js @@ -1,4 +1,5 @@ import OptionsWidget from "../options_widget.js"; +import utils from "../../../../services/utils.js"; const TPL = `
@@ -43,6 +44,10 @@ const SEARCH_ENGINES = { } export default class SearchEngineOptions extends OptionsWidget { + isEnabled() { + return super.isEnabled() && utils.isElectron(); + } + doRender() { this.$widget = $(TPL); From 61616f708f96f368894549c4b1c07f584c0bd230 Mon Sep 17 00:00:00 2001 From: Nriver <6752679+Nriver@users.noreply.github.com> Date: Thu, 4 May 2023 18:01:51 +0800 Subject: [PATCH 04/16] add default options for search engine options --- src/services/options_init.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/options_init.js b/src/services/options_init.js index fd66718f8..1ce5bbd5d 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -89,6 +89,8 @@ const defaultOptions = [ { name: 'minTocHeadings', value: '5', isSynced: true }, { name: 'checkForUpdates', value: 'true', isSynced: true }, { name: 'disableTray', value: 'false', isSynced: false }, + { name: 'customSearchEngineName', value: 'Duckduckgo', isSynced: false }, + { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: false }, ]; function initStartupOptions() { From 386e8dd32eb08f767bba02fe8da61d1753068a03 Mon Sep 17 00:00:00 2001 From: contributor Date: Thu, 4 May 2023 19:56:02 +0300 Subject: [PATCH 05/16] zip import - remove html tags added by Trilium --- src/services/export/zip.js | 4 ++-- src/services/import/zip.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/services/export/zip.js b/src/services/export/zip.js index 6bbd1b6ed..d31927d19 100644 --- a/src/services/export/zip.js +++ b/src/services/export/zip.js @@ -257,11 +257,11 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) - ${htmlTitle} + ${htmlTitle}
-

${htmlTitle}

+

${htmlTitle}

${content}
diff --git a/src/services/import/zip.js b/src/services/import/zip.js index abe3b58a9..74a942113 100644 --- a/src/services/import/zip.js +++ b/src/services/import/zip.js @@ -240,6 +240,8 @@ async function importZip(taskContext, fileBuffer, importRootNote) { return /^(?:[a-z]+:)?\/\//i.test(url); } + content = removeTrilumTags(content); + content = content.replace(/

([^<]*)<\/h1>/gi, (match, text) => { if (noteTitle.trim() === text.trim()) { return ""; // remove whole H1 tag @@ -325,6 +327,18 @@ async function importZip(taskContext, fileBuffer, importRootNote) { return content; } + function removeTrilumTags(content) { + const tagsToRemove = [ + '

([^<]*)<\/h1>', + '([^<]*)<\/title>' + ] + for (const tag of tagsToRemove) { + let re = new RegExp(tag, "gi"); + content = content.replace(re, ''); + } + return content; + } + function processNoteContent(noteMeta, type, mime, content, noteTitle, filePath) { if (noteMeta?.format === 'markdown' || (!noteMeta && taskContext.data.textImportedAsText && ['text/markdown', 'text/x-markdown'].includes(mime))) { From bb9631476e5d22db78a5d8390aece8670c7ea415 Mon Sep 17 00:00:00 2001 From: contributor <foss.contributor@gmail.com> Date: Wed, 3 May 2023 18:49:46 +0300 Subject: [PATCH 06/16] bump metaFile format version --- src/services/export/zip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/export/zip.js b/src/services/export/zip.js index d31927d19..1bc73f768 100644 --- a/src/services/export/zip.js +++ b/src/services/export/zip.js @@ -417,7 +417,7 @@ ${markdownContent}`; const rootMeta = getNoteMeta(branch, { notePath: [] }, existingFileNames); const metaFile = { - formatVersion: 1, + formatVersion: 2, appVersion: packageInfo.version, files: [ rootMeta ] }; From 26a6ef8c03393c7e3c0331cf40e1e3eecbbb1f07 Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Fri, 5 May 2023 18:27:26 +0000 Subject: [PATCH 07/16] Allow etapi to update attribute fields isInheritable, position --- src/etapi/attributes.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/etapi/attributes.js b/src/etapi/attributes.js index 74d3dbfa9..751166858 100644 --- a/src/etapi/attributes.js +++ b/src/etapi/attributes.js @@ -17,7 +17,8 @@ function register(router) { 'type': [v.mandatory, v.notNull, v.isAttributeType], 'name': [v.mandatory, v.notNull, v.isString], 'value': [v.notNull, v.isString], - 'isInheritable': [v.notNull, v.isBoolean] + 'isInheritable': [v.notNull, v.isBoolean], + 'position': [v.notNull, v.isInteger] }; eu.route(router, 'post' ,'/etapi/attributes', (req, res, next) => { @@ -40,7 +41,9 @@ function register(router) { }); const ALLOWED_PROPERTIES_FOR_PATCH = { - 'value': [v.notNull, v.isString] + 'value': [v.notNull, v.isString], + 'isInheritable': [v.notNull, v.isBoolean], + 'position': [v.notNull, v.isInteger] }; eu.route(router, 'patch' ,'/etapi/attributes/:attributeId', (req, res, next) => { From 79d4dcf5f1f2d79e7b6890525f6c77bb570691bd Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Fri, 5 May 2023 18:33:26 +0000 Subject: [PATCH 08/16] Enable generated etapi client --- src/etapi/attributes.js | 2 +- src/etapi/branches.js | 2 +- src/etapi/etapi.openapi.yaml | 101 ++++++++++++++++------------------- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/src/etapi/attributes.js b/src/etapi/attributes.js index 74d3dbfa9..b4f10c93f 100644 --- a/src/etapi/attributes.js +++ b/src/etapi/attributes.js @@ -20,7 +20,7 @@ function register(router) { 'isInheritable': [v.notNull, v.isBoolean] }; - eu.route(router, 'post' ,'/etapi/attributes', (req, res, next) => { + eu.route(router, 'post' ,'/etapi/attributes/:attributeId', (req, res, next) => { if (req.body.type === 'relation') { eu.getAndCheckNote(req.body.value); } diff --git a/src/etapi/branches.js b/src/etapi/branches.js index 6c83c0928..6258de95c 100644 --- a/src/etapi/branches.js +++ b/src/etapi/branches.js @@ -21,7 +21,7 @@ function register(router) { 'isExpanded': [v.notNull, v.isBoolean] }; - eu.route(router, 'post' ,'/etapi/branches', (req, res, next) => { + eu.route(router, 'post' ,'/etapi/branches/:branchId', (req, res, next) => { const params = {}; eu.validateAndPatch(params, req.body, ALLOWED_PROPERTIES_FOR_CREATE_BRANCH); diff --git a/src/etapi/etapi.openapi.yaml b/src/etapi/etapi.openapi.yaml index b8f0b5382..83826042c 100644 --- a/src/etapi/etapi.openapi.yaml +++ b/src/etapi/etapi.openapi.yaml @@ -31,7 +31,7 @@ paths: '201': description: note created content: - application/json: + application/json; charset=utf-8: schema: properties: note: @@ -43,7 +43,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /notes: @@ -163,13 +163,13 @@ paths: '200': description: search response content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/SearchResponse' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /notes/{noteId}: @@ -186,13 +186,13 @@ paths: '200': description: note response content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' patch: @@ -208,13 +208,13 @@ paths: '200': description: note updated content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' delete: @@ -226,7 +226,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /notes/{noteId}/content: @@ -288,7 +288,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /notes/{noteId}/note-revision: @@ -315,7 +315,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /branches/{branchId}: @@ -332,13 +332,13 @@ paths: '200': description: branch response content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Branch' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' post: @@ -357,19 +357,19 @@ paths: '200': description: branch updated (branch between parent note and child note already existed) content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Branch' '201': description: branch created content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Branch' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' patch: @@ -385,13 +385,13 @@ paths: '200': description: branch updated content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Branch' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' delete: @@ -405,7 +405,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /attributes/{attributeId}: @@ -422,13 +422,13 @@ paths: '200': description: attribute response content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Attribute' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' post: @@ -444,13 +444,13 @@ paths: '201': description: attribute created content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Attribute' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' patch: @@ -466,13 +466,13 @@ paths: '200': description: attribute updated content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Attribute' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' delete: @@ -484,7 +484,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /refresh-note-ordering/{parentNoteId}: @@ -506,7 +506,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /inbox/{date}: @@ -527,13 +527,13 @@ paths: '200': description: inbox note content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /calendar/days/{date}: @@ -552,13 +552,13 @@ paths: '200': description: day note content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /calendar/weeks/{date}: @@ -577,13 +577,13 @@ paths: '200': description: week note content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /calendar/months/{month}: @@ -602,13 +602,13 @@ paths: '200': description: month note content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /calendar/years/{year}: @@ -627,13 +627,13 @@ paths: '200': description: year note content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Note' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /auth/login: @@ -654,7 +654,7 @@ paths: '201': description: auth token content: - application/json: + application/json; charset=utf-8: schema: properties: authToken: @@ -665,7 +665,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /auth/logout: @@ -678,7 +678,7 @@ paths: default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' /app-info: @@ -689,13 +689,13 @@ paths: '200': description: app info content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/AppInfo' default: description: unexpected error content: - application/json: + application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' @@ -774,7 +774,7 @@ components: type: string type: type: string - enum: [text, code, render, file, image, search, relationMap, book, noteMap, mermaid, webView, shortcut] + enum: [text, code, render, file, image, search, relationMap, book, noteMap, mermaid, webView, shortcut, doc, contentWidget, launcher] mime: type: string isProtected: @@ -810,9 +810,6 @@ components: Branch: type: object description: Branch places the note into the tree, it represents the relationship between a parent note and child note - required: - - noteId - - parentNoteId properties: branchId: $ref: '#/components/schemas/EntityId' @@ -837,8 +834,6 @@ components: Attribute: type: object description: Attribute (Label, Relation) is a key-value record attached to a note. - required: - - noteId properties: attributeId: $ref: '#/components/schemas/EntityId' @@ -851,7 +846,7 @@ components: enum: [label, relation] name: type: string - pattern: '^[\p{L}\p{N}_:]+' + pattern: '^[^\s]+' example: shareCss value: type: string @@ -881,7 +876,7 @@ components: description: debugging info on parsing the search query enabled with &debug=true parameter EntityId: type: string - pattern: '[a-zA-Z0-9]{4,32}' + pattern: '[a-zA-Z0-9_]{4,32}' example: evnnmvHTCgIn EntityIdList: type: array @@ -889,7 +884,7 @@ components: $ref: '#/components/schemas/EntityId' LocalDateTime: type: string - pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}' + pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}[\+\-][0-9]{4}' example: 2021-12-31 20:18:11.939+0100 UtcDateTime: type: string @@ -897,10 +892,6 @@ components: example: 2021-12-31 19:18:11.939Z AppInfo: type: object - required: - - statu - - code - - message properties: appVersion: type: string From 4aeecfdfa94f993e97b0a182e374d7c1d236be09 Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Fri, 5 May 2023 18:41:29 +0000 Subject: [PATCH 09/16] Update etapi test --- test-etapi/create-entities.http | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-etapi/create-entities.http b/test-etapi/create-entities.http index b5e7fd52a..420d3a013 100644 --- a/test-etapi/create-entities.http +++ b/test-etapi/create-entities.http @@ -26,7 +26,7 @@ Content-Type: application/json ### Clone to another location -POST {{triliumHost}}/etapi/branches +POST {{triliumHost}}/etapi/branches/dummyBranchId Authorization: {{authToken}} Content-Type: application/json @@ -93,7 +93,7 @@ Authorization: {{authToken}} ### -POST {{triliumHost}}/etapi/attributes +POST {{triliumHost}}/etapi/attributes/dummyAttributeId Content-Type: application/json Authorization: {{authToken}} From 3cafad3bf47cf9026ba03ceaeb8ed21a32a382b5 Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Sat, 6 May 2023 23:42:48 +0000 Subject: [PATCH 10/16] Remove isInheritable from PATCH --- src/etapi/attributes.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/etapi/attributes.js b/src/etapi/attributes.js index 751166858..6886e0845 100644 --- a/src/etapi/attributes.js +++ b/src/etapi/attributes.js @@ -42,7 +42,6 @@ function register(router) { const ALLOWED_PROPERTIES_FOR_PATCH = { 'value': [v.notNull, v.isString], - 'isInheritable': [v.notNull, v.isBoolean], 'position': [v.notNull, v.isInteger] }; From ad0b98e2a18bbe2ccfec50a898c016c89d23ab07 Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Sun, 7 May 2023 00:18:28 +0000 Subject: [PATCH 11/16] Omit attributeId/branchId path params from postAttribute/postBranch in etapi.openapi.yaml --- src/etapi/etapi.openapi.yaml | 92 ++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/etapi/etapi.openapi.yaml b/src/etapi/etapi.openapi.yaml index 83826042c..974acbdfe 100644 --- a/src/etapi/etapi.openapi.yaml +++ b/src/etapi/etapi.openapi.yaml @@ -318,29 +318,7 @@ paths: application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' - /branches/{branchId}: - parameters: - - name: branchId - in: path - required: true - schema: - $ref: '#/components/schemas/EntityId' - get: - description: Returns a branch identified by its ID - operationId: getBranchById - responses: - '200': - description: branch response - content: - application/json; charset=utf-8: - schema: - $ref: '#/components/schemas/Branch' - default: - description: unexpected error - content: - application/json; charset=utf-8: - schema: - $ref: '#/components/schemas/Error' + /branches: post: description: > Create a branch (clone a note to a different location in the tree). @@ -372,6 +350,29 @@ paths: application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' + /branches/{branchId}: + parameters: + - name: branchId + in: path + required: true + schema: + $ref: '#/components/schemas/EntityId' + get: + description: Returns a branch identified by its ID + operationId: getBranchById + responses: + '200': + description: branch response + content: + application/json; charset=utf-8: + schema: + $ref: '#/components/schemas/Branch' + default: + description: unexpected error + content: + application/json; charset=utf-8: + schema: + $ref: '#/components/schemas/Error' patch: description: patch a branch identified by the branchId with changes in the body operationId: patchBranchById @@ -408,6 +409,29 @@ paths: application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' + /attributes: + post: + description: create an attribute for a given note + operationId: postAttribute + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Attribute' + responses: + '201': + description: attribute created + content: + application/json; charset=utf-8: + schema: + $ref: '#/components/schemas/Attribute' + default: + description: unexpected error + content: + application/json; charset=utf-8: + schema: + $ref: '#/components/schemas/Error' /attributes/{attributeId}: parameters: - name: attributeId @@ -431,28 +455,6 @@ paths: application/json; charset=utf-8: schema: $ref: '#/components/schemas/Error' - post: - description: create an attribute for a given note - operationId: postAttribute - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Attribute' - responses: - '201': - description: attribute created - content: - application/json; charset=utf-8: - schema: - $ref: '#/components/schemas/Attribute' - default: - description: unexpected error - content: - application/json; charset=utf-8: - schema: - $ref: '#/components/schemas/Error' patch: description: patch a attribute identified by the attributeId with changes in the body operationId: patchAttributeById From ec662d01d063311c688d0aa74b925fc4edbab985 Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Sun, 7 May 2023 00:18:39 +0000 Subject: [PATCH 12/16] Revert "Update etapi test" This reverts commit 4aeecfdfa94f993e97b0a182e374d7c1d236be09. --- test-etapi/create-entities.http | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-etapi/create-entities.http b/test-etapi/create-entities.http index 420d3a013..b5e7fd52a 100644 --- a/test-etapi/create-entities.http +++ b/test-etapi/create-entities.http @@ -26,7 +26,7 @@ Content-Type: application/json ### Clone to another location -POST {{triliumHost}}/etapi/branches/dummyBranchId +POST {{triliumHost}}/etapi/branches Authorization: {{authToken}} Content-Type: application/json @@ -93,7 +93,7 @@ Authorization: {{authToken}} ### -POST {{triliumHost}}/etapi/attributes/dummyAttributeId +POST {{triliumHost}}/etapi/attributes Content-Type: application/json Authorization: {{authToken}} From d09132dd60fa8456be05e274776b4c040eaac053 Mon Sep 17 00:00:00 2001 From: mm21 <8033134+mm21@users.noreply.github.com> Date: Sun, 7 May 2023 00:32:42 +0000 Subject: [PATCH 13/16] Revert path param changes for POST --- src/etapi/attributes.js | 2 +- src/etapi/branches.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/etapi/attributes.js b/src/etapi/attributes.js index b4f10c93f..74d3dbfa9 100644 --- a/src/etapi/attributes.js +++ b/src/etapi/attributes.js @@ -20,7 +20,7 @@ function register(router) { 'isInheritable': [v.notNull, v.isBoolean] }; - eu.route(router, 'post' ,'/etapi/attributes/:attributeId', (req, res, next) => { + eu.route(router, 'post' ,'/etapi/attributes', (req, res, next) => { if (req.body.type === 'relation') { eu.getAndCheckNote(req.body.value); } diff --git a/src/etapi/branches.js b/src/etapi/branches.js index 6258de95c..6c83c0928 100644 --- a/src/etapi/branches.js +++ b/src/etapi/branches.js @@ -21,7 +21,7 @@ function register(router) { 'isExpanded': [v.notNull, v.isBoolean] }; - eu.route(router, 'post' ,'/etapi/branches/:branchId', (req, res, next) => { + eu.route(router, 'post' ,'/etapi/branches', (req, res, next) => { const params = {}; eu.validateAndPatch(params, req.body, ALLOWED_PROPERTIES_FOR_CREATE_BRANCH); From 46ed61d38a181efb3bb6c99c81536244de5fa458 Mon Sep 17 00:00:00 2001 From: MeIchthys <10717998+meichthys@users.noreply.github.com> Date: Tue, 9 May 2023 16:29:04 -0400 Subject: [PATCH 14/16] Make active ribbon item more obvious --- src/public/app/widgets/containers/ribbon_container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/containers/ribbon_container.js b/src/public/app/widgets/containers/ribbon_container.js index 3bb19d95c..e9fbd307c 100644 --- a/src/public/app/widgets/containers/ribbon_container.js +++ b/src/public/app/widgets/containers/ribbon_container.js @@ -39,7 +39,7 @@ const TPL = ` .ribbon-tab-title.active { color: var(--main-text-color); - border-bottom: 1px solid var(--main-text-color); + border-bottom: 3px solid var(--main-text-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; From 6a9aa5eedaf27d8b077d200cca659eef541b2143 Mon Sep 17 00:00:00 2001 From: baiyongjie <407221377@qq.com> Date: Wed, 10 May 2023 18:08:25 +0800 Subject: [PATCH 15/16] fix cursor position when Jumping from note to included note --- src/public/app/widgets/type_widgets/editable_text.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js index 2c6cf55f2..826a9eab3 100644 --- a/src/public/app/widgets/type_widgets/editable_text.js +++ b/src/public/app/widgets/type_widgets/editable_text.js @@ -186,6 +186,11 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { const noteComplement = await froca.getNoteComplement(note.noteId); await this.spacedUpdate.allowUpdateWithoutChange(() => { + // https://github.com/zadam/trilium/issues/3914 + // todo: quite hacky, but it works. remove it if ckeditor has fixed it. + this.$editor.trigger('focus'); + this.$editor.trigger('blur') + this.watchdog.editor.setData(noteComplement.content || ""); }); } From 4849dacd52bc5742f20ca75c06e5867276bf3f68 Mon Sep 17 00:00:00 2001 From: MeIchthys <10717998+meichthys@users.noreply.github.com> Date: Fri, 12 May 2023 10:14:34 -0400 Subject: [PATCH 16/16] auto flex note title in tree --- src/public/stylesheets/tree.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/public/stylesheets/tree.css b/src/public/stylesheets/tree.css index 8962e812d..6e26b872c 100644 --- a/src/public/stylesheets/tree.css +++ b/src/public/stylesheets/tree.css @@ -11,6 +11,7 @@ span.fancytree-node.fancytree-hide { } .fancytree-title { + flex: auto; margin-left: 7px; outline: none; position: relative;