diff --git a/extensions/database/src/ui/Database.tsx b/extensions/database/src/ui/Database.tsx index 82ec6d0a..572244f3 100644 --- a/extensions/database/src/ui/Database.tsx +++ b/extensions/database/src/ui/Database.tsx @@ -11,7 +11,7 @@ export const Database = ({ const { databaseId } = element return ( - + {children} {children} diff --git a/extensions/database/src/ui/TableView.tsx b/extensions/database/src/ui/TableView.tsx index 34f186e9..81123d64 100644 --- a/extensions/database/src/ui/TableView.tsx +++ b/extensions/database/src/ui/TableView.tsx @@ -16,7 +16,7 @@ export const TableView = ({ return ( - + {/* */} {children} diff --git a/extensions/list/src/types.ts b/extensions/list/src/types.ts index abef80b9..d1a30d2f 100644 --- a/extensions/list/src/types.ts +++ b/extensions/list/src/types.ts @@ -13,6 +13,7 @@ export interface TitleElement extends BaseElement { nodeType?: string props?: { date: string + color: string } } diff --git a/extensions/list/src/ui/Title.tsx b/extensions/list/src/ui/Title.tsx index c2c7d589..d090afdf 100644 --- a/extensions/list/src/ui/Title.tsx +++ b/extensions/list/src/ui/Title.tsx @@ -31,6 +31,7 @@ export const Title = ({ ].includes(element.nodeType as any) const isDaily = element.nodeType === NodeType.DAILY + const isDatabase = element.nodeType === NodeType.DATABASE // useFocusTitle(element) @@ -43,6 +44,7 @@ export const Title = ({ relative cursorNotAllowed={disabled} mb4 + toCenterY {...attributes} // {...nodeProps} css={{ @@ -59,6 +61,17 @@ export const Title = ({ }, }} > + {isDatabase && ( + + # + + )} {!isDaily && children} {isDaily && ( diff --git a/extensions/tag/src/ui/Tag.tsx b/extensions/tag/src/ui/Tag.tsx index 247044aa..eb4978b9 100644 --- a/extensions/tag/src/ui/Tag.tsx +++ b/extensions/tag/src/ui/Tag.tsx @@ -16,7 +16,7 @@ export const Tag = ({ const node = nodeList.nodeMap.get(element.databaseId)! async function clickTag() { - const database = await db.getDatabaseByName(element.name) + const database = await db.getNode(element.databaseId) if (database) { console.log('=====database:', database) @@ -49,7 +49,7 @@ export const Tag = ({ color--D4--hover={node?.tagColor} onClick={clickTag} > - # {element.name || node?.tagName} + # {node.tagName} ) diff --git a/packages/model/src/Node.ts b/packages/model/src/Node.ts index 5ba7f7bc..8f3753d7 100644 --- a/packages/model/src/Node.ts +++ b/packages/model/src/Node.ts @@ -46,7 +46,13 @@ export class Node { this.raw.element = JSON.parse(JSON.stringify(this.raw.element)) // override the title - if (this.isDaily || this.isDailyRoot || this.isInbox || this.isTrash) { + if ( + this.isDaily || + this.isDailyRoot || + this.isInbox || + this.isTrash || + this.isDatabase + ) { this.raw.element[0].children[0].text = this.title } @@ -66,6 +72,7 @@ export class Node { if (this.isTrash) return 'Trash' if (this.isDatabaseRoot) return 'Tags' if (this.isDailyRoot) return 'Daily Notes' + if (this.isDatabase) return this.props.name return this.element[0]?.children?.[0]?.text || this.props.name || '' } diff --git a/packages/serializer/src/nodeToSlate.ts b/packages/serializer/src/nodeToSlate.ts index ccf3a3ba..ff119b81 100644 --- a/packages/serializer/src/nodeToSlate.ts +++ b/packages/serializer/src/nodeToSlate.ts @@ -14,8 +14,6 @@ import { INode } from '@penx/model-types' * @returns */ export function nodeToSlate(node: INode, allNodes: INode[]) { - // console.log('node........:', node) - const serializer = new NodeToSlateSerializer( new Node(node), allNodes.map((n) => new Node(n)), @@ -147,7 +145,16 @@ export class NodeToSlateSerializer { } function getDatabaseNodeEditorValue(node: Node) { + // console.log('node-------:', node) + const value = [ + { + id: node.id, + type: ELEMENT_TITLE, + props: node.props, + nodeType: node.type, + children: node.element, + }, { type: ELEMENT_UL, children: [ @@ -174,7 +181,6 @@ function getDatabaseNodeEditorValue(node: Node) { }, ] - console.log('======value:', value) return value } diff --git a/packages/service/src/NodeService.ts b/packages/service/src/NodeService.ts index 5fe04f36..3f00a1d6 100644 --- a/packages/service/src/NodeService.ts +++ b/packages/service/src/NodeService.ts @@ -105,9 +105,15 @@ export class NodeService { isInReference = false, ) => { if (title) { - node = await db.updateNode(node.id, { - element: title.children, - }) + if (this.node.isDatabase) { + node = await db.updateNode(node.id, { + props: { ...node.props, name: SlateNode.string(title) }, + }) + } else { + node = await db.updateNode(node.id, { + element: title.children, + }) + } // update space name if (this.node.isRootNode) { @@ -117,7 +123,7 @@ export class NodeService { } } - if (ul) { + if (ul && !this.node.isDatabase) { await this.saveNodes(node.id, ul) } diff --git a/packages/store/src/stores/NodeStore.ts b/packages/store/src/stores/NodeStore.ts index 1f7534ba..f836c7cd 100644 --- a/packages/store/src/stores/NodeStore.ts +++ b/packages/store/src/stores/NodeStore.ts @@ -68,7 +68,7 @@ export class NodeStore { const activeNodes = this.getActiveNodes() if (index === 0 && isEqual(activeNodes[0], node)) { - // console.log('is equal node') + console.log('is equal node') return }