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

Commit 98f664c

Browse files
committed
Merge branch '25-fr-inline-field-supported'
2 parents 7486ceb + ec02170 commit 98f664c

File tree

16 files changed

+343
-145
lines changed

16 files changed

+343
-145
lines changed

docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.2.0
2+
### Shiny new things
3+
- Edit inline fields are now supported! [ISSUE#25](https://github.com/RafaelGB/obsidian-db-folder/issues/25)
4+
- Big refactor about edit engine to improve resiliency and performance
5+
- new adjsutment section in column menu where, at the moment, you can select if column is of inline type or not
6+
7+
### Improved
8+
- Now when you create a column, the field asociated is not inserted into all the rows. Just will be inserted when you edit the cell asociated.
19
## 0.1.2
210
*Published on 2022/05/04*
311
### Improved

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": "0.1.2",
4+
"version": "0.2.0",
55
"minAppVersion": "0.14.6",
66
"description": "Folder with the capability to store and retrieve data from a folder like database",
77
"author": "RafaelGB",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-dbfolder",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/cdm/FolderModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ export type NoteContentAction = {
121121
file: TFile,
122122
action: string,
123123
regexp: RegExp,
124-
newValue: string
124+
newValue?: string
125125
}

src/cdm/RowSelectModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ActionType } from "react-table";
22
import NoteInfo from "services/NoteInfo";
3+
import { TableDataType } from "cdm/FolderModel";
34

