Skip to content

Commit c933a6b

Browse files
committed
fix #159
1 parent 5a12492 commit c933a6b

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Obsidian Meta Bind Changelog
22

3+
# 0.10.1
4+
5+
Bug Fixes
6+
7+
- Fixed a bug with suggesters using Dataview not opening the suggester modal [#159](https://github.com/mProjectsCode/obsidian-meta-bind-plugin/issues/159)
8+
39
# 0.10.0
410

511
New Features

exampleVault/Advanced Examples/DnD 5e Travel Calculator.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ TravelDistance: 1000
1111
varMins: 60
1212
---
1313

14-
| DnD5e Travel Calculator |
15-
| ------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| DnD5e Travel Calculator |
15+
| ---- |
1616
| **Select Base Speed:** `INPUT[inlineSelect(option(30, Walking), option(50, Camel), option(40, Donkey), option(40, Mule), option(40, Draft Horse), option(40, Elephant), option(40, Mastiff), option(40, Moorbounder), option(40, Pony), option(40, Rhinoceros), option(60, Riding Horse), option(40, Saber-Toothed Tiger), option(60, Warhorse), option(20, Griffon [walking]), option(80, Griffon [flying]), option(40, Hippogriff [walking]), option(60, Hippogriff [flying]), option(60, Pegasus [walking]), option(90, Pegasus [flying]), option(20, Peryton [walking]), option(60, Peryton [flyingg]), option(50, Unicorn), option(60, Peryton [flying]), option(50, Unicorn), option(50, Broom of Flying), option(30, Broom of Flying [over 200 lbs]), option(80, Carpet of Flying [3ft x 5ft]), option(60, Carpet of Flying [4ft x 6ft]), option(40, Carpet of Flying [5ft x 7ft]), option(30, Carpet of Flying [6ft x 9ft]), option(300, Wind Walk), option(50, Cauldron of Flying), option(30, Cart pulled by Horses), option(30, Cart pulled by PCs), option(20, PHB Galley), option(5, PHB Keelboat), option(15, PHB Longship), option(10, PHB Rowboat), option(10, PHB Sailing Ship), option(15, PHB Warship), option(45, Aquisions Inc Battle Balloon), option(15, Aquisions Inc Mechanical Beholder), option(200, Ebberon Lyrandar Airship), option(100, Ebberon Lyrandar Galleon), option(300, Ebberon Orien Lightning Rail), showcase):BaseSpeed]` |
17-
| **Select Travel Speed:** `INPUT[inlineSelect(option(1, Normal Pace), option(1.333333, Slow Pace), option(0.666667, Fast Pace), showcase):SpeedMultiplier]` |
17+
| **Select Travel Speed:** `INPUT[inlineSelect(option(1, Normal Pace), option(1.333333, Slow Pace), option(0.666667, Fast Pace), showcase):SpeedMultiplier]` |
1818
| Additional Bonus Speed: `INPUT[number:AdditionalBonus]` |
19-
| Encumbered: `INPUT[toggle:Encumbered]` (`VIEW[{Encumbered} ? -10 : 0]`) Horseshoes of Speed: `INPUT[toggle:HorseshoesofSpeed]` (`VIEW[{HorseshoesofSpeed} ? 30 : 0]`) |
20-
| **Travel Hours Per Day:** `INPUT[number:HoursPerDay]` |
19+
| Encumbered: `INPUT[toggle:Encumbered]` (`VIEW[{Encumbered} ? -10 : 0]`) Horseshoes of Speed: `INPUT[toggle:HorseshoesofSpeed]` (`VIEW[{HorseshoesofSpeed} ? 30 : 0]`) |
20+
| **Travel Hours Per Day:** `INPUT[number:HoursPerDay]` |
2121
| Exhaustion Level: `INPUT[inlineSelect(option(0, 0 No exhaustion), option(1, 1 Disadvantage on ability checks), option(2, 2 Speed halved), option(3, 3 Disadvantage on attack rolls and saving throws), option(4, 4 Hit point maximum halved), option(5, 5 Speed reduced to 0), option(6, 6 Death)):ExhaustionLevel]` |
22-
| New Base Speed: `VIEW[{BaseSpeed} / ({ExhaustionLevel} > 1 ? 2 : 1) + ({Encumbered} ? -10 : 0) + ({HorseshoesofSpeed} ? 30 : 0) + {AdditionalBonus}]` |
23-
| Miles To Travel: `INPUT[number:TravelDistance]` |
22+
| New Base Speed: `VIEW[{BaseSpeed} / ({ExhaustionLevel} > 1 ? 2 : 1) + ({Encumbered} ? -10 : 0) + ({HorseshoesofSpeed} ? 30 : 0) + {AdditionalBonus}]` |
23+
| Miles To Travel: `INPUT[number:TravelDistance]` |
2424
| **Days Travel 🕓:** `VIEW[round(({TravelDistance} * ({varMins}/(({BaseSpeed} / ({ExhaustionLevel} > 1 ? 2 : 1) + ({Encumbered} ? -10 : 0) + ({HorseshoesofSpeed} ? 30 : 0) + {AdditionalBonus}) / 10) * {SpeedMultiplier})) / 60 / {HoursPerDay}, 1)]` |
2525

2626
Check out this calculator on [Josh's Publish](https://obsidianttrpgtutorials.com/Obsidian+TTRPG+Tutorials/Plugin+Tutorials/Travel+Calculators/DnD+5e+Travel+Calc/DnD+5e+Travel+Calc).

src/fields/inputFields/fields/Suggester/SuggesterModalHelper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Notice } from 'obsidian';
77
import { SuggesterInputModal } from './SuggesterInputModal';
88
import { type SuggesterLikeIFP, SuggesterOption } from './SuggesterHelper';
99
import type MetaBindPlugin from '../../../../main';
10+
import { getDataViewPluginAPI } from '../../../../utils/ObsUtils';
1011

1112
export function getSuggesterOptions(
1213
dv: DataviewApi | undefined,
@@ -58,8 +59,8 @@ export function getSuggesterOptionsForInputField(
5859
plugin: MetaBindPlugin,
5960
): SuggesterOption<MBLiteral>[] {
6061
const app = plugin.app;
61-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
62-
const dv = (app.plugins.getPlugin('obsidian-dataview') as any).api as DataviewApi | undefined;
62+
63+
const dv = getDataViewPluginAPI(app);
6364
const optionArgs = inputField.base.getArguments(InputFieldArgumentType.OPTION);
6465
const optionQueryArgs = inputField.base.getArguments(InputFieldArgumentType.OPTION_QUERY);
6566
const useLinksArgs = inputField.base.getArgument(InputFieldArgumentType.USE_LINKS);

src/utils/ObsUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1+
import { type App } from 'obsidian';
2+
import { type DataviewApi } from 'obsidian-dataview';
3+
14
export function imagePathToUri(imagePath: string): string {
25
// this is using the deprecated app, but it is a pain to pass the app instance through all the svelte components
36
return app.vault.adapter.getResourcePath(imagePath);
47
}
8+
9+
export function getDataViewPluginAPI(app: App): DataviewApi | undefined {
10+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
11+
return (app.plugins.getPlugin('dataview') as any)?.api as DataviewApi | undefined;
12+
}

0 commit comments

Comments
 (0)