feat(formatter): Add replace transformer to text action

This commit is contained in:
Faruk AYDIN
2023-09-01 17:51:23 +02:00
committed by Ali BARIN
parent feb613cb6d
commit e19340f1e0
4 changed files with 45 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import extractNumber from './transformers/extract-number';
import lowercase from './transformers/lowercase';
import pluralize from './transformers/pluralize';
import trimWhitespace from './transformers/trim-whitespace';
import replace from './transformers/replace';
const transformers = {
capitalize,
@@ -19,6 +20,7 @@ const transformers = {
lowercase,
pluralize,
trimWhitespace,
replace,
};
export default defineAction({
@@ -44,6 +46,7 @@ export default defineAction({
{ label: 'Lowercase', value: 'lowercase' },
{ label: 'Pluralize', value: 'pluralize' },
{ label: 'Trim Whitespace', value: 'trimWhitespace' },
{ label: 'Replace', value: 'replace' },
],
additionalFields: {
type: 'query',

View File

@@ -0,0 +1,12 @@
import { IGlobalVariable } from '@automatisch/types';
const replace = ($: IGlobalVariable) => {
const input = $.step.parameters.input as string;
const find = $.step.parameters.find as string;
const replace = $.step.parameters.replace as string;
return input.replaceAll(find, replace);
};
export default replace;