mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 02:22:26 +08:00
chore(code): fix editorconfig for src/public
This commit is contained in:
parent
ae90ff2df4
commit
b321d99076
@ -1,18 +1,18 @@
|
|||||||
// TODO: Deduplicate with src/services/entity_changes_interface.ts
|
// TODO: Deduplicate with src/services/entity_changes_interface.ts
|
||||||
export interface EntityChange {
|
export interface EntityChange {
|
||||||
id?: number | null;
|
id?: number | null;
|
||||||
noteId?: string;
|
noteId?: string;
|
||||||
entityName: string;
|
entityName: string;
|
||||||
entityId: string;
|
entityId: string;
|
||||||
entity?: any;
|
entity?: any;
|
||||||
positions?: Record<string, number>;
|
positions?: Record<string, number>;
|
||||||
hash: string;
|
hash: string;
|
||||||
utcDateChanged?: string;
|
utcDateChanged?: string;
|
||||||
utcDateModified?: string;
|
utcDateModified?: string;
|
||||||
utcDateCreated?: string;
|
utcDateCreated?: string;
|
||||||
isSynced: boolean | 1 | 0;
|
isSynced: boolean | 1 | 0;
|
||||||
isErased: boolean | 1 | 0;
|
isErased: boolean | 1 | 0;
|
||||||
componentId?: string | null;
|
componentId?: string | null;
|
||||||
changeId?: string | null;
|
changeId?: string | null;
|
||||||
instanceId?: string | null;
|
instanceId?: string | null;
|
||||||
}
|
}
|
@ -111,4 +111,3 @@
|
|||||||
.calendar-dropdown-widget .calendar-date:not(.calendar-date-active) {
|
.calendar-dropdown-widget .calendar-date:not(.calendar-date-active) {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ html {
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
/* Fix for CKEditor block gutter icon "stretching" body and causing scrollbar to appear after pressing enter
|
/* Fix for CKEditor block gutter icon "stretching" body and causing scrollbar to appear after pressing enter
|
||||||
on the last line of the editor. */
|
on the last line of the editor. */
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Light theme is special since it's also baseline/default so when a theme does not define some variable then
|
/* Light theme is special since it's also baseline/default so when a theme does not define some variable then
|
||||||
value from this theme will be used. For this reason this theme uses "html" instead of ":root"
|
value from this theme will be used. For this reason this theme uses "html" instead of ":root"
|
||||||
since it's less "specific" and thus serves as default */
|
since it's less "specific" and thus serves as default */
|
||||||
html {
|
html {
|
||||||
/* either light or dark, colored theme with darker tones are also dark, used e.g. for note map node colors */
|
/* either light or dark, colored theme with darker tones are also dark, used e.g. for note map node colors */
|
||||||
--theme-style: light;
|
--theme-style: light;
|
||||||
|
@ -49,18 +49,18 @@ function getRecentNotes(activeNoteId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const recentNotes = becca.getRecentNotesFromQuery(`
|
const recentNotes = becca.getRecentNotesFromQuery(`
|
||||||
SELECT
|
SELECT
|
||||||
recent_notes.*
|
recent_notes.*
|
||||||
FROM
|
FROM
|
||||||
recent_notes
|
recent_notes
|
||||||
JOIN notes USING(noteId)
|
JOIN notes USING(noteId)
|
||||||
WHERE
|
WHERE
|
||||||
notes.isDeleted = 0
|
notes.isDeleted = 0
|
||||||
AND notes.noteId != ?
|
AND notes.noteId != ?
|
||||||
${extraCondition}
|
${extraCondition}
|
||||||
ORDER BY
|
ORDER BY
|
||||||
utcDateCreated DESC
|
utcDateCreated DESC
|
||||||
LIMIT 200`, params);
|
LIMIT 200`, params);
|
||||||
|
|
||||||
return recentNotes.map(rn => {
|
return recentNotes.map(rn => {
|
||||||
const notePathArray = rn.notePath.split('/');
|
const notePathArray = rn.notePath.split('/');
|
||||||
|
@ -219,9 +219,9 @@ function getDeleteNotesPreview(req: Request) {
|
|||||||
brokenRelations = sql.getRows<AttributeRow>(`
|
brokenRelations = sql.getRows<AttributeRow>(`
|
||||||
SELECT attr.noteId, attr.name, attr.value
|
SELECT attr.noteId, attr.name, attr.value
|
||||||
FROM attributes attr
|
FROM attributes attr
|
||||||
JOIN param_list ON param_list.paramId = attr.value
|
JOIN param_list ON param_list.paramId = attr.value
|
||||||
WHERE attr.isDeleted = 0
|
WHERE attr.isDeleted = 0
|
||||||
AND attr.type = 'relation'`).filter(attr => attr.noteId && !noteIdsToBeDeleted.has(attr.noteId));
|
AND attr.type = 'relation'`).filter(attr => attr.noteId && !noteIdsToBeDeleted.has(attr.noteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -35,7 +35,7 @@ function getRevisionBlob(req: Request) {
|
|||||||
function getRevisions(req: Request) {
|
function getRevisions(req: Request) {
|
||||||
return becca.getRevisionsFromQuery(`
|
return becca.getRevisionsFromQuery(`
|
||||||
SELECT revisions.*,
|
SELECT revisions.*,
|
||||||
LENGTH(blobs.content) AS contentLength
|
LENGTH(blobs.content) AS contentLength
|
||||||
FROM revisions
|
FROM revisions
|
||||||
JOIN blobs ON revisions.blobId = blobs.blobId
|
JOIN blobs ON revisions.blobId = blobs.blobId
|
||||||
WHERE revisions.noteId = ?
|
WHERE revisions.noteId = ?
|
||||||
@ -160,7 +160,7 @@ function getEditedNotesOnDate(req: Request) {
|
|||||||
WHERE noteId IN (
|
WHERE noteId IN (
|
||||||
SELECT noteId FROM notes
|
SELECT noteId FROM notes
|
||||||
WHERE notes.dateCreated LIKE :date
|
WHERE notes.dateCreated LIKE :date
|
||||||
OR notes.dateModified LIKE :date
|
OR notes.dateModified LIKE :date
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT noteId FROM revisions
|
SELECT noteId FROM revisions
|
||||||
WHERE revisions.dateLastEdited LIKE :date
|
WHERE revisions.dateLastEdited LIKE :date
|
||||||
|
@ -12,8 +12,8 @@ function getNoteSize(req: Request) {
|
|||||||
LEFT JOIN attachments ON attachments.blobId = blobs.blobId AND attachments.ownerId = ? AND attachments.isDeleted = 0
|
LEFT JOIN attachments ON attachments.blobId = blobs.blobId AND attachments.ownerId = ? AND attachments.isDeleted = 0
|
||||||
LEFT JOIN revisions ON revisions.blobId = blobs.blobId AND revisions.noteId = ?
|
LEFT JOIN revisions ON revisions.blobId = blobs.blobId AND revisions.noteId = ?
|
||||||
WHERE notes.noteId IS NOT NULL
|
WHERE notes.noteId IS NOT NULL
|
||||||
OR attachments.attachmentId IS NOT NULL
|
OR attachments.attachmentId IS NOT NULL
|
||||||
OR revisions.revisionId IS NOT NULL`, [noteId, noteId, noteId]);
|
OR revisions.revisionId IS NOT NULL`, [noteId, noteId, noteId]);
|
||||||
|
|
||||||
const noteSize = Object.values(blobSizes).reduce((acc, blobSize) => acc + blobSize, 0);
|
const noteSize = Object.values(blobSizes).reduce((acc, blobSize) => acc + blobSize, 0);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ function getChanged(req: Request) {
|
|||||||
SELECT *
|
SELECT *
|
||||||
FROM entity_changes
|
FROM entity_changes
|
||||||
WHERE isSynced = 1
|
WHERE isSynced = 1
|
||||||
AND id > ?
|
AND id > ?
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
LIMIT 1000`, [lastEntityChangeId]);
|
LIMIT 1000`, [lastEntityChangeId]);
|
||||||
|
|
||||||
@ -133,8 +133,8 @@ function getChanged(req: Request) {
|
|||||||
SELECT COUNT(id)
|
SELECT COUNT(id)
|
||||||
FROM entity_changes
|
FROM entity_changes
|
||||||
WHERE isSynced = 1
|
WHERE isSynced = 1
|
||||||
AND instanceId != ?
|
AND instanceId != ?
|
||||||
AND id > ?`, [clientInstanceId, lastEntityChangeId])
|
AND id > ?`, [clientInstanceId, lastEntityChangeId])
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,22 +18,22 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
|
|||||||
async function register(app: express.Application) {
|
async function register(app: express.Application) {
|
||||||
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
if (env.isDev()) {
|
if (env.isDev()) {
|
||||||
const webpack = (await import("webpack")).default;
|
const webpack = (await import("webpack")).default;
|
||||||
const webpackMiddleware = (await import("webpack-dev-middleware")).default;
|
const webpackMiddleware = (await import("webpack-dev-middleware")).default;
|
||||||
const productionConfig = (await import("../../webpack.config.js")).default;
|
const productionConfig = (await import("../../webpack.config.js")).default;
|
||||||
|
|
||||||
const frontendCompiler = webpack({
|
const frontendCompiler = webpack({
|
||||||
mode: "development",
|
mode: "development",
|
||||||
entry: productionConfig.entry,
|
entry: productionConfig.entry,
|
||||||
module: productionConfig.module,
|
module: productionConfig.module,
|
||||||
resolve: productionConfig.resolve,
|
resolve: productionConfig.resolve,
|
||||||
devtool: productionConfig.devtool,
|
devtool: productionConfig.devtool,
|
||||||
target: productionConfig.target
|
target: productionConfig.target
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));
|
app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));
|
||||||
} else {
|
} else {
|
||||||
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, 'public/app')));
|
app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, 'public/app')));
|
||||||
}
|
}
|
||||||
app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(srcRoot, 'public/app-dist')));
|
app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(srcRoot, 'public/app-dist')));
|
||||||
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, 'public/fonts')));
|
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, 'public/fonts')));
|
||||||
@ -56,19 +56,19 @@ async function register(app: express.Application) {
|
|||||||
|
|
||||||
// KaTeX
|
// KaTeX
|
||||||
app.use(
|
app.use(
|
||||||
`/${assetPath}/node_modules/katex/dist/katex.min.js`,
|
`/${assetPath}/node_modules/katex/dist/katex.min.js`,
|
||||||
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/katex.min.js')));
|
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/katex.min.js')));
|
||||||
app.use(
|
app.use(
|
||||||
`/${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js`,
|
`/${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js`,
|
||||||
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/mhchem.min.js')));
|
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/mhchem.min.js')));
|
||||||
app.use(
|
app.use(
|
||||||
`/${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js`,
|
`/${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js`,
|
||||||
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/auto-render.min.js')));
|
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/auto-render.min.js')));
|
||||||
// expose the whole dist folder
|
// expose the whole dist folder
|
||||||
app.use(`/node_modules/katex/dist/`,
|
app.use(`/node_modules/katex/dist/`,
|
||||||
express.static(path.join(srcRoot, '..', 'node_modules/katex/dist/')));
|
express.static(path.join(srcRoot, '..', 'node_modules/katex/dist/')));
|
||||||
app.use(`/${assetPath}/node_modules/katex/dist/`,
|
app.use(`/${assetPath}/node_modules/katex/dist/`,
|
||||||
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/')));
|
persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/')));
|
||||||
|
|
||||||
app.use(`/${assetPath}/node_modules/dayjs/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/dayjs/')));
|
app.use(`/${assetPath}/node_modules/dayjs/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/dayjs/')));
|
||||||
app.use(`/${assetPath}/node_modules/force-graph/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/force-graph/dist/')));
|
app.use(`/${assetPath}/node_modules/force-graph/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/force-graph/dist/')));
|
||||||
|
@ -24,9 +24,9 @@ UPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN (${b
|
|||||||
UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered';
|
UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered';
|
||||||
UPDATE options SET value = 'anonymized' WHERE name IN
|
UPDATE options SET value = 'anonymized' WHERE name IN
|
||||||
('documentId', 'documentSecret', 'encryptedDataKey',
|
('documentId', 'documentSecret', 'encryptedDataKey',
|
||||||
'passwordVerificationHash', 'passwordVerificationSalt',
|
'passwordVerificationHash', 'passwordVerificationSalt',
|
||||||
'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')
|
'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')
|
||||||
AND value != '';
|
AND value != '';
|
||||||
|
|
||||||
VACUUM;
|
VACUUM;
|
||||||
`;
|
`;
|
||||||
@ -37,15 +37,15 @@ VACUUM;
|
|||||||
function getLightAnonymizationScript() {
|
function getLightAnonymizationScript() {
|
||||||
return `UPDATE blobs SET content = 'text' WHERE content IS NOT NULL AND blobId NOT IN (
|
return `UPDATE blobs SET content = 'text' WHERE content IS NOT NULL AND blobId NOT IN (
|
||||||
SELECT blobId FROM notes WHERE mime IN ('application/javascript;env=backend', 'application/javascript;env=frontend')
|
SELECT blobId FROM notes WHERE mime IN ('application/javascript;env=backend', 'application/javascript;env=frontend')
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT blobId FROM revisions WHERE mime IN ('application/javascript;env=backend', 'application/javascript;env=frontend')
|
SELECT blobId FROM revisions WHERE mime IN ('application/javascript;env=backend', 'application/javascript;env=frontend')
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE options SET value = 'anonymized' WHERE name IN
|
UPDATE options SET value = 'anonymized' WHERE name IN
|
||||||
('documentId', 'documentSecret', 'encryptedDataKey',
|
('documentId', 'documentSecret', 'encryptedDataKey',
|
||||||
'passwordVerificationHash', 'passwordVerificationSalt',
|
'passwordVerificationHash', 'passwordVerificationSalt',
|
||||||
'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')
|
'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')
|
||||||
AND value != '';`;
|
AND value != '';`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createAnonymizedCopy(type: "full" | "light") {
|
async function createAnonymizedCopy(type: "full" | "light") {
|
||||||
|
@ -48,7 +48,7 @@ function installLocalAppIcon() {
|
|||||||
|
|
||||||
fs.writeFile(desktopFilePath, getDesktopFileContent(), function (err) {
|
fs.writeFile(desktopFilePath, getDesktopFileContent(), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error("Desktop icon installation to ~/.local/share/applications failed.");
|
log.error("Desktop icon installation to ~/.local/share/applications failed.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ function escapePath(path: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExePath() {
|
function getExePath() {
|
||||||
return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium');
|
return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -66,10 +66,10 @@ function getAttributeNames(type: string, nameLike: string) {
|
|||||||
|
|
||||||
let names = sql.getColumn<string>(
|
let names = sql.getColumn<string>(
|
||||||
`SELECT DISTINCT name
|
`SELECT DISTINCT name
|
||||||
FROM attributes
|
FROM attributes
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND type = ?
|
AND type = ?
|
||||||
AND name LIKE ?`, [type, `%${nameLike}%`]);
|
AND name LIKE ?`, [type, `%${nameLike}%`]);
|
||||||
|
|
||||||
for (const attr of BUILTIN_ATTRIBUTES) {
|
for (const attr of BUILTIN_ATTRIBUTES) {
|
||||||
if (attr.type === type && attr.name.toLowerCase().includes(nameLike) && !names.includes(attr.name)) {
|
if (attr.type === type && attr.name.toLowerCase().includes(nameLike) && !names.includes(attr.name)) {
|
||||||
|
@ -61,51 +61,51 @@ interface NoteAndBranch {
|
|||||||
|
|
||||||
interface Api {
|
interface Api {
|
||||||
/**
|
/**
|
||||||
* Note where the script started executing (entrypoint).
|
* Note where the script started executing (entrypoint).
|
||||||
* As an analogy, in C this would be the file which contains the main() function of the current process.
|
* As an analogy, in C this would be the file which contains the main() function of the current process.
|
||||||
*/
|
*/
|
||||||
startNote?: BNote | null;
|
startNote?: BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note where the script is currently executing. This comes into play when your script is spread in multiple code
|
* Note where the script is currently executing. This comes into play when your script is spread in multiple code
|
||||||
* notes, the script starts in "startNote", but then through function calls may jump into another note (currentNote).
|
* notes, the script starts in "startNote", but then through function calls may jump into another note (currentNote).
|
||||||
* A similar concept in C would be __FILE__
|
* A similar concept in C would be __FILE__
|
||||||
* Don't mix this up with the concept of active note.
|
* Don't mix this up with the concept of active note.
|
||||||
*/
|
*/
|
||||||
currentNote: BNote;
|
currentNote: BNote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity whose event triggered this execution
|
* Entity whose event triggered this execution
|
||||||
*/
|
*/
|
||||||
originEntity?: AbstractBeccaEntity<any> | null;
|
originEntity?: AbstractBeccaEntity<any> | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Axios library for HTTP requests. See {@link https://axios-http.com} for documentation
|
* Axios library for HTTP requests. See {@link https://axios-http.com} for documentation
|
||||||
* @deprecated use native (browser compatible) fetch() instead
|
* @deprecated use native (browser compatible) fetch() instead
|
||||||
*/
|
*/
|
||||||
axios: typeof axios;
|
axios: typeof axios;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* day.js library for date manipulation. See {@link https://day.js.org} for documentation
|
* day.js library for date manipulation. See {@link https://day.js.org} for documentation
|
||||||
*/
|
*/
|
||||||
dayjs: typeof dayjs;
|
dayjs: typeof dayjs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation
|
* xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xml2js: typeof xml2js;
|
xml2js: typeof xml2js;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cheerio library for HTML parsing and manipulation. See {@link https://cheerio.js.org} for documentation
|
* cheerio library for HTML parsing and manipulation. See {@link https://cheerio.js.org} for documentation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cheerio: typeof cheerio;
|
cheerio: typeof cheerio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance name identifies particular Trilium instance. It can be useful for scripts
|
* Instance name identifies particular Trilium instance. It can be useful for scripts
|
||||||
* if some action needs to happen on only one specific instance.
|
* if some action needs to happen on only one specific instance.
|
||||||
*/
|
*/
|
||||||
getInstanceName(): string | null;
|
getInstanceName(): string | null;
|
||||||
|
|
||||||
getNote(noteId: string): BNote | null;
|
getNote(noteId: string): BNote | null;
|
||||||
@ -120,76 +120,76 @@ interface Api {
|
|||||||
getAttribute(attributeId: string): BAttribute | null;
|
getAttribute(attributeId: string): BAttribute | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||||
* "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options
|
* "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options
|
||||||
*/
|
*/
|
||||||
searchForNotes(query: string, searchParams: SearchParams): BNote[];
|
searchForNotes(query: string, searchParams: SearchParams): BNote[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||||
* "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options
|
* "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options
|
||||||
*/
|
*/
|
||||||
searchForNote(query: string, searchParams: SearchParams): BNote | null;
|
searchForNote(query: string, searchParams: SearchParams): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves notes with given label name & value
|
* Retrieves notes with given label name & value
|
||||||
*
|
*
|
||||||
* @param name - attribute name
|
* @param name - attribute name
|
||||||
* @param value - attribute value
|
* @param value - attribute value
|
||||||
*/
|
*/
|
||||||
getNotesWithLabel(name: string, value?: string): BNote[];
|
getNotesWithLabel(name: string, value?: string): BNote[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves first note with given label name & value
|
* Retrieves first note with given label name & value
|
||||||
*
|
*
|
||||||
* @param name - attribute name
|
* @param name - attribute name
|
||||||
* @param value - attribute value
|
* @param value - attribute value
|
||||||
*/
|
*/
|
||||||
getNoteWithLabel(name: string, value?: string): BNote | null;
|
getNoteWithLabel(name: string, value?: string): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.
|
* If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.
|
||||||
*
|
*
|
||||||
* @param prefix - if branch is created between note and parent note, set this prefix
|
* @param prefix - if branch is created between note and parent note, set this prefix
|
||||||
*/
|
*/
|
||||||
ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix: string): {
|
ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix: string): {
|
||||||
branch: BBranch | null
|
branch: BBranch | null
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there's a branch between note and parent note, remove it. Otherwise, do nothing.
|
* If there's a branch between note and parent note, remove it. Otherwise, do nothing.
|
||||||
*/
|
*/
|
||||||
ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string): void;
|
ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on the value, either create or remove branch between note and parent note.
|
* Based on the value, either create or remove branch between note and parent note.
|
||||||
*
|
*
|
||||||
* @param present - true if we want the branch to exist, false if we want it gone
|
* @param present - true if we want the branch to exist, false if we want it gone
|
||||||
* @param prefix - if branch is created between note and parent note, set this prefix
|
* @param prefix - if branch is created between note and parent note, set this prefix
|
||||||
*/
|
*/
|
||||||
toggleNoteInParent(present: true, noteId: string, parentNoteId: string, prefix: string): void;
|
toggleNoteInParent(present: true, noteId: string, parentNoteId: string, prefix: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create text note. See also createNewNote() for more options.
|
* Create text note. See also createNewNote() for more options.
|
||||||
*/
|
*/
|
||||||
createTextNote(parentNoteId: string, title: string, content: string): NoteAndBranch;
|
createTextNote(parentNoteId: string, title: string, content: string): NoteAndBranch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and
|
* Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and
|
||||||
* JSON MIME type. See also createNewNote() for more options.
|
* JSON MIME type. See also createNewNote() for more options.
|
||||||
*/
|
*/
|
||||||
createDataNote(parentNoteId: string, title: string, content: {}): NoteAndBranch;
|
createDataNote(parentNoteId: string, title: string, content: {}): NoteAndBranch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns object contains newly created entities note and branch
|
* @returns object contains newly created entities note and branch
|
||||||
*/
|
*/
|
||||||
createNewNote(params: NoteParams): NoteAndBranch;
|
createNewNote(params: NoteParams): NoteAndBranch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs
|
* @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs
|
||||||
* @param parentNoteId - create new note under this parent
|
* @param parentNoteId - create new note under this parent
|
||||||
* @returns object contains newly created entities note and branch
|
* @returns object contains newly created entities note and branch
|
||||||
*/
|
*/
|
||||||
createNote(parentNoteId: string, title: string, content: string, extraOptions: Omit<NoteParams, "title" | "content" | "type" | "parentNoteId"> & {
|
createNote(parentNoteId: string, title: string, content: string, extraOptions: Omit<NoteParams, "title" | "content" | "type" | "parentNoteId"> & {
|
||||||
/** should the note be JSON */
|
/** should the note be JSON */
|
||||||
json?: boolean;
|
json?: boolean;
|
||||||
@ -200,37 +200,37 @@ interface Api {
|
|||||||
logSpacedUpdates: Record<string, SpacedUpdate>;
|
logSpacedUpdates: Record<string, SpacedUpdate>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log given message to trilium logs and log pane in UI
|
* Log given message to trilium logs and log pane in UI
|
||||||
*/
|
*/
|
||||||
log(message: string): void;
|
log(message: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns root note of the calendar.
|
* Returns root note of the calendar.
|
||||||
*/
|
*/
|
||||||
getRootCalendarNote(): BNote | null;
|
getRootCalendarNote(): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns day note for given date. If such note doesn't exist, it is created.
|
* Returns day note for given date. If such note doesn't exist, it is created.
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param date in YYYY-MM-DD format
|
* @param date in YYYY-MM-DD format
|
||||||
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
||||||
*/
|
*/
|
||||||
getDayNote(date: string, rootNote?: BNote): BNote | null;
|
getDayNote(date: string, rootNote?: BNote): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns today's day note. If such note doesn't exist, it is created.
|
* Returns today's day note. If such note doesn't exist, it is created.
|
||||||
*
|
*
|
||||||
* @param rootNote specify calendar root note, normally leave empty to use the default calendar
|
* @param rootNote specify calendar root note, normally leave empty to use the default calendar
|
||||||
*/
|
*/
|
||||||
getTodayNote(rootNote?: BNote): BNote | null;
|
getTodayNote(rootNote?: BNote): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns note for the first date of the week of the given date.
|
* Returns note for the first date of the week of the given date.
|
||||||
*
|
*
|
||||||
* @param date in YYYY-MM-DD format
|
* @param date in YYYY-MM-DD format
|
||||||
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
||||||
*/
|
*/
|
||||||
getWeekNote(date: string, options: {
|
getWeekNote(date: string, options: {
|
||||||
// TODO: Deduplicate type with date_notes.ts once ES modules are added.
|
// TODO: Deduplicate type with date_notes.ts once ES modules are added.
|
||||||
/** either "monday" (default) or "sunday" */
|
/** either "monday" (default) or "sunday" */
|
||||||
@ -238,90 +238,90 @@ interface Api {
|
|||||||
}, rootNote: BNote): BNote | null;
|
}, rootNote: BNote): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns month note for given date. If such a note doesn't exist, it is created.
|
* Returns month note for given date. If such a note doesn't exist, it is created.
|
||||||
*
|
*
|
||||||
* @param date in YYYY-MM format
|
* @param date in YYYY-MM format
|
||||||
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
||||||
*/
|
*/
|
||||||
getMonthNote(date: string, rootNote: BNote): BNote | null;
|
getMonthNote(date: string, rootNote: BNote): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns year note for given year. If such a note doesn't exist, it is created.
|
* Returns year note for given year. If such a note doesn't exist, it is created.
|
||||||
*
|
*
|
||||||
* @param year in YYYY format
|
* @param year in YYYY format
|
||||||
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
* @param rootNote - specify calendar root note, normally leave empty to use the default calendar
|
||||||
*/
|
*/
|
||||||
getYearNote(year: string, rootNote?: BNote): BNote | null;
|
getYearNote(year: string, rootNote?: BNote): BNote | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort child notes of a given note.
|
* Sort child notes of a given note.
|
||||||
*/
|
*/
|
||||||
sortNotes(parentNoteId: string, sortConfig: {
|
sortNotes(parentNoteId: string, sortConfig: {
|
||||||
/** 'title', 'dateCreated', 'dateModified' or a label name
|
/** 'title', 'dateCreated', 'dateModified' or a label name
|
||||||
* See {@link https://triliumnext.github.io/Docs/Wiki/sorting.html} for details. */
|
* See {@link https://triliumnext.github.io/Docs/Wiki/sorting.html} for details. */
|
||||||
sortBy?: string;
|
sortBy?: string;
|
||||||
reverse?: boolean;
|
reverse?: boolean;
|
||||||
foldersFirst?: boolean;
|
foldersFirst?: boolean;
|
||||||
}): void;
|
}): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method finds note by its noteId and prefix and either sets it to the given parentNoteId
|
* This method finds note by its noteId and prefix and either sets it to the given parentNoteId
|
||||||
* or removes the branch (if parentNoteId is not given).
|
* or removes the branch (if parentNoteId is not given).
|
||||||
*
|
*
|
||||||
* This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
|
* This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
|
||||||
*
|
*
|
||||||
* @deprecated this method is pretty confusing and serves specialized purpose only
|
* @deprecated this method is pretty confusing and serves specialized purpose only
|
||||||
*/
|
*/
|
||||||
setNoteToParent(noteId: string, prefix: string, parentNoteId: string | null): void;
|
setNoteToParent(noteId: string, prefix: string, parentNoteId: string | null): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions wraps code which is supposed to be running in transaction. If transaction already
|
* This functions wraps code which is supposed to be running in transaction. If transaction already
|
||||||
* exists, then we'll use that transaction.
|
* exists, then we'll use that transaction.
|
||||||
*
|
*
|
||||||
* @param func
|
* @param func
|
||||||
* @returns result of func callback
|
* @returns result of func callback
|
||||||
*/
|
*/
|
||||||
transactional(func: () => void): any;
|
transactional(func: () => void): any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return randomly generated string of given length. This random string generation is NOT cryptographically secure.
|
* Return randomly generated string of given length. This random string generation is NOT cryptographically secure.
|
||||||
*
|
*
|
||||||
* @param length of the string
|
* @param length of the string
|
||||||
* @returns random string
|
* @returns random string
|
||||||
*/
|
*/
|
||||||
randomString(length: number): string;
|
randomString(length: number): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param to escape
|
* @param to escape
|
||||||
* @returns escaped string
|
* @returns escaped string
|
||||||
*/
|
*/
|
||||||
escapeHtml(string: string): string;
|
escapeHtml(string: string): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string to unescape
|
* @param string to unescape
|
||||||
* @returns unescaped string
|
* @returns unescaped string
|
||||||
*/
|
*/
|
||||||
unescapeHtml(string: string): string;
|
unescapeHtml(string: string): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sql
|
* sql
|
||||||
* @type {module:sql}
|
* @type {module:sql}
|
||||||
*/
|
*/
|
||||||
sql: any;
|
sql: any;
|
||||||
|
|
||||||
getAppInfo(): typeof appInfo;
|
getAppInfo(): typeof appInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
|
* Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
|
||||||
*/
|
*/
|
||||||
createOrUpdateLauncher(opts: {
|
createOrUpdateLauncher(opts: {
|
||||||
/** id of the launcher, only alphanumeric at least 6 characters long */
|
/** id of the launcher, only alphanumeric at least 6 characters long */
|
||||||
id: string;
|
id: string;
|
||||||
/** one of
|
/** one of
|
||||||
* - "note" - activating the launcher will navigate to the target note (specified in targetNoteId param)
|
* - "note" - activating the launcher will navigate to the target note (specified in targetNoteId param)
|
||||||
* - "script" - activating the launcher will execute the script (specified in scriptNoteId param)
|
* - "script" - activating the launcher will execute the script (specified in scriptNoteId param)
|
||||||
* - "customWidget" - the launcher will be rendered with a custom widget (specified in widgetNoteId param)
|
* - "customWidget" - the launcher will be rendered with a custom widget (specified in widgetNoteId param)
|
||||||
*/
|
*/
|
||||||
type: "note" | "script" | "customWidget";
|
type: "note" | "script" | "customWidget";
|
||||||
title: string;
|
title: string;
|
||||||
/** if true, will be created in the "Visible launchers", otherwise in "Available launchers" */
|
/** if true, will be created in the "Visible launchers", otherwise in "Available launchers" */
|
||||||
@ -339,44 +339,44 @@ interface Api {
|
|||||||
}): { note: BNote };
|
}): { note: BNote };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param format - either 'html' or 'markdown'
|
* @param format - either 'html' or 'markdown'
|
||||||
*/
|
*/
|
||||||
exportSubtreeToZipFile(noteId: string, format: "markdown" | "html", zipFilePath: string): Promise<void>;
|
exportSubtreeToZipFile(noteId: string, format: "markdown" | "html", zipFilePath: string): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes given anonymous function on the frontend(s).
|
* Executes given anonymous function on the frontend(s).
|
||||||
* Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
|
* Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.
|
||||||
* Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all
|
* Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all
|
||||||
* instances execute the given function.
|
* instances execute the given function.
|
||||||
*
|
*
|
||||||
* @param script - script to be executed on the frontend
|
* @param script - script to be executed on the frontend
|
||||||
* @param params - list of parameters to the anonymous function to be sent to frontend
|
* @param params - list of parameters to the anonymous function to be sent to frontend
|
||||||
* @returns no return value is provided.
|
* @returns no return value is provided.
|
||||||
*/
|
*/
|
||||||
runOnFrontend(script: () => void | string, params: []): void;
|
runOnFrontend(script: () => void | string, params: []): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync process can make data intermittently inconsistent. Scripts which require strong data consistency
|
* Sync process can make data intermittently inconsistent. Scripts which require strong data consistency
|
||||||
* can use this function to wait for a possible sync process to finish and prevent new sync process from starting
|
* can use this function to wait for a possible sync process to finish and prevent new sync process from starting
|
||||||
* while it is running.
|
* while it is running.
|
||||||
*
|
*
|
||||||
* Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case
|
* Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case
|
||||||
* you need to make some DB changes, you need to surround your call with api.transactional(...)
|
* you need to make some DB changes, you need to surround your call with api.transactional(...)
|
||||||
*
|
*
|
||||||
* @param callback - function to be executed while sync process is not running
|
* @param callback - function to be executed while sync process is not running
|
||||||
* @returns resolves once the callback is finished (callback is awaited)
|
* @returns resolves once the callback is finished (callback is awaited)
|
||||||
*/
|
*/
|
||||||
runOutsideOfSync(callback: () => void): Promise<void>;
|
runOutsideOfSync(callback: () => void): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param backupName - If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file
|
* @param backupName - If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file
|
||||||
* @returns resolves once the backup is finished
|
* @returns resolves once the backup is finished
|
||||||
*/
|
*/
|
||||||
backupNow(backupName: string): Promise<string>;
|
backupNow(backupName: string): Promise<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.
|
* This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.
|
||||||
*/
|
*/
|
||||||
__private: {
|
__private: {
|
||||||
/** provides access to the backend in-memory object graph, see {@link Becca} */
|
/** provides access to the backend in-memory object graph, see {@link Becca} */
|
||||||
becca: Becca;
|
becca: Becca;
|
||||||
|
@ -27,8 +27,8 @@ class ConsistencyChecks {
|
|||||||
private reloadNeeded: boolean;
|
private reloadNeeded: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param autoFix - automatically fix all encountered problems. False is only for debugging during development (fail fast)
|
* @param autoFix - automatically fix all encountered problems. False is only for debugging during development (fail fast)
|
||||||
*/
|
*/
|
||||||
constructor(autoFix: boolean) {
|
constructor(autoFix: boolean) {
|
||||||
this.autoFix = autoFix;
|
this.autoFix = autoFix;
|
||||||
this.unrecoveredConsistencyErrors = false;
|
this.unrecoveredConsistencyErrors = false;
|
||||||
@ -138,9 +138,9 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT branchId, branches.noteId
|
SELECT branchId, branches.noteId
|
||||||
FROM branches
|
FROM branches
|
||||||
LEFT JOIN notes USING (noteId)
|
LEFT JOIN notes USING (noteId)
|
||||||
WHERE branches.isDeleted = 0
|
WHERE branches.isDeleted = 0
|
||||||
AND notes.noteId IS NULL`,
|
AND notes.noteId IS NULL`,
|
||||||
({branchId, noteId}) => {
|
({branchId, noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branch = becca.getBranch(branchId);
|
const branch = becca.getBranch(branchId);
|
||||||
@ -160,10 +160,10 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT branchId, branches.parentNoteId AS parentNoteId
|
SELECT branchId, branches.parentNoteId AS parentNoteId
|
||||||
FROM branches
|
FROM branches
|
||||||
LEFT JOIN notes ON notes.noteId = branches.parentNoteId
|
LEFT JOIN notes ON notes.noteId = branches.parentNoteId
|
||||||
WHERE branches.isDeleted = 0
|
WHERE branches.isDeleted = 0
|
||||||
AND branches.noteId != 'root'
|
AND branches.noteId != 'root'
|
||||||
AND notes.noteId IS NULL`,
|
AND notes.noteId IS NULL`,
|
||||||
({branchId, parentNoteId}) => {
|
({branchId, parentNoteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
// Delete the old branch and recreate it with root as parent.
|
// Delete the old branch and recreate it with root as parent.
|
||||||
@ -205,9 +205,9 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attributeId, attributes.noteId
|
SELECT attributeId, attributes.noteId
|
||||||
FROM attributes
|
FROM attributes
|
||||||
LEFT JOIN notes USING (noteId)
|
LEFT JOIN notes USING (noteId)
|
||||||
WHERE attributes.isDeleted = 0
|
WHERE attributes.isDeleted = 0
|
||||||
AND notes.noteId IS NULL`,
|
AND notes.noteId IS NULL`,
|
||||||
({attributeId, noteId}) => {
|
({attributeId, noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attribute = becca.getAttribute(attributeId);
|
const attribute = becca.getAttribute(attributeId);
|
||||||
@ -227,10 +227,10 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attributeId, attributes.value AS noteId
|
SELECT attributeId, attributes.value AS noteId
|
||||||
FROM attributes
|
FROM attributes
|
||||||
LEFT JOIN notes ON notes.noteId = attributes.value
|
LEFT JOIN notes ON notes.noteId = attributes.value
|
||||||
WHERE attributes.isDeleted = 0
|
WHERE attributes.isDeleted = 0
|
||||||
AND attributes.type = 'relation'
|
AND attributes.type = 'relation'
|
||||||
AND notes.noteId IS NULL`,
|
AND notes.noteId IS NULL`,
|
||||||
({attributeId, noteId}) => {
|
({attributeId, noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attribute = becca.getAttribute(attributeId);
|
const attribute = becca.getAttribute(attributeId);
|
||||||
@ -255,7 +255,7 @@ class ConsistencyChecks {
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT revisionId FROM revisions
|
SELECT revisionId FROM revisions
|
||||||
)
|
)
|
||||||
AND attachments.isDeleted = 0`,
|
AND attachments.isDeleted = 0`,
|
||||||
({attachmentId, ownerId}) => {
|
({attachmentId, ownerId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attachment = becca.getAttachment(attachmentId);
|
const attachment = becca.getAttachment(attachmentId);
|
||||||
@ -282,11 +282,11 @@ class ConsistencyChecks {
|
|||||||
// another check might create missing branch
|
// another check might create missing branch
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT branchId,
|
SELECT branchId,
|
||||||
noteId
|
noteId
|
||||||
FROM branches
|
FROM branches
|
||||||
JOIN notes USING (noteId)
|
JOIN notes USING (noteId)
|
||||||
WHERE notes.isDeleted = 1
|
WHERE notes.isDeleted = 1
|
||||||
AND branches.isDeleted = 0`,
|
AND branches.isDeleted = 0`,
|
||||||
({branchId, noteId}) => {
|
({branchId, noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branch = becca.getBranch(branchId);
|
const branch = becca.getBranch(branchId);
|
||||||
@ -303,11 +303,11 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT branchId,
|
SELECT branchId,
|
||||||
parentNoteId
|
parentNoteId
|
||||||
FROM branches
|
FROM branches
|
||||||
JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteId
|
JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteId
|
||||||
WHERE parentNote.isDeleted = 1
|
WHERE parentNote.isDeleted = 1
|
||||||
AND branches.isDeleted = 0
|
AND branches.isDeleted = 0
|
||||||
`, ({branchId, parentNoteId}) => {
|
`, ({branchId, parentNoteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branch = becca.getBranch(branchId);
|
const branch = becca.getBranch(branchId);
|
||||||
@ -327,9 +327,9 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT DISTINCT notes.noteId
|
SELECT DISTINCT notes.noteId
|
||||||
FROM notes
|
FROM notes
|
||||||
LEFT JOIN branches ON notes.noteId = branches.noteId AND branches.isDeleted = 0
|
LEFT JOIN branches ON notes.noteId = branches.noteId AND branches.isDeleted = 0
|
||||||
WHERE notes.isDeleted = 0
|
WHERE notes.isDeleted = 0
|
||||||
AND branches.branchId IS NULL
|
AND branches.branchId IS NULL
|
||||||
`, ({noteId}) => {
|
`, ({noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branch = new BBranch({
|
const branch = new BBranch({
|
||||||
@ -349,21 +349,21 @@ class ConsistencyChecks {
|
|||||||
// there should be a unique relationship between note and its parent
|
// there should be a unique relationship between note and its parent
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT noteId,
|
SELECT noteId,
|
||||||
parentNoteId
|
parentNoteId
|
||||||
FROM branches
|
FROM branches
|
||||||
WHERE branches.isDeleted = 0
|
WHERE branches.isDeleted = 0
|
||||||
GROUP BY branches.parentNoteId,
|
GROUP BY branches.parentNoteId,
|
||||||
branches.noteId
|
branches.noteId
|
||||||
HAVING COUNT(1) > 1`,
|
HAVING COUNT(1) > 1`,
|
||||||
({noteId, parentNoteId}) => {
|
({noteId, parentNoteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branchIds = sql.getColumn<string>(
|
const branchIds = sql.getColumn<string>(
|
||||||
`SELECT branchId
|
`SELECT branchId
|
||||||
FROM branches
|
FROM branches
|
||||||
WHERE noteId = ?
|
WHERE noteId = ?
|
||||||
and parentNoteId = ?
|
and parentNoteId = ?
|
||||||
and isDeleted = 0
|
and isDeleted = 0
|
||||||
ORDER BY utcDateModified`, [noteId, parentNoteId]);
|
ORDER BY utcDateModified`, [noteId, parentNoteId]);
|
||||||
|
|
||||||
const branches = branchIds.map(branchId => becca.getBranch(branchId));
|
const branches = branchIds.map(branchId => becca.getBranch(branchId));
|
||||||
|
|
||||||
@ -393,11 +393,11 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attachmentId,
|
SELECT attachmentId,
|
||||||
attachments.ownerId AS noteId
|
attachments.ownerId AS noteId
|
||||||
FROM attachments
|
FROM attachments
|
||||||
JOIN notes ON notes.noteId = attachments.ownerId
|
JOIN notes ON notes.noteId = attachments.ownerId
|
||||||
WHERE notes.isDeleted = 1
|
WHERE notes.isDeleted = 1
|
||||||
AND attachments.isDeleted = 0`,
|
AND attachments.isDeleted = 0`,
|
||||||
({attachmentId, noteId}) => {
|
({attachmentId, noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attachment = becca.getAttachment(attachmentId);
|
const attachment = becca.getAttachment(attachmentId);
|
||||||
@ -420,7 +420,7 @@ class ConsistencyChecks {
|
|||||||
SELECT noteId, type
|
SELECT noteId, type
|
||||||
FROM notes
|
FROM notes
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND type NOT IN (${noteTypesStr})`,
|
AND type NOT IN (${noteTypesStr})`,
|
||||||
({noteId, type}) => {
|
({noteId, type}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const note = becca.getNote(noteId);
|
const note = becca.getNote(noteId);
|
||||||
@ -439,7 +439,7 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT notes.noteId, notes.isProtected, notes.type, notes.mime
|
SELECT notes.noteId, notes.isProtected, notes.type, notes.mime
|
||||||
FROM notes
|
FROM notes
|
||||||
LEFT JOIN blobs USING (blobId)
|
LEFT JOIN blobs USING (blobId)
|
||||||
WHERE blobs.blobId IS NULL
|
WHERE blobs.blobId IS NULL
|
||||||
AND notes.isDeleted = 0`,
|
AND notes.isDeleted = 0`,
|
||||||
({noteId, isProtected, type, mime}) => {
|
({noteId, isProtected, type, mime}) => {
|
||||||
@ -494,10 +494,10 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT notes.noteId, notes.type, notes.mime
|
SELECT notes.noteId, notes.type, notes.mime
|
||||||
FROM notes
|
FROM notes
|
||||||
JOIN blobs USING (blobId)
|
JOIN blobs USING (blobId)
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND isProtected = 0
|
AND isProtected = 0
|
||||||
AND content IS NULL`,
|
AND content IS NULL`,
|
||||||
({noteId, type, mime}) => {
|
({noteId, type, mime}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const note = becca.getNote(noteId);
|
const note = becca.getNote(noteId);
|
||||||
@ -520,7 +520,7 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT revisions.revisionId, blobs.blobId
|
SELECT revisions.revisionId, blobs.blobId
|
||||||
FROM revisions
|
FROM revisions
|
||||||
LEFT JOIN blobs USING (blobId)
|
LEFT JOIN blobs USING (blobId)
|
||||||
WHERE blobs.blobId IS NULL`,
|
WHERE blobs.blobId IS NULL`,
|
||||||
({revisionId, blobId}) => {
|
({revisionId, blobId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
@ -537,7 +537,7 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attachments.attachmentId, blobs.blobId
|
SELECT attachments.attachmentId, blobs.blobId
|
||||||
FROM attachments
|
FROM attachments
|
||||||
LEFT JOIN blobs USING (blobId)
|
LEFT JOIN blobs USING (blobId)
|
||||||
WHERE blobs.blobId IS NULL`,
|
WHERE blobs.blobId IS NULL`,
|
||||||
({attachmentId, blobId}) => {
|
({attachmentId, blobId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
@ -554,17 +554,17 @@ class ConsistencyChecks {
|
|||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT parentNoteId
|
SELECT parentNoteId
|
||||||
FROM branches
|
FROM branches
|
||||||
JOIN notes ON notes.noteId = branches.parentNoteId
|
JOIN notes ON notes.noteId = branches.parentNoteId
|
||||||
WHERE notes.isDeleted = 0
|
WHERE notes.isDeleted = 0
|
||||||
AND notes.type == 'search'
|
AND notes.type == 'search'
|
||||||
AND branches.isDeleted = 0`,
|
AND branches.isDeleted = 0`,
|
||||||
({parentNoteId}) => {
|
({parentNoteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branchIds = sql.getColumn<string>(`
|
const branchIds = sql.getColumn<string>(`
|
||||||
SELECT branchId
|
SELECT branchId
|
||||||
FROM branches
|
FROM branches
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND parentNoteId = ?`, [parentNoteId]);
|
AND parentNoteId = ?`, [parentNoteId]);
|
||||||
|
|
||||||
const branches = branchIds.map(branchId => becca.getBranch(branchId));
|
const branches = branchIds.map(branchId => becca.getBranch(branchId));
|
||||||
|
|
||||||
@ -594,8 +594,8 @@ class ConsistencyChecks {
|
|||||||
SELECT attributeId
|
SELECT attributeId
|
||||||
FROM attributes
|
FROM attributes
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND type = 'relation'
|
AND type = 'relation'
|
||||||
AND value = ''`,
|
AND value = ''`,
|
||||||
({attributeId}) => {
|
({attributeId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const relation = becca.getAttribute(attributeId);
|
const relation = becca.getAttribute(attributeId);
|
||||||
@ -612,11 +612,11 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attributeId,
|
SELECT attributeId,
|
||||||
type
|
type
|
||||||
FROM attributes
|
FROM attributes
|
||||||
WHERE isDeleted = 0
|
WHERE isDeleted = 0
|
||||||
AND type != 'label'
|
AND type != 'label'
|
||||||
AND type != 'relation'`,
|
AND type != 'relation'`,
|
||||||
({attributeId, type}) => {
|
({attributeId, type}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attribute = becca.getAttribute(attributeId);
|
const attribute = becca.getAttribute(attributeId);
|
||||||
@ -634,11 +634,11 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attributeId,
|
SELECT attributeId,
|
||||||
attributes.noteId
|
attributes.noteId
|
||||||
FROM attributes
|
FROM attributes
|
||||||
JOIN notes ON attributes.noteId = notes.noteId
|
JOIN notes ON attributes.noteId = notes.noteId
|
||||||
WHERE attributes.isDeleted = 0
|
WHERE attributes.isDeleted = 0
|
||||||
AND notes.isDeleted = 1`,
|
AND notes.isDeleted = 1`,
|
||||||
({attributeId, noteId}) => {
|
({attributeId, noteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attribute = becca.getAttribute(attributeId);
|
const attribute = becca.getAttribute(attributeId);
|
||||||
@ -655,12 +655,12 @@ class ConsistencyChecks {
|
|||||||
|
|
||||||
this.findAndFixIssues(`
|
this.findAndFixIssues(`
|
||||||
SELECT attributeId,
|
SELECT attributeId,
|
||||||
attributes.value AS targetNoteId
|
attributes.value AS targetNoteId
|
||||||
FROM attributes
|
FROM attributes
|
||||||
JOIN notes ON attributes.value = notes.noteId
|
JOIN notes ON attributes.value = notes.noteId
|
||||||
WHERE attributes.type = 'relation'
|
WHERE attributes.type = 'relation'
|
||||||
AND attributes.isDeleted = 0
|
AND attributes.isDeleted = 0
|
||||||
AND notes.isDeleted = 1`,
|
AND notes.isDeleted = 1`,
|
||||||
({attributeId, targetNoteId}) => {
|
({attributeId, targetNoteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const attribute = becca.getAttribute(attributeId);
|
const attribute = becca.getAttribute(attributeId);
|
||||||
@ -706,9 +706,9 @@ class ConsistencyChecks {
|
|||||||
FROM entity_changes
|
FROM entity_changes
|
||||||
LEFT JOIN ${entityName} ON entityId = ${entityName}.${key}
|
LEFT JOIN ${entityName} ON entityId = ${entityName}.${key}
|
||||||
WHERE
|
WHERE
|
||||||
entity_changes.isErased = 0
|
entity_changes.isErased = 0
|
||||||
AND entity_changes.entityName = '${entityName}'
|
AND entity_changes.entityName = '${entityName}'
|
||||||
AND ${entityName}.${key} IS NULL`,
|
AND ${entityName}.${key} IS NULL`,
|
||||||
({id, entityId}) => {
|
({id, entityId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
sql.execute("DELETE FROM entity_changes WHERE entityName = ? AND entityId = ?", [entityName, entityId]);
|
sql.execute("DELETE FROM entity_changes WHERE entityName = ? AND entityId = ?", [entityName, entityId]);
|
||||||
@ -724,8 +724,8 @@ class ConsistencyChecks {
|
|||||||
FROM entity_changes
|
FROM entity_changes
|
||||||
JOIN ${entityName} ON entityId = ${entityName}.${key}
|
JOIN ${entityName} ON entityId = ${entityName}.${key}
|
||||||
WHERE
|
WHERE
|
||||||
entity_changes.isErased = 1
|
entity_changes.isErased = 1
|
||||||
AND entity_changes.entityName = '${entityName}'`,
|
AND entity_changes.entityName = '${entityName}'`,
|
||||||
({id, entityId}) => {
|
({id, entityId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
sql.execute(`DELETE FROM ${entityName} WHERE ${key} = ?`, [entityId]);
|
sql.execute(`DELETE FROM ${entityName} WHERE ${key} = ?`, [entityId]);
|
||||||
|
@ -18,12 +18,12 @@ function getEntityHashes() {
|
|||||||
const hashRows = sql.disableSlowQueryLogging(
|
const hashRows = sql.disableSlowQueryLogging(
|
||||||
() => sql.getRawRows<HashRow>(`
|
() => sql.getRawRows<HashRow>(`
|
||||||
SELECT entityName,
|
SELECT entityName,
|
||||||
entityId,
|
entityId,
|
||||||
hash,
|
hash,
|
||||||
isErased
|
isErased
|
||||||
FROM entity_changes
|
FROM entity_changes
|
||||||
WHERE isSynced = 1
|
WHERE isSynced = 1
|
||||||
AND entityName != 'note_reordering'`)
|
AND entityName != 'note_reordering'`)
|
||||||
);
|
);
|
||||||
|
|
||||||
// sorting is faster in memory
|
// sorting is faster in memory
|
||||||
|
@ -39,9 +39,9 @@ function putEntityChange(origEntityChange: EntityChange) {
|
|||||||
ec.isErased = ec.isErased ? 1 : 0;
|
ec.isErased = ec.isErased ? 1 : 0;
|
||||||
ec.id = sql.replace("entity_changes", ec);
|
ec.id = sql.replace("entity_changes", ec);
|
||||||
|
|
||||||
if (ec.id) {
|
if (ec.id) {
|
||||||
maxEntityChangeId = Math.max(maxEntityChangeId, ec.id);
|
maxEntityChangeId = Math.max(maxEntityChangeId, ec.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.putEntityChange(ec);
|
cls.putEntityChange(ec);
|
||||||
}
|
}
|
||||||
@ -110,9 +110,9 @@ function addEntityChangesForDependingEntity(sector: string, tableName: string, p
|
|||||||
|
|
||||||
function cleanupEntityChangesForMissingEntities(entityName: string, entityPrimaryKey: string) {
|
function cleanupEntityChangesForMissingEntities(entityName: string, entityPrimaryKey: string) {
|
||||||
sql.execute(`
|
sql.execute(`
|
||||||
DELETE
|
DELETE
|
||||||
FROM entity_changes
|
FROM entity_changes
|
||||||
WHERE
|
WHERE
|
||||||
isErased = 0
|
isErased = 0
|
||||||
AND entityName = '${entityName}'
|
AND entityName = '${entityName}'
|
||||||
AND entityId NOT IN (SELECT ${entityPrimaryKey} FROM ${entityName})`);
|
AND entityId NOT IN (SELECT ${entityPrimaryKey} FROM ${entityName})`);
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
export interface EntityChange {
|
export interface EntityChange {
|
||||||
id?: number | null;
|
id?: number | null;
|
||||||
noteId?: string;
|
noteId?: string;
|
||||||
entityName: string;
|
entityName: string;
|
||||||
entityId: string;
|
entityId: string;
|
||||||
entity?: any;
|
entity?: any;
|
||||||
positions?: Record<string, number>;
|
positions?: Record<string, number>;
|
||||||
hash: string;
|
hash: string;
|
||||||
utcDateChanged?: string;
|
utcDateChanged?: string;
|
||||||
utcDateModified?: string;
|
utcDateModified?: string;
|
||||||
utcDateCreated?: string;
|
utcDateCreated?: string;
|
||||||
isSynced: boolean | 1 | 0;
|
isSynced: boolean | 1 | 0;
|
||||||
isErased: boolean | 1 | 0;
|
isErased: boolean | 1 | 0;
|
||||||
componentId?: string | null;
|
componentId?: string | null;
|
||||||
changeId?: string | null;
|
changeId?: string | null;
|
||||||
instanceId?: string | null;
|
instanceId?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntityRow {
|
export interface EntityRow {
|
||||||
isDeleted?: boolean;
|
isDeleted?: boolean;
|
||||||
content?: Buffer | string;
|
content?: Buffer | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntityChangeRecord {
|
export interface EntityChangeRecord {
|
||||||
entityChange: EntityChange;
|
entityChange: EntityChange;
|
||||||
entity?: EntityRow;
|
entity?: EntityRow;
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,8 @@ function eraseUnusedBlobs() {
|
|||||||
LEFT JOIN attachments ON attachments.blobId = blobs.blobId
|
LEFT JOIN attachments ON attachments.blobId = blobs.blobId
|
||||||
LEFT JOIN revisions ON revisions.blobId = blobs.blobId
|
LEFT JOIN revisions ON revisions.blobId = blobs.blobId
|
||||||
WHERE notes.noteId IS NULL
|
WHERE notes.noteId IS NULL
|
||||||
AND attachments.attachmentId IS NULL
|
AND attachments.attachmentId IS NULL
|
||||||
AND revisions.revisionId IS NULL`);
|
AND revisions.revisionId IS NULL`);
|
||||||
|
|
||||||
if (unusedBlobIds.length === 0) {
|
if (unusedBlobIds.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -8,25 +8,25 @@ let instance: TurndownService | null = null;
|
|||||||
const fencedCodeBlockFilter: TurndownService.Rule = {
|
const fencedCodeBlockFilter: TurndownService.Rule = {
|
||||||
filter: function (node, options) {
|
filter: function (node, options) {
|
||||||
return (
|
return (
|
||||||
options.codeBlockStyle === 'fenced' &&
|
options.codeBlockStyle === 'fenced' &&
|
||||||
node.nodeName === 'PRE' &&
|
node.nodeName === 'PRE' &&
|
||||||
node.firstChild !== null &&
|
node.firstChild !== null &&
|
||||||
node.firstChild.nodeName === 'CODE'
|
node.firstChild.nodeName === 'CODE'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
replacement: function (content, node, options) {
|
replacement: function (content, node, options) {
|
||||||
if (!node.firstChild || !("getAttribute" in node.firstChild) || typeof node.firstChild.getAttribute !== "function") {
|
if (!node.firstChild || !("getAttribute" in node.firstChild) || typeof node.firstChild.getAttribute !== "function") {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = node.firstChild.getAttribute('class') || ''
|
const className = node.firstChild.getAttribute('class') || ''
|
||||||
const language = rewriteLanguageTag((className.match(/language-(\S+)/) || [null, ''])[1]);
|
const language = rewriteLanguageTag((className.match(/language-(\S+)/) || [null, ''])[1]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
'\n\n' + options.fence + language + '\n' +
|
'\n\n' + options.fence + language + '\n' +
|
||||||
node.firstChild.textContent +
|
node.firstChild.textContent +
|
||||||
'\n' + options.fence + '\n\n'
|
'\n' + options.fence + '\n\n'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -44,7 +44,7 @@ function toMarkdown(content: string) {
|
|||||||
|
|
||||||
function rewriteLanguageTag(source: string) {
|
function rewriteLanguageTag(source: string) {
|
||||||
if (!source) {
|
if (!source) {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source === "text-x-trilium-auto") {
|
if (source === "text-x-trilium-auto") {
|
||||||
|
@ -324,9 +324,9 @@ async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "h
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1 data-trilium-h1>${htmlTitle}</h1>
|
<h1 data-trilium-h1>${htmlTitle}</h1>
|
||||||
|
|
||||||
<div class="ck-content">${content}</div>
|
<div class="ck-content">${content}</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
|
@ -11,12 +11,12 @@ export async function initializeTranslations() {
|
|||||||
|
|
||||||
// Initialize translations
|
// Initialize translations
|
||||||
await i18next.use(Backend).init({
|
await i18next.use(Backend).init({
|
||||||
lng: getCurrentLanguage(),
|
lng: getCurrentLanguage(),
|
||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
ns: "server",
|
ns: "server",
|
||||||
backend: {
|
backend: {
|
||||||
loadPath: join(resourceDir, "translations/{{lng}}/{{ns}}.json")
|
loadPath: join(resourceDir, "translations/{{lng}}/{{ns}}.json")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,8 +601,8 @@ function getDefaultKeyboardActions() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apply macOS-specific tweaks.
|
* Apply macOS-specific tweaks.
|
||||||
*/
|
*/
|
||||||
const platformModifier = isMac ? 'Meta' : 'Ctrl';
|
const platformModifier = isMac ? 'Meta' : 'Ctrl';
|
||||||
|
|
||||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||||
|
@ -5,13 +5,13 @@ export interface KeyboardShortcut {
|
|||||||
defaultShortcuts?: string[];
|
defaultShortcuts?: string[];
|
||||||
effectiveShortcuts?: string[];
|
effectiveShortcuts?: string[];
|
||||||
/**
|
/**
|
||||||
* Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work,
|
* Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work,
|
||||||
* the focus has to be inside the element.
|
* the focus has to be inside the element.
|
||||||
*
|
*
|
||||||
* So e.g. shortcuts with "note-tree" scope work only when the focus is in note tree.
|
* So e.g. shortcuts with "note-tree" scope work only when the focus is in note tree.
|
||||||
* This allows to have the same shortcut have different actions attached based on the context
|
* This allows to have the same shortcut have different actions attached based on the context
|
||||||
* e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.
|
* e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.
|
||||||
*/
|
*/
|
||||||
scope?: "window" | "note-tree" | "text-detail" | "code-detail";
|
scope?: "window" | "note-tree" | "text-detail" | "code-detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ async function migrate() {
|
|||||||
await executeMigration(mig);
|
await executeMigration(mig);
|
||||||
|
|
||||||
sql.execute(`UPDATE options
|
sql.execute(`UPDATE options
|
||||||
SET value = ?
|
SET value = ?
|
||||||
WHERE name = ?`, [mig.dbVersion.toString(), "dbVersion"]);
|
WHERE name = ?`, [mig.dbVersion.toString(), "dbVersion"]);
|
||||||
|
|
||||||
log.info(`Migration to version ${mig.dbVersion} has been successful.`);
|
log.info(`Migration to version ${mig.dbVersion} has been successful.`);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -812,9 +812,9 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskCon
|
|||||||
const attributeRows = sql.getRows<AttributeRow>(`
|
const attributeRows = sql.getRows<AttributeRow>(`
|
||||||
SELECT * FROM attributes
|
SELECT * FROM attributes
|
||||||
WHERE isDeleted = 1
|
WHERE isDeleted = 1
|
||||||
AND deleteId = ?
|
AND deleteId = ?
|
||||||
AND (noteId = ?
|
AND (noteId = ?
|
||||||
OR (type = 'relation' AND value = ?))`, [deleteId, noteRow.noteId, noteRow.noteId]);
|
OR (type = 'relation' AND value = ?))`, [deleteId, noteRow.noteId, noteRow.noteId]);
|
||||||
|
|
||||||
for (const attributeRow of attributeRows) {
|
for (const attributeRow of attributeRows) {
|
||||||
// relation might point to a note which hasn't been undeleted yet and would thus throw up
|
// relation might point to a note which hasn't been undeleted yet and would thus throw up
|
||||||
@ -824,8 +824,8 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskCon
|
|||||||
const attachmentRows = sql.getRows<AttachmentRow>(`
|
const attachmentRows = sql.getRows<AttachmentRow>(`
|
||||||
SELECT * FROM attachments
|
SELECT * FROM attachments
|
||||||
WHERE isDeleted = 1
|
WHERE isDeleted = 1
|
||||||
AND deleteId = ?
|
AND deleteId = ?
|
||||||
AND ownerId = ?`, [deleteId, noteRow.noteId]);
|
AND ownerId = ?`, [deleteId, noteRow.noteId]);
|
||||||
|
|
||||||
for (const attachmentRow of attachmentRows) {
|
for (const attachmentRow of attachmentRows) {
|
||||||
new BAttachment(attachmentRow).save();
|
new BAttachment(attachmentRow).save();
|
||||||
@ -835,8 +835,8 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskCon
|
|||||||
SELECT branches.branchId
|
SELECT branches.branchId
|
||||||
FROM branches
|
FROM branches
|
||||||
WHERE branches.isDeleted = 1
|
WHERE branches.isDeleted = 1
|
||||||
AND branches.deleteId = ?
|
AND branches.deleteId = ?
|
||||||
AND branches.parentNoteId = ?`, [deleteId, noteRow.noteId]);
|
AND branches.parentNoteId = ?`, [deleteId, noteRow.noteId]);
|
||||||
|
|
||||||
for (const childBranchId of childBranchIds) {
|
for (const childBranchId of childBranchIds) {
|
||||||
undeleteBranch(childBranchId, deleteId, taskContext);
|
undeleteBranch(childBranchId, deleteId, taskContext);
|
||||||
@ -853,9 +853,9 @@ function getUndeletedParentBranchIds(noteId: string, deleteId: string) {
|
|||||||
FROM branches
|
FROM branches
|
||||||
JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteId
|
JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteId
|
||||||
WHERE branches.noteId = ?
|
WHERE branches.noteId = ?
|
||||||
AND branches.isDeleted = 1
|
AND branches.isDeleted = 1
|
||||||
AND branches.deleteId = ?
|
AND branches.deleteId = ?
|
||||||
AND parentNote.isDeleted = 0`, [noteId, deleteId]);
|
AND parentNote.isDeleted = 0`, [noteId, deleteId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scanForLinks(note: BNote, content: string | Buffer) {
|
function scanForLinks(note: BNote, content: string | Buffer) {
|
||||||
|
@ -26,10 +26,10 @@ interface NotSyncedOpts {
|
|||||||
interface DefaultOption {
|
interface DefaultOption {
|
||||||
name: string;
|
name: string;
|
||||||
/**
|
/**
|
||||||
* The value to initialize the option with, if the option is not already present in the database.
|
* The value to initialize the option with, if the option is not already present in the database.
|
||||||
*
|
*
|
||||||
* If a function is passed in instead, the function is called if the option does not exist (with access to the current options) and the return value is used instead. Useful to migrate a new option with a value depending on some other option that might be initialized.
|
* If a function is passed in instead, the function is called if the option does not exist (with access to the current options) and the return value is used instead. Useful to migrate a new option with a value depending on some other option that might be initialized.
|
||||||
*/
|
*/
|
||||||
value: string | ((options: OptionMap) => string);
|
value: string | ((options: OptionMap) => string);
|
||||||
isSynced: boolean;
|
isSynced: boolean;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ function upsert<T extends {}>(tableName: string, primaryKey: string, rec: T) {
|
|||||||
const updateMarks = keys.map(colName => `${colName} = @${colName}`).join(", ");
|
const updateMarks = keys.map(colName => `${colName} = @${colName}`).join(", ");
|
||||||
|
|
||||||
const query = `INSERT INTO ${tableName} (${columns}) VALUES (${questionMarks})
|
const query = `INSERT INTO ${tableName} (${columns}) VALUES (${questionMarks})
|
||||||
ON CONFLICT (${primaryKey}) DO UPDATE SET ${updateMarks}`;
|
ON CONFLICT (${primaryKey}) DO UPDATE SET ${updateMarks}`;
|
||||||
|
|
||||||
for (const idx in rec) {
|
for (const idx in rec) {
|
||||||
if (rec[idx] === true || rec[idx] === false) {
|
if (rec[idx] === true || rec[idx] === false) {
|
||||||
@ -345,60 +345,60 @@ export default {
|
|||||||
replace,
|
replace,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get single value from the given query - first column from first returned row.
|
* Get single value from the given query - first column from first returned row.
|
||||||
*
|
*
|
||||||
* @param query - SQL query with ? used as parameter placeholder
|
* @param query - SQL query with ? used as parameter placeholder
|
||||||
* @param params - array of params if needed
|
* @param params - array of params if needed
|
||||||
* @returns single value
|
* @returns single value
|
||||||
*/
|
*/
|
||||||
getValue,
|
getValue,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get first returned row.
|
* Get first returned row.
|
||||||
*
|
*
|
||||||
* @param query - SQL query with ? used as parameter placeholder
|
* @param query - SQL query with ? used as parameter placeholder
|
||||||
* @param params - array of params if needed
|
* @param params - array of params if needed
|
||||||
* @returns - map of column name to column value
|
* @returns - map of column name to column value
|
||||||
*/
|
*/
|
||||||
getRow,
|
getRow,
|
||||||
getRowOrNull,
|
getRowOrNull,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all returned rows.
|
* Get all returned rows.
|
||||||
*
|
*
|
||||||
* @param query - SQL query with ? used as parameter placeholder
|
* @param query - SQL query with ? used as parameter placeholder
|
||||||
* @param params - array of params if needed
|
* @param params - array of params if needed
|
||||||
* @returns - array of all rows, each row is a map of column name to column value
|
* @returns - array of all rows, each row is a map of column name to column value
|
||||||
*/
|
*/
|
||||||
getRows,
|
getRows,
|
||||||
getRawRows,
|
getRawRows,
|
||||||
iterateRows,
|
iterateRows,
|
||||||
getManyRows,
|
getManyRows,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a map of first column mapping to second column.
|
* Get a map of first column mapping to second column.
|
||||||
*
|
*
|
||||||
* @param query - SQL query with ? used as parameter placeholder
|
* @param query - SQL query with ? used as parameter placeholder
|
||||||
* @param params - array of params if needed
|
* @param params - array of params if needed
|
||||||
* @returns - map of first column to second column
|
* @returns - map of first column to second column
|
||||||
*/
|
*/
|
||||||
getMap,
|
getMap,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a first column in an array.
|
* Get a first column in an array.
|
||||||
*
|
*
|
||||||
* @param query - SQL query with ? used as parameter placeholder
|
* @param query - SQL query with ? used as parameter placeholder
|
||||||
* @param params - array of params if needed
|
* @param params - array of params if needed
|
||||||
* @returns array of first column of all returned rows
|
* @returns array of first column of all returned rows
|
||||||
*/
|
*/
|
||||||
getColumn,
|
getColumn,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute SQL
|
* Execute SQL
|
||||||
*
|
*
|
||||||
* @param query - SQL query with ? used as parameter placeholder
|
* @param query - SQL query with ? used as parameter placeholder
|
||||||
* @param params - array of params if needed
|
* @param params - array of params if needed
|
||||||
*/
|
*/
|
||||||
execute,
|
execute,
|
||||||
executeMany,
|
executeMany,
|
||||||
executeScript,
|
executeScript,
|
||||||
|
@ -22,7 +22,7 @@ const dbReady = utils.deferred<void>();
|
|||||||
|
|
||||||
function schemaExists() {
|
function schemaExists() {
|
||||||
return !!sql.getValue(`SELECT name FROM sqlite_master
|
return !!sql.getValue(`SELECT name FROM sqlite_master
|
||||||
WHERE type = 'table' AND name = 'options'`);
|
WHERE type = 'table' AND name = 'options'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDbInitialized() {
|
function isDbInitialized() {
|
||||||
|
@ -272,14 +272,14 @@ function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?: strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface DeferredPromise<T> extends Promise<T> {
|
interface DeferredPromise<T> extends Promise<T> {
|
||||||
resolve: (value: T | PromiseLike<T>) => void,
|
resolve: (value: T | PromiseLike<T>) => void,
|
||||||
reject: (reason?: any) => void
|
reject: (reason?: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function deferred<T>(): DeferredPromise<T> {
|
function deferred<T>(): DeferredPromise<T> {
|
||||||
return (() => {
|
return (() => {
|
||||||
let resolve!: (value: T | PromiseLike<T>) => void;
|
let resolve!: (value: T | PromiseLike<T>) => void;
|
||||||
let reject!: (reason?: any) => void;
|
let reject!: (reason?: any) => void;
|
||||||
|
|
||||||
let promise = new Promise<T>((res, rej) => {
|
let promise = new Promise<T>((res, rej) => {
|
||||||
resolve = res;
|
resolve = res;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user