mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
Merge branch 'feature/typescript_backend' into feature/typescript_backend_2
This commit is contained in:
@@ -20,7 +20,7 @@ function getBlobPojo(entityName: string, entityId: string) {
|
||||
if (!entity.hasStringContent()) {
|
||||
pojo.content = null;
|
||||
} else {
|
||||
pojo.content = processContent(pojo.content, entity.isProtected, true);
|
||||
pojo.content = processContent(pojo.content, !!entity.isProtected, true);
|
||||
}
|
||||
|
||||
return pojo;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export = { buildDate:"2024-01-21T23:49:23+01:00", buildRevision: "4f8073daa7cff1b8b6737ae45792b2e87c2adf33" };
|
||||
export = { buildDate:"2024-03-28T07:11:39+01:00", buildRevision: "399458b52f250b22be22d980a78de0b3390d7521" };
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
interface DefinitionObject {
|
||||
isPromoted: boolean;
|
||||
labelType: string;
|
||||
multiplicity: string;
|
||||
numberPrecision: number;
|
||||
promotedAlias: string;
|
||||
inverseRelation: string;
|
||||
isPromoted?: boolean;
|
||||
labelType?: string;
|
||||
multiplicity?: string;
|
||||
numberPrecision?: number;
|
||||
promotedAlias?: string;
|
||||
inverseRelation?: string;
|
||||
}
|
||||
|
||||
function parse(value: string): DefinitionObject {
|
||||
const tokens = value.split(',').map(t => t.trim());
|
||||
const defObj: Partial<DefinitionObject> = {};
|
||||
const defObj: DefinitionObject = {};
|
||||
|
||||
for (const token of tokens) {
|
||||
if (token === 'promoted') {
|
||||
@@ -41,7 +41,7 @@ function parse(value: string): DefinitionObject {
|
||||
}
|
||||
}
|
||||
|
||||
return defObj as DefinitionObject;
|
||||
return defObj;
|
||||
}
|
||||
|
||||
export = {
|
||||
|
||||
@@ -111,11 +111,7 @@ class NoteContentFulltextExp extends Expression {
|
||||
|
||||
if (type === 'text' && mime === 'text/html') {
|
||||
if (!this.raw && content.length < 20000) { // striptags is slow for very large notes
|
||||
// allow link to preserve URLs: https://github.com/zadam/trilium/issues/2412
|
||||
content = striptags(content, ['a'], ' ');
|
||||
|
||||
// at least the closing tag can be easily stripped
|
||||
content = content.replace(/<\/a>/ig, "");
|
||||
content = this.stripTags(content);
|
||||
}
|
||||
|
||||
content = content.replace(/ /g, ' ');
|
||||
@@ -123,6 +119,23 @@ class NoteContentFulltextExp extends Expression {
|
||||
|
||||
return content.trim();
|
||||
}
|
||||
|
||||
stripTags(content) {
|
||||
// we want to allow link to preserve URLs: https://github.com/zadam/trilium/issues/2412
|
||||
// we want to insert space in place of block tags (because they imply text separation)
|
||||
// but we don't want to insert text for typical formatting inline tags which can occur within one word
|
||||
const linkTag = 'a';
|
||||
const inlineFormattingTags = ['b', 'strong', 'em', 'i', 'span', 'big', 'small', 'font', 'sub', 'sup'];
|
||||
|
||||
// replace tags which imply text separation with a space
|
||||
content = striptags(content, [linkTag, ...inlineFormattingTags], ' ');
|
||||
|
||||
// replace the inline formatting tags (but not links) without a space
|
||||
content = striptags(content, [linkTag], '');
|
||||
|
||||
// at least the closing link tag can be easily stripped
|
||||
return content.replace(/<\/a>/ig, "");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NoteContentFulltextExp;
|
||||
|
||||
@@ -49,7 +49,7 @@ class TaskContext {
|
||||
type: 'taskProgressCount',
|
||||
taskId: this.taskId,
|
||||
taskType: this.taskType,
|
||||
data: this.data || undefined,
|
||||
data: this.data,
|
||||
progressCount: this.progressCount
|
||||
});
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class TaskContext {
|
||||
type: 'taskError',
|
||||
taskId: this.taskId,
|
||||
taskType: this.taskType,
|
||||
data: this.data || undefined,
|
||||
data: this.data,
|
||||
message: message
|
||||
});
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class TaskContext {
|
||||
type: 'taskSucceeded',
|
||||
taskId: this.taskId,
|
||||
taskType: this.taskType,
|
||||
data: this.data || undefined,
|
||||
data: this.data,
|
||||
result: result
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ let lastSyncedPush: number | null = null;
|
||||
interface Message {
|
||||
type: string;
|
||||
data?: {
|
||||
lastSyncedPush?: number,
|
||||
lastSyncedPush?: number | null,
|
||||
entityChanges?: any[]
|
||||
},
|
||||
lastSyncedPush?: number,
|
||||
} | null,
|
||||
lastSyncedPush?: number | null,
|
||||
|
||||
progressCount?: number;
|
||||
taskId?: string;
|
||||
@@ -142,7 +142,7 @@ function fillInAdditionalProperties(entityChange: EntityChange) {
|
||||
if (!entityChange.entity) {
|
||||
entityChange.entity = sql.getRow(`SELECT * FROM notes WHERE noteId = ?`, [entityChange.entityId]);
|
||||
|
||||
if (entityChange.entity && entityChange.entity.isProtected) {
|
||||
if (entityChange.entity?.isProtected) {
|
||||
entityChange.entity.title = protectedSessionService.decryptString(entityChange.entity.title || "");
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ function fillInAdditionalProperties(entityChange: EntityChange) {
|
||||
|
||||
if (parentNote) {
|
||||
for (const childBranch of parentNote.getChildBranches()) {
|
||||
if (childBranch && childBranch.branchId) {
|
||||
if (childBranch?.branchId) {
|
||||
entityChange.positions[childBranch.branchId] = childBranch.notePosition;
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ function sendPing(client: WebSocket, entityChangeIds = []) {
|
||||
sendMessage(client, {
|
||||
type: 'frontend-update',
|
||||
data: {
|
||||
lastSyncedPush: lastSyncedPush || undefined,
|
||||
lastSyncedPush,
|
||||
entityChanges
|
||||
}
|
||||
});
|
||||
@@ -237,19 +237,19 @@ function sendTransactionEntityChangesToAllClients() {
|
||||
}
|
||||
|
||||
function syncPullInProgress() {
|
||||
sendMessageToAllClients({ type: 'sync-pull-in-progress', lastSyncedPush: lastSyncedPush || undefined });
|
||||
sendMessageToAllClients({ type: 'sync-pull-in-progress', lastSyncedPush });
|
||||
}
|
||||
|
||||
function syncPushInProgress() {
|
||||
sendMessageToAllClients({ type: 'sync-push-in-progress', lastSyncedPush: lastSyncedPush || undefined });
|
||||
sendMessageToAllClients({ type: 'sync-push-in-progress', lastSyncedPush });
|
||||
}
|
||||
|
||||
function syncFinished() {
|
||||
sendMessageToAllClients({ type: 'sync-finished', lastSyncedPush: lastSyncedPush || undefined });
|
||||
sendMessageToAllClients({ type: 'sync-finished', lastSyncedPush });
|
||||
}
|
||||
|
||||
function syncFailed() {
|
||||
sendMessageToAllClients({ type: 'sync-failed', lastSyncedPush: lastSyncedPush || undefined });
|
||||
sendMessageToAllClients({ type: 'sync-failed', lastSyncedPush });
|
||||
}
|
||||
|
||||
function reloadFrontend(reason: string) {
|
||||
|
||||
Reference in New Issue
Block a user