attachments WIP

This commit is contained in:
zadam 2023-05-29 00:19:54 +02:00
parent c2f70031d0
commit 0aa119af2c
37 changed files with 448 additions and 320 deletions

View File

@ -5,8 +5,8 @@
}
/*
* CKEditor 5 (v35.4.0) content styles.
* Generated on Wed, 14 Dec 2022 12:53:04 GMT.
* CKEditor 5 (v38.0.1) content styles.
* Generated on Thu, 25 May 2023 13:25:51 GMT.
* For more information, check out https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/content-styles.html
*/
@ -28,29 +28,7 @@
--ck-todo-list-checkmark-size: 16px;
}
/* ckeditor5-basic-styles/theme/code.css */
.ck-content code {
background-color: hsla(0, 0%, 78%, 0.3);
padding: .15em;
border-radius: 2px;
}
/* ckeditor5-font/theme/fontsize.css */
.ck-content .text-tiny {
font-size: .7em;
}
/* ckeditor5-font/theme/fontsize.css */
.ck-content .text-small {
font-size: .85em;
}
/* ckeditor5-font/theme/fontsize.css */
.ck-content .text-big {
font-size: 1.4em;
}
/* ckeditor5-font/theme/fontsize.css */
.ck-content .text-huge {
font-size: 1.8em;
}
/* ckeditor5-block-quote/theme/blockquote.css */
/* @ckeditor/ckeditor5-block-quote/theme/blockquote.css */
.ck-content blockquote {
overflow: hidden;
padding-right: 1.5em;
@ -60,75 +38,60 @@
font-style: italic;
border-left: solid 5px hsl(0, 0%, 80%);
}
/* ckeditor5-block-quote/theme/blockquote.css */
/* @ckeditor/ckeditor5-block-quote/theme/blockquote.css */
.ck-content[dir="rtl"] blockquote {
border-left: 0;
border-right: solid 5px hsl(0, 0%, 80%);
}
/* ckeditor5-highlight/theme/highlight.css */
/* @ckeditor/ckeditor5-basic-styles/theme/code.css */
.ck-content code {
background-color: hsla(0, 0%, 78%, 0.3);
padding: .15em;
border-radius: 2px;
}
/* @ckeditor/ckeditor5-font/theme/fontsize.css */
.ck-content .text-tiny {
font-size: .7em;
}
/* @ckeditor/ckeditor5-font/theme/fontsize.css */
.ck-content .text-small {
font-size: .85em;
}
/* @ckeditor/ckeditor5-font/theme/fontsize.css */
.ck-content .text-big {
font-size: 1.4em;
}
/* @ckeditor/ckeditor5-font/theme/fontsize.css */
.ck-content .text-huge {
font-size: 1.8em;
}
/* @ckeditor/ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-yellow {
background-color: var(--ck-highlight-marker-yellow);
}
/* ckeditor5-highlight/theme/highlight.css */
/* @ckeditor/ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-green {
background-color: var(--ck-highlight-marker-green);
}
/* ckeditor5-highlight/theme/highlight.css */
/* @ckeditor/ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-pink {
background-color: var(--ck-highlight-marker-pink);
}
/* ckeditor5-highlight/theme/highlight.css */
/* @ckeditor/ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-blue {
background-color: var(--ck-highlight-marker-blue);
}
/* ckeditor5-highlight/theme/highlight.css */
/* @ckeditor/ckeditor5-highlight/theme/highlight.css */
.ck-content .pen-red {
color: var(--ck-highlight-pen-red);
background-color: transparent;
}
/* ckeditor5-highlight/theme/highlight.css */
/* @ckeditor/ckeditor5-highlight/theme/highlight.css */
.ck-content .pen-green {
color: var(--ck-highlight-pen-green);
background-color: transparent;
}
/* ckeditor5-image/theme/image.css */
.ck-content .image {
display: table;
clear: both;
text-align: center;
margin: 0.9em auto;
min-width: 50px;
}
/* ckeditor5-image/theme/image.css */
.ck-content .image img {
display: block;
margin: 0 auto;
max-width: 100%;
min-width: 100%;
}
/* ckeditor5-image/theme/image.css */
.ck-content .image-inline {
/*
* Normally, the .image-inline would have "display: inline-block" and "img { width: 100% }" (to follow the wrapper while resizing).;
* Unfortunately, together with "srcset", it gets automatically stretched up to the width of the editing root.
* This strange behavior does not happen with inline-flex.
*/
display: inline-flex;
max-width: 100%;
align-items: flex-start;
}
/* ckeditor5-image/theme/image.css */
.ck-content .image-inline picture {
display: flex;
}
/* ckeditor5-image/theme/image.css */
.ck-content .image-inline picture,
.ck-content .image-inline img {
flex-grow: 1;
flex-shrink: 1;
max-width: 100%;
}
/* ckeditor5-image/theme/imagecaption.css */
/* @ckeditor/ckeditor5-image/theme/imagecaption.css */
.ck-content .image > figcaption {
display: table-caption;
caption-side: bottom;
@ -139,98 +102,167 @@
font-size: .75em;
outline-offset: -1px;
}
/* ckeditor5-image/theme/imageresize.css */
/* @ckeditor/ckeditor5-image/theme/image.css */
.ck-content .image {
display: table;
clear: both;
text-align: center;
margin: 0.9em auto;
min-width: 50px;
}
/* @ckeditor/ckeditor5-image/theme/image.css */
.ck-content .image img {
display: block;
margin: 0 auto;
max-width: 100%;
min-width: 100%;
}
/* @ckeditor/ckeditor5-image/theme/image.css */
.ck-content .image-inline {
/*
* Normally, the .image-inline would have "display: inline-block" and "img { width: 100% }" (to follow the wrapper while resizing).;
* Unfortunately, together with "srcset", it gets automatically stretched up to the width of the editing root.
* This strange behavior does not happen with inline-flex.
*/
display: inline-flex;
max-width: 100%;
align-items: flex-start;
}
/* @ckeditor/ckeditor5-image/theme/image.css */
.ck-content .image-inline picture {
display: flex;
}
/* @ckeditor/ckeditor5-image/theme/image.css */
.ck-content .image-inline picture,
.ck-content .image-inline img {
flex-grow: 1;
flex-shrink: 1;
max-width: 100%;
}
/* @ckeditor/ckeditor5-image/theme/imageresize.css */
.ck-content .image.image_resized {
max-width: 100%;
display: block;
box-sizing: border-box;
}
/* ckeditor5-image/theme/imageresize.css */
/* @ckeditor/ckeditor5-image/theme/imageresize.css */
.ck-content .image.image_resized img {
width: 100%;
}
/* ckeditor5-image/theme/imageresize.css */
/* @ckeditor/ckeditor5-image/theme/imageresize.css */
.ck-content .image.image_resized > figcaption {
display: block;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-block-align-left,
.ck-content .image-style-block-align-right {
max-width: calc(100% - var(--ck-image-style-spacing));
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-align-left,
.ck-content .image-style-align-right {
clear: none;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-side {
float: right;
margin-left: var(--ck-image-style-spacing);
max-width: 50%;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-align-left {
float: left;
margin-right: var(--ck-image-style-spacing);
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-align-center {
margin-left: auto;
margin-right: auto;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-align-right {
float: right;
margin-left: var(--ck-image-style-spacing);
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-block-align-right {
margin-right: 0;
margin-left: auto;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-style-block-align-left {
margin-left: 0;
margin-right: auto;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content p + .image-style-align-left,
.ck-content p + .image-style-align-right,
.ck-content p + .image-style-side {
margin-top: 0;
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-inline.image-style-align-left,
.ck-content .image-inline.image-style-align-right {
margin-top: var(--ck-inline-image-style-spacing);
margin-bottom: var(--ck-inline-image-style-spacing);
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-inline.image-style-align-left {
margin-right: var(--ck-inline-image-style-spacing);
}
/* ckeditor5-image/theme/imagestyle.css */
/* @ckeditor/ckeditor5-image/theme/imagestyle.css */
.ck-content .image-inline.image-style-align-right {
margin-left: var(--ck-inline-image-style-spacing);
}
/* ckeditor5-language/theme/language.css */
.ck-content span[lang] {
font-style: italic;
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ol {
list-style-type: decimal;
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ol ol {
list-style-type: lower-latin;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ol ol ol {
list-style-type: lower-roman;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ol ol ol ol {
list-style-type: upper-latin;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ol ol ol ol ol {
list-style-type: upper-roman;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ul {
list-style-type: disc;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ul ul {
list-style-type: circle;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ul ul ul {
list-style-type: square;
}
/* @ckeditor/ckeditor5-list/theme/list.css */
.ck-content ul ul ul ul {
list-style-type: square;
}
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list {
list-style: none;
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list li {
margin-bottom: 5px;
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list li .todo-list {
margin-top: 5px;
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input {
-webkit-appearance: none;
display: inline-block;
@ -244,7 +276,7 @@
right: 0;
margin-left: 0;
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input::before {
display: block;
position: absolute;
@ -256,7 +288,7 @@
border-radius: 2px;
transition: 250ms ease-in-out box-shadow, 250ms ease-in-out background, 250ms ease-in-out border;
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input::after {
display: block;
position: absolute;
@ -272,27 +304,27 @@
border-width: 0 calc( var(--ck-todo-list-checkmark-size) / 8 ) calc( var(--ck-todo-list-checkmark-size) / 8 ) 0;
transform: rotate(45deg);
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input[checked]::before {
background: hsl(126, 64%, 41%);
border-color: hsl(126, 64%, 41%);
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input[checked]::after {
border-color: hsl(0, 0%, 100%);
}
/* ckeditor5-list/theme/todolist.css */
/* @ckeditor/ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label .todo-list__label__description {
vertical-align: middle;
}
/* ckeditor5-media-embed/theme/mediaembed.css */
/* @ckeditor/ckeditor5-media-embed/theme/mediaembed.css */
.ck-content .media {
clear: both;
margin: 0.9em 0;
display: block;
min-width: 15em;
}
/* ckeditor5-page-break/theme/pagebreak.css */
/* @ckeditor/ckeditor5-page-break/theme/pagebreak.css */
.ck-content .page-break {
position: relative;
clear: both;
@ -301,14 +333,14 @@
align-items: center;
justify-content: center;
}
/* ckeditor5-page-break/theme/pagebreak.css */
/* @ckeditor/ckeditor5-page-break/theme/pagebreak.css */
.ck-content .page-break::after {
content: '';
position: absolute;
border-bottom: 2px dashed hsl(0, 0%, 77%);
width: 100%;
}
/* ckeditor5-page-break/theme/pagebreak.css */
/* @ckeditor/ckeditor5-page-break/theme/pagebreak.css */
.ck-content .page-break__label {
position: relative;
z-index: 1;
@ -328,12 +360,25 @@
-ms-user-select: none;
user-select: none;
}
/* ckeditor5-table/theme/table.css */
/* @ckeditor/ckeditor5-table/theme/tablecolumnresize.css */
.ck-content .table .ck-table-resized {
table-layout: fixed;
}
/* @ckeditor/ckeditor5-table/theme/tablecolumnresize.css */
.ck-content .table table {
overflow: hidden;
}
/* @ckeditor/ckeditor5-table/theme/tablecolumnresize.css */
.ck-content .table td,
.ck-content .table th {
position: relative;
}
/* @ckeditor/ckeditor5-table/theme/table.css */
.ck-content .table {
margin: 0.9em auto;
display: table;
}
/* ckeditor5-table/theme/table.css */
/* @ckeditor/ckeditor5-table/theme/table.css */
.ck-content .table table {
border-collapse: collapse;
border-spacing: 0;
@ -341,40 +386,27 @@
height: 100%;
border: 1px double hsl(0, 0%, 70%);
}
/* ckeditor5-table/theme/table.css */
/* @ckeditor/ckeditor5-table/theme/table.css */
.ck-content .table table td,
.ck-content .table table th {
min-width: 2em;
padding: .4em;
border: 1px solid hsl(0, 0%, 75%);
}
/* ckeditor5-table/theme/table.css */
/* @ckeditor/ckeditor5-table/theme/table.css */
.ck-content .table table th {
font-weight: bold;
background: hsla(0, 0%, 0%, 5%);
}
/* ckeditor5-table/theme/table.css */
/* @ckeditor/ckeditor5-table/theme/table.css */
.ck-content[dir="rtl"] .table th {
text-align: right;
}
/* ckeditor5-table/theme/table.css */
/* @ckeditor/ckeditor5-table/theme/table.css */
.ck-content[dir="ltr"] .table th {
text-align: left;
}
/* ckeditor5-table/theme/tablecolumnresize.css */
.ck-content .table .ck-table-resized {
table-layout: fixed;
}
/* ckeditor5-table/theme/tablecolumnresize.css */
.ck-content .table table {
overflow: hidden;
}
/* ckeditor5-table/theme/tablecolumnresize.css */
.ck-content .table td,
.ck-content .table th {
position: relative;
}
/* ckeditor5-table/theme/tablecaption.css */
/* @ckeditor/ckeditor5-table/theme/tablecaption.css */
.ck-content .table > figcaption {
display: table-caption;
caption-side: top;
@ -386,7 +418,7 @@
font-size: .75em;
outline-offset: -1px;
}
/* ckeditor5-code-block/theme/codeblock.css */
/* @ckeditor/ckeditor5-code-block/theme/codeblock.css */
.ck-content pre {
padding: 1em;
color: hsl(0, 0%, 20.8%);
@ -400,66 +432,30 @@
font-style: normal;
min-width: 200px;
}
/* ckeditor5-code-block/theme/codeblock.css */
/* @ckeditor/ckeditor5-code-block/theme/codeblock.css */
.ck-content pre code {
background: unset;
padding: 0;
border-radius: 0;
}
/* ckeditor5-horizontal-line/theme/horizontalline.css */
/* @ckeditor/ckeditor5-horizontal-line/theme/horizontalline.css */
.ck-content hr {
margin: 15px 0;
height: 4px;
background: hsl(0, 0%, 87%);
border: 0;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ol {
list-style-type: decimal;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ol ol {
list-style-type: lower-latin;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ol ol ol {
list-style-type: lower-roman;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ol ol ol ol {
list-style-type: upper-latin;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ol ol ol ol ol {
list-style-type: upper-roman;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ul {
list-style-type: circle;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ul ul {
list-style-type: disc;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ul ul ul {
list-style-type: square;
}
/* ckeditor5-list/theme/liststyles.css */
.ck-content ul ul ul ul {
list-style-type: square;
}
/* ckeditor5-mention/theme/mention.css */
/* @ckeditor/ckeditor5-mention/theme/mention.css */
.ck-content .mention {
background: var(--ck-color-mention-background);
color: var(--ck-color-mention-text);
}
@media print {
/* ckeditor5-page-break/theme/pagebreak.css */
/* @ckeditor/ckeditor5-page-break/theme/pagebreak.css */
.ck-content .page-break {
padding: 0;
}
/* ckeditor5-page-break/theme/pagebreak.css */
/* @ckeditor/ckeditor5-page-break/theme/pagebreak.css */
.ck-content .page-break::after {
display: none;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

150
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "trilium",
"version": "0.60.0-beta",
"version": "0.60.1-beta",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "trilium",
"version": "0.60.0-beta",
"version": "0.60.1-beta",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {
@ -16,7 +16,7 @@
"archiver": "5.3.1",
"async-mutex": "0.4.0",
"axios": "1.4.0",
"better-sqlite3": "8.3.0",
"better-sqlite3": "8.4.0",
"chokidar": "3.5.3",
"cls-hooked": "4.2.2",
"commonmark": "0.30.0",
@ -39,15 +39,15 @@
"helmet": "7.0.0",
"html": "1.0.0",
"html2plaintext": "2.1.4",
"http-proxy-agent": "6.1.0",
"https-proxy-agent": "6.2.0",
"http-proxy-agent": "7.0.0",
"https-proxy-agent": "7.0.0",
"image-type": "4.1.0",
"ini": "3.0.1",
"is-animated": "2.0.2",
"is-svg": "4.3.2",
"jimp": "0.22.8",
"joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.0.0",
"jsdom": "22.1.0",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.40.0",
@ -71,7 +71,7 @@
"turndown": "7.1.2",
"unescape": "1.0.1",
"ws": "8.13.0",
"xml2js": "0.5.0",
"xml2js": "0.6.0",
"yauzl": "2.10.0"
},
"bin": {
@ -79,7 +79,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.0.0-beta.7",
"electron": "25.0.0-beta.8",
"electron-builder": "23.6.0",
"electron-packager": "17.1.1",
"electron-rebuild": "3.2.9",
@ -99,7 +99,7 @@
"nodemon": "2.0.22",
"prettier": "2.8.8",
"rcedit": "3.0.1",
"webpack": "5.83.1",
"webpack": "5.84.1",
"webpack-cli": "5.1.1"
},
"optionalDependencies": {
@ -1752,9 +1752,9 @@
}
},
"node_modules/acorn-import-assertions": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz",
"integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==",
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz",
"integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==",
"dev": true,
"peerDependencies": {
"acorn": "^8"
@ -2443,9 +2443,9 @@
}
},
"node_modules/better-sqlite3": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.3.0.tgz",
"integrity": "sha512-JTmvBZL/JLTc+3Msbvq6gK6elbU9/wVMqiudplHrVJpr7sVMR9KJrNhZAbW+RhXKlpMcuEhYkdcHa3TXKNXQ1w==",
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.4.0.tgz",
"integrity": "sha512-NmsNW1CQvqMszu/CFAJ3pLct6NEFlNfuGM6vw72KHkjOD1UDnL96XNN1BMQc1hiHo8vE2GbOWQYIpZ+YM5wrZw==",
"hasInstallScript": true,
"dependencies": {
"bindings": "^1.5.0",
@ -4198,9 +4198,9 @@
}
},
"node_modules/electron": {
"version": "25.0.0-beta.7",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.0.0-beta.7.tgz",
"integrity": "sha512-pNlAmEH0v3ADTUeMfDiD5u2ODTQKdhABBSkUzvmq+tMJgCbbb8SlffcmekL2fHENDxwPycaH1ld+fCMG33ce6g==",
"version": "25.0.0-beta.8",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.0.0-beta.8.tgz",
"integrity": "sha512-o3X0pkg1PyR/yawlSJzTXrh5GG8sH7jjtOzr74f0Zb4PnInzI3MIr8NopyhcGCW0JmOwFu+DLZX4bDlaLmtyGQ==",
"hasInstallScript": true,
"dependencies": {
"@electron/get": "^2.0.0",
@ -4843,9 +4843,9 @@
}
},
"node_modules/enhanced-resolve": {
"version": "5.14.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.0.tgz",
"integrity": "sha512-+DCows0XNwLDcUhbFJPdlQEVnT2zXlCv7hPxemTz86/O+B/hCQ+mb7ydkPKiflpVraqLPCAfu7lDy+hBXueojw==",
"version": "5.14.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz",
"integrity": "sha512-Vklwq2vDKtl0y/vtwjSesgJ5MYS7Etuk5txS8VdKL4AOS1aUlD96zqIfsOSLQsdv3xgMRbtkWM8eG9XDfKUPow==",
"dev": true,
"dependencies": {
"graceful-fs": "^4.2.4",
@ -6964,11 +6964,11 @@
}
},
"node_modules/http-proxy-agent": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-6.1.0.tgz",
"integrity": "sha512-75t5ACHLOMnz/KsDAS4BdHx4J0sneT/HW+Sz070NR+n7RZ7SmYXYn2FXq6D0XwQid8hYgRVf6HZJrYuGzaEqtw==",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz",
"integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==",
"dependencies": {
"agent-base": "^7.0.2",
"agent-base": "^7.1.0",
"debug": "^4.3.4"
},
"engines": {
@ -6976,9 +6976,9 @@
}
},
"node_modules/http-proxy-agent/node_modules/agent-base": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.0.2.tgz",
"integrity": "sha512-k2/tQ1+8Zf50dEUJWklUP80LcE/+Ph+OJ6cf2Ff2fD/c/TtCe6ofnCoNMz9UnyxOQYlaAALZtEWETzn+1JjfHg==",
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz",
"integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==",
"dependencies": {
"debug": "^4.3.4"
},
@ -7013,9 +7013,9 @@
}
},
"node_modules/https-proxy-agent": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-6.2.0.tgz",
"integrity": "sha512-4xhCnMpxR9fupa7leh9uJK2P/qjYIeaM9uZ9c1bi1JDSwX2VH9NDk/oKSToNX4gBKa2WT31Mldne7e26ckohLQ==",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.0.tgz",
"integrity": "sha512-0euwPCRyAPSgGdzD1IVN9nJYHtBhJwb6XPfbpQcYbPCwrBidX6GzxmchnaF4sfF/jPb74Ojx5g4yTg3sixlyPw==",
"dependencies": {
"agent-base": "^7.0.2",
"debug": "4"
@ -7985,9 +7985,9 @@
}
},
"node_modules/jsdom": {
"version": "22.0.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.0.0.tgz",
"integrity": "sha512-p5ZTEb5h+O+iU02t0GfEjAnkdYPrQSkfuTSMkMYyIoMvUNEHsbG0bHHbfXIcfTqD2UfvjQX7mmgiFsyRwGscVw==",
"version": "22.1.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.1.0.tgz",
"integrity": "sha512-/9AVW7xNbsBv6GfWho4TTNjEo9fe6Zhf9O7s0Fhhr3u+awPwAJMKwAMXnkk5vBxflqLW9hTHX/0cs+P3gW+cQw==",
"dependencies": {
"abab": "^2.0.6",
"cssstyle": "^3.0.0",
@ -12564,9 +12564,9 @@
}
},
"node_modules/webpack": {
"version": "5.83.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.83.1.tgz",
"integrity": "sha512-TNsG9jDScbNuB+Lb/3+vYolPplCS3bbEaJf+Bj0Gw4DhP3ioAflBb1flcRt9zsWITyvOhM96wMQNRWlSX52DgA==",
"version": "5.84.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.84.1.tgz",
"integrity": "sha512-ZP4qaZ7vVn/K8WN/p990SGATmrL1qg4heP/MrVneczYtpDGJWlrgZv55vxaV2ul885Kz+25MP2kSXkPe3LZfmg==",
"dev": true,
"dependencies": {
"@types/eslint-scope": "^3.7.3",
@ -12575,10 +12575,10 @@
"@webassemblyjs/wasm-edit": "^1.11.5",
"@webassemblyjs/wasm-parser": "^1.11.5",
"acorn": "^8.7.1",
"acorn-import-assertions": "^1.7.6",
"acorn-import-assertions": "^1.9.0",
"browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.14.0",
"enhanced-resolve": "^5.14.1",
"es-module-lexer": "^1.2.1",
"eslint-scope": "5.1.1",
"events": "^3.2.0",
@ -12894,9 +12894,9 @@
"integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g=="
},
"node_modules/xml2js": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz",
"integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==",
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.0.tgz",
"integrity": "sha512-eLTh0kA8uHceqesPqSE+VvO1CDDJWMwlQfB6LuN6T8w6MaDJ8Txm8P7s5cHD0miF0V+GGTZrDQfxPZQVsur33w==",
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
@ -14362,9 +14362,9 @@
"dev": true
},
"acorn-import-assertions": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz",
"integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==",
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz",
"integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==",
"dev": true,
"requires": {}
},
@ -14900,9 +14900,9 @@
}
},
"better-sqlite3": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.3.0.tgz",
"integrity": "sha512-JTmvBZL/JLTc+3Msbvq6gK6elbU9/wVMqiudplHrVJpr7sVMR9KJrNhZAbW+RhXKlpMcuEhYkdcHa3TXKNXQ1w==",
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.4.0.tgz",
"integrity": "sha512-NmsNW1CQvqMszu/CFAJ3pLct6NEFlNfuGM6vw72KHkjOD1UDnL96XNN1BMQc1hiHo8vE2GbOWQYIpZ+YM5wrZw==",
"requires": {
"bindings": "^1.5.0",
"prebuild-install": "^7.1.0"
@ -16251,9 +16251,9 @@
}
},
"electron": {
"version": "25.0.0-beta.7",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.0.0-beta.7.tgz",
"integrity": "sha512-pNlAmEH0v3ADTUeMfDiD5u2ODTQKdhABBSkUzvmq+tMJgCbbb8SlffcmekL2fHENDxwPycaH1ld+fCMG33ce6g==",
"version": "25.0.0-beta.8",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.0.0-beta.8.tgz",
"integrity": "sha512-o3X0pkg1PyR/yawlSJzTXrh5GG8sH7jjtOzr74f0Zb4PnInzI3MIr8NopyhcGCW0JmOwFu+DLZX4bDlaLmtyGQ==",
"requires": {
"@electron/get": "^2.0.0",
"@types/node": "^18.11.18",
@ -16753,9 +16753,9 @@
}
},
"enhanced-resolve": {
"version": "5.14.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.0.tgz",
"integrity": "sha512-+DCows0XNwLDcUhbFJPdlQEVnT2zXlCv7hPxemTz86/O+B/hCQ+mb7ydkPKiflpVraqLPCAfu7lDy+hBXueojw==",
"version": "5.14.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz",
"integrity": "sha512-Vklwq2vDKtl0y/vtwjSesgJ5MYS7Etuk5txS8VdKL4AOS1aUlD96zqIfsOSLQsdv3xgMRbtkWM8eG9XDfKUPow==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.4",
@ -18343,18 +18343,18 @@
}
},
"http-proxy-agent": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-6.1.0.tgz",
"integrity": "sha512-75t5ACHLOMnz/KsDAS4BdHx4J0sneT/HW+Sz070NR+n7RZ7SmYXYn2FXq6D0XwQid8hYgRVf6HZJrYuGzaEqtw==",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz",
"integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==",
"requires": {
"agent-base": "^7.0.2",
"agent-base": "^7.1.0",
"debug": "^4.3.4"
},
"dependencies": {
"agent-base": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.0.2.tgz",
"integrity": "sha512-k2/tQ1+8Zf50dEUJWklUP80LcE/+Ph+OJ6cf2Ff2fD/c/TtCe6ofnCoNMz9UnyxOQYlaAALZtEWETzn+1JjfHg==",
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz",
"integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==",
"requires": {
"debug": "^4.3.4"
}
@ -18381,9 +18381,9 @@
}
},
"https-proxy-agent": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-6.2.0.tgz",
"integrity": "sha512-4xhCnMpxR9fupa7leh9uJK2P/qjYIeaM9uZ9c1bi1JDSwX2VH9NDk/oKSToNX4gBKa2WT31Mldne7e26ckohLQ==",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.0.tgz",
"integrity": "sha512-0euwPCRyAPSgGdzD1IVN9nJYHtBhJwb6XPfbpQcYbPCwrBidX6GzxmchnaF4sfF/jPb74Ojx5g4yTg3sixlyPw==",
"requires": {
"agent-base": "^7.0.2",
"debug": "4"
@ -19077,9 +19077,9 @@
}
},
"jsdom": {
"version": "22.0.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.0.0.tgz",
"integrity": "sha512-p5ZTEb5h+O+iU02t0GfEjAnkdYPrQSkfuTSMkMYyIoMvUNEHsbG0bHHbfXIcfTqD2UfvjQX7mmgiFsyRwGscVw==",
"version": "22.1.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.1.0.tgz",
"integrity": "sha512-/9AVW7xNbsBv6GfWho4TTNjEo9fe6Zhf9O7s0Fhhr3u+awPwAJMKwAMXnkk5vBxflqLW9hTHX/0cs+P3gW+cQw==",
"requires": {
"abab": "^2.0.6",
"cssstyle": "^3.0.0",
@ -22556,9 +22556,9 @@
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g=="
},
"webpack": {
"version": "5.83.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.83.1.tgz",
"integrity": "sha512-TNsG9jDScbNuB+Lb/3+vYolPplCS3bbEaJf+Bj0Gw4DhP3ioAflBb1flcRt9zsWITyvOhM96wMQNRWlSX52DgA==",
"version": "5.84.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.84.1.tgz",
"integrity": "sha512-ZP4qaZ7vVn/K8WN/p990SGATmrL1qg4heP/MrVneczYtpDGJWlrgZv55vxaV2ul885Kz+25MP2kSXkPe3LZfmg==",
"dev": true,
"requires": {
"@types/eslint-scope": "^3.7.3",
@ -22567,10 +22567,10 @@
"@webassemblyjs/wasm-edit": "^1.11.5",
"@webassemblyjs/wasm-parser": "^1.11.5",
"acorn": "^8.7.1",
"acorn-import-assertions": "^1.7.6",
"acorn-import-assertions": "^1.9.0",
"browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.14.0",
"enhanced-resolve": "^5.14.1",
"es-module-lexer": "^1.2.1",
"eslint-scope": "5.1.1",
"events": "^3.2.0",
@ -22786,9 +22786,9 @@
"integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g=="
},
"xml2js": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz",
"integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==",
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.0.tgz",
"integrity": "sha512-eLTh0kA8uHceqesPqSE+VvO1CDDJWMwlQfB6LuN6T8w6MaDJ8Txm8P7s5cHD0miF0V+GGTZrDQfxPZQVsur33w==",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"

View File

@ -37,7 +37,7 @@
"archiver": "5.3.1",
"async-mutex": "0.4.0",
"axios": "1.4.0",
"better-sqlite3": "8.3.0",
"better-sqlite3": "8.4.0",
"chokidar": "3.5.3",
"cls-hooked": "4.2.2",
"commonmark": "0.30.0",
@ -60,15 +60,15 @@
"helmet": "7.0.0",
"html": "1.0.0",
"html2plaintext": "2.1.4",
"http-proxy-agent": "6.1.0",
"https-proxy-agent": "6.2.0",
"http-proxy-agent": "7.0.0",
"https-proxy-agent": "7.0.0",
"image-type": "4.1.0",
"ini": "3.0.1",
"is-animated": "2.0.2",
"is-svg": "4.3.2",
"jimp": "0.22.8",
"joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.0.0",
"jsdom": "22.1.0",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.40.0",
@ -97,7 +97,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.0.0-beta.7",
"electron": "25.0.0-beta.8",
"electron-builder": "23.6.0",
"electron-packager": "17.1.1",
"electron-rebuild": "3.2.9",

View File

@ -77,6 +77,7 @@ class BAttachment extends AbstractBeccaEntity {
});
}
/** @returns {BNote} */
getNote() {
return this.becca.notes[this.parentId];
}

View File

@ -1116,6 +1116,8 @@ class BNote extends AbstractBeccaEntity {
/** @returns {BAttachment[]} */
getAttachments(opts = {}) {
opts.includeContentLength = !!opts.includeContentLength;
// from testing it looks like calculating length does not make a difference in performance even on large-ish DB
// given that we're always fetching attachments only for a specific note, we might just do it always
const query = opts.includeContentLength
? `SELECT attachments.*, LENGTH(blobs.content) AS contentLength

View File

@ -231,8 +231,7 @@ class FNote {
/** @returns {Promise<FAttachment[]>} */
async getAttachments() {
if (!this.attachments) {
this.attachments = (await server.get(`notes/${this.noteId}/attachments`))
.map(row => new FAttachment(froca, row));
this.attachments = await this.froca.getAttachmentsForNote(this.noteId);
}
return this.attachments;

View File

@ -20,7 +20,7 @@ async function renderAttribute(attribute, renderIsInheritable) {
// when the relation has just been created, then it might not have a value
if (attribute.value) {
$attr.append(document.createTextNode(`~${attribute.name}${isInheritable}=`));
$attr.append(await createNoteLink(attribute.value));
$attr.append(await createLink(attribute.value));
}
} else {
ws.logError(`Unknown attr type: ${attribute.type}`);
@ -47,7 +47,7 @@ function formatValue(val) {
}
}
async function createNoteLink(noteId) {
async function createLink(noteId) {
const note = await froca.getNote(noteId);
if (!note) {

View File

@ -71,7 +71,7 @@ async function copy(branchIds) {
const links = [];
for (const branch of froca.getBranches(clipboardBranchIds)) {
const $link = await linkService.createNoteLink(`${branch.parentNoteId}/${branch.noteId}`, { referenceLink: true });
const $link = await linkService.createLink(`${branch.parentNoteId}/${branch.noteId}`, { referenceLink: true });
links.push($link[0].outerHTML);
}

View File

@ -100,9 +100,7 @@ async function renderText(note, options, $renderedContent) {
await froca.getNotes(noteIdsToPrefetch);
for (const el of referenceLinks) {
const noteId = getNoteIdFromLink(el);
await linkService.loadReferenceLinkTitle(noteId, $(el));
await linkService.loadReferenceLinkTitle($(el));
}
} else {
await renderChildrenList($renderedContent, note);
@ -146,15 +144,6 @@ function renderFile(entity, type, $renderedContent) {
throw new Error(`Can't recognize entity type of '${entity}'`);
}
const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>');
const $openButton = $('<button class="file-open btn btn-primary" type="button">Open</button>');
$downloadButton.on('click', () => openService.downloadFileNote(entity.noteId));
$openButton.on('click', () => openService.openNoteExternally(entity.noteId, entity.mime));
// open doesn't work for protected notes since it works through a browser which isn't in protected session
$openButton.toggle(!entity.isProtected);
const $content = $('<div style="display: flex; flex-direction: column; height: 100%;">');
if (type === 'pdf') {
@ -178,11 +167,23 @@ function renderFile(entity, type, $renderedContent) {
$content.append($videoPreview);
}
$content.append(
$('<div style="display: flex; justify-content: space-evenly; margin-top: 5px;">')
.append($downloadButton)
.append($openButton)
);
if (entityType === 'notes') {
// TODO: we should make this available also for attachments, but there's a problem with "Open externally" support
// in attachment list
const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>');
const $openButton = $('<button class="file-open btn btn-primary" type="button">Open</button>');
$downloadButton.on('click', () => openService.downloadFileNote(entity.noteId));
$openButton.on('click', () => openService.openNoteExternally(entity.noteId, entity.mime));
// open doesn't work for protected notes since it works through a browser which isn't in protected session
$openButton.toggle(!entity.isProtected);
$content.append(
$('<div style="display: flex; justify-content: space-evenly; margin-top: 5px;">')
.append($downloadButton)
.append($openButton)
);
}
$renderedContent.append($content);
}
@ -253,7 +254,7 @@ async function renderChildrenList($renderedContent, note) {
const childNotes = await froca.getNotes(childNoteIds);
for (const childNote of childNotes) {
$renderedContent.append(await linkService.createNoteLink(`${note.noteId}/${childNote.noteId}`, {
$renderedContent.append(await linkService.createLink(`${note.noteId}/${childNote.noteId}`, {
showTooltip: false,
showNoteIcon: true
}));

View File

@ -314,10 +314,45 @@ class Froca {
return child.parentToBranch[parentNoteId];
}
/** @returns {Promise<FAttachment>} */
async getAttachment(attachmentId) {
const attachmentRow = await server.get(`attachments/${attachmentId}`);
const attachment = this.attachments[attachmentId];
if (attachment) {
return attachment;
}
return attachmentRow ? new FAttachment(this, attachmentRow) : null;
// load all attachments for the given note even if one is requested, don't load one by one
const attachmentRows = await server.get(`attachments/${attachmentId}/all`);
const attachments = this.processAttachmentRows(attachmentRows);
if (attachments.length) {
attachments[0].getNote().attachments = attachments;
}
return this.attachments[attachmentId];
}
/** @returns {Promise<FAttachment[]>} */
async getAttachmentsForNote(noteId) {
const attachmentRows = await server.get(`notes/${noteId}/attachments`);
return this.processAttachmentRows(attachmentRows);
}
/** @returns {FAttachment[]} */
processAttachmentRows(attachmentRows) {
return attachmentRows.map(attachmentRow => {
let attachment;
if (attachmentRow.attachmentId in this.attachments) {
attachment = this.attachments[attachmentRow.attachmentId];
attachment.update(attachmentRow);
} else {
attachment = new FAttachment(this, attachmentRow);
this.attachments[attachment.attachmentId] = attachment;
}
return attachment;
});
}
/** @returns {Promise<FBlob>} */

View File

@ -269,7 +269,7 @@ function processAttachment(loadResults, ec) {
} else {
const note = froca.notes[ec.entity.parentId];
if (note && note.attachments) {
if (note?.attachments) {
note.attachments.push(new FAttachment(froca, ec.entity));
}
}

View File

@ -217,7 +217,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* Returns list of notes. If note is missing from the cache, it's loaded.
*
* This is often used to bulk-fill the cache with notes which would have to be picked one by one
* otherwise (by e.g. createNoteLink())
* otherwise (by e.g. createLink())
*
* @method
* @param {string[]} noteIds
@ -302,7 +302,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {boolean} [params.showNoteIcon=false] - show also note icon before the title
* @param {string} [params.title=] - custom link tile with note's title as default
*/
this.createNoteLink = linkService.createNoteLink;
this.createLink = linkService.createLink;
/**
* Adds given text to the editor cursor

View File

@ -10,7 +10,7 @@ function getNotePathFromUrl(url) {
return notePathMatch === null ? null : notePathMatch[1];
}
async function createNoteLink(notePath, options = {}) {
async function createLink(notePath, options = {}) {
if (!notePath || !notePath.trim()) {
logError("Missing note path");
@ -29,26 +29,50 @@ async function createNoteLink(notePath, options = {}) {
const referenceLink = options.referenceLink === undefined ? false : options.referenceLink;
const { noteId, parentNoteId } = treeService.getNoteIdAndParentIdFromNotePath(notePath);
const noteTitle = options.title || await treeService.getNoteTitle(noteId, parentNoteId);
const viewScope = options.viewScope || {};
const viewMode = viewScope.viewMode || 'default';
let linkTitle = options.title;
if (!linkTitle) {
if (viewMode === 'attachments' && viewScope.attachmentId) {
const attachment = await froca.getAttachment(viewScope.attachmentId);
linkTitle = attachment ? attachment.title : '[missing attachment]';
} else {
linkTitle = await treeService.getNoteTitle(noteId, parentNoteId);
}
}
const $container = $("<span>");
if (showNoteIcon) {
const note = await froca.getNote(noteId);
let icon;
$container
.append($("<span>").addClass(`bx ${note.getIcon()}`))
.append(" ");
if (viewMode === 'default') {
const note = await froca.getNote(noteId);
icon = note.getIcon();
} else if (viewMode === 'source') {
icon = 'bx-code-curly';
} else if (viewMode === 'attachments') {
icon = 'bx-file';
}
if (icon) {
$container
.append($("<span>").addClass(`bx ${icon}`))
.append(" ");
}
}
const hash = calculateHash({
notePath,
viewScope: options.viewScope
viewScope: viewScope
});
const $noteLink = $("<a>", {
href: hash,
text: noteTitle
text: linkTitle
});
if (!showTooltip) {
@ -228,7 +252,14 @@ function linkContextMenu(e) {
linkContextMenuService.openContextMenu(notePath, e, viewScope, null);
}
async function loadReferenceLinkTitle(noteId, $el) {
async function loadReferenceLinkTitle($el) {
const url = $el.attr("href");
if (!url) {
console.warn("Empty URL for parsing");
return;
}
const {noteId} = parseNavigationStateFromUrl(url);
const note = await froca.getNote(noteId, true);
let title;
@ -279,7 +310,7 @@ $(document).on('mousedown', 'a', e => {
export default {
getNotePathFromUrl,
createNoteLink,
createLink,
goToLink,
loadReferenceLinkTitle,
calculateHash,

View File

@ -284,7 +284,7 @@ class NoteListRenderer {
.append($('<span class="note-icon">').addClass(note.getIcon()))
.append(this.viewType === 'grid'
? $('<span class="note-book-title">').text(note.title)
: (await linkService.createNoteLink(notePath, {showTooltip: false, showNotePath: this.showNotePath}))
: (await linkService.createLink(notePath, {showTooltip: false, showNotePath: this.showNotePath}))
.addClass("note-book-title")
)
.append($renderedAttributes)

View File

@ -513,6 +513,15 @@ function areObjectsEqual () {
return true;
}
function copyHtmlToClipboard(content) {
const clipboardItem = new ClipboardItem({
'text/html': new Blob([content], {type: 'text/html'}),
'text/plain': new Blob([content], {type: 'text/plain'})
});
navigator.clipboard.write([clipboardItem]);
}
export default {
reloadFrontendApp,
parseDate,
@ -558,5 +567,6 @@ export default {
isValidAttributeName,
sleep,
escapeRegExp,
areObjectsEqual
areObjectsEqual,
copyHtmlToClipboard
};

View File

@ -6,6 +6,7 @@ import options from "../services/options.js";
import imageService from "../services/image.js";
import linkService from "../services/link.js";
import contentRenderer from "../services/content_renderer.js";
import toastService from "../services/toast.js";
const TPL = `
<div class="attachment-detail-widget">
@ -126,7 +127,7 @@ export default class AttachmentDetailWidget extends BasicWidget {
if (!this.isFullDetail) {
this.$wrapper.find('.attachment-title').append(
await linkService.createNoteLink(this.attachment.parentId, {
await linkService.createLink(this.attachment.parentId, {
title: this.attachment.title,
viewScope: {
viewMode: 'attachments',
@ -174,16 +175,20 @@ export default class AttachmentDetailWidget extends BasicWidget {
if (this.attachment.role === 'image') {
imageService.copyImageReferenceToClipboard(this.$wrapper.find('.attachment-content-wrapper'));
} else if (this.attachment.role === 'file') {
const $link = await linkService.createNoteLink(this.attachment.parentId, {
const $link = await linkService.createLink(this.attachment.parentId, {
referenceLink: true,
viewScope: {
viewMode: 'attachments',
attachmentId: this.attachment.attachmentId
}
});
utils.copyHtmlToClipboard($link[0].outerHTML);
} else {
throw new Error(`Unrecognized attachment role '${this.attachment.role}'.`);
}
toastService.showMessage("Attachment link copied to clipboard.");
}
async entitiesReloadedEvent({loadResults}) {

View File

@ -437,7 +437,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
.empty()
.append(attribute.type === 'label' ? 'Label' : 'Relation')
.append(' is owned by note ')
.append(await linkService.createNoteLink(attribute.noteId))
.append(await linkService.createLink(attribute.noteId))
}
this.$inputName
@ -602,7 +602,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
for (const note of displayedNotes) {
const notePath = note.getBestNotePathString(hoistedNoteId);
const $noteLink = await linkService.createNoteLink(notePath, {showNotePath: true});
const $noteLink = await linkService.createLink(notePath, {showNotePath: true});
this.$relatedNotesList.append(
$("<li>").append($noteLink)
@ -699,7 +699,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
this.toggleInt(false);
}
createNoteLink(noteId) {
createLink(noteId) {
return $("<a>", {
href: `#root/${noteId}`,
class: 'reference-link'

View File

@ -2,12 +2,13 @@ import NoteContextAwareWidget from "../note_context_aware_widget.js";
import noteAutocompleteService from "../../services/note_autocomplete.js";
import server from "../../services/server.js";
import contextMenuService from "../../menus/context_menu.js";
import attributesParser from "../../services/attribute_parser.js";
import attributeParser from "../../services/attribute_parser.js";
import libraryLoader from "../../services/library_loader.js";
import froca from "../../services/froca.js";
import attributeRenderer from "../../services/attribute_renderer.js";
import noteCreateService from "../../services/note_create.js";
import attributeService from "../../services/attributes.js";
import linkService from "../../services/link.js";
const HELP_TEXT = `
<p>To add label, just type e.g. <code>#rock</code> or if you want to add also value then e.g. <code>#year = 2020</code></p>
@ -321,7 +322,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {
parseAttributes() {
try {
return attributesParser.lexAndParse(this.getPreprocessedData());
return attributeParser.lexAndParse(this.getPreprocessedData());
}
catch (e) {
this.$errors.text(e.message).slideDown();
@ -385,7 +386,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {
let parsedAttrs;
try {
parsedAttrs = attributesParser.lexAndParse(this.getPreprocessedData(), true);
parsedAttrs = attributeParser.lexAndParse(this.getPreprocessedData(), true);
}
catch (e) {
// the input is incorrect because user messed up with it and now needs to fix it manually
@ -455,7 +456,8 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {
return clickIndex;
}
async loadReferenceLinkTitle(noteId, $el) {
async loadReferenceLinkTitle($el) {
const {noteId} = linkService.parseNavigationStateFromUrl($el.attr("href"));
const note = await froca.getNote(noteId, true);
let title;

View File

@ -56,7 +56,6 @@ export default class AttachmentActionsWidget extends BasicWidget {
doRender() {
this.$widget = $(TPL);
this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));
this.$widget.find("[data-trigger-command='copyAttachmentLinkToClipboard']").toggle(this.attachment.role === 'image');
this.$uploadNewRevisionInput = this.$widget.find(".attachment-upload-new-revision-input");
this.$uploadNewRevisionInput.on('change', async () => {

View File

@ -66,7 +66,7 @@ export default class BookmarkFolderWidget extends RightDropdownButtonWidget {
};
this.$parentNote.append(
(await linkService.createNoteLink(this.note.noteId, linkOptions))
(await linkService.createLink(this.note.noteId, linkOptions))
.addClass("note-link")
);
@ -74,7 +74,7 @@ export default class BookmarkFolderWidget extends RightDropdownButtonWidget {
this.$childrenNotes.append(
$("<li>")
.append(
(await linkService.createNoteLink(childNote.noteId, linkOptions))
(await linkService.createLink(childNote.noteId, linkOptions))
.addClass("note-link")
)
);

View File

@ -120,7 +120,7 @@ export default class DeleteNotesDialog extends BasicWidget {
for (const note of await froca.getNotes(response.noteIdsToBeDeleted)) {
this.$deleteNotesList.append(
$("<li>").append(
await linkService.createNoteLink(note.noteId, {showNotePath: true})
await linkService.createLink(note.noteId, {showNotePath: true})
)
);
}
@ -136,9 +136,9 @@ export default class DeleteNotesDialog extends BasicWidget {
this.$brokenRelationsList.append(
$("<li>")
.append(`Note `)
.append(await linkService.createNoteLink(attr.value))
.append(await linkService.createLink(attr.value))
.append(` (to be deleted) is referenced by relation <code>${attr.name}</code> originating from `)
.append(await linkService.createNoteLink(attr.noteId))
.append(await linkService.createLink(attr.noteId))
);
}
}

View File

@ -110,7 +110,7 @@ export default class RecentChangesDialog extends BasicWidget {
const notePath = note.getBestNotePathString();
if (notePath) {
$noteLink = await linkService.createNoteLink(notePath, {
$noteLink = await linkService.createLink(notePath, {
title: change.title,
showNotePath: true
});

View File

@ -131,7 +131,7 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
for (const backlink of backlinks) {
const $item = $("<div>");
$item.append(await linkService.createNoteLink(backlink.noteId, {
$item.append(await linkService.createLink(backlink.noteId, {
showNoteIcon: true,
showNotePath: true,
showTooltip: false

View File

@ -396,11 +396,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}));
if (notes.length === 1) {
linkService.createNoteLink(notes[0].noteId, {referenceLink: true})
linkService.createLink(notes[0].noteId, {referenceLink: true})
.then($link => data.dataTransfer.setData("text/html", $link[0].outerHTML));
}
else {
Promise.all(notes.map(note => linkService.createNoteLink(note.noteId, {referenceLink: true}))).then(links => {
Promise.all(notes.map(note => linkService.createLink(note.noteId, {referenceLink: true}))).then(links => {
const $list = $("<ul>").append(...links.map($link => $("<li>").append($link)));
data.dataTransfer.setData("text/html", $list[0].outerHTML);

View File

@ -121,7 +121,7 @@ export default class QuickSearchWidget extends BasicWidget {
}
for (const note of await froca.getNotes(displayedNoteIds)) {
const $link = await linkService.createNoteLink(note.noteId, {showNotePath: true});
const $link = await linkService.createLink(note.noteId, {showNotePath: true});
$link.addClass('dropdown-item');
$link.attr("tabIndex", "0");
$link.on('click', e => {

View File

@ -78,7 +78,7 @@ export default class EditedNotesWidget extends NoteContextAwareWidget {
}
else {
$item.append(editedNote.notePath
? await linkService.createNoteLink(editedNote.notePath.join("/"), {showNotePath: true})
? await linkService.createLink(editedNote.notePath.join("/"), {showNotePath: true})
: $("<span>").text(editedNote.title));
}

View File

@ -96,7 +96,7 @@ export default class NotePathsWidget extends NoteContextAwareWidget {
async getRenderedPath(notePath, notePathRecord = null) {
const title = await treeService.getNotePathTitle(notePath);
const $noteLink = await linkService.createNoteLink(notePath, {title});
const $noteLink = await linkService.createLink(notePath, {title});
$noteLink
.find('a')

View File

@ -85,7 +85,7 @@ export default class SimilarNotesWidget extends NoteContextAwareWidget {
continue;
}
const $item = (await linkService.createNoteLink(similarNote.notePath.join("/")))
const $item = (await linkService.createLink(similarNote.notePath.join("/")))
.css("font-size", 24 * (1 - 1 / (1 + similarNote.score)));
$list.append($item);

View File

@ -77,7 +77,7 @@ export default class AbstractTextTypeWidget extends TypeWidget {
if (note) {
const $wrapper = $('<div class="include-note-wrapper">');
const $link = await linkService.createNoteLink(note.noteId, {
const $link = await linkService.createLink(note.noteId, {
showTooltip: false
});
@ -97,8 +97,48 @@ export default class AbstractTextTypeWidget extends TypeWidget {
}
}
async loadReferenceLinkTitle(noteId, $el) {
await linkService.loadReferenceLinkTitle(noteId, $el);
async loadReferenceLinkTitle($el) {
await linkService.loadReferenceLinkTitle($el);
}
async getReferenceLinkTitle(href) {
const {noteId, viewScope} = linkService.parseNavigationStateFromUrl(href);
if (!noteId) {
return "[missing note]";
}
const note = await froca.getNote(noteId);
if (!note) {
return "[missing note]";
}
if (viewScope?.viewMode === 'attachments' && viewScope?.attachmentId) {
const attachment = await note.getAttachmentById(viewScope.attachmentId);
return attachment ? attachment.title : "[missing attachment]";
} else {
return note.title;
}
}
getReferenceLinkTitleSync(href) {
const {noteId, viewScope} = linkService.parseNavigationStateFromUrl(href);
if (!noteId) {
return "[missing note]";
}
const note = froca.getNoteFromCache(noteId);
if (!note) {
return "[missing note]";
}
if (viewScope?.viewMode === 'attachments' && viewScope?.attachmentId) {
const attachment = note.attachments[viewScope.attachmentId];
return attachment ? attachment.title : "[missing attachment]";
} else {
return note.title;
}
}
refreshIncludedNote($container, noteId) {

View File

@ -47,9 +47,9 @@ export default class AttachmentDetailTypeWidget extends TypeWidget {
this.$linksWrapper.append(
"Owning note: ",
await linkService.createNoteLink(this.noteId),
await linkService.createLink(this.noteId),
", you can also open the ",
await linkService.createNoteLink(this.noteId, {
await linkService.createLink(this.noteId, {
title: 'List of all attachments',
viewScope: {
viewMode: 'attachments'

View File

@ -40,7 +40,7 @@ export default class AttachmentListTypeWidget extends TypeWidget {
this.$linksWrapper.append(
$('<div>').append(
"Owning note: ",
await linkService.createNoteLink(this.noteId),
await linkService.createLink(this.noteId),
),
$('<button class="btn btn-xs">')
.text("Upload attachments")

View File

@ -97,10 +97,7 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
this.$content.html(blob.content);
this.$content.find("a.reference-link").each(async (_, el) => {
const notePath = $(el).attr('href');
const noteId = treeService.getNoteIdFromNotePath(notePath);
this.loadReferenceLinkTitle(noteId, $(el));
this.loadReferenceLinkTitle($(el));
});
this.$content.find("section").each(async (_, el) => {

View File

@ -469,7 +469,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
}
async createNoteBox(noteId, title, x, y) {
const $link = await linkService.createNoteLink(noteId, {title});
const $link = await linkService.createLink(noteId, {title});
$link.mousedown(e => linkService.goToLink(e));
const note = await froca.getNote(noteId);

View File

@ -19,6 +19,14 @@ function getAttachment(req) {
return becca.getAttachmentOrThrow(attachmentId, {includeContentLength: true});
}
function getAllAttachments(req) {
const {attachmentId} = req.params;
// one particular attachment is requested, but return all note's attachments
const attachment = becca.getAttachmentOrThrow(attachmentId);
return attachment.getNote()?.getAttachments({includeContentLength: true}) || [];
}
function saveAttachment(req) {
const {noteId} = req.params;
const {attachmentId, role, mime, title, content} = req.body;
@ -48,6 +56,7 @@ module.exports = {
getAttachmentBlob,
getAttachments,
getAttachment,
getAllAttachments,
saveAttachment,
deleteAttachment,
convertAttachmentToNote

View File

@ -153,6 +153,7 @@ function register(app) {
apiRoute(GET, '/api/notes/:noteId/attachments', attachmentsApiRoute.getAttachments);
apiRoute(PST, '/api/notes/:noteId/attachments', attachmentsApiRoute.saveAttachment);
apiRoute(GET, '/api/attachments/:attachmentId', attachmentsApiRoute.getAttachment);
apiRoute(GET, '/api/attachments/:attachmentId/all', attachmentsApiRoute.getAllAttachments);
apiRoute(PST, '/api/attachments/:attachmentId/convert-to-note', attachmentsApiRoute.convertAttachmentToNote);
apiRoute(DEL, '/api/attachments/:attachmentId', attachmentsApiRoute.deleteAttachment);
apiRoute(GET, '/api/attachments/:attachmentId/blob', attachmentsApiRoute.getAttachmentBlob);