feat(formatter): add trim whitespace transformer to text action (#1261)
This commit is contained in:
@@ -7,6 +7,7 @@ import extractEmailAddress from './transformers/extract-email-address';
|
|||||||
import extractNumber from './transformers/extract-number';
|
import extractNumber from './transformers/extract-number';
|
||||||
import lowercase from './transformers/lowercase';
|
import lowercase from './transformers/lowercase';
|
||||||
import pluralize from './transformers/pluralize';
|
import pluralize from './transformers/pluralize';
|
||||||
|
import trimWhitespace from './transformers/trim-whitespace';
|
||||||
|
|
||||||
const transformers = {
|
const transformers = {
|
||||||
capitalize,
|
capitalize,
|
||||||
@@ -17,6 +18,7 @@ const transformers = {
|
|||||||
extractNumber,
|
extractNumber,
|
||||||
lowercase,
|
lowercase,
|
||||||
pluralize,
|
pluralize,
|
||||||
|
trimWhitespace,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
||||||
@@ -41,6 +43,7 @@ export default defineAction({
|
|||||||
{ label: 'Extract Number', value: 'extractNumber' },
|
{ label: 'Extract Number', value: 'extractNumber' },
|
||||||
{ label: 'Lowercase', value: 'lowercase' },
|
{ label: 'Lowercase', value: 'lowercase' },
|
||||||
{ label: 'Pluralize', value: 'pluralize' },
|
{ label: 'Pluralize', value: 'pluralize' },
|
||||||
|
{ label: 'Trim Whitespace', value: 'trimWhitespace' },
|
||||||
],
|
],
|
||||||
additionalFields: {
|
additionalFields: {
|
||||||
type: 'query',
|
type: 'query',
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
|
const trimWhitespace = ($: IGlobalVariable) => {
|
||||||
|
const input = $.step.parameters.input as string;
|
||||||
|
return input.trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
export default trimWhitespace;
|
@@ -7,6 +7,7 @@ import extractEmailAddress from './options/extract-email-address';
|
|||||||
import extractNumber from './options/extract-number';
|
import extractNumber from './options/extract-number';
|
||||||
import lowercase from './options/lowercase';
|
import lowercase from './options/lowercase';
|
||||||
import pluralize from './options/pluralize';
|
import pluralize from './options/pluralize';
|
||||||
|
import trimWhitespace from './options/trim-whitespace';
|
||||||
|
|
||||||
const options: IJSONObject = {
|
const options: IJSONObject = {
|
||||||
capitalize,
|
capitalize,
|
||||||
@@ -17,6 +18,7 @@ const options: IJSONObject = {
|
|||||||
extractNumber,
|
extractNumber,
|
||||||
lowercase,
|
lowercase,
|
||||||
pluralize,
|
pluralize,
|
||||||
|
trimWhitespace,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@@ -0,0 +1,12 @@
|
|||||||
|
const trimWhitespace = [
|
||||||
|
{
|
||||||
|
label: 'Input',
|
||||||
|
key: 'input',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'Text you want to remove leading and trailing spaces.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default trimWhitespace;
|
Reference in New Issue
Block a user