45
export type RowSelectOption = {
56
backgroundColor: string,
@@ -11,4 +12,5 @@ export type PopperProps = {
1112
column: any;
1213
columns: any;
1314
note: NoteInfo;
15+
state: TableDataType;
1416
};

src/components/Cell.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export default function DefaultCell(cellProperties: Cell) {
122122
column={cellProperties.column}
123123
columns={columns}
124124
note={note}
125+
state={(cellProperties as any).initialState}
125126
/>
126127
</CellContext.Provider>
127128
);

src/components/Header.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default function Header(headerProps: DatabaseHeaderProps) {
5757
const [domReady, setDomReady] = useState(false);
5858
const [referenceElement, setReferenceElement] = useState(null);
5959
const [isMetadata, setIsMetadata] = useState(headerProps.column.isMetadata);
60+
const [isInline, setIsInline] = useState(headerProps.column.isInline);
6061
const [labelState, setLabelState] = useState(headerProps.column.label);
6162
React.useEffect(() => {
6263
setDomReady(true);
@@ -119,6 +120,7 @@ export default function Header(headerProps: DatabaseHeaderProps) {
119120
>
120121
<span className="svg-icon svg-gray icon-margin">{propertyIcon}</span>
121122
{labelState}
123+
{isInline && <span>*</span>}
122124
</div>
123125
{!isMetadata && domReady
124126
? ReactDOM.createPortal(
@@ -134,6 +136,8 @@ export default function Header(headerProps: DatabaseHeaderProps) {
134136
referenceElement={referenceElement}
135137
labelState={labelState}
136138
setLabelState={setLabelState}
139+
isInline={isInline}
140+
setIsInline={setIsInline}
137141
initialState={initialState}
138142
/>,
139143
document.getElementById("popper-container")

src/components/HeaderMenu.tsx

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import TrashIcon from "components/img/Trash";
1414
import TextIcon from "components/img/Text";
1515
import MultiIcon from "components/img/Multi";
1616
import HashIcon from "components/img/Hash";
17+
import AdjustmentsIcon from "components/img/AdjustmentsIcon";
1718
import React, { useContext, useEffect, useState } from "react";
1819
import { ActionType } from "react-table";
1920
import { usePopper } from "react-popper";
2021
import { HeaderContext } from "components/contexts/HeaderContext";
22+
import { FormControlLabel, FormGroup, Switch } from "@material-ui/core";
2123
type HeaderMenuProps = {
2224
dispatch: (action: ActionType) => void;
2325
setSortBy: any;
@@ -31,6 +33,8 @@ type HeaderMenuProps = {
3133
labelState: string;
3234
setLabelState: (label: string) => void;
3335
initialState: TableDataType;
36+
isInline: boolean;
37+
setIsInline: (isInline: boolean) => void;
3438
};
3539
const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
3640
const {
@@ -44,6 +48,8 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
4448
labelState,
4549
setLabelState,
4650
initialState,
51+
isInline,
52+
setIsInline,
4753
} = headerMenuProps;
4854
/** state of width columns */
4955
const { columnWidthState, setColumnWidthState } = useContext(HeaderContext);
@@ -56,11 +62,17 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
5662
placement: "bottom",
5763
strategy: "absolute",
5864
});
65+
// Manage type of data
5966
const [typeReferenceElement, setTypeReferenceElement] = useState(null);
6067
const [typePopperElement, setTypePopperElement] = useState(null);
61-
6268
const [showType, setShowType] = useState(false);
6369

70+
// Manage settings
71+
const [settingsReferenceElement, setSettingsReferenceElement] =
72+
useState(null);
73+
const [settingsPopperElement, setSettingsPopperElement] = useState(null);
74+
const [showSettings, setShowSettings] = useState(false);
75+
6476
useEffect(() => {
6577
if (created) {
6678
setExpanded(true);
@@ -193,6 +205,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
193205
strategy: "fixed",
194206
});
195207

208+
const settingsPopper = usePopper(
209+
settingsReferenceElement,
210+
settingsPopperElement,
211+
{
212+
placement: "right",
213+
strategy: "fixed",
214+
}
215+
);
216+
196217
function persistLabelChange() {
197218
dispatch({
198219
type: ActionTypes.UPDATE_COLUMN_LABEL,
@@ -240,6 +261,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
240261
return { name: columnName, position: columnNumber, label: columnLabel };
241262
}
242263

264+
function handleChangeToggleInlineFrontmatter(e: any) {
265+
setIsInline(e.target.checked);
266+
dispatch({
267+
type: ActionTypes.TOGGLE_INLINE_FRONTMATTER,
268+
columnId: id,
269+
isInline: e.target.checked,
270+
});
271+
}
272+
243273
return (
244274
<div>
245275
{expanded && (
@@ -288,7 +318,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
288318
Property Type
289319
</span>
290320
</div>
291-
{/** Edit header label section */}
321+
{/** Type of column section */}
292322
<div style={{ padding: "4px 0px" }}>
293323
<button
294324
className="sort-button"
@@ -330,6 +360,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
330360
</div>
331361
)}
332362
</div>
363+
{/** Action buttons section */}
333364
<div
334365
style={{
335366
borderTop: `2px solid ${StyleVariables.BACKGROUND_DIVIDER}`,
@@ -350,6 +381,58 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
350381
</button>
351382
))}
352383
</div>
384+
<div
385+
style={{
386+
borderTop: `2px solid ${StyleVariables.BACKGROUND_DIVIDER}`,
387+
padding: "4px 0px",
388+
}}
389+
>
390+
{/** Column settings section */}
391+
<div style={{ padding: "4px 0px" }}>
392+
<button
393+
className="sort-button"
394+
type="button"
395+
onMouseEnter={() => setShowSettings(true)}
396+
onMouseLeave={() => setShowSettings(false)}
397+
ref={setSettingsReferenceElement}
398+
>
399+
<span className="svg-icon svg-text icon-margin">
400+
<AdjustmentsIcon />
401+
</span>
402+
<span>Settings</span>
403+
</button>
404+
{showSettings && (
405+
<div
406+
className="shadow-5 border-radius-m"
407+
ref={setSettingsPopperElement}
408+
onMouseEnter={() => setShowSettings(true)}
409+
onMouseLeave={() => setShowSettings(false)}
410+
{...settingsPopper.attributes.popper}
411+
style={{
412+
...settingsPopper.styles.popper,
413+
width: 200,
414+
backgroundColor: StyleVariables.BACKGROUND_SECONDARY,
415+
zIndex: 4,
416+
padding: "4px 0px",
417+
}}
418+
>
419+
<FormGroup>
420+
<FormControlLabel
421+
control={
422+
<Switch
423+
checked={isInline}
424+
onChange={(event) => {
425+
handleChangeToggleInlineFrontmatter(event);
426+
}}
427+
/>
428+
}
429+
label="Inline"
430+
/>
431+
</FormGroup>
432+
</div>
433+
)}
434+
</div>
435+
</div>
353436
</div>
354437
</div>
355438
)}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
3+
export default function AdjustmentsIcon() {
4+
return (
5+
<svg
6+
width="24"
7+
height="24"
8+
viewBox="0 0 24 24"
9+
strokeWidth="2"
10+
stroke="currentColor"
11+
fill="none"
12+
strokeLinecap="round"
13+
strokeLinejoin="round"
14+
>
15+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
16+
<circle cx="14" cy="6" r="2" />
17+
<line x1="4" y1="6" x2="12" y2="6" />
18+
<line x1="16" y1="6" x2="20" y2="6" />
19+
<circle cx="8" cy="12" r="2" />
20+
<line x1="4" y1="12" x2="6" y2="12" />
21+
<line x1="10" y1="12" x2="20" y2="12" />
22+
<circle cx="17" cy="18" r="2" />
23+
<line x1="4" y1="18" x2="15" y2="18" />
24+
<line x1="19" y1="18" x2="20" y2="18" />
25+
</svg>
26+
);
27+
}

src/components/portals/PopperSelectPortal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { PopperProps } from "cdm/RowSelectModel";
99
import { CellContext } from "components/contexts/CellContext";
1010

1111
const PopperSelectPortal = (popperProps: PopperProps) => {
12-
const { dispatch, row, column, columns, note } = popperProps;
12+
const { dispatch, row, column, columns, note, state } = popperProps;
1313
/** state of cell value */
1414
const { value, setValue } = useContext(CellContext);
1515
// Selector reference state
@@ -41,6 +41,7 @@ const PopperSelectPortal = (popperProps: PopperProps) => {
4141
value: option.label,
4242
row: row,
4343
columnId: column.id,
44+
state: state,
4445
});
4546
}
4647

0 commit comments

Comments
 (0)