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

Commit c98d697

Browse files
authored
Merge pull request #897 from trey-wallis/dev
8.15.6
2 parents adc3f83 + 02abd90 commit c98d697

20 files changed

+698
-67
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"fundingUrl": {
1010
"Buymeacoffee": "https://www.buymeacoffee.com/treywallis"
1111
},
12-
"version": "8.15.5"
12+
"version": "8.15.6"
1313
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-dataloom",
3-
"version": "8.15.5",
3+
"version": "8.15.6",
44
"description": "Weave together data from diverse sources into different views. Inspired by Excel Spreadsheets and Notion.so.",
55
"main": "main.js",
66
"scripts": {

src/data/serialize-frontmatter.ts

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export const serializeFrontmatter = async (app: App, state: LoomState) => {
6262
rowId: row.id,
6363
});
6464

65+
const { hasValidFrontmatter } = cell;
66+
//If we don't have valid frontmatter, skip this cell, so we don't overwrite the invalid value
67+
//we want the user to correct it themselves
68+
if (hasValidFrontmatter === false) continue;
69+
6570
let saveValue: unknown = null;
6671
if (type === CellType.TEXT) {
6772
const { content } = cell as TextCell;

src/data/serialize-state.ts

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
LoomState17,
2626
LoomState18,
2727
LoomState19,
28+
LoomState20,
2829
} from "src/shared/loom-state/types";
2930

