Skip to content

Commit

Permalink
Add Calculate Expression action
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Jan 18, 2024
1 parent 8c6ab3d commit 2b82e24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import SetName from "~/actions/set-name";
import Output from "~/actions/output";
import CopyToClipboard from "~/actions/copy-to-clipboard";
import RunShortcut from "~/actions/run-shortcut";
import CalculateExpression from "~/actions/calculate-expression";

interface ActionDefinitions {
[key: string]: ActionDefinition
Expand Down Expand Up @@ -73,6 +74,7 @@ export let actions: ActionDefinitions = {
'output': Output,
'setclipboard': CopyToClipboard,
'runworkflow': RunShortcut,
'calculateexpression': CalculateExpression,
};

export function actionText(value: string): HTMLElement {
Expand Down
20 changes: 20 additions & 0 deletions src/actions/calculate-expression.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {renderValue} from "~/value";
import {renderActionHeader} from "~/render";
import {actions} from "~/actions";

interface CalculateExpressionParameters {
Input: string | object
}

export default {
title: "Calculate expression",
icon: 'f_cursive_circle',
background: '#8e8e93',
render: (container: HTMLElement, params: CalculateExpressionParameters) => {
container.className += ' sp-date-action';

return renderActionHeader(actions['calculateexpression'],
renderValue(params['Input'], '7 + 7'),
);
}
}

0 comments on commit 2b82e24

Please sign in to comment.