Skip to content

Commit f5b0049

Browse files
committed
implement #436
1 parent 94e5083 commit f5b0049

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

exampleVault/Buttons/Button Example.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ With a custom class and a CSS snippet we can change the button to be green.
1818

1919
```meta-bind-button
2020
style: primary
21-
label: Open Meta Bind FAQ
21+
label: Open Meta Bind Playground
2222
class: green-button
2323
action:
2424
type: command
25-
command: obsidian-meta-bind-plugin:open-faq
25+
command: obsidian-meta-bind-plugin:open-playground
2626
```
2727

2828
And custom JS buttons as well

packages/core/src/config/ButtonConfigValidators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const V_InsertIntoNoteButtonAction = schemaForType<InsertIntoNoteButtonAc
165165
}),
166166
);
167167

168-
export const V_InlineJsButtonAction = schemaForType<InlineJSButtonAction>()(
168+
export const V_InlineJSButtonAction = schemaForType<InlineJSButtonAction>()(
169169
z.object({
170170
type: z.literal(ButtonActionType.INLINE_JS),
171171
code: stringValidator('inlineJS', 'code', 'code string to run'),
@@ -186,7 +186,7 @@ export const V_ButtonAction = schemaForType<ButtonAction>()(
186186
V_ReplaceSelfButtonAction,
187187
V_RegexpReplaceInNoteButtonAction,
188188
V_InsertIntoNoteButtonAction,
189-
V_InlineJsButtonAction,
189+
V_InlineJSButtonAction,
190190
]),
191191
);
192192

packages/core/src/fields/button/actions/OpenButtonActionConfig.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
ButtonContext,
55
OpenButtonAction,
66
} from 'packages/core/src/config/ButtonConfig';
7-
import { ButtonActionType } from 'packages/core/src/config/ButtonConfig';
7+
import { ButtonActionType, ButtonClickType } from 'packages/core/src/config/ButtonConfig';
88
import { AbstractButtonActionConfig } from 'packages/core/src/fields/button/AbstractButtonActionConfig';
99
import type { IPlugin } from 'packages/core/src/IPlugin';
1010
import { MDLinkParser } from 'packages/core/src/parsers/MarkdownLinkParser';
@@ -19,9 +19,10 @@ export class OpenButtonActionConfig extends AbstractButtonActionConfig<OpenButto
1919
action: OpenButtonAction,
2020
filePath: string,
2121
_context: ButtonContext,
22-
_click: ButtonClickContext,
22+
click: ButtonClickContext,
2323
): Promise<void> {
24-
MDLinkParser.parseLinkOrUrl(action.link).open(this.plugin, filePath, action.newTab ?? false);
24+
const newTab = click.type === ButtonClickType.MIDDLE || click.ctrlKey || (action.newTab ?? false);
25+
MDLinkParser.parseLinkOrUrl(action.link).open(this.plugin, filePath, newTab);
2526
}
2627

2728
create(): Required<OpenButtonAction> {

0 commit comments

Comments
 (0)