Skip to content

Commit 183bd53

Browse files
committed
generic hell
1 parent 2db3f3e commit 183bd53

27 files changed

+1007
-917
lines changed

exampleVault/Input Fields/Image Suggester.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
image: Other/Images/img_flower.webp
2+
image: Other/Images/img_butterfly.webp
33
---
44

55
```meta-bind

exampleVault/Input Fields/Progress Bar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
progress1: -7
2+
progress1: -9
33
---
44

55
```meta-bind

exampleVault/Input Fields/Suggester.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
fileSuggest: "[[Other/Example Notes/Example Note with Image.md|Example Note with Image]]"
3-
suggest: option 1
2+
fileSuggest: "[[Other/Example Notes/Example Note with Embeds.md|Example Note with Embeds]]"
3+
suggest: option 2
44
---
55

66
### Simple Suggester

exampleVault/View Fields/View Field.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
number1: 11
2+
number1: 13
33
number2: 20
4-
unit: m
4+
unit: km
55
---
66

77
`INPUT[number:number1]`

exampleVault/examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
slider1: 8
2+
slider1: 9
33
suggest: test
44
toggle1: false
55
Domestic_tasks:

exampleVault/other note.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
tags: test
33
title: test test
4-
select: option b
5-
date: Wednesday, August 16th 2023
4+
select: option d
5+
date: Friday, August 18th 2023
66
time: 19:20
77
multi-select:
88
- option a

src/api/API.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { BindTargetParser } from '../parsers/BindTargetParser';
55
import { ViewFieldMDRC } from '../renderChildren/ViewFieldMDRC';
66
import { JsViewFieldMDRC } from '../renderChildren/JsViewFieldMDRC';
77
import MetaBindPlugin from '../main';
8-
import { NewInputFieldDeclarationParser, UnvalidatedInputFieldDeclaration } from '../parsers/newInputFieldParser/InputFieldParser';
8+
import { NewInputFieldDeclarationParser } from '../parsers/newInputFieldParser/InputFieldParser';
99
import { Component, MarkdownPostProcessorContext } from 'obsidian';
1010
import { InputFieldAPI } from './InputFieldAPI';
11+
import { UnvalidatedInputFieldDeclaration } from '../parsers/newInputFieldParser/InputFieldDeclarationValidator';
1112

1213
export class API {
1314
public plugin: MetaBindPlugin;

src/api/InputFieldAPI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { InputFieldArgumentType, InputFieldType } from '../parsers/InputFieldDeclarationParser';
2-
import { StructureParserResult, UnvalidatedInputFieldDeclaration } from '../parsers/newInputFieldParser/InputFieldParser';
32
import { ErrorCollection } from '../utils/errors/ErrorCollection';
43
import { API } from './API';
54
import { useSyncExternalStore } from 'preact/compat';
5+
import { UnvalidatedInputFieldDeclaration } from '../parsers/newInputFieldParser/InputFieldDeclarationValidator';
6+
import { StructureParserResult } from '../parsers/newInputFieldParser/StructureParser';
67

78
export class InputFieldAPI {
89
private readonly api: API;

src/main.ts

Lines changed: 11 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ export default class MetaBindPlugin extends Plugin implements IPlugin {
109109
},
110110
});
111111

112-
this.addCommand({
113-
id: 'mb-test-command',
114-
name: 'test command',
115-
editorCallback: (editor: Editor, view: MarkdownView | MarkdownFileInfo) => {
116-
if (view.file) {
117-
this.app.fileManager.processFrontMatter(view.file, frontmatter => {
118-
return frontmatter;
119-
});
120-
}
121-
},
122-
});
112+
// this.addCommand({
113+
// id: 'mb-test-command',
114+
// name: 'test command',
115+
// editorCallback: (editor: Editor, view: MarkdownView | MarkdownFileInfo) => {
116+
// if (view.file) {
117+
// this.app.fileManager.processFrontMatter(view.file, frontmatter => {
118+
// return frontmatter;
119+
// });
120+
// }
121+
// },
122+
// });
123123

124124
// if (this.settings.devMode) {
125125
// this.addCommand({
@@ -138,55 +138,6 @@ export default class MetaBindPlugin extends Plugin implements IPlugin {
138138
this.addSettingTab(new MetaBindSettingTab(this.app, this));
139139
}
140140

141-
/**
142-
* Inspired by https://github.com/SilentVoid13/Templater/blob/487805b5ad1fd7fbc145040ed82b4c41fc2c48e2/src/editor/Editor.ts#L67
143-
*/
144-
async registerCodeMirrorMode(): Promise<void> {
145-
const js_mode: Mode<any> = window.CodeMirror.getMode({}, 'javascript');
146-
if (js_mode == null || js_mode.name === 'null') {
147-
console.log("Couldn't find js mode, can't enable syntax highlighting.");
148-
return;
149-
}
150-
151-
// if templater enabled, this only runs on the code blocks, otherwise this runs on the whole document
152-
153-
window.CodeMirror.defineMode('meta-bind-js', config => {
154-
const mbOverlay: any = {
155-
startState: () => {
156-
const js_state = window.CodeMirror.startState(js_mode);
157-
return {
158-
...js_state,
159-
};
160-
},
161-
blankLine: (state: any) => {
162-
return null;
163-
},
164-
copyState: (state: any) => {
165-
const js_state = window.CodeMirror.startState(js_mode);
166-
return {
167-
...js_state,
168-
};
169-
},
170-
token: (stream: any, state: any) => {
171-
// const globals = ['app', 'mb', 'dv', 'filePath', 'ctx'];
172-
173-
// console.log(stream);
174-
175-
// for (const global of globals) {
176-
// if (stream.match(global)) {
177-
// return 'variable';
178-
// }
179-
// }
180-
181-
const js_result = js_mode.token && js_mode.token(stream, state);
182-
return `line-HyperMD-codeblock ${js_result}`;
183-
},
184-
};
185-
186-
return mbOverlay;
187-
});
188-
}
189-
190141
onunload(): void {
191142
console.log(`meta-bind | Main >> unload`);
192143
this.mdrcManager.unload();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { UnvalidatedInputFieldDeclaration } from './InputFieldDeclarationValidator';
2+
3+
export interface TemplateSupplierTemplate<T> {
4+
readonly name: string;
5+
readonly template: Readonly<T>;
6+
}
7+
8+
export interface ITemplateSupplier<T> {
9+
getTemplate(templateName: string): Readonly<T> | undefined;
10+
}
11+
12+
export class EmptyTemplateSupplier implements ITemplateSupplier<UnvalidatedInputFieldDeclaration> {
13+
public getTemplate(templateName: string): Readonly<UnvalidatedInputFieldDeclaration> | undefined {
14+
return undefined;
15+
}
16+
}

0 commit comments

Comments
 (0)