Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/backend_api/BAttachment.html
#	docs/backend_api/BNote.html
#	docs/backend_api/becca_entities_bnote.js.html
#	docs/frontend_api/FAttribute.html
#	docs/frontend_api/FBranch.html
#	docs/frontend_api/FNote.html
#	docs/frontend_api/FrontendScriptApi.html
#	docs/frontend_api/entities_fattachment.js.html
#	docs/frontend_api/entities_fattribute.js.html
#	docs/frontend_api/entities_fblob.js.html
#	docs/frontend_api/entities_fbranch.js.html
#	docs/frontend_api/entities_fnote.js.html
#	docs/frontend_api/global.html
#	docs/frontend_api/index.html
#	docs/frontend_api/services_frontend_script_api.js.html
#	package-lock.json
  • Loading branch information
zadam committed Sep 25, 2023
2 parents 528d94a + be91862 commit af24758
Show file tree
Hide file tree
Showing 23 changed files with 323 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ image:
file: .gitpod.dockerfile

tasks:
- before: nvm install 18.16.1 && nvm use 18.16.1
- before: nvm install 18.18.0 && nvm use 18.18.0
init: npm install
command: npm run start-server

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!!
FROM node:18.16.1-alpine
FROM node:18.18.0-alpine

# Create app directory
WORKDIR /usr/src/app
Expand Down
15 changes: 0 additions & 15 deletions bin/build-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,3 @@ echo "Packaging debian x64 distribution..."
VERSION=`jq -r ".version" package.json`

./node_modules/.bin/electron-installer-debian --config bin/deb-options.json --options.version=${VERSION} --arch amd64


# hacky stop-gag measure to produce debian compatible XZ compressed debs until this is fixed: https://github.com/electron-userland/electron-installer-debian/issues/272
cd dist
ar x trilium_${VERSION}_amd64.deb
rm trilium_${VERSION}_amd64.deb
# recompress
< control.tar.zst zstd -d | xz > control.tar.xz
< data.tar.zst zstd -d | xz > data.tar.xz
# create deb archive (I really do not know, what argument "sdsd" is for but something is required for ar to create the archive as desired)
ar -m -c -a sdsd trilium_${VERSION}_amd64.deb debian-binary control.tar.xz data.tar.xz

rm control* data* debian-binary

echo "Converted to XZ deb"
2 changes: 1 addition & 1 deletion bin/build-server.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

PKG_DIR=dist/trilium-linux-x64-server
NODE_VERSION=18.16.1
NODE_VERSION=18.18.0

if [ "$1" != "DONTCOPY" ]
then
Expand Down
4 changes: 2 additions & 2 deletions bin/copy-trilium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [[ $# -eq 0 ]] ; then
exit 1
fi

n exec 18.16.1 npm run webpack
n exec 18.18.0 npm run webpack

DIR=$1

Expand All @@ -27,7 +27,7 @@ cp -r electron.js $DIR/
cp webpack-* $DIR/

# run in subshell (so we return to original dir)
(cd $DIR && n exec 18.16.1 npm install --only=prod)
(cd $DIR && n exec 18.18.0 npm install --only=prod)

# cleanup of useless files in dependencies
rm -r $DIR/node_modules/image-q/demo
Expand Down
3 changes: 2 additions & 1 deletion bin/deb-options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"src": "dist/trilium-linux-x64",
"dest": "dist/",
"compression": "xz",
"name": "trilium",
"productName": "Trilium Notes",
"genericName": "Note taker",
Expand All @@ -11,4 +12,4 @@
"bin": "trilium",
"icon": "dist/trilium-linux-x64/icon.png",
"categories": [ "Office" ]
}
}
4 changes: 2 additions & 2 deletions docs/backend_api/services_sql.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h1 class="page-title">Source: services/sql.js</h1>
});

