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

Commit d7a1779

Browse files
committed
fixed
1 parent 1884854 commit d7a1779

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

docs/docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Visual bug after deleting and adding the same column. The data was removed into the note but not into the table [ISSUE#83](https://github.com/RafaelGB/obsidian-db-folder/issues/83)
77
- Add column is out of draggable area now, so you cant dnd to the right [ISSUE#63](https://github.com/RafaelGB/obsidian-db-folder/issues/63)
88
- onBlur event when changing the name of a column now works correctly [ISSUE#96](https://github.com/RafaelGB/obsidian-db-folder/issues/96)
9+
- `:` inside text cells now saves wrapped with `"your msg"` [ISSUE#90](https://github.com/RafaelGB/obsidian-db-folder/issues/90)
910
## 1.6.2
1011
*Published on 2022/06/02*
1112
### No longer broken

src/helpers/VaultManagement.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export async function adapterTFilesToRows(folderPath: string, columns: TableColu
7575
if (dbYaml.filters) {
7676
folderFiles = folderFiles.where(p => DataviewService.filter(dbYaml.filters, p));
7777
}
78-
7978
folderFiles.map(async (page) => {
8079
const noteInfo = new NoteInfo(page, ++id);
8180
rows.push(noteInfo.getRowDataType(columns));

src/parsers/RowDatabaseFieldsToFile.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { RowDatabaseFields } from "cdm/DatabaseModel";
2+
import { DataTypes } from "helpers/Constants";
23
import { Literal } from "obsidian-dataview/lib/data-model/value";
34
import { DataviewService } from "services/DataviewService";
45
export const parseFrontmatterFieldsToString = (databaseFields: RowDatabaseFields, deletedColumn?: string): string => {
@@ -25,16 +26,17 @@ export const parseInlineFieldsToString = (inlineFields: RowDatabaseFields): stri
2526
function parseLiteralToString(literal: Literal, level: number, key?: string): string[] {
2627
const literalBlock: string[] = [];
2728
literal = DataviewService.parseDataArray(literal);
29+
// Manage Arrays
2830
if (DataviewService.getDataviewAPI().value.isArray(literal)) {
2931
literalBlock.push(`${" ".repeat(level)}${key}:`);
3032
literal.forEach((literal, index) => {
3133
literalBlock.push(...parseLiteralToString(literal, level + 1));
3234
});
3335
}
3436
else if (key) {
35-
literalBlock.push(`${" ".repeat(level)}${key}: ${literal}`);
37+
literalBlock.push(`${" ".repeat(level)}${key}: ${DataviewService.parseLiteral(literal, DataTypes.MARKDOWN)}`);
3638
} else {
37-
literalBlock.push(`${" ".repeat(level)}- ${literal}`);
39+
literalBlock.push(`${" ".repeat(level)}- ${DataviewService.parseLiteral(literal, DataTypes.MARKDOWN)}`);
3840
}
3941
return literalBlock;
4042
}

src/services/DataviewService.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class DataviewProxy {
7474
.type} to ${dataTypeDst}`);
7575
// Check empty or undefined literals
7676
switch (dataTypeDst) {
77+
case DataTypes.TEXT:
78+
parsedLiteral = this.parseToString(wrapped);
79+
break;
80+
case DataTypes.MARKDOWN:
81+
parsedLiteral = this.parseToMarkdown(wrapped);
82+
break;
7783
case DataTypes.CALENDAR:
7884
case DataTypes.CALENDAR_TIME:
7985
parsedLiteral = this.parseToCalendar(wrapped);
@@ -120,17 +126,35 @@ class DataviewProxy {
120126
return this.instance;
121127
}
122128

123-
private parseToCalendar(literal: WrappedLiteral): Literal {
124-
if (DateTime.isDateTime(literal.value)) {
125-
if (literal.type === 'string') {
126-
return DateTime.fromISO(literal.value);
129+
private parseToCalendar(wrapped: WrappedLiteral): Literal {
130+
if (DateTime.isDateTime(wrapped.value)) {
131+
if (wrapped.type === 'string') {
132+
return DateTime.fromISO(wrapped.value);
127133
} else {
128-
return literal.value;
134+
return wrapped.value;
129135
}
130136
} else {
131137
return null;
132138
}
133139
}
140+
141+
private parseToString(wrapped: WrappedLiteral): Literal {
142+
if (DateTime.isDateTime(wrapped.value)) {
143+
LOGGER.debug("adapting DateTime to string...");
144+
// Values of dataview parse to md friendly strings
145+
return wrapped.value.toFormat("yyyy-MM-dd");
146+
} else {
147+
return this.getDataviewAPI().value.toString(wrapped.value);
148+
}
149+
}
150+
151+
private parseToMarkdown(wrapped: WrappedLiteral): Literal {
152+
let auxMarkdown = this.parseToString(wrapped) as string;
153+
if (auxMarkdown.contains(":")) {
154+
auxMarkdown = `"${auxMarkdown}"`;
155+
}
156+
return auxMarkdown;
157+
}
134158
}
135159

136160
export const DataviewService = DataviewProxy.getInstance();

src/services/NoteInfo.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default class NoteInfo {
2929
aFile[MetadataColumns.CREATED] = this.page.file.ctime;
3030
aFile[MetadataColumns.MODIFIED] = this.page.file.mtime;
3131
aFile[MetadataColumns.TASKS] = this.page.file.tasks;
32-
3332
/** Optional fields */
3433
Object.keys(this.page).forEach(property => {
3534
const value = this.page[property];

0 commit comments

Comments
 (0)