in editor/common/blockHelper.js [12:73]
module.exports.parseArgs = function (argsStr) {
if (!argsStr) {
return [];
}
const argsArr = [];
let itemStr = '';
let inStr = false;
let inVariable = false;
let inObjectLevel = 0;
let startQuot = '';
let prevCh;
for (let i = 0; i < argsStr.length; i++) {
const ch = argsStr[i];
if (ch === '"' || ch === '\'') {
if (inStr) {
if (startQuot === ch) {
inStr = false;
}
}
else {
startQuot = ch;
inStr = true;
}
itemStr += ch;
}
else if (inStr) {
itemStr += ch;
}
else if (ch === '{') {
itemStr += ch;
if (prevCh === '$') {
inVariable = true;
}
else {
// Value may be an object.
inObjectLevel++;
}
}
else if (ch === '}') {
itemStr += ch;
if (inVariable) {
inVariable = false;
}
else {
inObjectLevel--;
}
}
else if (ch === ',' && inObjectLevel === 0) {
argsArr.push(parseArgKv(itemStr));
itemStr = '';
}
else {
itemStr += ch;
}
prevCh = ch;
}
if (itemStr.trim()) {
argsArr.push(parseArgKv(itemStr));
}
// Ignore galleryViewPath and galleryEditorPath
return argsArr.filter(item => item[0] !== 'galleryViewPath' && item[0] !== 'galleryEditorPath');
};