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

Commit e4806af

Browse files
committed
Merge branch 'master' into imed-docu-branch
2 parents f9a40aa + 513e8c7 commit e4806af

File tree

13 files changed

+81
-104
lines changed

13 files changed

+81
-104
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can add a folder database by right clicking on the folder where you want to
1313
<img src="https://github.com/RafaelGB/obsidian-db-folder/blob/master/docs/resources/AddDatabase.gif" width="200" height="250"/>
1414

1515
### How to use?
16-
Database has its own type of view. It will search all notes into the same folder of the database and show the columns that you specify. Check our [documentation](https://rafaelgb.github.io/obsidian-db-folder/features/rows/) for more information.
16+
Database has its own type of view. It will search all notes into the same folder of the database and show the columns that you specify. Check our [documentation](https://rafaelgb.github.io/obsidian-db-folder/features/Columns/) for more information.
1717

1818
The information you add or edit will be saved into the target obsidian note.
1919

docs/docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.4.1
2+
*Published on 2022/09/09*
3+
### Visual
4+
- Search now indicate the number of avaliable rows always, not just like placeholder [ISSUE#130](https://github.com/RafaelGB/obsidian-db-folder/issues/130)
5+
### No longer broken
6+
- FINALLY, DnD columns is enabled by default and the developer config about it was removed. It does not break Obsidian DnD anymore [ISSUE#239](https://github.com/RafaelGB/obsidian-db-folder/issues/239)
17
# 2.4.0
28
*Published on 2022/09/08*
39
### Shiny new things

manifest-beta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "dbfolder",
33
"name": "DB Folder",
4-
"version": "2.4.0",
4+
"version": "2.4.1",
55
"minAppVersion": "0.15.9",
66
"description": "Folder with the capability to store and retrieve data from a folder like database",
77
"author": "RafaelGB",

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "dbfolder",
33
"name": "DB Folder",
4-
"version": "2.4.0",
4+
"version": "2.4.1",
55
"minAppVersion": "0.15.9",
66
"description": "Folder with the capability to store and retrieve data from a folder like database",
77
"author": "RafaelGB",

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-dbfolder",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {
@@ -27,7 +27,7 @@
2727
"@testing-library/react": "13.3.0",
2828
"@types/jest": "28.1.8",
2929
"@types/luxon": "3.0.1",
30-
"@types/node": "18.7.14",
30+
"@types/node": "18.7.16",
3131
"@types/react": "18.0.18",
3232
"@types/react-color": "3.0.6",
3333
"@types/react-csv": "1.1.3",
@@ -57,13 +57,11 @@
5757
"luxon": "3.0.3",
5858
"fuse.js": "6.6.2",
5959
"monkey-around": "2.3.0",
60-
"obsidian-dataview": "0.5.43",
60+
"obsidian-dataview": "0.5.45",
6161
"react": "18.2.0",
6262
"react-color": "2.19.3",
6363
"react-csv": "2.2.2",
6464
"react-datepicker": "4.8.0",
65-
"react-dnd": "16.0.1",
66-
"react-dnd-html5-backend": "16.0.1",
6765
"react-dom": "18.2.0",
6866
"react-popper": "2.3.0",
6967
"react-select": "5.4.0",

src/cdm/SettingsModel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export interface GlobalSettings {
1616
enable_debug_mode: boolean;
1717
logger_level_info: string;
1818
media_settings: MediaSettings;
19-
enable_dnd: boolean;
2019
enable_show_state: boolean;
2120
}
2221

src/components/Table.tsx

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ import { HeaderNavBar } from "components/NavBar";
3838
import TableHeader from "components/TableHeader";
3939
import CustomTemplateSelectorStyles from "components/styles/RowTemplateStyles";
4040
import Select, { OnChangeValue } from "react-select";
41-
import { DndProvider } from "react-dnd";
42-
import { HTML5Backend } from "react-dnd-html5-backend";
4341
import TableRow from "components/TableRow";
4442
import getInitialColumnSizing from "components/behavior/InitialColumnSizeRecord";
4543
import { globalDatabaseFilterFn } from "components/reducers/TableFilterFlavours";
@@ -332,39 +330,26 @@ export function Table(tableData: TableDataType) {
332330
key={`${headerGroup.id}-${headerGroupIndex}`}
333331
className={`${c("tr header-group")}`}
334332
>
335-
{/* TODO manage context with documentFragment in any way to fix DnD conflict with Obsidian */}
336-
<DndProvider
337-
key={`${headerGroup.id}-${headerGroupIndex}-dnd-provider`}
338-
debugMode={globalConfig.enable_debug_mode}
339-
backend={HTML5Backend}
340-
context={
341-
(globalConfig.enable_debug_mode,
342-
globalConfig.enable_dnd
343-
? activeWindow
344-
: activeDocument.createElement("div"))
345-
}
346-
>
347-
{headerGroup.headers
348-
.filter(
349-
(o: Header<RowDataType, TableColumn>) =>
350-
(o.column.columnDef as TableColumn).key !==
351-
MetadataColumns.ADD_COLUMN
333+
{headerGroup.headers
334+
.filter(
335+
(o: Header<RowDataType, TableColumn>) =>
336+
(o.column.columnDef as TableColumn).key !==
337+
MetadataColumns.ADD_COLUMN
338+
)
339+
.map(
340+
(
341+
header: Header<RowDataType, TableColumn>,
342+
headerIndex: number
343+
) => (
344+
<TableHeader
345+
key={`${header.id}-${headerIndex}`}
346+
table={table}
347+
header={header}
348+
reorderColumn={reorderColumn}
349+
headerIndex={headerIndex}
350+
/>
352351
)
353-
.map(
354-
(
355-
header: Header<RowDataType, TableColumn>,
356-
headerIndex: number
357-
) => (
358-
<TableHeader
359-
key={`${header.id}-${headerIndex}`}
360-
table={table}
361-
header={header}
362-
reorderColumn={reorderColumn}
363-
headerIndex={headerIndex}
364-
/>
365-
)
366-
)}
367-
</DndProvider>
352+
)}
368353
{headerGroup.headers
369354
.filter(
370355
(o: Header<RowDataType, TableColumn>) =>

src/components/TableHeader.tsx

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import React from "react";
2-
import { Column, flexRender } from "@tanstack/react-table";
2+
import { flexRender } from "@tanstack/react-table";
33
import { c } from "helpers/StylesHelper";
44
import { TableHeaderProps } from "cdm/HeaderModel";
5-
import { useDrag, useDrop } from "react-dnd";
6-
import { RowDataType } from "cdm/FolderModel";
7-
import { DnDConfiguration } from "helpers/Constants";
85

96
export default function TableHeader(headerProps: TableHeaderProps) {
107
const { table, header, reorderColumn, headerIndex } = headerProps;
118
const { view } = table.options.meta;
129
const { columnOrder } = table.options.state;
13-
10+
const [isDragging, setIsDragging] = React.useState(false);
11+
const dndRef = React.useRef(null);
1412
function moveColumn(
1513
draggedColumnId: string,
1614
targetColumnId: string,
@@ -27,37 +25,49 @@ export default function TableHeader(headerProps: TableHeaderProps) {
2725
return newColumnOrder;
2826
}
2927

30-
const [, dropRef] = useDrop({
31-
accept: DnDConfiguration.DRAG_TYPE,
32-
drop: (draggedColumn: Column<RowDataType>) => {
33-
const newColumnOrder = moveColumn(
34-
draggedColumn.id,
35-
header.column.id,
36-
columnOrder
37-
);
38-
table.setColumnOrder(newColumnOrder);
39-
},
40-
});
41-
42-
const [{ isDragging }, dragRef] = useDrag({
43-
collect: (monitor) => ({
44-
isDragging: monitor.isDragging(),
45-
}),
46-
item: () => header.column,
47-
type: DnDConfiguration.DRAG_TYPE,
48-
});
49-
5028
return (
5129
<div
5230
key={`${header.id}-${headerIndex}`}
5331
className={`${c("th noselect")} header`}
32+
ref={dndRef}
5433
style={{
5534
width: header.getSize(),
5635
opacity: isDragging ? 0.5 : 1,
5736
}}
58-
ref={dropRef}
37+
onDrop={(e) => {
38+
e.preventDefault();
39+
const newColumnOrder = moveColumn(
40+
e.dataTransfer.getData("dbfolderDragId"),
41+
header.column.id,
42+
columnOrder
43+
);
44+
table.setColumnOrder(newColumnOrder);
45+
return false;
46+
}}
47+
draggable
48+
onDragStart={(e) => {
49+
setIsDragging(true);
50+
e.dataTransfer.effectAllowed = "move";
51+
e.dataTransfer.setData("dbfolderDragId", header.column.id);
52+
}}
53+
onDragEnter={(e) => {
54+
dndRef.current.classList.add("over");
55+
}}
56+
onDragLeave={(e) => {
57+
dndRef.current.classList.remove("over");
58+
}}
59+
onDragEnd={(e) => {
60+
setIsDragging(false);
61+
}}
62+
onDragOver={(e) => {
63+
if (e.preventDefault) {
64+
e.preventDefault();
65+
}
66+
e.dataTransfer.dropEffect = "move";
67+
return false;
68+
}}
5969
>
60-
<div ref={dragRef} key={`${header.id}-${headerIndex}-dnd`}>
70+
<div key={`${header.id}-${headerIndex}-dnd`}>
6171
{header.isPlaceholder
6272
? null
6373
: flexRender(header.column.columnDef.header, header.getContext())}

src/components/reducers/GlobalFilter.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,22 @@ export default function GlobalFilter(globalFilterProps: GlobalFilterProps) {
2020
return (
2121
<Search>
2222
<SearchIconWrapper>
23-
<SearchIcon />
23+
<div
24+
style={{
25+
listStyleType: "none",
26+
}}
27+
>
28+
<li>
29+
<SearchIcon />
30+
</li>
31+
<li>{hits}</li>
32+
</div>
2433
</SearchIconWrapper>
2534
<DebouncedInputWrapper>
2635
<DebouncedInput
2736
value={globalFilter ?? ""}
2837
onChange={(value) => setGlobalFilter(String(value))}
29-
placeholder={`Search... (${hits})`}
38+
placeholder={`Search...`}
3039
/>
3140
</DebouncedInputWrapper>
3241
</Search>

src/components/styles/NavBarStyles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ export const Search = styled('div')(({ theme }) => ({
1818
}));
1919

2020
export const SearchIconWrapper = styled('div')(({ theme }) => ({
21-
padding: theme.spacing(0, 2),
21+
padding: theme.spacing(0, 1),
2222
height: '100%',
2323
position: 'absolute',
2424
pointerEvents: 'none',
2525
display: 'flex',
2626
alignItems: 'center',
2727
justifyContent: 'center',
28+
textAlign: 'center'
2829
}));
2930

3031
export const DebouncedInputWrapper = styled('div')(({ theme }) => ({

0 commit comments

Comments
 (0)