Skip to content

Commit

Permalink
implement #477
Browse files Browse the repository at this point in the history
  • Loading branch information
mProjectsCode committed Dec 2, 2024
1 parent da1831a commit e21434f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export abstract class API<Plugin extends IPlugin> {
}

/**
* Checks if a string is any declaration and if yes returns the widget type.
* Checks if a string is any declaration. If yes, it returns the widget type, otherwise undefined.
*
* @param str the declaration string
*/
Expand Down Expand Up @@ -635,7 +635,7 @@ export abstract class API<Plugin extends IPlugin> {
*
* @param storageType the storage type (also named metadata source sometimes)
* @param storagePath the storage path (usually the file path)
* @param property the property path a.b.c = ['a', 'b', 'c']
* @param property the property access path as an array. E.g. for the path `cache.a.b.c`, the array would be `['a', 'b', 'c']`.
* @param listenToChildren whether to listen to children, only relevant for arrays and objects
*/
public createBindTarget(
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/ButtonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface InsertIntoNoteButtonAction {
export interface InlineJSButtonAction {
type: ButtonActionType.INLINE_JS;
code: string;
args?: Record<string, unknown>;
}

export type ButtonAction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export const V_InlineJSButtonAction = schemaForType<InlineJSButtonAction>()(
z.object({
type: z.literal(ButtonActionType.INLINE_JS),
code: actionFieldString('inlineJS', 'code', 'code string to run'),
args: z.record(z.unknown()).optional(),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class InlineJSButtonActionConfig extends AbstractButtonActionConfig<Inlin

const configOverrides: Record<string, unknown> = {
buttonConfig: structuredClone(config),
args: structuredClone(action.args),
buttonContext: structuredClone(context),
click: structuredClone(click),
};
Expand All @@ -42,6 +43,7 @@ export class InlineJSButtonActionConfig extends AbstractButtonActionConfig<Inlin
return {
type: ButtonActionType.INLINE_JS,
code: 'console.log("Hello world")',
args: {},
};
}

Expand Down

0 comments on commit e21434f

Please sign in to comment.