function insert(tableName, rec, replace = false) {
const keys = Object.keys(rec);
const keys = Object.keys(rec || {});
if (keys.length === 0) {
log.error(`Can't insert empty object into table ${tableName}`);
return;
Expand All @@ -81,7 +81,7 @@ <h1 class="page-title">Source: services/sql.js</h1>
}

function upsert(tableName, primaryKey, rec) {
const keys = Object.keys(rec);
const keys = Object.keys(rec || {});
if (keys.length === 0) {
log.error(`Can't upsert empty object into table ${tableName}`);
return;
Expand Down
3 changes: 3 additions & 0 deletions electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ appIconService.installLocalAppIcon();

require('electron-dl')({ saveAs: true });

// needed for excalidraw export https://github.com/zadam/trilium/issues/4271
app.commandLine.appendSwitch("enable-experimental-web-platform-features");

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
Expand Down
293 changes: 147 additions & 146 deletions libraries/mermaid.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.61.6-beta",
"version": "0.61.7-beta",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@braintree/sanitize-url": "6.0.4",
"@electron/remote": "2.0.11",
"@excalidraw/excalidraw": "0.15.3",
"@excalidraw/excalidraw": "0.16.1",
"archiver": "5.3.1",
"async-mutex": "0.4.0",
"axios": "1.5.0",
Expand All @@ -43,7 +43,7 @@
"compression": "1.7.4",
"cookie-parser": "1.4.6",
"csurf": "1.11.0",
"dayjs": "1.11.9",
"dayjs": "1.11.10",
"dayjs-plugin-utc": "0.1.2",
"debounce": "1.2.1",
"ejs": "3.1.9",
Expand All @@ -68,7 +68,7 @@
"jimp": "0.22.10",
"joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.1.0",
"marked": "9.0.0",
"marked": "9.0.3",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.47.0",
Expand All @@ -91,17 +91,17 @@
"tmp": "0.2.1",
"turndown": "7.1.2",
"unescape": "1.0.1",
"ws": "8.14.1",
"ws": "8.14.2",
"xml2js": "0.6.2",
"yauzl": "2.10.0"
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.8.1",
"electron": "25.8.2",
"electron-builder": "24.6.4",
"electron-packager": "17.1.2",
"electron-rebuild": "3.2.9",
"eslint": "8.48.0",
"eslint": "8.49.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
Expand Down
35 changes: 33 additions & 2 deletions src/public/app/services/frontend_script_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import NoteContextAwareWidget from "../widgets/note_context_aware_widget.js";
import BasicWidget from "../widgets/basic_widget.js";
import SpacedUpdate from "./spaced_update.js";
import shortcutService from "./shortcuts.js";
import dialogService from "./dialog.js";


/**
Expand Down Expand Up @@ -288,21 +289,51 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
this.parseDate = utils.parseDate;

/**
* Show an info message to the user.
* Show an info toast message to the user.
*
* @method
* @param {string} message
*/
this.showMessage = toastService.showMessage;

/**
* Show an error message to the user.
* Show an error toast message to the user.
*
* @method
* @param {string} message
*/
this.showError = toastService.showError;

/**
* Show an info dialog to the user.
*
* @method
* @param {string} message
* @returns {Promise}
*/
this.showInfoDialog = dialogService.info;

/**
* Show confirm dialog to the user.
*
* @method
* @param {string} message
* @returns {Promise<boolean>} promise resolving to true if the user confirmed
*/
this.showConfirmDialog = dialogService.confirm;

/**
* Show prompt dialog to the user.
*
* @method
* @param {object} props
* @param {string} props.title
* @param {string} props.message
* @param {string} props.defaultValue
* @returns {Promise<string>} promise resolving to the answer provided by the user
*/
this.showPromptDialog = dialogService.prompt;

/**
* Trigger command. This is a very low-level API which should be avoided if possible.
*
Expand Down
38 changes: 21 additions & 17 deletions src/public/app/widgets/type_widgets/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ const TPL = `
display: block;
}
.excalidraw-wrapper {
height: 100%;
}
.excalidraw button[data-testid="json-export-button"] {
display: none !important;
}
:root[dir="ltr"]
.excalidraw
Expand Down Expand Up @@ -60,8 +63,8 @@ const TPL = `
* for sketching. Excalidraw has a vibrant and active community.
*
* Functionality:
* We store the excalidraw assets (elements, appState, files) in the note. In addition to that, we
* export the SVG from the canvas on every update. The SVG is also saved in the note. It is used when
* We store the excalidraw assets (elements and files) in the note. In addition to that, we
* export the SVG from the canvas on every update and store it in the note's attachment. It is used when
* calling api/images and makes referencing very easy.
*
* Paths not taken.
Expand Down Expand Up @@ -209,19 +212,15 @@ export default class ExcalidrawTypeWidget extends TypeWidget {

content = {
elements: [],
appState: {},
files: [],
appState: {}
};
}

const {elements, appState, files} = content;
const {elements, files, appState} = content;

appState.theme = this.themeStyle;

/**
* use widths and offsets of current view, since stored appState has the state from
* previous edit. using the stored state would lead to pointer mismatch.
*/
const boundingClientRect = this.excalidrawWrapperRef.current.getBoundingClientRect();
appState.width = boundingClientRect.width;
appState.height = boundingClientRect.height;
Expand Down Expand Up @@ -284,10 +283,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
*/
const files = this.excalidrawRef.current.getFiles();

/**
* parallel svg export to combat bitrot and enable rendering image for note inclusion,
* preview, and share.
*/
// parallel svg export to combat bitrot and enable rendering image for note inclusion, preview, and share
const svg = await window.ExcalidrawLib.exportToSvg({
elements,
appState,
Expand All @@ -302,14 +298,18 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
if (element.fileId) {
activeFiles[element.fileId] = files[element.fileId];
}
})
});

const content = {
type: "excalidraw",
version: 2,
elements,
appState,
files: activeFiles
files: activeFiles,
appState: {
scrollX: appState.scrollX,
scrollY: appState.scrollY,
zoom: appState.zoom
}
};

const attachments = [
Expand Down Expand Up @@ -339,7 +339,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {

return {
content: JSON.stringify(content),
attachments: attachments
attachments
};
}

Expand Down Expand Up @@ -458,6 +458,10 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
handleKeyboardGlobally: false,
autoFocus: false,
onLinkOpen,
UIOptions: {
saveToActiveFile: false,
saveAsImage: false
}
})
)
);
Expand Down
6 changes: 1 addition & 5 deletions src/routes/api/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ function update(req) {

const {entities, instanceId} = body;

sql.transactional(() => {
for (const {entityChange, entity} of entities) {
syncUpdateService.updateEntity(entityChange, entity, instanceId);
}
});
sql.transactional(() => syncUpdateService.updateEntities(entities, instanceId));
}

