macro checkbox args + search & replace imporved

This commit is contained in:
Jan Prochazka
2020-11-01 10:22:14 +01:00
parent 20180fe4c4
commit 4efa87c3c8
5 changed files with 45 additions and 2 deletions

View File

@@ -24,8 +24,22 @@ const macros = [
label: 'Replace with',
name: 'replace',
},
{
type: 'checkbox',
label: 'Case sensitive',
name: 'caseSensitive',
},
{
type: 'checkbox',
label: 'Regular expression',
name: 'isRegex',
},
],
code: `return value ? value.toString().replace(args.find, args.replace) : value`,
code: `
const rtext = args.isRegex ? args.find : modules.lodash.escapeRegExp(args.find);
const rflags = args.caseSensitive ? 'g' : 'ig';
return value ? value.toString().replace(new RegExp(rtext, rflags), args.replace || '') : value
`,
},
{
title: 'Change text case',