mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
wip conversion to ES modules
This commit is contained in:
parent
722299dd26
commit
5205800720
4
LICENSE
4
LICENSE
@ -643,7 +643,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <http://www.js.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
@ -658,4 +658,4 @@ specific requirements.
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
<http://www.js.gnu.org/licenses/>.
|
||||
|
Binary file not shown.
20
electron.js
20
electron.js
@ -1,17 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const {app, globalShortcut, BrowserWindow} = require('electron');
|
||||
const sqlInit = require('./src/services/sql_init');
|
||||
const appIconService = require('./src/services/app_icon');
|
||||
const windowService = require('./src/services/window');
|
||||
const tray = require('./src/services/tray');
|
||||
import { app, globalShortcut, BrowserWindow } from 'electron';
|
||||
import sqlInit from './src/services/sql_init.js';
|
||||
import appIconService from './src/services/app_icon.js';
|
||||
import windowService from './src/services/window.js';
|
||||
import tray from './src/services/tray.js';
|
||||
import electron_debug from "electron-debug";
|
||||
import electron_dl from "electron-dl";
|
||||
|
||||
import './src/www.js';
|
||||
|
||||
// Adds debug features like hotkeys for triggering dev tools and reload
|
||||
require('electron-debug')();
|
||||
electron_debug();
|
||||
|
||||
appIconService.installLocalAppIcon();
|
||||
|
||||
require('electron-dl')({ saveAs: true });
|
||||
electron_dl({ saveAs: true });
|
||||
|
||||
// needed for excalidraw export https://github.com/zadam/trilium/issues/4271
|
||||
app.commandLine.appendSwitch("enable-experimental-web-platform-features");
|
||||
@ -58,5 +62,3 @@ app.on('will-quit', () => {
|
||||
|
||||
// this is to disable electron warning spam in the dev console (local development only)
|
||||
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
|
||||
|
||||
require('./src/www');
|
||||
|
38
package-lock.json
generated
38
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.62.1-beta",
|
||||
"version": "0.62.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "trilium",
|
||||
"version": "0.62.1-beta",
|
||||
"version": "0.62.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
@ -16,7 +16,7 @@
|
||||
"archiver": "6.0.1",
|
||||
"async-mutex": "0.4.0",
|
||||
"axios": "1.6.2",
|
||||
"better-sqlite3": "8.4.0",
|
||||
"better-sqlite3": "9.1.1",
|
||||
"chokidar": "3.5.3",
|
||||
"cls-hooked": "4.2.2",
|
||||
"compression": "1.7.4",
|
||||
@ -77,11 +77,11 @@
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
"bin": {
|
||||
"trilium": "src/www"
|
||||
"trilium": "src/www.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "25.9.5",
|
||||
"electron": "28.0.0-beta.8",
|
||||
"electron-builder": "24.6.4",
|
||||
"electron-packager": "17.1.2",
|
||||
"electron-rebuild": "3.2.9",
|
||||
@ -2540,13 +2540,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/better-sqlite3": {
|
||||
"version": "8.4.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.4.0.tgz",
|
||||
"integrity": "sha512-NmsNW1CQvqMszu/CFAJ3pLct6NEFlNfuGM6vw72KHkjOD1UDnL96XNN1BMQc1hiHo8vE2GbOWQYIpZ+YM5wrZw==",
|
||||
"version": "9.1.1",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.1.1.tgz",
|
||||
"integrity": "sha512-FhW7bS7cXwkB2SFnPJrSGPmQerVSCzwBgmQ1cIRcYKxLsyiKjljzCbyEqqhYXo5TTBqt5BISiBj2YE2Sy2ynaA==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"bindings": "^1.5.0",
|
||||
"prebuild-install": "^7.1.0"
|
||||
"prebuild-install": "^7.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/big-integer": {
|
||||
@ -4366,9 +4366,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron": {
|
||||
"version": "25.9.5",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
|
||||
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
|
||||
"version": "28.0.0-beta.8",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-28.0.0-beta.8.tgz",
|
||||
"integrity": "sha512-8SwL743EG3sIdwqvgq+fteYexRGb0qTg8MUSm77IRnw6tOxbCfgd8QztpYS7z8SNDcpAABXD4I1X9nqBVBLshQ==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@electron/get": "^2.0.0",
|
||||
@ -15572,12 +15572,12 @@
|
||||
}
|
||||
},
|
||||
"better-sqlite3": {
|
||||
"version": "8.4.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.4.0.tgz",
|
||||
"integrity": "sha512-NmsNW1CQvqMszu/CFAJ3pLct6NEFlNfuGM6vw72KHkjOD1UDnL96XNN1BMQc1hiHo8vE2GbOWQYIpZ+YM5wrZw==",
|
||||
"version": "9.1.1",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.1.1.tgz",
|
||||
"integrity": "sha512-FhW7bS7cXwkB2SFnPJrSGPmQerVSCzwBgmQ1cIRcYKxLsyiKjljzCbyEqqhYXo5TTBqt5BISiBj2YE2Sy2ynaA==",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"prebuild-install": "^7.1.0"
|
||||
"prebuild-install": "^7.1.1"
|
||||
}
|
||||
},
|
||||
"big-integer": {
|
||||
@ -16964,9 +16964,9 @@
|
||||
}
|
||||
},
|
||||
"electron": {
|
||||
"version": "25.9.5",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
|
||||
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
|
||||
"version": "28.0.0-beta.8",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-28.0.0-beta.8.tgz",
|
||||
"integrity": "sha512-8SwL743EG3sIdwqvgq+fteYexRGb0qTg8MUSm77IRnw6tOxbCfgd8QztpYS7z8SNDcpAABXD4I1X9nqBVBLshQ==",
|
||||
"requires": {
|
||||
"@electron/get": "^2.0.0",
|
||||
"@types/node": "^18.11.18",
|
||||
|
15
package.json
15
package.json
@ -5,21 +5,22 @@
|
||||
"version": "0.62.2",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "electron.js",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"trilium": "./src/www"
|
||||
"trilium": "src/www.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zadam/trilium.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start-server": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon ./src/www",
|
||||
"start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon ./src/www",
|
||||
"qstart-server": "npm run qswitch-server && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon ./src/www",
|
||||
"start-server": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.js",
|
||||
"start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.js",
|
||||
"qstart-server": "npm run qswitch-server && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.js",
|
||||
"start-electron": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .",
|
||||
"start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .",
|
||||
"qstart-electron": "npm run qswitch-electron && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .",
|
||||
"start-test-server": "npm run qswitch-server; rm -rf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 node ./src/www",
|
||||
"start-test-server": "npm run qswitch-server; rm -rf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 node src/www.js",
|
||||
"switch-server": "rm -rf ./node_modules/better-sqlite3 && npm install",
|
||||
"switch-electron": "./node_modules/.bin/electron-rebuild",
|
||||
"qswitch-server": "rm -rf ./node_modules/better-sqlite3/bin ; mkdir -p ./node_modules/better-sqlite3/build ; cp ./bin/better-sqlite3/linux-server-better_sqlite3.node ./node_modules/better-sqlite3/build/better_sqlite3.node",
|
||||
@ -42,7 +43,7 @@
|
||||
"archiver": "6.0.1",
|
||||
"async-mutex": "0.4.0",
|
||||
"axios": "1.6.2",
|
||||
"better-sqlite3": "8.4.0",
|
||||
"better-sqlite3": "9.1.1",
|
||||
"chokidar": "3.5.3",
|
||||
"cls-hooked": "4.2.2",
|
||||
"compression": "1.7.4",
|
||||
@ -104,7 +105,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "25.9.5",
|
||||
"electron": "28.0.0-beta.8",
|
||||
"electron-builder": "24.6.4",
|
||||
"electron-packager": "17.1.2",
|
||||
"electron-rebuild": "3.2.9",
|
||||
|
@ -1,8 +1,6 @@
|
||||
const {
|
||||
describeEtapi, postEtapi,
|
||||
putEtapiContent
|
||||
} = require("../support/etapi");
|
||||
const {getEtapi} = require("../support/etapi.js");
|
||||
import {describeEtapi, postEtapi, putEtapiContent,getEtapi} from "../support/etapi";
|
||||
|
||||
|
||||
|
||||
describeEtapi("app_info", () => {
|
||||
it("get", async () => {
|
||||
|
@ -1,8 +1,4 @@
|
||||
const {
|
||||
describeEtapi, postEtapi,
|
||||
getEtapi,
|
||||
} = require("../support/etapi");
|
||||
const {putEtapiContent} = require("../support/etapi.js");
|
||||
import {describeEtapi, getEtapi, postEtapi,putEtapiContent} from "../support/etapi";
|
||||
|
||||
describeEtapi("backup", () => {
|
||||
it("create", async () => {
|
||||
|
@ -1,10 +1,9 @@
|
||||
const {
|
||||
describeEtapi, postEtapi,
|
||||
postEtapiContent,
|
||||
} = require("../support/etapi");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const {getEtapiContent} = require("../support/etapi.js");
|
||||
import {describeEtapi, postEtapi, postEtapiContent,getEtapiContent} from "../support/etapi";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import {fileURLToPath} from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
describeEtapi("import", () => {
|
||||
it("import", async () => {
|
||||
|
@ -1,13 +1,14 @@
|
||||
const crypto = require('crypto');
|
||||
const {
|
||||
import crypto from "crypto";
|
||||
|
||||
import {
|
||||
deleteEtapi,
|
||||
getEtapiResponse,
|
||||
describeEtapi, postEtapi,
|
||||
describeEtapi,
|
||||
getEtapi,
|
||||
getEtapiContent,
|
||||
patchEtapi, putEtapi,
|
||||
putEtapiContent
|
||||
} = require("../support/etapi");
|
||||
getEtapiResponse,
|
||||
patchEtapi,
|
||||
postEtapi, putEtapi, putEtapiContent
|
||||
} from "../support/etapi";
|
||||
|
||||
describeEtapi("notes", () => {
|
||||
it("create", async () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
const anonymizationService = require('./services/anonymization');
|
||||
const sqlInit = require('./services/sql_init');
|
||||
require('./becca/entity_constructor');
|
||||
import anonymizationService from './services/anonymization.js'
|
||||
import sqlInit from './services/sql_init.js'
|
||||
import './becca/entity_constructor.js';
|
||||
|
||||
sqlInit.dbReady.then(async () => {
|
||||
try {
|
||||
|
66
src/app.js
66
src/app.js
@ -1,14 +1,37 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const favicon = require('serve-favicon');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const helmet = require('helmet');
|
||||
const compression = require('compression');
|
||||
const sessionParser = require('./routes/session_parser');
|
||||
const utils = require('./services/utils');
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import favicon from 'serve-favicon';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import helmet from 'helmet';
|
||||
import compression from 'compression';
|
||||
import sessionParser from './routes/session_parser.js'
|
||||
import utils from './services/utils.js'
|
||||
import './services/handlers.js';
|
||||
import './becca/becca_loader.js';
|
||||
|
||||
require('./services/handlers');
|
||||
require('./becca/becca_loader');
|
||||
// triggers sync timer
|
||||
import './services/sync.js';
|
||||
|
||||
// triggers backup timer
|
||||
import './services/backup.js';
|
||||
|
||||
// trigger consistency checks timer
|
||||
import './services/consistency_checks.js';
|
||||
|
||||
import './services/scheduler.js';
|
||||
|
||||
import assetRoutes from './routes/assets.js'
|
||||
|
||||
import routes from './routes/routes.js'
|
||||
|
||||
import customRoutes from './routes/custom.js'
|
||||
|
||||
import errorHandlerRoutes from './routes/error_handlers.js'
|
||||
|
||||
import {initialize} from "@electron/remote/main/index.js";
|
||||
import {fileURLToPath} from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const app = express();
|
||||
|
||||
@ -37,24 +60,13 @@ app.use(`/robots.txt`, express.static(path.join(__dirname, 'public/robots.txt'))
|
||||
app.use(sessionParser);
|
||||
app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`));
|
||||
|
||||
require('./routes/assets').register(app);
|
||||
require('./routes/routes').register(app);
|
||||
require('./routes/custom').register(app);
|
||||
require('./routes/error_handlers').register(app);
|
||||
|
||||
// triggers sync timer
|
||||
require('./services/sync');
|
||||
|
||||
// triggers backup timer
|
||||
require('./services/backup');
|
||||
|
||||
// trigger consistency checks timer
|
||||
require('./services/consistency_checks');
|
||||
|
||||
require('./services/scheduler');
|
||||
assetRoutes.register(app);
|
||||
routes.register(app);
|
||||
customRoutes.register(app);
|
||||
errorHandlerRoutes.register(app);
|
||||
|
||||
if (utils.isElectron()) {
|
||||
require('@electron/remote/main').initialize();
|
||||
initialize();
|
||||
}
|
||||
|
||||
module.exports = app;
|
||||
export default app;
|
||||
|
@ -1,8 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require("../services/sql");
|
||||
const NoteSet = require("../services/search/note_set");
|
||||
const NotFoundError = require("../errors/not_found_error");
|
||||
import sql from '../services/sql.js'
|
||||
import NoteSet from '../services/search/note_set.js'
|
||||
import NotFoundError from '../errors/not_found_error.js'
|
||||
|
||||
import BRevision from './entities/brevision.js' // avoiding circular dependency problems
|
||||
|
||||
import BAttachment from './entities/battachment.js' // avoiding circular dependency problems
|
||||
|
||||
import BBlob from './entities/bblob.js' // avoiding circular dependency problems
|
||||
|
||||
import BRecentNote from './entities/brecent_note.js' // avoiding circular dependency problems
|
||||
|
||||
/**
|
||||
* Becca is a backend cache of all notes, branches, and attributes.
|
||||
@ -147,8 +155,6 @@ class Becca {
|
||||
/** @returns {BRevision|null} */
|
||||
getRevision(revisionId) {
|
||||
const row = sql.getRow("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]);
|
||||
|
||||
const BRevision = require("./entities/brevision"); // avoiding circular dependency problems
|
||||
return row ? new BRevision(row) : null;
|
||||
}
|
||||
|
||||
@ -162,9 +168,6 @@ class Becca {
|
||||
JOIN blobs USING (blobId)
|
||||
WHERE attachmentId = ? AND isDeleted = 0`
|
||||
: `SELECT * FROM attachments WHERE attachmentId = ? AND isDeleted = 0`;
|
||||
|
||||
const BAttachment = require("./entities/battachment"); // avoiding circular dependency problems
|
||||
|
||||
return sql.getRows(query, [attachmentId])
|
||||
.map(row => new BAttachment(row))[0];
|
||||
}
|
||||
@ -180,7 +183,7 @@ class Becca {
|
||||
|
||||
/** @returns {BAttachment[]} */
|
||||
getAttachments(attachmentIds) {
|
||||
const BAttachment = require("./entities/battachment"); // avoiding circular dependency problems
|
||||
// avoiding circular dependency problems
|
||||
return sql.getManyRows("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds)
|
||||
.map(row => new BAttachment(row));
|
||||
}
|
||||
@ -188,8 +191,6 @@ class Becca {
|
||||
/** @returns {BBlob|null} */
|
||||
getBlob(entity) {
|
||||
const row = sql.getRow("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
|
||||
|
||||
const BBlob = require("./entities/bblob"); // avoiding circular dependency problems
|
||||
return row ? new BBlob(row) : null;
|
||||
}
|
||||
|
||||
@ -237,16 +238,12 @@ class Becca {
|
||||
/** @returns {BRecentNote[]} */
|
||||
getRecentNotesFromQuery(query, params = []) {
|
||||
const rows = sql.getRows(query, params);
|
||||
|
||||
const BRecentNote = require("./entities/brecent_note"); // avoiding circular dependency problems
|
||||
return rows.map(row => new BRecentNote(row));
|
||||
}
|
||||
|
||||
/** @returns {BRevision[]} */
|
||||
getRevisionsFromQuery(query, params = []) {
|
||||
const rows = sql.getRows(query, params);
|
||||
|
||||
const BRevision = require("./entities/brevision"); // avoiding circular dependency problems
|
||||
return rows.map(row => new BRevision(row));
|
||||
}
|
||||
|
||||
@ -279,4 +276,4 @@ class Becca {
|
||||
|
||||
const becca = new Becca();
|
||||
|
||||
module.exports = becca;
|
||||
export default becca;
|
||||
|
@ -1,24 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../services/sql');
|
||||
const eventService = require('../services/events');
|
||||
const becca = require('./becca');
|
||||
const sqlInit = require('../services/sql_init');
|
||||
const log = require('../services/log');
|
||||
const BNote = require('./entities/bnote');
|
||||
const BBranch = require('./entities/bbranch');
|
||||
const BAttribute = require('./entities/battribute');
|
||||
const BOption = require('./entities/boption');
|
||||
const BEtapiToken = require("./entities/betapi_token");
|
||||
const cls = require("../services/cls");
|
||||
const entityConstructor = require("../becca/entity_constructor");
|
||||
import sql from '../services/sql.js'
|
||||
import eventService from '../services/events.js'
|
||||
import becca from './becca.js'
|
||||
import sqlInit from '../services/sql_init.js'
|
||||
import log from '../services/log.js'
|
||||
import BNote from './entities/bnote.js'
|
||||
import BBranch from './entities/bbranch.js'
|
||||
import BAttribute from './entities/battribute.js'
|
||||
import BOption from './entities/boption.js'
|
||||
import BEtapiToken from './entities/betapi_token.js'
|
||||
import cls from '../services/cls.js'
|
||||
import entityConstructor from '../becca/entity_constructor.js'
|
||||
|
||||
import services from '../services/options_init.js'
|
||||
|
||||
import services0 from '../services/ws.js'
|
||||
|
||||
const beccaLoaded = new Promise((res, rej) => {
|
||||
sqlInit.dbReady.then(() => {
|
||||
cls.init(() => {
|
||||
load();
|
||||
|
||||
require('../services/options_init').initStartupOptions();
|
||||
services.initStartupOptions();
|
||||
|
||||
res();
|
||||
});
|
||||
@ -71,7 +75,7 @@ function load() {
|
||||
function reload(reason) {
|
||||
load();
|
||||
|
||||
require('../services/ws').reloadFrontend(reason || "becca reloaded");
|
||||
services0.reloadFrontend(reason || "becca reloaded");
|
||||
}
|
||||
|
||||
eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED], ({entityName, entityRow}) => {
|
||||
@ -282,7 +286,7 @@ eventService.subscribeBeccaLoader(eventService.ENTER_PROTECTED_SESSION, () => {
|
||||
|
||||
eventService.subscribeBeccaLoader(eventService.LEAVE_PROTECTED_SESSION, load);
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
load,
|
||||
reload,
|
||||
beccaLoaded
|
||||
|
@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const becca = require('./becca');
|
||||
const cls = require('../services/cls');
|
||||
const log = require('../services/log');
|
||||
import becca from './becca.js'
|
||||
import cls from '../services/cls.js'
|
||||
import log from '../services/log.js'
|
||||
|
||||
function isNotePathArchived(notePath) {
|
||||
const noteId = notePath[notePath.length - 1];
|
||||
@ -82,7 +82,7 @@ function getNoteTitleForPath(notePathArray) {
|
||||
return titles.join(' / ');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getNoteTitle,
|
||||
getNoteTitleForPath,
|
||||
isNotePathArchived
|
||||
|
@ -1,14 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const utils = require('../../services/utils');
|
||||
const sql = require('../../services/sql');
|
||||
const entityChangesService = require('../../services/entity_changes');
|
||||
const eventService = require("../../services/events");
|
||||
const dateUtils = require("../../services/date_utils");
|
||||
const cls = require("../../services/cls");
|
||||
const log = require("../../services/log");
|
||||
const protectedSessionService = require("../../services/protected_session");
|
||||
const blobService = require("../../services/blob");
|
||||
import utils from '../../services/utils.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import entityChangesService from '../../services/entity_changes.js'
|
||||
import eventService from '../../services/events.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import cls from '../../services/cls.js'
|
||||
import log from '../../services/log.js'
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import blobService from '../../services/blob.js'
|
||||
|
||||
import becca0 from '../becca.js'
|
||||
|
||||
let becca = null;
|
||||
|
||||
@ -34,7 +36,7 @@ class AbstractBeccaEntity {
|
||||
*/
|
||||
get becca() {
|
||||
if (!becca) {
|
||||
becca = require('../becca');
|
||||
becca = becca0;
|
||||
}
|
||||
|
||||
return becca;
|
||||
@ -306,4 +308,4 @@ class AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AbstractBeccaEntity;
|
||||
export default AbstractBeccaEntity;
|
||||
|
@ -1,11 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
const utils = require('../../services/utils');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
const sql = require("../../services/sql");
|
||||
const protectedSessionService = require("../../services/protected_session");
|
||||
const log = require("../../services/log");
|
||||
import utils from '../../services/utils.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import log from '../../services/log.js'
|
||||
|
||||
import noteService from '../../services/notes.js'
|
||||
|
||||
const attachmentRoleToNoteTypeMapping = {
|
||||
'image': 'image'
|
||||
@ -37,7 +39,7 @@ class BAttachment extends AbstractBeccaEntity {
|
||||
|
||||
/** @type {string} */
|
||||
this.attachmentId = row.attachmentId;
|
||||
/**
|
||||
/**
|
||||
* either noteId or revisionId to which this attachment belongs
|
||||
* @type {string}
|
||||
*/
|
||||
@ -152,9 +154,6 @@ class BAttachment extends AbstractBeccaEntity {
|
||||
if (!this.isContentAvailable()) { // isProtected is the same for attachment
|
||||
throw new Error(`Cannot convert protected attachment outside of protected session`);
|
||||
}
|
||||
|
||||
const noteService = require('../../services/notes');
|
||||
|
||||
const { note, branch } = noteService.createNewNote({
|
||||
parentNoteId: this.ownerId,
|
||||
title: this.title,
|
||||
@ -240,4 +239,4 @@ class BAttachment extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BAttachment;
|
||||
export default BAttachment;
|
||||
|
@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const BNote = require('./bnote');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
const sql = require("../../services/sql");
|
||||
const dateUtils = require("../../services/date_utils");
|
||||
const promotedAttributeDefinitionParser = require("../../services/promoted_attribute_definition_parser");
|
||||
const {sanitizeAttributeName} = require("../../services/sanitize_attribute_name");
|
||||
import BNote from './bnote.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import promotedAttributeDefinitionParser from '../../services/promoted_attribute_definition_parser.js'
|
||||
import { sanitizeAttributeName } from '../../services/sanitize_attribute_name.js';
|
||||
|
||||
|
||||
/**
|
||||
@ -239,4 +239,4 @@ class BAttribute extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BAttribute;
|
||||
export default BAttribute;
|
||||
|
@ -27,4 +27,4 @@ class BBlob {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BBlob;
|
||||
export default BBlob;
|
||||
|
@ -1,12 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const BNote = require('./bnote');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
const dateUtils = require("../../services/date_utils");
|
||||
const utils = require("../../services/utils");
|
||||
const TaskContext = require("../../services/task_context");
|
||||
const cls = require("../../services/cls");
|
||||
const log = require("../../services/log");
|
||||
import BNote from './bnote.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import TaskContext from '../../services/task_context.js'
|
||||
import cls from '../../services/cls.js'
|
||||
import log from '../../services/log.js'
|
||||
|
||||
|
||||
// needs to be run before branches and attributes are deleted and thus attached relations disappear
|
||||
import handlers from '../../services/handlers.js'
|
||||
|
||||
/**
|
||||
* Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple
|
||||
@ -160,8 +164,6 @@ class BBranch extends AbstractBeccaEntity {
|
||||
const parentBranches = note.getParentBranches();
|
||||
|
||||
if (parentBranches.length === 1 && parentBranches[0] === this) {
|
||||
// needs to be run before branches and attributes are deleted and thus attached relations disappear
|
||||
const handlers = require("../../services/handlers");
|
||||
handlers.runAttachedRelations(note, 'runOnNoteDeletion', note);
|
||||
}
|
||||
}
|
||||
@ -279,4 +281,4 @@ class BBranch extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BBranch;
|
||||
export default BBranch;
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
|
||||
/**
|
||||
* EtapiToken is an entity representing token used to authenticate against Trilium REST API from client applications.
|
||||
@ -75,4 +75,4 @@ class BEtapiToken extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BEtapiToken;
|
||||
export default BEtapiToken;
|
||||
|
@ -1,17 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const log = require('../../services/log');
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
const BRevision = require("./brevision");
|
||||
const BAttachment = require("./battachment");
|
||||
const TaskContext = require("../../services/task_context");
|
||||
const dayjs = require("dayjs");
|
||||
const utc = require('dayjs/plugin/utc');
|
||||
const eventService = require("../../services/events");
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import log from '../../services/log.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
import BRevision from './brevision.js'
|
||||
import BAttachment from './battachment.js'
|
||||
import TaskContext from '../../services/task_context.js'
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc.js";
|
||||
import eventService from '../../services/events.js'
|
||||
import searchService from '../../services/search/services/search.js'
|
||||
|
||||
import BAttribute from './battribute.js'
|
||||
|
||||
import cloningService from '../../services/cloning.js'
|
||||
|
||||
import noteService from '../../services/notes.js'
|
||||
|
||||
|
||||
// needs to be run before branches and attributes are deleted and thus attached relations disappear
|
||||
import handlers from '../../services/handlers.js'
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const LABEL = 'label';
|
||||
@ -903,7 +915,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
}
|
||||
|
||||
try {
|
||||
const searchService = require("../../services/search/services/search");
|
||||
const {searchResultNoteIds} = searchService.searchFromNote(this);
|
||||
|
||||
const becca = this.becca;
|
||||
@ -1303,8 +1314,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const BAttribute = require("./battribute");
|
||||
|
||||
new BAttribute({
|
||||
noteId: this.noteId,
|
||||
type: type,
|
||||
@ -1343,8 +1352,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
* @returns {BAttribute}
|
||||
*/
|
||||
addAttribute(type, name, value = "", isInheritable = false, position = null) {
|
||||
const BAttribute = require("./battribute");
|
||||
|
||||
return new BAttribute({
|
||||
noteId: this.noteId,
|
||||
type: type,
|
||||
@ -1448,8 +1455,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
removeRelation(name, value) { return this.removeAttribute(RELATION, name, value); }
|
||||
|
||||
searchNotesInSubtree(searchString) {
|
||||
const searchService = require("../../services/search/services/search");
|
||||
|
||||
return searchService.searchNotes(searchString);
|
||||
}
|
||||
|
||||
@ -1462,8 +1467,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
* @returns {{success: boolean, message: string, branchId: string, notePath: string}}
|
||||
*/
|
||||
cloneTo(parentNoteId) {
|
||||
const cloningService = require("../../services/cloning");
|
||||
|
||||
const branch = this.becca.getNote(parentNoteId).getParentBranches()[0];
|
||||
|
||||
return cloningService.cloneNoteToBranch(this.noteId, branch.branchId);
|
||||
@ -1536,8 +1539,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
const fixedContent = utils.replaceAll(parentContent, oldNoteUrl, newAttachmentUrl);
|
||||
|
||||
parentNote.setContent(fixedContent);
|
||||
|
||||
const noteService = require("../../services/notes");
|
||||
noteService.asyncPostProcessContent(parentNote, fixedContent); // to mark an unused attachment for deletion
|
||||
|
||||
this.deleteNote();
|
||||
@ -1563,9 +1564,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
if (!taskContext) {
|
||||
taskContext = new TaskContext('no-progress-reporting');
|
||||
}
|
||||
|
||||
// needs to be run before branches and attributes are deleted and thus attached relations disappear
|
||||
const handlers = require("../../services/handlers");
|
||||
handlers.runAttachedRelations(this, 'runOnNoteDeletion', this);
|
||||
taskContext.noteDeletionHandlerTriggered = true;
|
||||
|
||||
@ -1725,4 +1723,4 @@ class BNote extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BNote;
|
||||
export default BNote;
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
|
||||
/**
|
||||
* Option represents a name-value pair, either directly configurable by the user or some system property.
|
||||
@ -47,4 +47,4 @@ class BOption extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BOption;
|
||||
export default BOption;
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
|
||||
/**
|
||||
* RecentNote represents recently visited note.
|
||||
@ -32,4 +32,4 @@ class BRecentNote extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BRecentNote;
|
||||
export default BRecentNote;
|
||||
|
@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const utils = require('../../services/utils');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const becca = require('../becca');
|
||||
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
||||
const sql = require("../../services/sql");
|
||||
const BAttachment = require("./battachment");
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import becca from '../becca.js'
|
||||
import AbstractBeccaEntity from './abstract_becca_entity.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import BAttachment from './battachment.js'
|
||||
|
||||
/**
|
||||
* Revision represents a snapshot of note's title and content at some point in the past.
|
||||
@ -205,4 +205,4 @@ class BRevision extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BRevision;
|
||||
export default BRevision;
|
||||
|
@ -1,12 +1,12 @@
|
||||
const BAttachment = require("./entities/battachment");
|
||||
const BAttribute = require('./entities/battribute');
|
||||
const BBlob = require("./entities/bblob");
|
||||
const BBranch = require('./entities/bbranch');
|
||||
const BEtapiToken = require('./entities/betapi_token');
|
||||
const BNote = require('./entities/bnote');
|
||||
const BOption = require('./entities/boption');
|
||||
const BRecentNote = require('./entities/brecent_note');
|
||||
const BRevision = require('./entities/brevision');
|
||||
import BAttachment from './entities/battachment.js'
|
||||
import BAttribute from './entities/battribute.js'
|
||||
import BBlob from './entities/bblob.js'
|
||||
import BBranch from './entities/bbranch.js'
|
||||
import BEtapiToken from './entities/betapi_token.js'
|
||||
import BNote from './entities/bnote.js'
|
||||
import BOption from './entities/boption.js'
|
||||
import BRecentNote from './entities/brecent_note.js'
|
||||
import BRevision from './entities/brevision.js'
|
||||
|
||||
const ENTITY_NAME_TO_ENTITY = {
|
||||
"attachments": BAttachment,
|
||||
@ -28,6 +28,6 @@ function getEntityFromEntityName(entityName) {
|
||||
return ENTITY_NAME_TO_ENTITY[entityName];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getEntityFromEntityName
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
const becca = require('./becca');
|
||||
const log = require('../services/log');
|
||||
const beccaService = require('./becca_service');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const {JSDOM} = require("jsdom");
|
||||
import becca from './becca.js'
|
||||
import log from '../services/log.js'
|
||||
import beccaService from './becca_service.js'
|
||||
import dateUtils from '../services/date_utils.js'
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
@ -35,7 +35,7 @@ const IGNORED_ATTR_NAMES = [
|
||||
function filterUrlValue(value) {
|
||||
return value
|
||||
.replace(/https?:\/\//ig, "")
|
||||
.replace(/www\./ig, "")
|
||||
.replace(/www.js\./ig, "")
|
||||
.replace(/(\.net|\.com|\.org|\.info|\.edu)/ig, "");
|
||||
}
|
||||
|
||||
@ -456,6 +456,6 @@ function setImmediatePromise() {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
findSimilarNotes
|
||||
};
|
||||
|
@ -4,4 +4,4 @@ class NotFoundError {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NotFoundError;
|
||||
export default NotFoundError;
|
@ -4,4 +4,4 @@ class ValidationError {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ValidationError;
|
||||
export default ValidationError;
|
@ -1,5 +1,5 @@
|
||||
const appInfo = require('../services/app_info');
|
||||
const eu = require("./etapi_utils");
|
||||
import appInfo from '../services/app_info.js'
|
||||
import eu from './etapi_utils.js'
|
||||
|
||||
function register(router) {
|
||||
eu.route(router, 'get', '/etapi/app-info', (req, res, next) => {
|
||||
@ -7,6 +7,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
const becca = require("../becca/becca");
|
||||
const eu = require("./etapi_utils");
|
||||
const mappers = require("./mappers");
|
||||
const v = require("./validators");
|
||||
const utils = require("../services/utils");
|
||||
import becca from '../becca/becca.js'
|
||||
import eu from './etapi_utils.js'
|
||||
import mappers from './mappers.js'
|
||||
import v from './validators.js'
|
||||
import utils from '../services/utils.js'
|
||||
|
||||
function register(router) {
|
||||
const ALLOWED_PROPERTIES_FOR_CREATE_ATTACHMENT = {
|
||||
@ -98,6 +98,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
const becca = require("../becca/becca");
|
||||
const eu = require("./etapi_utils");
|
||||
const mappers = require("./mappers");
|
||||
const attributeService = require("../services/attributes");
|
||||
const v = require("./validators");
|
||||
import becca from '../becca/becca.js'
|
||||
import eu from './etapi_utils.js'
|
||||
import mappers from './mappers.js'
|
||||
import attributeService from '../services/attributes.js'
|
||||
import v from './validators.js'
|
||||
|
||||
function register(router) {
|
||||
eu.route(router, 'get', '/etapi/attributes/:attributeId', (req, res, next) => {
|
||||
@ -78,6 +78,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
const becca = require("../becca/becca");
|
||||
const eu = require("./etapi_utils");
|
||||
const passwordEncryptionService = require("../services/encryption/password_encryption");
|
||||
const etapiTokenService = require("../services/etapi_tokens");
|
||||
import becca from '../becca/becca.js'
|
||||
import eu from './etapi_utils.js'
|
||||
import passwordEncryptionService from '../services/encryption/password_encryption.js'
|
||||
import etapiTokenService from '../services/etapi_tokens.js'
|
||||
|
||||
function register(router, loginMiddleware) {
|
||||
eu.NOT_AUTHENTICATED_ROUTE(router, 'post', '/etapi/auth/login', loginMiddleware, (req, res, next) => {
|
||||
@ -38,6 +38,6 @@ function register(router, loginMiddleware) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
const eu = require("./etapi_utils");
|
||||
const backupService = require("../services/backup");
|
||||
import eu from './etapi_utils.js'
|
||||
import backupService from '../services/backup.js'
|
||||
|
||||
function register(router) {
|
||||
eu.route(router, 'put', '/etapi/backup/:backupName', async (req, res, next) => {
|
||||
@ -9,6 +9,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
const becca = require("../becca/becca");
|
||||
const eu = require("./etapi_utils");
|
||||
const mappers = require("./mappers");
|
||||
const BBranch = require("../becca/entities/bbranch");
|
||||
const entityChangesService = require("../services/entity_changes");
|
||||
const v = require("./validators");
|
||||
import becca from '../becca/becca.js'
|
||||
import eu from './etapi_utils.js'
|
||||
import mappers from './mappers.js'
|
||||
import BBranch from '../becca/entities/bbranch.js'
|
||||
import entityChangesService from '../services/entity_changes.js'
|
||||
import v from './validators.js'
|
||||
|
||||
function register(router) {
|
||||
eu.route(router, 'get', '/etapi/branches/:branchId', (req, res, next) => {
|
||||
@ -81,6 +81,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
const cls = require("../services/cls");
|
||||
const sql = require("../services/sql");
|
||||
const log = require("../services/log");
|
||||
const becca = require("../becca/becca");
|
||||
const etapiTokenService = require("../services/etapi_tokens");
|
||||
const config = require("../services/config");
|
||||
import cls from '../services/cls.js'
|
||||
import sql from '../services/sql.js'
|
||||
import log from '../services/log.js'
|
||||
import becca from '../becca/becca.js'
|
||||
import etapiTokenService from '../services/etapi_tokens.js'
|
||||
import config from '../services/config.js'
|
||||
const GENERIC_CODE = "GENERIC";
|
||||
|
||||
const noAuthentication = config.General && config.General.noAuthentication === true;
|
||||
@ -136,7 +136,7 @@ function validateAndPatch(target, source, allowedProperties) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
EtapiError,
|
||||
sendError,
|
||||
route,
|
||||
@ -147,4 +147,4 @@ module.exports = {
|
||||
getAndCheckBranch,
|
||||
getAndCheckAttribute,
|
||||
getAndCheckAttachment
|
||||
}
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ function mapAttachmentToPojo(attachment) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
mapNoteToPojo,
|
||||
mapBranchToPojo,
|
||||
mapAttributeToPojo,
|
||||
|
@ -1,14 +1,14 @@
|
||||
const becca = require("../becca/becca");
|
||||
const utils = require("../services/utils");
|
||||
const eu = require("./etapi_utils");
|
||||
const mappers = require("./mappers");
|
||||
const noteService = require("../services/notes");
|
||||
const TaskContext = require("../services/task_context");
|
||||
const v = require("./validators");
|
||||
const searchService = require("../services/search/services/search");
|
||||
const SearchContext = require("../services/search/search_context");
|
||||
const zipExportService = require("../services/export/zip");
|
||||
const zipImportService = require("../services/import/zip");
|
||||
import becca from '../becca/becca.js'
|
||||
import utils from '../services/utils.js'
|
||||
import eu from './etapi_utils.js'
|
||||
import mappers from './mappers.js'
|
||||
import noteService from '../services/notes.js'
|
||||
import TaskContext from '../services/task_context.js'
|
||||
import v from './validators.js'
|
||||
import searchService from '../services/search/services/search.js'
|
||||
import SearchContext from '../services/search/search_context.js'
|
||||
import zipExportService from '../services/export/zip.js'
|
||||
import zipImportService from '../services/import/zip.js'
|
||||
|
||||
function register(router) {
|
||||
eu.route(router, 'get', '/etapi/notes', (req, res, next) => {
|
||||
@ -251,6 +251,6 @@ function parseInteger(obj, name) {
|
||||
return integer;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,5 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const specPath = path.join(__dirname, 'etapi.openapi.yaml');
|
||||
let spec = null;
|
||||
@ -15,6 +18,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
const specialNotesService = require("../services/special_notes");
|
||||
const dateNotesService = require("../services/date_notes");
|
||||
const eu = require("./etapi_utils");
|
||||
const mappers = require("./mappers");
|
||||
import specialNotesService from '../services/special_notes.js'
|
||||
import dateNotesService from '../services/date_notes.js'
|
||||
import eu from './etapi_utils.js'
|
||||
import mappers from './mappers.js'
|
||||
|
||||
const getDateInvalidError = date => new eu.EtapiError(400, "DATE_INVALID", `Date "${date}" is not valid.`);
|
||||
const getMonthInvalidError = month => new eu.EtapiError(400, "MONTH_INVALID", `Month "${month}" is not valid.`);
|
||||
@ -72,6 +72,6 @@ function register(router) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
register
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
const noteTypeService = require("../services/note_types");
|
||||
const dateUtils = require("../services/date_utils");
|
||||
import noteTypeService from '../services/note_types.js'
|
||||
import dateUtils from '../services/date_utils.js'
|
||||
|
||||
import becca from '../becca/becca.js'
|
||||
|
||||
function mandatory(obj) {
|
||||
if (obj === undefined ) {
|
||||
@ -63,9 +65,6 @@ function isNoteId(obj) {
|
||||
if (obj === undefined || obj === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const becca = require('../becca/becca');
|
||||
|
||||
if (typeof obj !== 'string') {
|
||||
return `'${obj}' is not a valid noteId`;
|
||||
}
|
||||
@ -107,7 +106,7 @@ function isValidEntityId(obj) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
mandatory,
|
||||
notNull,
|
||||
isString,
|
||||
|
@ -10,6 +10,10 @@ import bundleService from "../services/bundle.js";
|
||||
import froca from "../services/froca.js";
|
||||
import linkService from "../services/link.js";
|
||||
|
||||
import {getCurrentWebContents, getCurrentWindow} from "@electron/remote";
|
||||
|
||||
import {ipcRenderer} from "electron";
|
||||
|
||||
export default class Entrypoints extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
@ -24,7 +28,7 @@ export default class Entrypoints extends Component {
|
||||
|
||||
openDevToolsCommand() {
|
||||
if (utils.isElectron()) {
|
||||
utils.dynamicRequire('@electron/remote').getCurrentWindow().toggleDevTools();
|
||||
getCurrentWindow().toggleDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +82,7 @@ export default class Entrypoints extends Component {
|
||||
|
||||
toggleFullscreenCommand() {
|
||||
if (utils.isElectron()) {
|
||||
const win = utils.dynamicRequire('@electron/remote').getCurrentWindow();
|
||||
const win = getCurrentWindow();
|
||||
|
||||
if (win.isFullScreenable()) {
|
||||
win.setFullScreen(!win.isFullScreen());
|
||||
@ -101,7 +105,7 @@ export default class Entrypoints extends Component {
|
||||
backInNoteHistoryCommand() {
|
||||
if (utils.isElectron()) {
|
||||
// standard JS version does not work completely correctly in electron
|
||||
const webContents = utils.dynamicRequire('@electron/remote').getCurrentWebContents();
|
||||
const webContents = getCurrentWebContents();
|
||||
const activeIndex = parseInt(webContents.getActiveIndex());
|
||||
|
||||
webContents.goToIndex(activeIndex - 1);
|
||||
@ -114,7 +118,7 @@ export default class Entrypoints extends Component {
|
||||
forwardInNoteHistoryCommand() {
|
||||
if (utils.isElectron()) {
|
||||
// standard JS version does not work completely correctly in electron
|
||||
const webContents = utils.dynamicRequire('@electron/remote').getCurrentWebContents();
|
||||
const webContents = getCurrentWebContents();
|
||||
const activeIndex = parseInt(webContents.getActiveIndex());
|
||||
|
||||
webContents.goToIndex(activeIndex + 1);
|
||||
@ -140,8 +144,6 @@ export default class Entrypoints extends Component {
|
||||
const extraWindowHash = linkService.calculateHash({notePath, hoistedNoteId, viewScope});
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const {ipcRenderer} = utils.dynamicRequire('electron');
|
||||
|
||||
ipcRenderer.send('create-extra-window', { extraWindowHash });
|
||||
}
|
||||
else {
|
||||
|
@ -158,7 +158,7 @@ class NoteContext extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await hoistedNoteService.checkNoteAccess(resolvedNotePath, this) === false) {
|
||||
if ((await hoistedNoteService.checkNoteAccess(resolvedNotePath, this)) === false) {
|
||||
return; // note is outside of hoisted subtree and user chose not to unhoist
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ import options from "../services/options.js";
|
||||
import froca from "../services/froca.js";
|
||||
import utils from "../services/utils.js";
|
||||
|
||||
import {BrowserWindow} from "@electron/remote";
|
||||
|
||||
export default class RootCommandExecutor extends Component {
|
||||
editReadOnlyNoteCommand() {
|
||||
const noteContext = appContext.tabManager.getActiveContext();
|
||||
@ -158,7 +160,6 @@ export default class RootCommandExecutor extends Component {
|
||||
|
||||
toggleTrayCommand() {
|
||||
if (!utils.isElectron()) return;
|
||||
const {BrowserWindow} = utils.dynamicRequire('@electron/remote');
|
||||
const windows = BrowserWindow.getAllWindows();
|
||||
const isVisible = windows.every(w => w.isVisible());
|
||||
const action = isVisible ? "hide" : "show"
|
||||
|
@ -248,7 +248,7 @@ export default class TabManager extends Component {
|
||||
|
||||
async switchToNoteContext(ntxId, notePath, viewScope = {}, hoistedNoteId = null) {
|
||||
const noteContext = this.noteContexts.find(nc => nc.ntxId === ntxId)
|
||||
|| await this.openEmptyTab();
|
||||
|| (await this.openEmptyTab());
|
||||
|
||||
await this.activateNoteContext(noteContext.ntxId);
|
||||
|
||||
|
@ -2,6 +2,8 @@ import options from "../services/options.js";
|
||||
import Component from "./component.js";
|
||||
import utils from "../services/utils.js";
|
||||
|
||||
import {webFrame} from "electron";
|
||||
|
||||
const MIN_ZOOM = 0.5;
|
||||
const MAX_ZOOM = 2.0;
|
||||
|
||||
@ -24,8 +26,6 @@ class ZoomComponent extends Component {
|
||||
|
||||
setZoomFactor(zoomFactor) {
|
||||
zoomFactor = parseFloat(zoomFactor);
|
||||
|
||||
const webFrame = utils.dynamicRequire('electron').webFrame;
|
||||
webFrame.setZoomFactor(zoomFactor);
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ class ZoomComponent extends Component {
|
||||
}
|
||||
|
||||
getCurrentZoom() {
|
||||
return utils.dynamicRequire('electron').webFrame.getZoomFactor();
|
||||
return webFrame.getZoomFactor();
|
||||
}
|
||||
|
||||
zoomOutEvent() {
|
||||
@ -56,7 +56,7 @@ class ZoomComponent extends Component {
|
||||
zoomResetEvent() {
|
||||
this.setZoomFactorAndSave(1);
|
||||
}
|
||||
|
||||
|
||||
setZoomFactorAndSaveEvent({zoomFactor}) {
|
||||
this.setZoomFactorAndSave(zoomFactor);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import electronContextMenu from "./menus/electron_context_menu.js";
|
||||
import DesktopLayout from "./layouts/desktop_layout.js";
|
||||
import glob from "./services/glob.js";
|
||||
|
||||
import {ipcRenderer} from "electron";
|
||||
|
||||
bundleService.getWidgetBundlesByParent().then(widgetBundles => {
|
||||
appContext.setLayout(new DesktopLayout(widgetBundles));
|
||||
appContext.start();
|
||||
@ -16,7 +18,7 @@ bundleService.getWidgetBundlesByParent().then(widgetBundles => {
|
||||
glob.setupGlobs();
|
||||
|
||||
if (utils.isElectron()) {
|
||||
utils.dynamicRequire('electron').ipcRenderer.on('globalShortcut',
|
||||
ipcRenderer.on('globalShortcut',
|
||||
async (event, actionName) => appContext.triggerCommand(actionName));
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,11 @@ import options from "../services/options.js";
|
||||
import zoomService from "../components/zoom.js";
|
||||
import contextMenu from "./context_menu.js";
|
||||
|
||||
function setupContextMenu() {
|
||||
const electron = utils.dynamicRequire('electron');
|
||||
import electron from "electron";
|
||||
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
import remote from "@electron/remote";
|
||||
|
||||
function setupContextMenu() {
|
||||
const {webContents} = remote.getCurrentWindow();
|
||||
|
||||
webContents.on('context-menu', (event, params) => {
|
||||
|
@ -134,7 +134,7 @@ export default class TreeContextMenu {
|
||||
this.treeWidget.triggerCommand("openNewNoteSplit", {ntxId, notePath});
|
||||
}
|
||||
else if (command === 'convertNoteToAttachment') {
|
||||
if (!await dialogService.confirm(`Are you sure you want to convert note selected notes into attachments of their parent notes?`)) {
|
||||
if (!(await dialogService.confirm(`Are you sure you want to convert note selected notes into attachments of their parent notes?`))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,10 @@ import froca from "./froca.js";
|
||||
import linkService from "./link.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
|
||||
// https://github.com/zadam/trilium/issues/2401
|
||||
import {clipboard} from "electron";
|
||||
|
||||
let clipboardBranchIds = [];
|
||||
let clipboardMode = null;
|
||||
|
||||
@ -66,8 +70,6 @@ async function copy(branchIds) {
|
||||
clipboardMode = 'copy';
|
||||
|
||||
if (utils.isElectron()) {
|
||||
// https://github.com/zadam/trilium/issues/2401
|
||||
const {clipboard} = require('electron');
|
||||
const links = [];
|
||||
|
||||
for (const branch of froca.getBranches(clipboardBranchIds)) {
|
||||
|
@ -53,7 +53,7 @@ async function checkNoteAccess(notePath, noteContext) {
|
||||
const hoistedNote = await froca.getNote(hoistedNoteId);
|
||||
|
||||
if (!hoistedNote.hasAncestor('_hidden')
|
||||
&& !await dialogService.confirm(`Requested note '${requestedNote.title}' is outside of hoisted note '${hoistedNote.title}' subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?`)) {
|
||||
&& !(await dialogService.confirm(`Requested note '${requestedNote.title}' is outside of hoisted note '${hoistedNote.title}' subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?`))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import appContext from "../components/app_context.js";
|
||||
import froca from "./froca.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
import electron from "electron";
|
||||
|
||||
function getNotePathFromUrl(url) {
|
||||
const notePathMatch = /#(root[A-Za-z0-9_/]*)$/.exec(url);
|
||||
|
||||
@ -242,8 +244,6 @@ function goToLinkExt(evt, hrefLink, $link) {
|
||||
if (hrefLink.toLowerCase().startsWith('http') || hrefLink.startsWith("api/")) {
|
||||
window.open(hrefLink, '_blank');
|
||||
} else if (hrefLink.toLowerCase().startsWith('file:') && utils.isElectron()) {
|
||||
const electron = utils.dynamicRequire('electron');
|
||||
|
||||
electron.shell.openPath(hrefLink);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
import utils from "./utils.js";
|
||||
import server from "./server.js";
|
||||
|
||||
import remote from "@electron/remote";
|
||||
|
||||
import {exec} from "child_process";
|
||||
|
||||
import electron from "electron";
|
||||
|
||||
function checkType(type) {
|
||||
if (type !== 'notes' && type !== 'attachments') {
|
||||
throw new Error(`Unrecognized type '${type}', should be 'notes' or 'attachments'`);
|
||||
@ -21,8 +27,6 @@ function getOpenFileUrl(type, noteId) {
|
||||
|
||||
function download(url) {
|
||||
if (utils.isElectron()) {
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
|
||||
remote.getCurrentWebContents().downloadURL(url);
|
||||
} else {
|
||||
window.location.href = url;
|
||||
@ -49,7 +53,6 @@ async function openCustom(type, entityId, mime) {
|
||||
|
||||
const resp = await server.post(`${type}/${entityId}/save-to-tmp-dir`);
|
||||
let filePath = resp.tmpFilePath;
|
||||
const {exec} = utils.dynamicRequire('child_process');
|
||||
const platform = process.platform;
|
||||
|
||||
if (platform === 'linux') {
|
||||
@ -139,8 +142,6 @@ async function openExternally(type, entityId, mime) {
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const resp = await server.post(`${type}/${entityId}/save-to-tmp-dir`);
|
||||
|
||||
const electron = utils.dynamicRequire('electron');
|
||||
const res = await electron.shell.openPath(resp.tmpFilePath);
|
||||
|
||||
if (res) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
import utils from './utils.js';
|
||||
import ValidationError from "./validation_error.js";
|
||||
|
||||
import {ipcRenderer as ipc} from "electron";
|
||||
|
||||
async function getHeaders(headers) {
|
||||
const appContext = (await import('../components/app_context.js')).default;
|
||||
const activeNoteContext = appContext.tabManager ? appContext.tabManager.getActiveContext() : null;
|
||||
@ -81,7 +83,6 @@ async function call(method, url, componentId, options = {}) {
|
||||
const {data} = options;
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const ipc = utils.dynamicRequire('electron').ipcRenderer;
|
||||
const requestId = idCounter++;
|
||||
|
||||
resp = await new Promise((resolve, reject) => {
|
||||
@ -159,8 +160,6 @@ function ajax(url, method, data, headers, silentNotFound) {
|
||||
}
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const ipc = utils.dynamicRequire('electron').ipcRenderer;
|
||||
|
||||
ipc.on('server-response', async (event, arg) => {
|
||||
if (arg.statusCode >= 200 && arg.statusCode < 300) {
|
||||
handleSuccessfulResponse(arg);
|
||||
|
@ -4,6 +4,8 @@ import froca from './froca.js';
|
||||
import hoistedNoteService from '../services/hoisted_note.js';
|
||||
import appContext from "../components/app_context.js";
|
||||
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
|
||||
/**
|
||||
* @returns {string|null}
|
||||
*/
|
||||
@ -121,7 +123,7 @@ ws.subscribeToMessages(message => {
|
||||
appContext.tabManager.activateOrOpenNote(message.noteId);
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const currentWindow = utils.dynamicRequire('@electron/remote').getCurrentWindow();
|
||||
const currentWindow = getCurrentWindow();
|
||||
|
||||
currentWindow.show();
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import utils from "./services/utils.js";
|
||||
import macInit from './services/mac_init.js';
|
||||
|
||||
import remote from "@electron/remote";
|
||||
|
||||
macInit.init();
|
||||
|
||||
function SetupModel() {
|
||||
@ -84,7 +86,6 @@ async function checkOutstandingSyncs() {
|
||||
|
||||
if (initialized) {
|
||||
if (utils.isElectron()) {
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
remote.app.relaunch();
|
||||
remote.app.exit(0);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
async deleteAttachmentCommand() {
|
||||
if (!await dialogService.confirm(`Are you sure you want to delete attachment '${this.attachment.title}'?`)) {
|
||||
if (!(await dialogService.confirm(`Are you sure you want to delete attachment '${this.attachment.title}'?`))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
async convertAttachmentIntoNoteCommand() {
|
||||
if (!await dialogService.confirm(`Are you sure you want to convert attachment '${this.attachment.title}' into a separate note?`)) {
|
||||
if (!(await dialogService.confirm(`Are you sure you want to convert attachment '${this.attachment.title}' into a separate note?`))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ import utils from "../../services/utils.js";
|
||||
import UpdateAvailableWidget from "./update_available.js";
|
||||
import options from "../../services/options.js";
|
||||
|
||||
import {webFrame} from "electron";
|
||||
|
||||
const TPL = `
|
||||
<div class="dropdown global-menu dropright">
|
||||
<style>
|
||||
@ -281,7 +283,7 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
const zoomFactor = utils.dynamicRequire('electron').webFrame.getZoomFactor();
|
||||
const zoomFactor = webFrame.getZoomFactor();
|
||||
const zoomPercent = Math.round(zoomFactor * 100);
|
||||
|
||||
this.$zoomState.text(`${zoomPercent}%`);
|
||||
|
@ -3,6 +3,8 @@ import contextMenu from "../../menus/context_menu.js";
|
||||
import treeService from "../../services/tree.js";
|
||||
import ButtonFromNoteWidget from "./button_from_note.js";
|
||||
|
||||
import {getCurrentWebContents} from "@electron/remote";
|
||||
|
||||
export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
constructor(launcherNote, command) {
|
||||
super();
|
||||
@ -27,7 +29,7 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
this.webContents = utils.dynamicRequire('@electron/remote').getCurrentWebContents();
|
||||
this.webContents = getCurrentWebContents();
|
||||
|
||||
// without this, the history is preserved across frontend reloads
|
||||
this.webContents.clearHistory();
|
||||
|
@ -119,7 +119,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
async convertNoteIntoAttachmentCommand() {
|
||||
if (!await dialogService.confirm(`Are you sure you want to convert note '${this.note.title}' into an attachment of the parent note?`)) {
|
||||
if (!(await dialogService.confirm(`Are you sure you want to convert note '${this.note.title}' into an attachment of the parent note?`))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ import BasicWidget from "../basic_widget.js";
|
||||
import shortcutService from "../../services/shortcuts.js";
|
||||
import server from "../../services/server.js";
|
||||
|
||||
import {clipboard} from "electron";
|
||||
|
||||
const TPL = `
|
||||
<div class="markdown-import-dialog modal fade mx-auto" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
@ -69,7 +71,6 @@ export default class MarkdownImportDialog extends BasicWidget {
|
||||
}
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const {clipboard} = utils.dynamicRequire('electron');
|
||||
const text = clipboard.readText();
|
||||
|
||||
this.convertMarkdownToHtml(text);
|
||||
|
@ -173,9 +173,9 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
type = 'readOnlyCode';
|
||||
} else if (viewScope.viewMode === 'attachments') {
|
||||
type = viewScope.attachmentId ? 'attachmentDetail' : 'attachmentList';
|
||||
} else if (type === 'text' && await this.noteContext.isReadOnly()) {
|
||||
} else if (type === 'text' && (await this.noteContext.isReadOnly())) {
|
||||
type = 'readOnlyText';
|
||||
} else if ((type === 'code' || type === 'mermaid') && await this.noteContext.isReadOnly()) {
|
||||
} else if ((type === 'code' || type === 'mermaid') && (await this.noteContext.isReadOnly())) {
|
||||
type = 'readOnlyCode';
|
||||
} else if (type === 'text') {
|
||||
type = 'editableText';
|
||||
@ -303,7 +303,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
this.handleEvent('noteTypeMimeChanged', {noteId: this.noteId});
|
||||
}
|
||||
else if (loadResults.isNoteReloaded(this.noteId, this.componentId)
|
||||
&& (this.type !== await this.getWidgetType() || this.mime !== this.note.mime)) {
|
||||
&& (this.type !== (await this.getWidgetType()) || this.mime !== this.note.mime)) {
|
||||
|
||||
// this needs to have a triggerEvent so that e.g., note type (not in the component subtree) is updated
|
||||
this.triggerEvent('noteTypeMimeChanged', {noteId: this.noteId});
|
||||
|
@ -998,8 +998,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
const oldActiveNode = this.getActiveNode();
|
||||
|
||||
const newActiveNode = this.noteContext?.notePath
|
||||
&& (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || await hoistedNoteService.isHoistedInHiddenSubtree())
|
||||
&& await this.getNodeFromPath(this.noteContext.notePath);
|
||||
&& (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || (await hoistedNoteService.isHoistedInHiddenSubtree()))
|
||||
&& (await this.getNodeFromPath(this.noteContext.notePath));
|
||||
|
||||
if (newActiveNode !== oldActiveNode) {
|
||||
let oldActiveNodeFocused = false;
|
||||
|
@ -135,7 +135,7 @@ export default class NoteTypeWidget extends NoteContextAwareWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type !== this.note.type && !await this.confirmChangeIfContent()) {
|
||||
if (type !== this.note.type && !(await this.confirmChangeIfContent())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ export default class SharedSwitchWidget extends SwitchWidget {
|
||||
if (this.note.getParentBranches().length === 1) {
|
||||
const text = "This note exists only as a shared note, unsharing would delete it. Do you want to continue and thus delete this note?";
|
||||
|
||||
if (!await dialogService.confirm(text)) {
|
||||
if (!(await dialogService.confirm(text))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import BasicWidget from "./basic_widget.js";
|
||||
import options from "../services/options.js";
|
||||
import utils from "../services/utils.js";
|
||||
|
||||
import remote from "@electron/remote";
|
||||
|
||||
const TPL = `
|
||||
<div class="title-bar-buttons">
|
||||
<style>
|
||||
@ -59,7 +61,6 @@ export default class TitleBarButtonsWidget extends BasicWidget {
|
||||
// When the window is restarted, the window will not be reset when it is set to the top,
|
||||
// so get the window status and set the icon background
|
||||
setTimeout(() => {
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
if (remote.BrowserWindow.getFocusedWindow()?.isAlwaysOnTop()) {
|
||||
$topBtn.addClass('active');
|
||||
}
|
||||
@ -67,7 +68,6 @@ export default class TitleBarButtonsWidget extends BasicWidget {
|
||||
|
||||
$topBtn.on('click', () => {
|
||||
$topBtn.trigger('blur');
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
const focusedWindow = remote.BrowserWindow.getFocusedWindow();
|
||||
const isAlwaysOnTop = focusedWindow.isAlwaysOnTop()
|
||||
if (isAlwaysOnTop) {
|
||||
@ -81,13 +81,11 @@ export default class TitleBarButtonsWidget extends BasicWidget {
|
||||
|
||||
$minimizeBtn.on('click', () => {
|
||||
$minimizeBtn.trigger('blur');
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
remote.BrowserWindow.getFocusedWindow().minimize();
|
||||
});
|
||||
|
||||
$maximizeBtn.on('click', () => {
|
||||
$maximizeBtn.trigger('blur');
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
const focusedWindow = remote.BrowserWindow.getFocusedWindow();
|
||||
|
||||
if (focusedWindow.isMaximized()) {
|
||||
@ -99,7 +97,6 @@ export default class TitleBarButtonsWidget extends BasicWidget {
|
||||
|
||||
$closeBtn.on('click', () => {
|
||||
$closeBtn.trigger('blur');
|
||||
const remote = utils.dynamicRequire('@electron/remote');
|
||||
remote.BrowserWindow.getFocusedWindow().close();
|
||||
});
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ import libraryLoader from "../../services/library_loader.js";
|
||||
import contextMenu from "../../menus/context_menu.js";
|
||||
import imageService from "../../services/image.js";
|
||||
|
||||
import {getCurrentWebContents} from "@electron/remote";
|
||||
|
||||
import electron from "electron";
|
||||
|
||||
const TPL = `
|
||||
<div class="note-detail-image note-detail-printable">
|
||||
<style>
|
||||
@ -75,8 +79,7 @@ class ImageTypeWidget extends TypeWidget {
|
||||
if (command === 'copyImageReferenceToClipboard') {
|
||||
imageService.copyImageReferenceToClipboard(this.$imageWrapper);
|
||||
} else if (command === 'copyImageToClipboard') {
|
||||
const webContents = utils.dynamicRequire('@electron/remote').getCurrentWebContents();
|
||||
utils.dynamicRequire('electron');
|
||||
const webContents = getCurrentWebContents();
|
||||
webContents.copyImageAt(e.pageX, e.pageY);
|
||||
} else {
|
||||
throw new Error(`Unrecognized command '${command}'`);
|
||||
|
@ -120,7 +120,7 @@ export default class EtapiOptions extends OptionsWidget {
|
||||
}
|
||||
|
||||
async deleteToken(etapiTokenId, name) {
|
||||
if (!await dialogService.confirm(`Are you sure you want to delete ETAPI token "${name}"?`)) {
|
||||
if (!(await dialogService.confirm(`Are you sure you want to delete ETAPI token "${name}"?`))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ export default class KeyboardShortcutsOptions extends OptionsWidget {
|
||||
});
|
||||
|
||||
this.$widget.find(".options-keyboard-shortcuts-set-all-to-default").on('click', async () => {
|
||||
if (!await dialogService.confirm("Do you really want to reset all keyboard shortcuts to the default?")) {
|
||||
if (!(await dialogService.confirm("Do you really want to reset all keyboard shortcuts to the default?"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import utils from "../../../services/utils.js";
|
||||
import OptionsWidget from "./options_widget.js";
|
||||
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
<h4>Spell Check</h4>
|
||||
@ -40,7 +42,7 @@ export default class SpellcheckOptions extends OptionsWidget {
|
||||
this.$availableLanguageCodes = this.$widget.find(".available-language-codes");
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const { webContents } = utils.dynamicRequire('@electron/remote').getCurrentWindow();
|
||||
const { webContents } = getCurrentWindow();
|
||||
|
||||
this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', '));
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
||||
items: [ {title: "Remove relation", command: "remove", uiIcon: "bx bx-trash"} ],
|
||||
selectMenuItemHandler: async ({command}) => {
|
||||
if (command === 'remove') {
|
||||
if (!await dialogService.confirm("Are you sure you want to remove the relation?")) {
|
||||
if (!(await dialogService.confirm("Are you sure you want to remove the relation?"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const appInfo = require('../../services/app_info');
|
||||
import appInfo from '../../services/app_info.js'
|
||||
|
||||
function getAppInfo() {
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getAppInfo
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
const becca = require("../../becca/becca");
|
||||
const blobService = require("../../services/blob");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
const imageService = require("../../services/image.js");
|
||||
import becca from '../../becca/becca.js'
|
||||
import blobService from '../../services/blob.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
import imageService from '../../services/image.js';
|
||||
|
||||
function getAttachmentBlob(req) {
|
||||
const preview = req.query.preview === 'true';
|
||||
@ -96,7 +96,7 @@ function convertAttachmentToNote(req) {
|
||||
return attachment.convertToNote();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getAttachmentBlob,
|
||||
getAttachments,
|
||||
getAttachment,
|
||||
|
@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const log = require('../../services/log');
|
||||
const attributeService = require('../../services/attributes');
|
||||
const BAttribute = require('../../becca/entities/battribute');
|
||||
const becca = require("../../becca/becca");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
import sql from '../../services/sql.js'
|
||||
import log from '../../services/log.js'
|
||||
import attributeService from '../../services/attributes.js'
|
||||
import BAttribute from '../../becca/entities/battribute.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
|
||||
function getEffectiveNoteAttributes(req) {
|
||||
const note = becca.getNote(req.params.noteId);
|
||||
@ -225,7 +225,7 @@ function deleteRelation(req) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
updateNoteAttributes,
|
||||
updateNoteAttribute,
|
||||
setNoteAttribute,
|
||||
|
@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const beccaService = require('../../becca/becca_service');
|
||||
const searchService = require('../../services/search/services/search');
|
||||
const log = require('../../services/log');
|
||||
const utils = require('../../services/utils');
|
||||
const cls = require('../../services/cls');
|
||||
const becca = require("../../becca/becca");
|
||||
import beccaService from '../../becca/becca_service.js'
|
||||
import searchService from '../../services/search/services/search.js'
|
||||
import log from '../../services/log.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import cls from '../../services/cls.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
|
||||
function getAutocomplete(req) {
|
||||
const query = req.query.query.trim();
|
||||
@ -70,6 +70,6 @@ function getRecentNotes(activeNoteId) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getAutocomplete
|
||||
};
|
||||
|
@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require('fs');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const {LOG_DIR} = require('../../services/data_dir');
|
||||
import fs from 'fs';
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import dataDir from '../../services/data_dir.js';
|
||||
|
||||
function getBackendLog() {
|
||||
const file = `${LOG_DIR}/trilium-${dateUtils.localNowDate()}.log`;
|
||||
const file = `${dataDir.LOG_DIR}/trilium-${dateUtils.localNowDate()}.log`;
|
||||
|
||||
try {
|
||||
return fs.readFileSync(file, 'utf8');
|
||||
@ -16,6 +16,6 @@ function getBackendLog() {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getBackendLog
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const entityChangesService = require('../../services/entity_changes');
|
||||
const treeService = require('../../services/tree');
|
||||
const eraseService = require('../../services/erase');
|
||||
const becca = require('../../becca/becca');
|
||||
const TaskContext = require('../../services/task_context');
|
||||
const branchService = require("../../services/branches");
|
||||
const log = require("../../services/log");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
const eventService = require("../../services/events.js");
|
||||
import sql from '../../services/sql.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import entityChangesService from '../../services/entity_changes.js'
|
||||
import treeService from '../../services/tree.js'
|
||||
import eraseService from '../../services/erase.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import TaskContext from '../../services/task_context.js'
|
||||
import branchService from '../../services/branches.js'
|
||||
import log from '../../services/log.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
import eventService from '../../services/events.js';
|
||||
|
||||
/**
|
||||
* Code in this file deals with moving and cloning branches. The relationship between note and parent note is unique
|
||||
@ -223,7 +223,7 @@ function setPrefix(req) {
|
||||
branch.save();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
moveBranchToParent,
|
||||
moveBranchBeforeNote,
|
||||
moveBranchAfterNote,
|
||||
|
@ -1,5 +1,5 @@
|
||||
const becca = require("../../becca/becca");
|
||||
const bulkActionService = require("../../services/bulk_actions");
|
||||
import becca from '../../becca/becca.js'
|
||||
import bulkActionService from '../../services/bulk_actions.js'
|
||||
|
||||
function execute(req) {
|
||||
const {noteIds, includeDescendants} = req.body;
|
||||
@ -42,7 +42,7 @@ function getAffectedNoteIds(noteIds, includeDescendants) {
|
||||
return affectedNoteIds;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
execute,
|
||||
getAffectedNoteCount
|
||||
};
|
||||
|
@ -1,19 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const attributeService = require("../../services/attributes");
|
||||
const cloneService = require("../../services/cloning");
|
||||
const noteService = require('../../services/notes');
|
||||
const dateNoteService = require('../../services/date_notes');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const imageService = require('../../services/image');
|
||||
const appInfo = require('../../services/app_info');
|
||||
const ws = require('../../services/ws');
|
||||
const log = require('../../services/log');
|
||||
const utils = require('../../services/utils');
|
||||
const path = require('path');
|
||||
const htmlSanitizer = require('../../services/html_sanitizer');
|
||||
const {formatAttrForSearch} = require("../../services/attribute_formatter");
|
||||
const jsdom = require("jsdom");
|
||||
import attributeService from '../../services/attributes.js'
|
||||
import cloneService from '../../services/cloning.js'
|
||||
import noteService from '../../services/notes.js'
|
||||
import dateNoteService from '../../services/date_notes.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import imageService from '../../services/image.js'
|
||||
import appInfo from '../../services/app_info.js'
|
||||
import ws from '../../services/ws.js'
|
||||
import log from '../../services/log.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import path from 'path';
|
||||
import htmlSanitizer from '../../services/html_sanitizer.js'
|
||||
import { formatAttrForSearch } from '../../services/attribute_formatter.js';
|
||||
import jsdom from 'jsdom';
|
||||
const { JSDOM } = jsdom;
|
||||
|
||||
function addClipping(req) {
|
||||
@ -211,7 +211,7 @@ function findNotesByUrl(req){
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
createNote,
|
||||
addClipping,
|
||||
openNote,
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const cloningService = require('../../services/cloning');
|
||||
import cloningService from '../../services/cloning.js'
|
||||
|
||||
function cloneNoteToBranch(req) {
|
||||
const {noteId, parentBranchId} = req.params;
|
||||
@ -28,7 +28,7 @@ function toggleNoteInParent(req) {
|
||||
return cloningService.toggleNoteInParent(present === 'true', noteId, parentNoteId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
cloneNoteToBranch,
|
||||
cloneNoteToParentNote,
|
||||
cloneNoteAfter,
|
||||
|
@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const log = require('../../services/log');
|
||||
const backupService = require('../../services/backup');
|
||||
const anonymizationService = require('../../services/anonymization');
|
||||
const consistencyChecksService = require('../../services/consistency_checks');
|
||||
import sql from '../../services/sql.js'
|
||||
import log from '../../services/log.js'
|
||||
import backupService from '../../services/backup.js'
|
||||
import anonymizationService from '../../services/anonymization.js'
|
||||
import consistencyChecksService from '../../services/consistency_checks.js'
|
||||
|
||||
function getExistingBackups() {
|
||||
return backupService.getExistingBackups();
|
||||
@ -44,7 +44,7 @@ function checkIntegrity() {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getExistingBackups,
|
||||
backupDatabase,
|
||||
vacuumDatabase,
|
||||
|
@ -1,4 +1,4 @@
|
||||
const etapiTokenService = require("../../services/etapi_tokens");
|
||||
import etapiTokenService from '../../services/etapi_tokens.js'
|
||||
|
||||
function getTokens() {
|
||||
const tokens = etapiTokenService.getTokens();
|
||||
@ -20,7 +20,7 @@ function deleteToken(req) {
|
||||
etapiTokenService.deleteToken(req.params.etapiTokenId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getTokens,
|
||||
createToken,
|
||||
patchToken,
|
||||
|
@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const zipExportService = require('../../services/export/zip');
|
||||
const singleExportService = require('../../services/export/single');
|
||||
const opmlExportService = require('../../services/export/opml');
|
||||
const becca = require('../../becca/becca');
|
||||
const TaskContext = require("../../services/task_context");
|
||||
const log = require("../../services/log");
|
||||
const NotFoundError = require("../../errors/not_found_error");
|
||||
import zipExportService from '../../services/export/zip.js'
|
||||
import singleExportService from '../../services/export/single.js'
|
||||
import opmlExportService from '../../services/export/opml.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import TaskContext from '../../services/task_context.js'
|
||||
import log from '../../services/log.js'
|
||||
import NotFoundError from '../../errors/not_found_error.js'
|
||||
|
||||
function exportBranch(req, res) {
|
||||
const {branchId, type, format, version, taskId} = req.params;
|
||||
@ -50,6 +50,6 @@ function exportBranch(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
exportBranch
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const utils = require('../../services/utils');
|
||||
const log = require('../../services/log');
|
||||
const noteService = require('../../services/notes');
|
||||
const tmp = require('tmp');
|
||||
const fs = require('fs');
|
||||
const { Readable } = require('stream');
|
||||
const chokidar = require('chokidar');
|
||||
const ws = require('../../services/ws');
|
||||
const becca = require("../../becca/becca");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import log from '../../services/log.js'
|
||||
import noteService from '../../services/notes.js'
|
||||
import tmp from 'tmp';
|
||||
import fs from 'fs';
|
||||
import { Readable } from 'stream';
|
||||
import chokidar from 'chokidar';
|
||||
import ws from '../../services/ws.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
|
||||
function updateFile(req) {
|
||||
const note = becca.getNoteOrThrow(req.params.noteId);
|
||||
@ -217,7 +217,7 @@ function uploadModifiedFileToAttachment(req) {
|
||||
attachment.setContent(fileContent);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
updateFile,
|
||||
updateAttachment,
|
||||
openFile,
|
||||
|
@ -1,4 +1,4 @@
|
||||
const optionService = require('../../services/options');
|
||||
import optionService from '../../services/options.js'
|
||||
|
||||
function getFontCss(req, res) {
|
||||
res.setHeader('Content-Type', 'text/css');
|
||||
@ -34,6 +34,6 @@ function getFontCss(req, res) {
|
||||
res.send(style);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getFontCss
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const imageService = require('../../services/image');
|
||||
const becca = require('../../becca/becca');
|
||||
const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR;
|
||||
const fs = require('fs');
|
||||
import imageService from '../../services/image.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import resourceDir from '../../services/resource_dir.js';
|
||||
import fs from 'fs';
|
||||
|
||||
function returnImageFromNote(req, res) {
|
||||
const image = becca.getNote(req.params.noteId);
|
||||
@ -24,7 +24,7 @@ function returnImageFromRevision(req, res) {
|
||||
function returnImageInt(image, res) {
|
||||
if (!image) {
|
||||
res.set('Content-Type', 'image/png');
|
||||
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
|
||||
return res.send(fs.readFileSync(`${resourceDir.RESOURCE_DIR}/db/image-deleted.png`));
|
||||
} else if (!["image", "canvas", "mermaid"].includes(image.type)) {
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
@ -67,7 +67,7 @@ function returnAttachedImage(req, res) {
|
||||
|
||||
if (!attachment) {
|
||||
res.set('Content-Type', 'image/png');
|
||||
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
|
||||
return res.send(fs.readFileSync(`${resourceDir.RESOURCE_DIR}/db/image-deleted.png`));
|
||||
}
|
||||
|
||||
if (!["image"].includes(attachment.role)) {
|
||||
@ -99,7 +99,7 @@ function updateImage(req) {
|
||||
return { uploaded: true };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
returnImageFromNote,
|
||||
returnImageFromRevision,
|
||||
returnAttachedImage,
|
||||
|
@ -1,16 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const enexImportService = require('../../services/import/enex');
|
||||
const opmlImportService = require('../../services/import/opml');
|
||||
const zipImportService = require('../../services/import/zip');
|
||||
const singleImportService = require('../../services/import/single');
|
||||
const cls = require('../../services/cls');
|
||||
const path = require('path');
|
||||
const becca = require('../../becca/becca');
|
||||
const beccaLoader = require('../../becca/becca_loader');
|
||||
const log = require('../../services/log');
|
||||
const TaskContext = require('../../services/task_context');
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
import enexImportService from '../../services/import/enex.js'
|
||||
import opmlImportService from '../../services/import/opml.js'
|
||||
import zipImportService from '../../services/import/zip.js'
|
||||
import singleImportService from '../../services/import/single.js'
|
||||
import cls from '../../services/cls.js'
|
||||
import path from 'path';
|
||||
import becca from '../../becca/becca.js'
|
||||
import beccaLoader from '../../becca/becca_loader.js'
|
||||
import log from '../../services/log.js'
|
||||
import TaskContext from '../../services/task_context.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
|
||||
async function importNotesToBranch(req) {
|
||||
const {parentNoteId} = req.params;
|
||||
@ -119,7 +119,7 @@ async function importAttachmentsToNote(req) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
importNotesToBranch,
|
||||
importAttachmentsToNote
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const keyboardActions = require('../../services/keyboard_actions');
|
||||
const becca = require('../../becca/becca');
|
||||
import keyboardActions from '../../services/keyboard_actions.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
|
||||
function getKeyboardActions() {
|
||||
return keyboardActions.getKeyboardActions();
|
||||
@ -14,7 +14,7 @@ function getShortcutsForNotes() {
|
||||
return labels.filter(attr => becca.getNote(attr.noteId)?.type !== 'launcher');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getKeyboardActions,
|
||||
getShortcutsForNotes
|
||||
};
|
||||
|
@ -1,17 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
const options = require('../../services/options');
|
||||
const utils = require('../../services/utils');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
const instanceId = require('../../services/instance_id');
|
||||
const passwordEncryptionService = require('../../services/encryption/password_encryption');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const appInfo = require('../../services/app_info');
|
||||
const eventService = require('../../services/events');
|
||||
const sqlInit = require('../../services/sql_init');
|
||||
const sql = require('../../services/sql');
|
||||
const ws = require("../../services/ws");
|
||||
const etapiTokenService = require("../../services/etapi_tokens");
|
||||
import options from '../../services/options.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
import instanceId from '../../services/instance_id.js'
|
||||
import passwordEncryptionService from '../../services/encryption/password_encryption.js'
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import appInfo from '../../services/app_info.js'
|
||||
import eventService from '../../services/events.js'
|
||||
import sqlInit from '../../services/sql_init.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import ws from '../../services/ws.js'
|
||||
import etapiTokenService from '../../services/etapi_tokens.js'
|
||||
|
||||
function loginSync(req) {
|
||||
if (!sqlInit.schemaExists()) {
|
||||
@ -102,7 +102,7 @@ function token(req) {
|
||||
return { token: authToken };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
loginSync,
|
||||
loginToProtectedSession,
|
||||
logoutFromProtectedSession,
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const becca = require("../../becca/becca");
|
||||
const { JSDOM } = require("jsdom");
|
||||
import becca from '../../becca/becca.js'
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
function buildDescendantCountMap(noteIdsToCount) {
|
||||
if (!Array.isArray(noteIdsToCount)) {
|
||||
@ -379,7 +379,7 @@ function getBacklinks(req) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getLinkMap,
|
||||
getTreeMap,
|
||||
getBacklinkCount,
|
||||
|
@ -1,15 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const noteService = require('../../services/notes');
|
||||
const eraseService = require('../../services/erase');
|
||||
const treeService = require('../../services/tree');
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const log = require('../../services/log');
|
||||
const TaskContext = require('../../services/task_context');
|
||||
const becca = require("../../becca/becca");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
const blobService = require("../../services/blob");
|
||||
import noteService from '../../services/notes.js'
|
||||
import eraseService from '../../services/erase.js'
|
||||
import treeService from '../../services/tree.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import log from '../../services/log.js'
|
||||
import TaskContext from '../../services/task_context.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
import blobService from '../../services/blob.js'
|
||||
|
||||
function getNote(req) {
|
||||
return becca.getNoteOrThrow(req.params.noteId);
|
||||
@ -236,7 +236,7 @@ function convertNoteToAttachment(req) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getNote,
|
||||
getNoteBlob,
|
||||
getNoteMetadata,
|
||||
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const optionService = require('../../services/options');
|
||||
const log = require('../../services/log');
|
||||
const searchService = require('../../services/search/services/search');
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
import optionService from '../../services/options.js'
|
||||
import log from '../../services/log.js'
|
||||
import searchService from '../../services/search/services/search.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
|
||||
// options allowed to be updated directly in the Options dialog
|
||||
const ALLOWED_OPTIONS = new Set([
|
||||
@ -135,7 +135,7 @@ function isAllowed(name) {
|
||||
|| name.startsWith("hideArchivedNotes");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getOptions,
|
||||
updateOption,
|
||||
updateOptions,
|
||||
|
@ -1,5 +1,5 @@
|
||||
const becca = require("../../becca/becca");
|
||||
const markdownService = require("../../services/import/markdown");
|
||||
import becca from '../../becca/becca.js'
|
||||
import markdownService from '../../services/import/markdown.js'
|
||||
|
||||
function getIconUsage() {
|
||||
const iconClassToCountMap = {};
|
||||
@ -33,7 +33,7 @@ function renderMarkdown(req) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getIconUsage,
|
||||
renderMarkdown
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const passwordService = require('../../services/encryption/password');
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
import passwordService from '../../services/encryption/password.js'
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
|
||||
function changePassword(req) {
|
||||
if (passwordService.isPasswordSet()) {
|
||||
@ -21,7 +21,7 @@ function resetPassword(req) {
|
||||
return passwordService.resetPassword();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
changePassword,
|
||||
resetPassword
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const noteService = require('../../services/notes');
|
||||
const becca = require("../../becca/becca");
|
||||
import sql from '../../services/sql.js'
|
||||
import protectedSessionService from '../../services/protected_session.js'
|
||||
import noteService from '../../services/notes.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
|
||||
function getRecentChanges(req) {
|
||||
const {ancestorNoteId} = req.params;
|
||||
@ -97,6 +97,6 @@ function getRecentChanges(req) {
|
||||
return recentChanges;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getRecentChanges
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const BRecentNote = require('../../becca/entities/brecent_note');
|
||||
const sql = require('../../services/sql');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
import BRecentNote from '../../becca/entities/brecent_note.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import dateUtils from '../../services/date_utils.js'
|
||||
|
||||
function addRecentNote(req) {
|
||||
new BRecentNote({
|
||||
@ -18,6 +18,6 @@ function addRecentNote(req) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
addRecentNote
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
const becca = require("../../becca/becca");
|
||||
const sql = require("../../services/sql");
|
||||
import becca from '../../becca/becca.js'
|
||||
import sql from '../../services/sql.js'
|
||||
|
||||
function getRelationMap(req) {
|
||||
const {relationMapNoteId, noteIds} = req.body;
|
||||
@ -64,6 +64,6 @@ function getRelationMap(req) {
|
||||
return resp;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getRelationMap
|
||||
};
|
@ -1,13 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
const beccaService = require('../../becca/becca_service');
|
||||
const revisionService = require('../../services/revisions');
|
||||
const utils = require('../../services/utils');
|
||||
const sql = require('../../services/sql');
|
||||
const cls = require('../../services/cls');
|
||||
const path = require('path');
|
||||
const becca = require("../../becca/becca");
|
||||
const blobService = require("../../services/blob");
|
||||
import beccaService from '../../becca/becca_service.js'
|
||||
import revisionService from '../../services/revisions.js'
|
||||
import utils from '../../services/utils.js'
|
||||
import sql from '../../services/sql.js'
|
||||
import cls from '../../services/cls.js'
|
||||
import path from 'path';
|
||||
import becca from '../../becca/becca.js'
|
||||
import blobService from '../../services/blob.js'
|
||||
|
||||
function getRevisionBlob(req) {
|
||||
const preview = req.query.preview === 'true';
|
||||
@ -185,7 +185,7 @@ function getNotePathData(note) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getRevisionBlob,
|
||||
getRevisions,
|
||||
getRevision,
|
||||
|
@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const scriptService = require('../../services/script');
|
||||
const attributeService = require('../../services/attributes');
|
||||
const becca = require('../../becca/becca');
|
||||
const syncService = require('../../services/sync');
|
||||
const sql = require('../../services/sql');
|
||||
import scriptService from '../../services/script.js'
|
||||
import attributeService from '../../services/attributes.js'
|
||||
import becca from '../../becca/becca.js'
|
||||
import syncService from '../../services/sync.js'
|
||||
import sql from '../../services/sql.js'
|
||||
|
||||
// The async/await here is very confusing, because the body.script may, but may not be async. If it is async, then we
|
||||
// need to await it and make the complete response including metadata available in a Promise, so that the route detects
|
||||
@ -120,7 +120,7 @@ function getBundle(req) {
|
||||
return scriptService.getScriptBundleForFrontend(note, script, params);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
exec,
|
||||
run,
|
||||
getStartupBundles,
|
||||
|
@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const becca = require('../../becca/becca');
|
||||
const SearchContext = require('../../services/search/search_context');
|
||||
const searchService = require('../../services/search/services/search');
|
||||
const bulkActionService = require("../../services/bulk_actions");
|
||||
const cls = require("../../services/cls");
|
||||
const {formatAttrForSearch} = require("../../services/attribute_formatter");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
import becca from '../../becca/becca.js'
|
||||
import SearchContext from '../../services/search/search_context.js'
|
||||
import searchService from '../../services/search/services/search.js'
|
||||
import bulkActionService from '../../services/bulk_actions.js'
|
||||
import cls from '../../services/cls.js'
|
||||
import { formatAttrForSearch } from '../../services/attribute_formatter.js';
|
||||
import ValidationError from '../../errors/validation_error.js'
|
||||
|
||||
function searchFromNote(req) {
|
||||
const note = becca.getNoteOrThrow(req.params.noteId);
|
||||
@ -123,7 +123,7 @@ function searchTemplates() {
|
||||
}).map(note => note.noteId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
searchFromNote,
|
||||
searchAndExecute,
|
||||
getRelatedNotes,
|
||||
|
@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const imageType = require('image-type');
|
||||
const imageService = require('../../services/image');
|
||||
const noteService = require('../../services/notes');
|
||||
const {sanitizeAttributeName} = require("../../services/sanitize_attribute_name");
|
||||
const specialNotesService = require("../../services/special_notes");
|
||||
import imageType from 'image-type';
|
||||
import imageService from '../../services/image.js'
|
||||
import noteService from '../../services/notes.js'
|
||||
import { sanitizeAttributeName } from '../../services/sanitize_attribute_name.js';
|
||||
import specialNotesService from '../../services/special_notes.js'
|
||||
|
||||
function uploadImage(req) {
|
||||
const file = req.file;
|
||||
@ -60,7 +60,7 @@ function saveNote(req) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
uploadImage,
|
||||
saveNote
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user