Update component imports and add conditional focus in PlaygroundForm
This commit is contained in:
24
src/utils/select-varaible.ts
Normal file
24
src/utils/select-varaible.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export const getVariable = (text: string) => {
|
||||
const regex = /{([^}]+)}/g;
|
||||
let data : {
|
||||
word: string,
|
||||
start: number,
|
||||
end: number
|
||||
} | null = null;
|
||||
|
||||
|
||||
let m: RegExpExecArray | null;
|
||||
|
||||
while ((m = regex.exec(text)) !== null) {
|
||||
if (m.index === regex.lastIndex) {
|
||||
regex.lastIndex++;
|
||||
}
|
||||
data = {
|
||||
word: m[1],
|
||||
start: m.index,
|
||||
end: m.index + m[0].length
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user