Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Fixes and improvements in document editor
Hakan Shehu0bd5c189073c
diff --git a/desktop/src/data/utils.ts b/desktop/src/data/utils.tsindex 7d19f7bd..7dfd44b9 100644--- a/desktop/src/data/utils.ts+++ b/desktop/src/data/utils.ts@@ -1,6 +1,7 @@import SQLite from 'better-sqlite3';import { Parser, AST, Select } from 'node-sql-parser';import { QueryResult } from 'kysely';+import { isEqual } from 'lodash';const parser = new Parser();const parseOptions = { database: 'Sqlite' };@@ -76,15 +77,9 @@ export const resultHasChanged = <R>(const oldRow = oldResult.rows[i];const newRow = newResult.rows[i];- if (Object.keys(oldRow).length !== Object.keys(newRow).length) {+ if (!isEqual(oldRow, newRow)) {return true;}-- for (const key in oldRow) {- if (oldRow[key] !== newRow[key]) {- return true;- }- }}return false;diff --git a/desktop/src/data/workspace-manager.ts b/desktop/src/data/workspace-manager.tsindex 3650483d..69ce832a 100644--- a/desktop/src/data/workspace-manager.ts+++ b/desktop/src/data/workspace-manager.ts@@ -157,6 +157,7 @@ export class WorkspaceManager {const newResult = await this.database.executeQuery(subscriberData.query);if (resultHasChanged(subscriberData.result, newResult)) {+ subscriberData.result = newResult;eventBus.publish({event: 'workspace_query_updated',payload: {diff --git a/desktop/src/editor/utils.ts b/desktop/src/editor/utils.tsindex c8512f56..56eebd0a 100644--- a/desktop/src/editor/utils.ts+++ b/desktop/src/editor/utils.ts@@ -23,8 +23,18 @@ export const mapNodeToEditorNode = (node: LocalNode): EditorNode => {id: node.id,type: node.type,parentId: node.parentId,- attrs: node.attrs,- content: node.content,+ attrs:+ node.attrs !== null &&+ node.attrs !== undefined &&+ Object.keys(node.attrs).length > 0+ ? node.attrs+ : null,+ content:+ node.content !== null &&+ node.content !== undefined &&+ node.content.length > 0+ ? node.content+ : null,index: node.index,};};@@ -159,6 +169,7 @@ const mapAndPushJSONContentToEditorNode = (parentId: parentId,index: index,attrs: attrs,+ content: null,};editorNodes.set(id, editorNode);diff --git a/desktop/src/types/editor.ts b/desktop/src/types/editor.tsindex 9e3ff0cf..f3de5f42 100644--- a/desktop/src/types/editor.ts+++ b/desktop/src/types/editor.ts@@ -23,7 +23,7 @@ export type EditorNode = {id: string;parentId: string;type: string;- index?: string | null;- attrs?: Record<string, any> | null;- content?: NodeBlock[] | null;+ index: string | null;+ attrs: Record<string, any> | null;+ content: NodeBlock[] | null;};