From 8e1926d2994c01e71dc32f666eef12675b0f2102 Mon Sep 17 00:00:00 2001 From: ririxi Date: Fri, 27 Sep 2024 20:46:51 +0200 Subject: [PATCH] fix(preprocess): add new regex to catch variable names for context menu --- src/preprocess/preprocess.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/preprocess/preprocess.go b/src/preprocess/preprocess.go index 8e7dbea7a7..6ea27620ef 100644 --- a/src/preprocess/preprocess.go +++ b/src/preprocess/preprocess.go @@ -564,15 +564,20 @@ func exposeAPIs_main(input string) string { croppedInput := utils.FindFirstMatch(input, `.*value:"contextmenu"`)[0] react := utils.FindLastMatch(croppedInput, `([a-zA-Z_\$][\w\$]*)\.useRef`)[1] candicates := utils.FindLastMatch(croppedInput, `\(\{[^}]*menu:([a-zA-Z_\$][\w\$]*),[^}]*trigger:([a-zA-Z_\$][\w\$]*),[^}]*triggerRef:([a-zA-Z_\$][\w\$]*)`) + oldCandicates := utils.FindLastMatch(croppedInput, `([a-zA-Z_\$][\w\$]*)=[\w_$]+\.menu[^}]*,([a-zA-Z_\$][\w\$]*)=[\w_$]+\.trigger[^}]*,([a-zA-Z_\$][\w\$]*)=[\w_$]+\.triggerRef`) var menu, trigger, target string - if len(candicates) == 0 { - menu = "e.menu" - trigger = "e.trigger" - target = "e.triggerRef" - } else { + if len(oldCandicates) != 0 { + menu = oldCandicates[1] + trigger = oldCandicates[2] + target = oldCandicates[3] + } else if len(candicates) != 0 { menu = candicates[1] trigger = candicates[2] target = candicates[3] + } else { + menu = "e.menu" + trigger = "e.trigger" + target = "e.triggerRef" } utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)`, func(submatches ...string) string {