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

Commit 23e351b

Browse files
committed
Merge branch 'root-id'
2 parents 553cc66 + 7a6dcc7 commit 23e351b

File tree

11 files changed

+54
-52
lines changed

11 files changed

+54
-52
lines changed

docs/docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
### Improved
77
- frontmatter embed links support [ISSUE#123](https://github.com/RafaelGB/obsidian-db-folder/issues/123)
88
### Visual
9-
- Multi-column sort order information [ISSUE#127](https://github.com/RafaelGB/obsidian-db-folder/issues/127]
9+
- Multi-column sort order information [ISSUE#127](https://github.com/RafaelGB/obsidian-db-folder/issues/127)
1010
### No longer broken
1111
- Enable frontmatter quotes wrapping does not break config that already has quotes [ISSUE#286](https://github.com/RafaelGB/obsidian-db-folder/issues/286)
1212
- Problem refreshing column info after modifying the label solved [ISSUE#300](https://github.com/RafaelGB/obsidian-db-folder/issues/300)

src/DatabaseView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
5353
this.register(
5454
this.containerEl.onWindowMigrated(() => {
5555
this.plugin.removeView(this);
56-
this.plugin.addView(this, this.data, this.isPrimary);
56+
this.plugin.addView(this, this.data);
5757
})
5858
);
5959
}
@@ -66,7 +66,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
6666
return this.data;
6767
}
6868

69-
setViewData(data: string, clear: boolean): void {
69+
setViewData(data: string): void {
7070
if (!isDatabaseNote(data)) {
7171
this.plugin.databaseFileModes[(this.leaf as any).id || this.file.path] =
7272
InputType.MARKDOWN;
@@ -76,7 +76,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
7676
return;
7777
}
7878

79-
this.plugin.addView(this, data, !clear && this.isPrimary);
79+
this.plugin.addView(this, data);
8080
}
8181

8282
getViewType(): string {
@@ -211,7 +211,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
211211
this.tableContainer = this.contentEl.createDiv(
212212
StyleClasses.TABLE_CONTAINER
213213
);
214-
this.tableContainer.setAttribute("id", "root");
214+
this.tableContainer.setAttribute("id", file.path);
215215
this.rootContainer = createRoot(this.tableContainer);
216216
return await super.onLoadFile(file);
217217
} catch (e) {

src/StateManager.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ export default class StateManager {
88
public file: TFile;
99
constructor(
1010
initialView: DatabaseView,
11-
initialData: string,
1211
onEmpty: () => void,
1312
getGlobalSettings: () => DatabaseSettings
1413
) {
1514
this.file = initialView.file;
1615
this.onEmpty = onEmpty;
1716
this.getGlobalSettings = getGlobalSettings;
1817

19-
this.registerView(initialView, initialData, true);
18+
this.registerView(initialView);
2019
}
2120

22-
registerView(view: DatabaseView, data: string, shouldParseData: boolean) {
23-
if (!this.viewSet.has(view)) {
24-
this.viewSet.add(view);
25-
view.initDatabase();
26-
}
21+
registerView(view: DatabaseView) {
22+
this.viewSet.clear();
23+
this.viewSet.add(view);
24+
view.initDatabase();
25+
2726
}
2827

2928
unregisterView(view: DatabaseView) {

src/components/DefaultHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function DefaultHeader(headerProps: DatabaseHeaderProps) {
5656
const created: boolean = false;
5757
/** Properties of header */
5858
const { header, table } = headerProps;
59-
const { tableState } = table.options.meta;
59+
const { tableState, view } = table.options.meta;
6060

6161
const [columnInfo, columnActions] = tableState.columns((state) => [
6262
state.info,
@@ -164,7 +164,7 @@ export default function DefaultHeader(headerProps: DatabaseHeaderProps) {
164164
labelState={labelState}
165165
setLabelState={setLabelState}
166166
/>,
167-
activeDocument.getElementById("popper-container")
167+
activeDocument.getElementById(`${view.file.path}-popper`)
168168
)
169169
: null}
170170
</>

src/components/Table.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export function Table(tableData: TableDataType) {
108108
targetColumnId: string,
109109
columnOrder: string[]
110110
): ColumnOrderState => {
111+
console.log("reorderColumn", draggedColumnId, targetColumnId, columnOrder);
111112
columnOrder.splice(
112113
columnOrder.indexOf(targetColumnId),
113114
0,

src/components/index/Database.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export function Database(tableProps: TableDataType) {
1111
return (
1212
<React.StrictMode>
1313
<Table {...tableProps} tableStore={tableStore} />
14-
<div id="popper-container" key={"popper-container-key"}></div>
14+
<div
15+
id={`${tableProps.view.file.path}-popper`}
16+
key={`${tableProps.view.file.path}-popper-key`}
17+
></div>
1518
</React.StrictMode>
1619
);
1720
}

src/components/portals/CalendarPortal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { TableColumn } from "cdm/FolderModel";
99
const CalendarPortal = (calendarProps: CellComponentProps) => {
1010
const { defaultCell } = calendarProps;
1111
const { row, column, table } = defaultCell;
12-
const { tableState } = table.options.meta;
12+
const { tableState, view } = table.options.meta;
1313
const tableColumn = column.columnDef as TableColumn;
1414
const dataActions = tableState.data((state) => state.actions);
1515

@@ -43,7 +43,7 @@ const CalendarPortal = (calendarProps: CellComponentProps) => {
4343
}
4444

4545
const CalendarContainer = (containerProps: any) => {
46-
const el = activeDocument.getElementById("popper-container");
46+
const el = activeDocument.getElementById(`${view.file.path}-popper`);
4747
return <Portal container={el}>{containerProps.children}</Portal>;
4848
};
4949
return showDatePicker ? (

src/components/portals/CalendarTimePortal.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,15 @@ import { TableColumn } from "cdm/FolderModel";
88
const CalendarTimePortal = (calendarTimeProps: CellComponentProps) => {
99
const { defaultCell } = calendarTimeProps;
1010
const { row, table, column } = defaultCell;
11+
const { tableState, view } = table.options.meta;
1112
const tableColumn = column.columnDef as TableColumn;
12-
const dataActions = table.options.meta.tableState.data(
13-
(state) => state.actions
14-
);
13+
const dataActions = tableState.data((state) => state.actions);
1514

16-
const calendatTimeRow = table.options.meta.tableState.data(
17-
(state) => state.rows[row.index]
18-
);
15+
const calendatTimeRow = tableState.data((state) => state.rows[row.index]);
1916

20-
const columnsInfo = table.options.meta.tableState.columns(
21-
(state) => state.info
22-
);
17+
const columnsInfo = tableState.columns((state) => state.info);
2318

24-
const configInfo = table.options.meta.tableState.configState(
25-
(state) => state.info
26-
);
19+
const configInfo = tableState.configState((state) => state.info);
2720

2821
// Calendar state
2922
const calendarTimeState = calendatTimeRow[tableColumn.key];
@@ -49,7 +42,7 @@ const CalendarTimePortal = (calendarTimeProps: CellComponentProps) => {
4942
}
5043

5144
const CalendarContainer = (containerProps: any) => {
52-
const el = activeDocument.getElementById("popper-container");
45+
const el = activeDocument.getElementById(`${view.file.path}-popper`);
5346
return <Portal container={el}>{containerProps.children}</Portal>;
5447
};
5548

src/components/portals/DataviewFiltersPortal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ const DataviewFiltersPortal = (props: DataviewFiltersProps) => {
274274
{domReady
275275
? ReactDOM.createPortal(
276276
currentFilters(),
277-
activeDocument.getElementById("popper-container")
277+
activeDocument.getElementById(`${view.file.path}-popper`)
278278
)
279279
: null}
280280
</>

src/components/portals/PopperSelectPortal.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,14 @@ import { TableColumn } from "cdm/FolderModel";
1616
const PopperSelectPortal = (popperProps: CellComponentProps) => {
1717
const { defaultCell } = popperProps;
1818
const { row, column, table } = defaultCell;
19+
const { tableState, view } = table.options.meta;
20+
const dataActions = tableState.data((state) => state.actions);
1921

20-
const dataActions = table.options.meta.tableState.data(
21-
(state) => state.actions
22-
);
23-
24-
const selectPortalRow = table.options.meta.tableState.data(
25-
(state) => state.rows[row.index]
26-
);
22+
const selectPortalRow = tableState.data((state) => state.rows[row.index]);
2723

28-
const columns = table.options.meta.tableState.columns(
29-
(state) => state.columns
30-
);
24+
const columns = tableState.columns((state) => state.columns);
3125

32-
const ddbbConfig = table.options.meta.tableState.configState(
33-
(state) => state.ddbbConfig
34-
);
26+
const ddbbConfig = tableState.configState((state) => state.ddbbConfig);
3527

3628
const tableColumn = column.columnDef as TableColumn;
3729

@@ -225,7 +217,7 @@ const PopperSelectPortal = (popperProps: CellComponentProps) => {
225217
{domReady
226218
? ReactDOM.createPortal(
227219
PortalSelect(),
228-
activeDocument.getElementById("popper-container")
220+
activeDocument.getElementById(`${view.file.path}-popper`)
229221
)
230222
: null}
231223
</>

0 commit comments

Comments
 (0)