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

feat: support pre-fill forms on the ask page #1014

Merged
merged 3 commits into from
Jul 12, 2024
Merged

Conversation

hgaol
Copy link
Member

@hgaol hgaol commented Jul 10, 2024

close #1009 . + @shuashuai to help to review, thx!

using prefill query parameter for pre-fill content. Using JSON format with same structure with draft data saved in local storage.

the query parameter should be serialized before using as parameter. the serialization steps are similar as below.

encodeURIComponent(JSON.stringify(<object>))

e.g.

http://localhost:3000/questions/ask?prefill=%7B%22title%22%3A%22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%22%2C%22tags%22%3A%5B%7B%22slug_name%22%3A%22test%22%2C%22display_name%22%3A%22test%22%2C%22original_text%22%3A%22tst%22%7D%5D%2C%22content%22%3A%22%20wwwwwwwwwwwwwwwwwwww%5Cn%20%5Cn%20%23%20hello%20world!%5Cn%20%5Cn%20%60%60%60js%5Cn%20const%20a%20%3D%201%3B%5Cn%20%60%60%60%22%2C%22answer_content%22%3A%22%22%7D

@shuashuai shuashuai self-requested a review July 10, 2024 09:50
@hgaol
Copy link
Member Author

hgaol commented Jul 11, 2024

the structure is as below.

{
  "title": "wwwwwwwwwwwwwwwww",
  "tags": [
    { "slug_name": "test", "display_name": "test", "original_text": "tst" }
  ],
  "content": "# wwwwwwwwwwwwwwwwwwww\n\nhello world!\n\n```js\nconst a = 1;\n```"
}

@shuashuai
Copy link
Member

Discussed some details with the product, from the user's point of view, the current program will bring some difficulty to the user, the specific implementation details I will add to issue #1009

  1. the goal should be to simplify the use of the program requires the user to go through a number of technical means to deal with the splicing of parameters, the use of the scenario is restricted.
  2. the tags parameter also needs to go through the system's tagging information in order to add tags correctly, which we should simplify here.

@hgaol
Copy link
Member Author

hgaol commented Jul 11, 2024

Discussed some details with the product, from the user's point of view, the current program will bring some difficulty to the user, the specific implementation details I will add to issue #1009

  1. the goal should be to simplify the use of the program requires the user to go through a number of technical means to deal with the splicing of parameters, the use of the scenario is restricted.
  2. the tags parameter also needs to go through the system's tagging information in order to add tags correctly, which we should simplify here.

updated. support pre-fill with markdown format.

e.g.

http://localhost:3000/questions/ask?prefill=---%0Atitle%3A%20hello%20world%0Atags%3A%20feature-request%2C%20template%2Ctest%0A---%0A%0ASome%20body%20text...%0A

Copy link
Member

@shuashuai shuashuai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@shuashuai shuashuai merged commit 0378b81 into apache:dev Jul 12, 2024
@hgaol hgaol deleted the 1009 branch July 12, 2024 12:32
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

Successfully merging this pull request may close these issues.

2 participants