Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 1663150

Browse files
committed
css and new metadata working
1 parent 41816ef commit 1663150

File tree

7 files changed

+53
-12
lines changed

7 files changed

+53
-12
lines changed

src/components/DefaultCell.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import MarkdownCell from "components/cellTypes/MarkdownCell";
1111
import TagsPortal from "components/portals/TagsPortal";
1212
import NumberCell from "components/cellTypes/NumberCell";
1313
import TextCell from "components/cellTypes/TextCell";
14+
import MetadataTimeCell from "components/cellTypes/MetadataTimeCell";
15+
import InOutLinksCell from "components/cellTypes/InOutLinksCell";
1416
import { CellContext } from "@tanstack/react-table";
1517
import { Literal } from "obsidian-dataview";
16-
import MetadataTimeCell from "./cellTypes/MetadataTimeCell";
1718

1819
export default function DefaultCell(
1920
defaultCell: CellContext<RowDataType, Literal>
@@ -63,6 +64,11 @@ export default function DefaultCell(
6364
case InputType.TASK:
6465
return <TaskCell defaultCell={defaultCell} />;
6566

67+
/** InOut links option */
68+
case InputType.INLINKS:
69+
case InputType.OUTLINKS:
70+
return <InOutLinksCell defaultCell={defaultCell} />;
71+
6672
/** Checkbox option */
6773
case InputType.CHECKBOX:
6874
return <CheckboxCell defaultCell={defaultCell} />;

src/components/DefaultHeader.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export default function DefaultHeader(headerProps: DatabaseHeaderProps) {
104104
case InputType.TAGS:
105105
propertyIcon = <TagsIcon />;
106106
break;
107+
case InputType.INLINKS:
108+
case InputType.OUTLINKS:
109+
propertyIcon = <TaskIcon />;
110+
break;
107111
case InputType.TASK:
108112
case InputType.CHECKBOX:
109113
propertyIcon = <TaskIcon />;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { CellComponentProps } from "cdm/ComponentsModel";
2+
import { renderMarkdown } from "components/obsidianArq/MarkdownRenderer";
3+
import { c } from "helpers/StylesHelper";
4+
import { Link } from "obsidian-dataview";
5+
import React, { useEffect, useRef } from "react";
6+
7+
const InOutLinksCell = (mdProps: CellComponentProps) => {
8+
const { defaultCell } = mdProps;
9+
const { table, row, column } = defaultCell;
10+
const { tableState } = table.options.meta;
11+
const markdownRow = tableState.data((state) => state.rows[row.index]);
12+
const mdRef = useRef<HTMLDivElement>();
13+
useEffect(() => {
14+
if (mdRef.current !== null) {
15+
mdRef.current.innerHTML = "";
16+
const links = markdownRow[column.id] as Link[];
17+
const markdownLinks: string[] = [];
18+
links.forEach((link) => {
19+
markdownLinks.push(`- ${link.markdown()}`);
20+
});
21+
renderMarkdown(defaultCell, markdownLinks.join("\n"), mdRef.current, 5);
22+
}
23+
});
24+
return <span ref={mdRef} className={c("md_cell text-align-left")}></span>;
25+
};
26+
27+
export default InOutLinksCell;

src/components/cellTypes/TaskCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const TaskCell = (taskProps: CellComponentProps) => {
3535
}, []);
3636
const taskRef = useRef<HTMLDivElement>();
3737

38-
return <div ref={taskRef} className={c("text-align-left")}></div>;
38+
return <div ref={taskRef} className={c("md_cell text-align-left")}></div>;
3939
};
4040

4141
export default TaskCell;

src/stateManagement/data/handlers/AddRowHandlerAction.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DatabaseView } from "DatabaseView";
66
import { SourceDataTypes } from "helpers/Constants";
77
import { resolve_tfolder } from "helpers/FileManagement";
88
import { DateTime } from "luxon";
9+
import { Link } from "obsidian-dataview";
910
import { VaultManagerDB } from "services/FileManagerService";
1011
import NoteInfo from "services/NoteInfo";
1112
import { AbstractTableAction } from "stateManagement/AbstractTableAction";
@@ -44,19 +45,17 @@ export default class AddRowlHandlerAction extends AbstractTableAction<DataState>
4445
rowRecord,
4546
ddbbConfig
4647
);
47-
4848
const newNote = new NoteInfo({
4949
...rowRecord.frontmatter,
5050
...rowRecord.inline,
5151
file: {
5252
path: filepath,
5353
ctime: DateTime.now(),
5454
mtime: DateTime.now(),
55-
link: {
56-
path: filepath,
57-
fileName: () => filename,
58-
},
55+
link: Link.file(filepath),
5956
tasks: [],
57+
inlinks: [],
58+
outlinks: [],
6059
},
6160
});
6261

src/stateManagement/data/handlers/SaveDataFromFileHandlerAction.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DataState, TableActionResponse } from "cdm/TableStateInterface";
44
import { DatabaseView } from "DatabaseView";
55
import { DEFAULT_SETTINGS, SourceDataTypes } from "helpers/Constants";
66
import { Notice } from "obsidian";
7-
import { Literal } from "obsidian-dataview";
7+
import { Link, Literal } from "obsidian-dataview";
88
import { DateTime } from "luxon";
99
import NoteInfo from "services/NoteInfo";
1010
import { AbstractTableAction } from "stateManagement/AbstractTableAction";
@@ -86,11 +86,10 @@ export default class SaveDataFromFileHandlerAction extends AbstractTableAction<D
8686
path: filepath,
8787
ctime: DateTime.now(),
8888
mtime: DateTime.now(),
89-
link: {
90-
path: filepath,
91-
fileName: () => filename,
92-
},
89+
link: Link.file(filepath),
9390
tasks: [],
91+
inlinks: [],
92+
outlinks: [],
9493
},
9594
});
9695

styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ div.database-plugin__checkbox {
188188
display: inline;
189189
}
190190

191+
.database-plugin__md_cell ul {
192+
margin-block-start: unset !important;
193+
margin-block-end: unset !important;
194+
display: inline-table;
195+
}
196+
191197
.database-plugin__markdown-preview-view {
192198
padding: 0;
193199
height: fit-content;

0 commit comments

Comments
 (0)