Merge branch 'fix/4337' of github.com:Budibase/budibase into fix/4337

This commit is contained in:
Andrew Kingston 2022-02-15 14:59:29 +00:00
commit 56f6656e6b
5 changed files with 1267 additions and 391 deletions

View File

@ -23,6 +23,10 @@
const dispatch = createEventDispatcher()
export let bindings
// jsValue/hbsValue are the state of the value that is being built
// within this binding panel - the value should not be updated until
// the binding panel is saved. This is the default value of the
// expression when the binding panel is opened, but shouldn't be updated.
export let value = ""
export let valid
export let allowJS = false
@ -53,7 +57,6 @@
const updateValue = val => {
valid = isValid(readableToRuntimeBinding(bindings, val))
value = val
if (valid) {
dispatch("change", value)
}
@ -61,7 +64,7 @@
// Adds a HBS helper to the expression
const addHelper = helper => {
hbsValue = addHBSBinding(value, getCaretPosition(), helper.text)
hbsValue = addHBSBinding(hbsValue, getCaretPosition(), helper.text)
updateValue(hbsValue)
}

View File

@ -41,8 +41,6 @@
"@spectrum-css/vars": "^3.0.1",
"apexcharts": "^3.22.1",
"dayjs": "^1.10.5",
"fs-extra": "^8.1.0",
"jsdom": "^16.0.1",
"postcss": "^8.2.10",
"rollup": "^2.44.0",
"rollup-plugin-json": "^4.0.0",

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ const { registerAll, registerMinimum } = require("./helpers/index")
const processors = require("./processors")
const { atob, btoa } = require("./utilities")
const manifest = require("../manifest.json")
const { FIND_HBS_REGEX, FIND_DOUBLE_HBS_REGEX } = require("./utilities")
const { FIND_HBS_REGEX, findDoubleHbsInstances } = require("./utilities")
const hbsInstance = handlebars.create()
registerAll(hbsInstance)
@ -135,8 +135,7 @@ module.exports.processStringSync = (string, context, opts) => {
* @param string the string to have double HBS statements converted to triple.
*/
module.exports.disableEscaping = string => {
let regexp = new RegExp(FIND_DOUBLE_HBS_REGEX)
const matches = string.match(regexp)
const matches = findDoubleHbsInstances(string)
if (matches == null) {
return string
}

View File

@ -1,7 +1,25 @@
const ALPHA_NUMERIC_REGEX = /^[A-Za-z0-9]+$/g
module.exports.FIND_HBS_REGEX = /{{([^{].*?)}}/g
module.exports.FIND_DOUBLE_HBS_REGEX = /(?<!{){{[^{}]+}}(?!})/g
module.exports.FIND_TRIPLE_HBS_REGEX = /{{{([^{].*?)}}}/g
// originally this could be done with a single regex using look behinds
// but safari does not support this feature
// original regex: /(?<!{){{[^{}]+}}(?!})/g
module.exports.findDoubleHbsInstances = string => {
let copied = string
const doubleRegex = new RegExp(exports.FIND_HBS_REGEX)
const regex = new RegExp(exports.FIND_TRIPLE_HBS_REGEX)
const tripleMatches = copied.match(regex)
// remove triple braces
if (tripleMatches) {
tripleMatches.forEach(match => {
copied = copied.replace(match, "")
})
}
const doubleMatches = copied.match(doubleRegex)
return doubleMatches ? doubleMatches : []
}
module.exports.isAlphaNumeric = char => {
return char.match(ALPHA_NUMERIC_REGEX)