Skip to content

Commit b652e7a

Browse files
committed
list input field
1 parent 9f6028d commit b652e7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+625
-231
lines changed

exampleVault/Input Fields/List.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
list:
3+
- apple
4+
- banana
5+
- berries
6+
---
7+
8+
9+
```meta-bind
10+
INPUT[list:list]
11+
```
12+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
added:
3+
- "1"
4+
- "2"
5+
removed:
6+
- "1"
7+
---
8+
# Added
9+
10+
```meta-bind
11+
INPUT[list:added]
12+
```
13+
14+
# Removed
15+
16+
```meta-bind
17+
INPUT[list:removed]
18+
```
19+
20+
# Total
21+
22+
```meta-bind-js
23+
asdasd
24+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
added:
3+
- "3"
4+
- "4"
5+
removed:
6+
- "2"
7+
- "3"
8+
---
9+
# Added
10+
11+
```meta-bind
12+
INPUT[list:added]
13+
```
14+
15+
# Removed
16+
17+
```meta-bind
18+
INPUT[list:removed]
19+
```
20+
21+
# Total
22+
23+
```meta-bind-js
24+
asdasd
25+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
added:
3+
- "5"
4+
- "4"
5+
removed:
6+
- "4"
7+
---
8+
9+
# Added
10+
11+
```meta-bind
12+
INPUT[list:added]
13+
```
14+
15+
# Removed
16+
17+
```meta-bind
18+
INPUT[list:removed]
19+
```
20+
21+
# Total
22+
23+
```meta-bind-js
24+
asdasd
25+
```

package-lock.json

Lines changed: 54 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
"@codemirror/language": "https://github.com/lishid/cm-language",
4646
"@opd-libs/opd-metadata-lib": "0.0.4",
4747
"@opd-libs/opd-utils-lib": "0.0.2",
48+
"@popperjs/core": "^2.11.8",
4849
"esbuild-plugin-conditional-build": "^1.0.2",
49-
"mathjs": "^11.8.0"
50+
"mathjs": "^11.8.0",
51+
"obsidian-svelte": "^0.1.9",
52+
"svelte-portal": "^2.2.0"
5053
}
5154
}

src/cm6/Cm6_ViewPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function createMarkdownRenderChildWidgetEditorPlugin(plugin: MetaBindPlug
130130
}
131131

132132
/**
133-
* reads the node, returning it's content and widgetType.
133+
* reads the node, returning its content and widgetType.
134134
*
135135
* @param view
136136
* @param from

src/inputFields/AbstractInputField.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export abstract class AbstractInputField {
99
constructor(inputFieldMDRC: InputFieldMDRC) {
1010
this.renderChild = inputFieldMDRC;
1111

12-
this.onValueChange = (value: any) => {
12+
this.onValueChange = (value: any): void => {
1313
console.debug(`meta-bind | input field on value change`, value);
1414
this.renderChild.readSignal.set(value);
1515
};

src/inputFields/InputFieldFactory.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
import { ToggleInputField } from './ToggleInputField';
1+
import { ToggleInputField } from './fields/ToggleInputField';
22
import { InputFieldMDRC, RenderChildType } from '../renderChildren/InputFieldMDRC';
3-
import { TextInputField } from './TextInputField';
4-
import { SliderInputField } from './SliderInputField';
5-
import { TextAreaInputField } from './TextAreaInputField';
6-
import { SelectInputField } from './SelectInputField';
7-
import { MultiSelectInputField } from './MultiSelectInputField';
8-
import { DateInputField } from './DateInputField';
9-
import { TimeInputField } from './TimeInputField';
3+
import { TextInputField } from './fields/TextInputField';
4+
import { SliderInputField } from './fields/SliderInputField';
5+
import { TextAreaInputField } from './fields/TextAreaInputField';
6+
import { SelectInputField } from './fields/SelectInputField';
7+
import { MultiSelectInputField } from './fields/MultiSelectInputField';
8+
import { DateInputField } from './fields/DateInputField';
9+
import { TimeInputField } from './fields/TimeInputField';
1010
import { AbstractInputField } from './AbstractInputField';
1111
import { InputFieldType } from '../parsers/InputFieldDeclarationParser';
12-
import { DatePickerInputField } from './DatePicker/DatePickerInputField';
13-
import { NumberInputField } from './NumberInputField';
14-
import { SuggestInputField } from './Suggest/SuggestInputField';
12+
import { DatePickerInputField } from './fields/DatePicker/DatePickerInputField';
13+
import { NumberInputField } from './fields/NumberInputField';
14+
import { SuggestInputField } from './fields/Suggest/SuggestInputField';
1515
import { ErrorLevel, MetaBindParsingError } from '../utils/errors/MetaBindErrors';
16-
import { EditorInputField } from './Editor/EditorInputField';
17-
import { ImageSuggestInputField } from './ImageSuggest/ImageSuggestInputField';
16+
import { EditorInputField } from './fields/Editor/EditorInputField';
17+
import { ImageSuggestInputField } from './fields/ImageSuggest/ImageSuggestInputField';
1818
import MetaBindPlugin from '../main';
19-
import { ProgressBarInputField } from './ProgressBar/ProgressBarInputField';
20-
import { InlineSelectInputField } from './InlineSelectInputField';
19+
import { ProgressBarInputField } from './fields/ProgressBar/ProgressBarInputField';
20+
import { InlineSelectInputField } from './fields/InlineSelectInputField';
21+
import { ListInputField } from './fields/List/ListInputField';
2122

2223
export class InputFieldFactory {
2324
static allowCodeBlockMap: Record<string, { block: boolean; inline: boolean }> = {
@@ -81,6 +82,10 @@ export class InputFieldFactory {
8182
block: InlineSelectInputField.allowBlock,
8283
inline: InlineSelectInputField.allowInline,
8384
},
85+
[InputFieldType.LIST]: {
86+
block: ListInputField.allowBlock,
87+
inline: ListInputField.allowInline,
88+
},
8489
};
8590

8691
static createInputField(inputFieldType: InputFieldType, args: { renderChildType: RenderChildType; inputFieldMDRC: InputFieldMDRC }): AbstractInputField | undefined {
@@ -118,6 +123,8 @@ export class InputFieldFactory {
118123
return new ProgressBarInputField(args.inputFieldMDRC);
119124
} else if (inputFieldType === InputFieldType.INLINE_SELECT) {
120125
return new InlineSelectInputField(args.inputFieldMDRC);
126+
} else if (inputFieldType === InputFieldType.LIST) {
127+
return new ListInputField(args.inputFieldMDRC);
121128
}
122129

123130
return undefined;

src/inputFields/DateInputField.ts renamed to src/inputFields/fields/DateInputField.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { AbstractInputField } from './AbstractInputField';
1+
import { AbstractInputField } from '../AbstractInputField';
22
import { DropdownComponent, moment, TextComponent } from 'obsidian';
3-
import { DateParser } from '../parsers/DateParser';
4-
import { ErrorLevel, MetaBindInternalError, MetaBindValueError } from '../utils/errors/MetaBindErrors';
5-
import { InputFieldMDRC } from '../renderChildren/InputFieldMDRC';
3+
import { DateParser } from '../../parsers/DateParser';
4+
import { ErrorLevel, MetaBindInternalError, MetaBindValueError } from '../../utils/errors/MetaBindErrors';
5+
import { InputFieldMDRC } from '../../renderChildren/InputFieldMDRC';
66

77
export class DateInputField extends AbstractInputField {
88
container: HTMLDivElement | undefined;

0 commit comments

Comments
 (0)