Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request ] Dynamic Variable Autocomplete in Textareas #11

Open
RohitKumarGit opened this issue Sep 22, 2024 · 2 comments
Open

Comments

@RohitKumarGit
Copy link

I worked on this library few years back:
https://formula-parser-editor.vercel.app/

GitHub URL

Screen.Recording.2024-09-22.at.3.28.34.PM.mov

Description:

Add support for dynamic variable autocomplete in any textarea (e.g., @variablename). These variables would be parsed and replaced with values fetched from an external source (e.g., a database) based on custom logic.

Use Case:

When a user types @variablename, the system suggests values or automatically replaces the variable upon invoking a method like input.getValue(). This feature should be lightweight with minimal impact on bundle size.

@knadh if this a good feature to be added , I can work on this

@knadh
Copy link
Owner

knadh commented Sep 24, 2024

Hi @RohitKumarGit. The exact UX seems outside the scope of floatype. You could just fork it and implement the @ style UX on top of it.

That said, the onQuery callback that you plug in can just return the appropriate suggestions based on whatever keyword, right? Eg: @abs.

@RohitKumarGit
Copy link
Author

Yes this might be out of scope , the main idea is "context aware". lets say you are writing this content

user @SomeRandomUserId , your account balance is SUM(@balance_prev_month,@current_spend)

^^ here @SomeRandomUserId need not be replaces with anything ,it could be maybe insta handle not variable

Now if we use the onQuery thing , then for each "@" it will show variable right? onQuery does not know context where it is written. Even if we do some prefix matching then also it won't be that context aware ( knowing where to show variable and where to not .. this is just one example ) . Also all "@[string]" would get styles same if we apply some static logic

In my code I achieved some level of context awareness ( could be improved ) by writing the below grammar using lexer

expression { Condition | tep    }
Operators {Assign| ArtithMeticOperators | LogicalOperators}
tep { Variable | Number | Functions | String }
Unlimited {  tep ',' Unlimited | "" | tep }
Condition { tep Operators tep}
 Functions {ARRAYFORMULA "(" expression ")"|FILTER "(" Unlimited ")"|ARRA
... contiued

Ayway thanks for replying , I was just looking to contribute on floatbase or some project of zerodha tech

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants