mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 05:56:03 +08:00
Merge remote-tracking branch 'origin/stable' into stable
This commit is contained in:
commit
f50bb2278c
12 changed files with 176 additions and 132 deletions
|
@ -5,8 +5,8 @@
|
|||
}
|
||||
|
||||
/*
|
||||
* CKEditor 5 (v24.0.0) content styles.
|
||||
* Generated on Thu, 10 Dec 2020 08:15:26 GMT.
|
||||
* CKEditor 5 (v27.1.0) content styles.
|
||||
* Generated on Wed, 21 Apr 2021 07:00:21 GMT.
|
||||
* For more information, check out https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/content-styles.html
|
||||
*/
|
||||
|
||||
|
@ -23,66 +23,6 @@
|
|||
--ck-todo-list-checkmark-size: 16px;
|
||||
}
|
||||
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized {
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized img {
|
||||
width: 100%;
|
||||
}
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized > figcaption {
|
||||
display: block;
|
||||
}
|
||||
/* 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 */
|
||||
.ck-content .image-style-align-left {
|
||||
float: left;
|
||||
margin-right: var(--ck-image-style-spacing);
|
||||
}
|
||||
/* ckeditor5-image/theme/imagestyle.css */
|
||||
.ck-content .image-style-align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagestyle.css */
|
||||
.ck-content .image-style-align-right {
|
||||
float: right;
|
||||
margin-left: var(--ck-image-style-spacing);
|
||||
}
|
||||
/* ckeditor5-image/theme/image.css */
|
||||
.ck-content .image {
|
||||
display: table;
|
||||
clear: both;
|
||||
text-align: center;
|
||||
margin: 1em auto;
|
||||
}
|
||||
/* ckeditor5-image/theme/image.css */
|
||||
.ck-content .image img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
min-width: 50px;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagecaption.css */
|
||||
.ck-content .image > figcaption {
|
||||
display: table-caption;
|
||||
caption-side: bottom;
|
||||
word-break: break-word;
|
||||
color: hsl(0, 0%, 20%);
|
||||
background-color: hsl(0, 0%, 97%);
|
||||
padding: .6em;
|
||||
font-size: .75em;
|
||||
outline-offset: -1px;
|
||||
}
|
||||
/* ckeditor5-highlight/theme/highlight.css */
|
||||
.ck-content .marker-yellow {
|
||||
background-color: var(--ck-highlight-marker-yellow);
|
||||
|
@ -125,6 +65,109 @@
|
|||
.ck-content .text-huge {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
/* 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 */
|
||||
.ck-content .image-style-align-left {
|
||||
float: left;
|
||||
margin-right: var(--ck-image-style-spacing);
|
||||
}
|
||||
/* ckeditor5-image/theme/imagestyle.css */
|
||||
.ck-content .image-style-align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagestyle.css */
|
||||
.ck-content .image-style-align-right {
|
||||
float: right;
|
||||
margin-left: var(--ck-image-style-spacing);
|
||||
}
|
||||
/* ckeditor5-code-block/theme/codeblock.css */
|
||||
.ck-content pre {
|
||||
padding: 1em;
|
||||
color: hsl(0, 0%, 20.8%);
|
||||
background: hsla(0, 0%, 78%, 0.3);
|
||||
border: 1px solid hsl(0, 0%, 77%);
|
||||
border-radius: 2px;
|
||||
text-align: left;
|
||||
direction: ltr;
|
||||
tab-size: 4;
|
||||
white-space: pre-wrap;
|
||||
font-style: normal;
|
||||
min-width: 200px;
|
||||
}
|
||||
/* ckeditor5-code-block/theme/codeblock.css */
|
||||
.ck-content pre code {
|
||||
background: unset;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
/* ckeditor5-html-embed/theme/htmlembed.css */
|
||||
.ck-content .raw-html-embed {
|
||||
margin: 1em auto;
|
||||
min-width: 15em;
|
||||
font-style: normal;
|
||||
}
|
||||
/* ckeditor5-horizontal-line/theme/horizontalline.css */
|
||||
.ck-content hr {
|
||||
margin: 15px 0;
|
||||
height: 4px;
|
||||
background: hsl(0, 0%, 87%);
|
||||
border: 0;
|
||||
}
|
||||
/* ckeditor5-image/theme/imagecaption.css */
|
||||
.ck-content .image > figcaption {
|
||||
display: table-caption;
|
||||
caption-side: bottom;
|
||||
word-break: break-word;
|
||||
color: hsl(0, 0%, 20%);
|
||||
background-color: hsl(0, 0%, 97%);
|
||||
padding: .6em;
|
||||
font-size: .75em;
|
||||
outline-offset: -1px;
|
||||
}
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized {
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized img {
|
||||
width: 100%;
|
||||
}
|
||||
/* ckeditor5-image/theme/imageresize.css */
|
||||
.ck-content .image.image_resized > figcaption {
|
||||
display: block;
|
||||
}
|
||||
/* ckeditor5-image/theme/image.css */
|
||||
.ck-content .image {
|
||||
display: table;
|
||||
clear: both;
|
||||
text-align: center;
|
||||
margin: 1em auto;
|
||||
}
|
||||
/* ckeditor5-image/theme/image.css */
|
||||
.ck-content .image img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
min-width: 50px;
|
||||
}
|
||||
/* ckeditor5-language/theme/language.css */
|
||||
.ck-content span[lang] {
|
||||
font-style: italic;
|
||||
}
|
||||
/* ckeditor5-basic-styles/theme/code.css */
|
||||
.ck-content code {
|
||||
background-color: hsla(0, 0%, 78%, 0.3);
|
||||
padding: .15em;
|
||||
border-radius: 2px;
|
||||
}
|
||||
/* ckeditor5-block-quote/theme/blockquote.css */
|
||||
.ck-content blockquote {
|
||||
overflow: hidden;
|
||||
|
@ -140,12 +183,6 @@
|
|||
border-left: 0;
|
||||
border-right: solid 5px hsl(0, 0%, 80%);
|
||||
}
|
||||
/* ckeditor5-basic-styles/theme/code.css */
|
||||
.ck-content code {
|
||||
background-color: hsla(0, 0%, 78%, 0.3);
|
||||
padding: .15em;
|
||||
border-radius: 2px;
|
||||
}
|
||||
/* ckeditor5-table/theme/table.css */
|
||||
.ck-content .table {
|
||||
margin: 1em auto;
|
||||
|
@ -289,39 +326,6 @@
|
|||
.ck-content .todo-list .todo-list__label .todo-list__label__description {
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* ckeditor5-html-embed/theme/htmlembed.css */
|
||||
.ck-content .raw-html-embed {
|
||||
margin: 1em auto;
|
||||
min-width: 15em;
|
||||
font-style: normal;
|
||||
}
|
||||
/* ckeditor5-horizontal-line/theme/horizontalline.css */
|
||||
.ck-content hr {
|
||||
margin: 15px 0;
|
||||
height: 4px;
|
||||
background: hsl(0, 0%, 87%);
|
||||
border: 0;
|
||||
}
|
||||
/* ckeditor5-code-block/theme/codeblock.css */
|
||||
.ck-content pre {
|
||||
padding: 1em;
|
||||
color: hsl(0, 0%, 20.8%);
|
||||
background: hsla(0, 0%, 78%, 0.3);
|
||||
border: 1px solid hsl(0, 0%, 77%);
|
||||
border-radius: 2px;
|
||||
text-align: left;
|
||||
direction: ltr;
|
||||
tab-size: 4;
|
||||
white-space: pre-wrap;
|
||||
font-style: normal;
|
||||
min-width: 200px;
|
||||
}
|
||||
/* ckeditor5-code-block/theme/codeblock.css */
|
||||
.ck-content pre code {
|
||||
background: unset;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
/* ckeditor5-mention/theme/mention.css */
|
||||
.ck-content .mention {
|
||||
background: var(--ck-color-mention-background);
|
||||
|
|
2
libraries/ckeditor/ckeditor.js
vendored
2
libraries/ckeditor/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
18
package-lock.json
generated
18
package-lock.json
generated
|
@ -2898,9 +2898,9 @@
|
|||
}
|
||||
},
|
||||
"electron": {
|
||||
"version": "13.0.0-beta.27",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-13.0.0-beta.27.tgz",
|
||||
"integrity": "sha512-Co5143QQBiUHLY8qKPbe4axGnFxFLIPbdBuKh0pMvhmsGsVbTK3mEihmhl/lBKQe36cu+gnODpvtZZ0uGsqlxA==",
|
||||
"version": "13.0.1",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-13.0.1.tgz",
|
||||
"integrity": "sha512-ds1cf0m46nStil0jbM2r9W/p+Kprdq22+2MikIUqEu69eGl1c86IinQVrpmJ9bR4RshDSF4j3uD32a0bsHDMnQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@electron/get": "^1.0.1",
|
||||
|
@ -2909,9 +2909,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "14.14.45",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.45.tgz",
|
||||
"integrity": "sha512-DssMqTV9UnnoxDWu959sDLZzfvqCF0qDNRjaWeYSui9xkFe61kKo4l1TWNTQONpuXEm+gLMRvdlzvNHBamzmEw==",
|
||||
"version": "14.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.1.tgz",
|
||||
"integrity": "sha512-/tpUyFD7meeooTRwl3sYlihx2BrJE7q9XF71EguPFIySj9B7qgnRtHsHTho+0AUm4m1SvWGm6uSncrR94q6Vtw==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
|
@ -5685,9 +5685,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node-abi": {
|
||||
"version": "2.26.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.26.0.tgz",
|
||||
"integrity": "sha512-ag/Vos/mXXpWLLAYWsAoQdgS+gW7IwvgMLOgqopm/DbzAjazLltzgzpVMsFlgmo9TzG5hGXeaBZx2AI731RIsQ==",
|
||||
"version": "2.29.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.29.0.tgz",
|
||||
"integrity": "sha512-+xu2xkzOkdVS0YAVpiF+xsYM+hM1ylmeGUaG1OC3To6+pUIL4yoCqU6ggWpZeeiq0GFPE2uUOCf36Y4iq3JnOA==",
|
||||
"requires": {
|
||||
"semver": "^5.4.1"
|
||||
},
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
"jsdom": "16.5.3",
|
||||
"mime-types": "2.1.30",
|
||||
"multer": "1.4.2",
|
||||
"node-abi": "2.26.0",
|
||||
"node-abi": "2.29.0",
|
||||
"open": "8.0.8",
|
||||
"portscanner": "2.2.0",
|
||||
"rand-token": "1.0.1",
|
||||
|
@ -80,7 +80,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "13.0.0-beta.27",
|
||||
"electron": "13.0.1",
|
||||
"electron-builder": "22.11.1",
|
||||
"electron-packager": "15.2.0",
|
||||
"electron-rebuild": "2.3.5",
|
||||
|
|
|
@ -7,7 +7,13 @@ const {LOG_DIR} = require('../../services/data_dir.js');
|
|||
function getBackendLog() {
|
||||
const file = `${LOG_DIR}/trilium-${dateUtils.localNowDate()}.log`;
|
||||
|
||||
return fs.readFileSync(file, 'utf8');
|
||||
try {
|
||||
return fs.readFileSync(file, 'utf8');
|
||||
}
|
||||
catch (e) {
|
||||
// most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -101,7 +101,12 @@ function route(method, path, middleware, routeHandler, resultHandler, transactio
|
|||
|
||||
if (resultHandler) {
|
||||
if (result && result.then) {
|
||||
result.then(actualResult => resultHandler(req, res, actualResult))
|
||||
result
|
||||
.then(actualResult => {
|
||||
resultHandler(req, res, actualResult);
|
||||
|
||||
log.request(req, res, Date.now() - start);
|
||||
})
|
||||
.catch(e => {
|
||||
log.error(`${method} ${path} threw exception: ` + e.stack);
|
||||
|
||||
|
@ -110,6 +115,8 @@ function route(method, path, middleware, routeHandler, resultHandler, transactio
|
|||
}
|
||||
else {
|
||||
resultHandler(req, res, result);
|
||||
|
||||
log.request(req, res, Date.now() - start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,8 +125,6 @@ function route(method, path, middleware, routeHandler, resultHandler, transactio
|
|||
|
||||
res.status(500).send(e.message);
|
||||
}
|
||||
|
||||
log.request(req, res, Date.now() - start);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -239,7 +244,7 @@ function register(app) {
|
|||
|
||||
// group of services below are meant to be executed from outside
|
||||
route(GET, '/api/setup/status', [], setupApiRoute.getStatus, apiResultHandler);
|
||||
route(POST, '/api/setup/new-document', [auth.checkAppNotInitialized], setupApiRoute.setupNewDocument, apiResultHandler);
|
||||
route(POST, '/api/setup/new-document', [auth.checkAppNotInitialized], setupApiRoute.setupNewDocument, apiResultHandler, false);
|
||||
route(POST, '/api/setup/sync-from-server', [auth.checkAppNotInitialized], setupApiRoute.setupSyncFromServer, apiResultHandler, false);
|
||||
route(GET, '/api/setup/sync-seed', [auth.checkCredentials], setupApiRoute.getSyncSeed, apiResultHandler);
|
||||
route(POST, '/api/setup/sync-seed', [auth.checkAppNotInitialized], setupApiRoute.saveSyncSeed, apiResultHandler, false);
|
||||
|
|
|
@ -11,7 +11,7 @@ function sanitize(dirtyHtml) {
|
|||
'figure', 'span', 'label', 'input'
|
||||
],
|
||||
allowedAttributes: {
|
||||
'a': [ 'href', 'class' ],
|
||||
'a': [ 'href', 'class', 'data-note-path' ],
|
||||
'img': [ 'src' ],
|
||||
'section': [ 'class', 'data-note-id' ],
|
||||
'figure': [ 'class' ],
|
||||
|
|
|
@ -307,6 +307,14 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
|||
return `href="#root/${targetNoteId}"`;
|
||||
});
|
||||
|
||||
content = content.replace(/data-note-path="([^"]*)"/g, (match, notePath) => {
|
||||
const noteId = notePath.split("/").pop();
|
||||
|
||||
const targetNoteId = noteIdMap[noteId];
|
||||
|
||||
return `data-note-path="root/${targetNoteId}"`;
|
||||
});
|
||||
|
||||
if (noteMeta) {
|
||||
const includeNoteLinks = (noteMeta.attributes || [])
|
||||
.filter(attr => attr.type === 'relation' && attr.name === 'includeNoteLink');
|
||||
|
|
|
@ -41,13 +41,17 @@ function initLogFile() {
|
|||
function checkDate(millisSinceMidnight) {
|
||||
if (millisSinceMidnight >= DAY) {
|
||||
initLogFile();
|
||||
|
||||
millisSinceMidnight =- DAY;
|
||||
}
|
||||
|
||||
return millisSinceMidnight;
|
||||
}
|
||||
|
||||
function log(str) {
|
||||
const millisSinceMidnight = Date.now() - todaysMidnight.getTime();
|
||||
let millisSinceMidnight = Date.now() - todaysMidnight.getTime();
|
||||
|
||||
checkDate(millisSinceMidnight);
|
||||
millisSinceMidnight = checkDate(millisSinceMidnight);
|
||||
|
||||
logFile.write(formatTime(millisSinceMidnight) + ' ' + str + NEW_LINE);
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ function initSyncedOptions(username, password) {
|
|||
passwordEncryptionService.setDataKey(password, utils.randomSecureToken(16), true);
|
||||
}
|
||||
|
||||
function initNotSyncedOptions(initialized, startNotePath = 'root', opts = {}) {
|
||||
function initNotSyncedOptions(initialized, opts = {}) {
|
||||
optionService.createOption('openTabs', JSON.stringify([
|
||||
{
|
||||
notePath: startNotePath,
|
||||
notePath: 'root',
|
||||
active: true
|
||||
}
|
||||
]), false);
|
||||
|
@ -98,7 +98,7 @@ function initStartupOptions() {
|
|||
if (!(name in optionsMap)) {
|
||||
optionService.createOption(name, value, isSynced);
|
||||
|
||||
log.info(`Created missing option "${name}" with default value "${value}"`);
|
||||
log.info(`Created option "${name}" with default value "${value}"`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ async function initDbConnection() {
|
|||
}
|
||||
|
||||
async function createInitialDatabase(username, password, theme) {
|
||||
log.info("Creating initial database ...");
|
||||
log.info("Creating database schema ...");
|
||||
|
||||
if (isDbInitialized()) {
|
||||
throw new Error("DB is already initialized");
|
||||
|
@ -58,6 +58,8 @@ async function createInitialDatabase(username, password, theme) {
|
|||
|
||||
let rootNote;
|
||||
|
||||
log.info("Creating root note ...");
|
||||
|
||||
sql.transactional(() => {
|
||||
sql.executeScript(schema);
|
||||
|
||||
|
@ -80,21 +82,36 @@ async function createInitialDatabase(username, password, theme) {
|
|||
isExpanded: true,
|
||||
notePosition: 10
|
||||
}).save();
|
||||
|
||||
const optionsInitService = require('./options_init');
|
||||
|
||||
optionsInitService.initDocumentOptions();
|
||||
optionsInitService.initSyncedOptions(username, password);
|
||||
optionsInitService.initNotSyncedOptions(true, { theme });
|
||||
optionsInitService.initStartupOptions();
|
||||
});
|
||||
|
||||
log.info("Importing demo content ...");
|
||||
|
||||
const dummyTaskContext = new TaskContext("initial-demo-import", 'import', false);
|
||||
|
||||
const zipImportService = require("./import/zip");
|
||||
await zipImportService.importZip(dummyTaskContext, demoFile, rootNote);
|
||||
|
||||
sql.transactional(() => {
|
||||
// this needs to happen after ZIP import
|
||||
// previous solution was to move option initialization here but then the important parts of initialization
|
||||
// are not all in one transaction (because ZIP import is async and thus not transactional)
|
||||
|
||||
const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
|
||||
|
||||
const optionsInitService = require('./options_init');
|
||||
|
||||
optionsInitService.initDocumentOptions();
|
||||
optionsInitService.initSyncedOptions(username, password);
|
||||
optionsInitService.initNotSyncedOptions(true, startNoteId, { theme });
|
||||
const optionService = require("./options");
|
||||
optionService.setOption('openTabs', JSON.stringify([
|
||||
{
|
||||
notePath: startNoteId,
|
||||
active: true
|
||||
}
|
||||
]));
|
||||
});
|
||||
|
||||
log.info("Schema and initial content generated.");
|
||||
|
@ -114,7 +131,7 @@ function createDatabaseForSync(options, syncServerHost = '', syncProxy = '') {
|
|||
sql.transactional(() => {
|
||||
sql.executeScript(schema);
|
||||
|
||||
require('./options_init').initNotSyncedOptions(false, 'root', { syncServerHost, syncProxy });
|
||||
require('./options_init').initNotSyncedOptions(false, { syncServerHost, syncProxy });
|
||||
|
||||
// document options required for sync to kick off
|
||||
for (const opt of options) {
|
||||
|
|
Loading…
Reference in a new issue