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

Commit ebd2855

Browse files
committed
add inline field works!
1 parent 7d3ffd3 commit ebd2855

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/helpers/VaultManagement.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ export async function updateRowFile(file: TFile, columnId: string, newValue: str
146146
* group 2 is the current value of inline field
147147
*/
148148
const frontmatterRegex = new RegExp(`(^${columnId}[:]{2}\\s)+([\\w\\W]+?$)`, 'gm');
149+
if (!frontmatterRegex.test(content)) {
150+
await addInlineColumn();
151+
return;
152+
}
149153
const noteObject = {
150154
action: 'replace',
151155
file: file,
@@ -154,6 +158,17 @@ export async function updateRowFile(file: TFile, columnId: string, newValue: str
154158
};
155159
await VaultManagerDB.editNoteContent(noteObject);
156160
}
161+
162+
async function addInlineColumn(): Promise<void> {
163+
const inlineAddRegex = new RegExp(`(^---\\s+[\\w\\W]+?\\s+---\\s)+(.[\\w\\W]+)`, 'g');
164+
const noteObject = {
165+
action: 'replace',
166+
file: file,
167+
regexp: inlineAddRegex,
168+
newValue: `$1${columnId}:: ${newValue}\n$2`
169+
};
170+
await VaultManagerDB.editNoteContent(noteObject);
171+
}
157172
// Record of options
158173
const updateOptions: Record<string, any> = {};
159174
updateOptions[UpdateRowOptions.COLUMN_VALUE] = columnValue;

0 commit comments

Comments
 (0)