Skip to content

Commit

Permalink
implement #436
Browse files Browse the repository at this point in the history
  • Loading branch information
mProjectsCode committed Nov 5, 2024
1 parent 94e5083 commit f5b0049
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions exampleVault/Buttons/Button Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ With a custom class and a CSS snippet we can change the button to be green.

```meta-bind-button
style: primary
label: Open Meta Bind FAQ
label: Open Meta Bind Playground
class: green-button
action:
type: command
command: obsidian-meta-bind-plugin:open-faq
command: obsidian-meta-bind-plugin:open-playground
```

And custom JS buttons as well
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/config/ButtonConfigValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const V_InsertIntoNoteButtonAction = schemaForType<InsertIntoNoteButtonAc
}),
);

export const V_InlineJsButtonAction = schemaForType<InlineJSButtonAction>()(
export const V_InlineJSButtonAction = schemaForType<InlineJSButtonAction>()(
z.object({
type: z.literal(ButtonActionType.INLINE_JS),
code: stringValidator('inlineJS', 'code', 'code string to run'),
Expand All @@ -186,7 +186,7 @@ export const V_ButtonAction = schemaForType<ButtonAction>()(
V_ReplaceSelfButtonAction,
V_RegexpReplaceInNoteButtonAction,
V_InsertIntoNoteButtonAction,
V_InlineJsButtonAction,
V_InlineJSButtonAction,
]),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
ButtonContext,
OpenButtonAction,
} from 'packages/core/src/config/ButtonConfig';
import { ButtonActionType } from 'packages/core/src/config/ButtonConfig';
import { ButtonActionType, ButtonClickType } from 'packages/core/src/config/ButtonConfig';
import { AbstractButtonActionConfig } from 'packages/core/src/fields/button/AbstractButtonActionConfig';
import type { IPlugin } from 'packages/core/src/IPlugin';
import { MDLinkParser } from 'packages/core/src/parsers/MarkdownLinkParser';
Expand All @@ -19,9 +19,10 @@ export class OpenButtonActionConfig extends AbstractButtonActionConfig<OpenButto
action: OpenButtonAction,
filePath: string,
_context: ButtonContext,
_click: ButtonClickContext,
click: ButtonClickContext,
): Promise<void> {
MDLinkParser.parseLinkOrUrl(action.link).open(this.plugin, filePath, action.newTab ?? false);
const newTab = click.type === ButtonClickType.MIDDLE || click.ctrlKey || (action.newTab ?? false);
MDLinkParser.parseLinkOrUrl(action.link).open(this.plugin, filePath, newTab);
}

create(): Required<OpenButtonAction> {
Expand Down

0 comments on commit f5b0049

Please sign in to comment.