feat(formatter): Add replace transformer to text action
This commit is contained in:
@@ -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',
|
||||
|
@@ -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;
|
@@ -8,6 +8,7 @@ import extractNumber from './options/extract-number';
|
||||
import lowercase from './options/lowercase';
|
||||
import pluralize from './options/pluralize';
|
||||
import trimWhitespace from './options/trim-whitespace';
|
||||
import replace from './options/replace';
|
||||
|
||||
const options: IJSONObject = {
|
||||
capitalize,
|
||||
@@ -19,6 +20,7 @@ const options: IJSONObject = {
|
||||
lowercase,
|
||||
pluralize,
|
||||
trimWhitespace,
|
||||
replace,
|
||||
};
|
||||
|
||||
export default {
|
||||
|
@@ -0,0 +1,28 @@
|
||||
const replace = [
|
||||
{
|
||||
label: 'Input',
|
||||
key: 'input',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Text that you want to search for and replace values.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Find',
|
||||
key: 'find',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Text that will be searched for.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Replace',
|
||||
key: 'replace',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Text that will replace the found text.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default replace;
|
Reference in New Issue
Block a user