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

Invalid markup syntax will lead to crash #675

Open
huozhi opened this issue Jan 5, 2021 · 4 comments
Open

Invalid markup syntax will lead to crash #675

huozhi opened this issue Jan 5, 2021 · 4 comments

Comments

@huozhi
Copy link

huozhi commented Jan 5, 2021

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to homepage https://idyll-lang.org/
  2. Click on the editable area and start to input []()
  3. See error

Expected behavior
render []() as text. or maybe just warn user it's not valid

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Mac
  • Browser chrome
  • Version 87

Additional context
N/A

@huozhi huozhi changed the title Invalid markup syntax will lead to crash instead of Invalid markup syntax will lead to crash Jan 6, 2021
@mathisonian
Copy link
Member

Thanks for reporting this @huozhi. We should definitely handle this more gracefully, and not have it blow up the entire website.

If anyone is willing to contribute a patch it would be appreciated! The relevant code for the homepage is here: https://github.com/idyll-lang/idyll/blob/master/packages/idyll-docs/pages/index.js#L140-L145.

@mrviniciux
Copy link
Contributor

@mathisonian hello there, I'm checking this issue on component text-input.js and I see that there's no validation in onChange event, just a this.props.updateProps that I really don't know what it does exactly. But I guess this seems to be normal, since the input will be used in many different situations and patterns right?

I'm new in the idyll universe, so maybe my question here is trivial... Is there any kind of "regex" that matches the input from "Write your own equation"?

Or this must be done only in the "idyll-docs" and not in "idyll-components"? Because my initial thought was to put some kind of red label above the input indicating error, very similar to material design form error highlight.

@mathisonian
Copy link
Member

Hi @mrviniciux - would you mind clarifying the use case a little bit?

With the [TextInput /] component, an author would typically use it by binding a variable to its value property, so that each time a user writes text, it updates the value of the variable:

[var name:"myvar" value:"" /] // initialize a variable as the empty string

[TextInput value:myvar /]

The value of myvar is [Display value:myvar /]`

which would result in this behavior:

text-input-example.mov

Looking at the implementation of text-input, you can see that the updateProps function is the how the component can tell Idyll, "If a variable is bound to my value property, set it to this new value", by calling `updateProps({ value: "some new value" }). Note that any component has access to this function, it is the mechanism by which any component is expected to effect change to the state of an Idyll article. There's a little more on that here.

@mrviniciux
Copy link
Contributor

@mathisonian sorry for the delay on this, finally I take some time to get back on board.

I opened a PR as mentioned above and hope that helps. In the next weeks I will stay tuned for your feedback and hope we can do something great about this. See ya!

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

No branches or pull requests

3 participants