setInterval(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/build.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { buildDate:"2023-09-06T23:57:29+02:00", buildRevision: "6fa9d996e84f87fcb73c3388a5170affd2c2f7cc" };
module.exports = { buildDate:"2023-09-21T23:38:18+02:00", buildRevision: "79e5e3b65ff613cdb81e2afaa832037ccf06d7b8" };
28 changes: 23 additions & 5 deletions src/services/consistency_checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const BBranch = require('../becca/entities/bbranch');
const revisionService = require('./revisions');
const becca = require("../becca/becca");
const utils = require("../services/utils");
const eraseService = require("../services/erase");
const {sanitizeAttributeName} = require("./sanitize_attribute_name");
const noteTypes = require("../services/note_types").getNoteTypeNames();

Expand Down Expand Up @@ -440,7 +441,7 @@ class ConsistencyChecks {
this.findAndFixIssues(`
SELECT notes.noteId, notes.type, notes.mime
FROM notes
JOIN blobs USING (blobId)
JOIN blobs USING (blobId)
WHERE isDeleted = 0
AND isProtected = 0
AND content IS NULL`,
Expand All @@ -460,19 +461,36 @@ class ConsistencyChecks {
}

this.findAndFixIssues(`
SELECT revisions.revisionId
SELECT revisions.revisionId, blobs.blobId
FROM revisions
LEFT JOIN blobs USING (blobId)
WHERE blobs.blobId IS NULL`,
({revisionId}) => {
({revisionId, blobId}) => {
if (this.autoFix) {
revisionService.eraseRevisions([revisionId]);

this.reloadNeeded = true;

logFix(`Note revision content '${revisionId}' was set to erased since its content did not exist.`);
logFix(`Note revision '${revisionId}' was erased since the referenced blob '${blobId}' did not exist.`);
} else {
logError(`Note revision content '${revisionId}' does not exist`);
logError(`Note revision '${revisionId}' blob '${blobId}' does not exist`);
}
});

this.findAndFixIssues(`
SELECT attachments.attachmentId, blobs.blobId
FROM attachments
LEFT JOIN blobs USING (blobId)
WHERE blobs.blobId IS NULL`,
({attachmentId, blobId}) => {
if (this.autoFix) {
eraseService.eraseAttachments([attachmentId]);

this.reloadNeeded = true;

logFix(`Attachment '${attachmentId}' was erased since the referenced blob '${blobId}' did not exist.`);
} else {
logError(`Attachment '${attachmentId}' blob '${blobId}' does not exist`);
}
});

Expand Down
Loading

0 comments on commit af24758

Please sign in to comment.