3031
import {
@@ -52,6 +53,7 @@ import {
5253
} from "src/shared/loom-state/migrate";
5354
import { LoomStateObject } from "src/shared/loom-state/validate-state";
5455
import DeserializationError from "./deserialization-error";
56+
import MigrateState21 from "src/shared/loom-state/migrate/migrate-state-21";
5557

5658
export const serializeState = (state: LoomState): string => {
5759
//Filter out any source rows, as these are populated by the plugin
@@ -304,6 +306,16 @@ export const deserializeState = (
304306
failedMigration = null;
305307
}
306308

309+
const VERSION_8_15_6 = "8.15.6";
310+
if (isVersionLessThan(fileVersion, VERSION_8_15_6)) {
311+
failedMigration = VERSION_8_15_6;
312+
const nextState = new MigrateState21().migrate(
313+
currentState as LoomState20
314+
);
315+
currentState = nextState;
316+
failedMigration = null;
317+
}
318+
307319
//TODO handle previous versions?
308320
LoomStateObject.check(currentState);
309321

src/react/loom-app/body-cell-container/index.tsx

+30-15
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { getSourceCellContent } from "src/shared/cell-content/source-cell-conten
6969
import { getSourceFileContent } from "src/shared/cell-content/source-file-content";
7070
import { getFileCellContent } from "src/shared/cell-content/file-cell-content";
7171
import { getDateCellContent } from "src/shared/cell-content/date-cell-content";
72+
import DisabledCell from "../disabled-cell";
7273

7374
interface BaseCellProps {
7475
frontmatterKey: string | null;
@@ -185,6 +186,7 @@ export default function BodyCellContainer(props: Props) {
185186
const {
186187
id,
187188
columnId,
189+
hasValidFrontmatter,
188190
source,
189191
includeTime,
190192
aspectRatio,
@@ -216,7 +218,17 @@ export default function BodyCellContainer(props: Props) {
216218
type === CellType.MULTI_TAG ||
217219
type === CellType.DATE;
218220

219-
const isDisabled = source !== null && frontmatterKey === null;
221+
let isDisabled = false;
222+
if (hasValidFrontmatter === false) {
223+
isDisabled = true;
224+
} else if (
225+
source !== null &&
226+
frontmatterKey === null &&
227+
type !== CellType.SOURCE &&
228+
type !== CellType.SOURCE_FILE
229+
) {
230+
isDisabled = true;
231+
}
220232

221233
const isUneditable =
222234
type === CellType.CHECKBOX ||
@@ -239,14 +251,12 @@ export default function BodyCellContainer(props: Props) {
239251

240252
function onMenuTriggerEnterDown(cellActionCallback: () => void) {
241253
return () => {
242-
if (isDisabled) return;
243254
cellActionCallback();
244255
};
245256
}
246257

247258
function onMenuTriggerClick(cellActionCallback: () => void) {
248259
return () => {
249-
if (isDisabled) return;
250260
cellActionCallback();
251261
};
252262
}
@@ -322,23 +332,29 @@ export default function BodyCellContainer(props: Props) {
322332

323333
if (isUneditable) {
324334
className += " dataloom-cell--uneditable";
325-
} else if (isDisabled) {
326-
className += " dataloom-cell--disabled";
327335
}
328336

329337
let shouldRunTrigger = true;
330-
if (isUneditable || isDisabled) {
338+
if (isUneditable) {
331339
shouldRunTrigger = false;
332340
}
333341

334-
let ariaLabel = "";
335-
if (
336-
isDisabled &&
337-
type !== CellType.SOURCE &&
338-
type !== CellType.SOURCE_FILE
339-
) {
340-
ariaLabel =
341-
"This cell is disabled until you choose a frontmatter key for this column";
342+
if (isDisabled) {
343+
return (
344+
<div
345+
className={
346+
className + " dataloom-cell--body__container--no-padding"
347+
}
348+
style={{
349+
width,
350+
}}
351+
>
352+
<DisabledCell
353+
hasValidFrontmatter={hasValidFrontmatter ?? true}
354+
doesColumnHaveFrontmatterKey={frontmatterKey !== null}
355+
/>
356+
</div>
357+
);
342358
}
343359

344360
let contentNode: React.ReactNode | null = null;
@@ -728,7 +744,6 @@ export default function BodyCellContainer(props: Props) {
728744
return (
729745
<>
730746
<MenuTrigger
731-
ariaLabel={ariaLabel}
732747
ref={menu.triggerRef}
733748
variant="cell"
734749
menuId={menu.id}

src/react/loom-app/body-cell-container/styles.css

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
width: 100%;
44
height: 100%;
55
min-height: var(--dataloom-cell-min-height);
6-
padding: var(--dataloom-cell-spacing-x) var(--dataloom-cell-spacing-y);
6+
padding: var(--dataloom-cell-spacing-x) var(--dataloom-cell-spacing-y);
77
cursor: pointer;
88
color: var(--text-normal); /* Stop dimming of text when mouse leaves embedded loom */
99
}
1010

11-
.dataloom-cell--uneditable {
12-
cursor: default;
11+
.dataloom-cell--body__container--no-padding {
12+
padding: 0;
1313
}
1414

15-
.dataloom-cell--disabled {
15+
.dataloom-cell--uneditable {
1616
cursor: default;
17-
background-color: var(--background-secondary);
1817
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Text from "src/react/shared/text";
2+
3+
import "./styles.css";
4+
5+
interface Props {
6+
hasValidFrontmatter: boolean;
7+
doesColumnHaveFrontmatterKey: boolean;
8+
}
9+
10+
export default function DisabledCell({
11+
hasValidFrontmatter,
12+
doesColumnHaveFrontmatterKey,
13+
}: Props) {
14+
let ariaLabel = "";
15+
if (!doesColumnHaveFrontmatterKey) {
16+
ariaLabel =
17+
"This cell is disabled until you choose a frontmatter key for this column";
18+
} else if (!hasValidFrontmatter) {
19+
ariaLabel =
20+
"This cell has an invalid property value. Please correct it in the source file.";
21+
}
22+
return (
23+
<div className="dataloom-disabled-cell" aria-label={ariaLabel}>
24+
<Text value={hasValidFrontmatter ? "" : "Invalid property value"} />
25+
</div>
26+
);
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.dataloom-disabled-cell {
2+
width: 100%;
3+
height: 100%;
4+
background-color: var(--background-secondary);
5+
cursor: default;
6+
padding: var(--dataloom-cell-spacing-x) var(--dataloom-cell-spacing-y);
7+
}

src/react/loom-app/table/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,11 @@ const Table = React.forwardRef<VirtuosoHandle, Props>(function Table(
376376

377377
key = column.id;
378378

379-
const { id } = cell;
379+
const { id, hasValidFrontmatter } = cell;
380380

381381
const commonProps = {
382382
id,
383+
hasValidFrontmatter,
383384
columnId,
384385
frontmatterKey,
385386
verticalPadding,

0 commit comments

Comments
 (0)