Skip to content

Commit ee0ba5d

Browse files
committed
fix #291
1 parent 1b591af commit ee0ba5d

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

exampleVault/Examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
slider1: 9
2+
slider1: 7
33
suggest: test
44
toggle1: false
55
Domestic_tasks:
@@ -13,7 +13,7 @@ inlineSelect: 1
1313
nested:
1414
object: test
1515
number1: 2
16-
number2: 18
16+
number2: 14
1717
time:
1818
---
1919

exampleVault/View Fields/JS View Field.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ save to {cssclasses}
3333
---
3434
const CLASS = 'test-class';
3535
36-
const addClass = context.bound.n1 >= 100;
37-
let css = new Set(context.metadata.frontmatter.cssclasses ?? []);
36+
let classes = new Set(context.metadata.frontmatter.cssclasses ?? []);
3837
39-
if (addClass) {
40-
css.add(CLASS);
38+
if (context.bound.n1 >= 100) {
39+
classes.add(CLASS);
4140
} else {
42-
css.delete(CLASS);
41+
classes.delete(CLASS);
4342
}
4443
45-
return [...css.values()];
44+
return [...classes.values()];
4645
```

packages/obsidian/src/cm6/Cm6_ViewPlugin.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ export function createMarkdownRenderChildWidgetEditorPlugin(plugin: MetaBindPlug
2222
this.component = new Component();
2323
this.component.load();
2424
this.decorations = this.renderWidgets(view) ?? Decoration.none;
25+
26+
view.dom.addEventListener('click', e => this.handleClick(e));
27+
}
28+
29+
handleClick(e: MouseEvent): void {
30+
if (e.target instanceof HTMLElement) {
31+
let parent: HTMLElement | null = e.target;
32+
33+
// check if the click was inside an input field
34+
while (parent !== null) {
35+
if (parent.classList.contains('mb-input')) {
36+
e.preventDefault();
37+
e.stopPropagation();
38+
break;
39+
}
40+
41+
parent = parent.parentElement;
42+
}
43+
}
2544
}
2645

2746
isLivePreview(state: EditorState): boolean {

0 commit comments

Comments
 (0)