-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
widgets: Support markdown in widgets. #28079
base: main
Are you sure you want to change the base?
Conversation
fd6cc8a
to
e66720e
Compare
0c7d818
to
e7c9978
Compare
@roanster007 Reviewed the changes locally <time and basic markdown seems to be working fine. I've noticed that the current process of adding time to a poll in Zulip involves typing the time in the compose box and then copying it to the "Add Option" field. While this works well, it would be even more user-friendly to directly implement time rendering for additional options. I suggest extending the time rendering functionality to the "Add Option" field, allowing users to input time in a similar manner. This enhancement would streamline the process and provide a consistent experience across the poll creation interface. Implementation Details: When users type a time in the "Add Option" field, the system should recognize and render it accordingly. Improved user experience by eliminating the need to copy-paste time from the compose box to the "Add Option" field. The decision should be made by project contributors to include the above suggestion or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works.
@bupd I agree that we should ideally have a better way to input times (and emoji), but let's make sure we get the rendering part of this working first. |
3c80967
to
d4bae1a
Compare
@alya I have updated the PR and screenshots as per the feedback. |
Thanks! It looks like the space after the |
Other than that, the screenshots look good to me. You can add the "maintainer review" label (via Zulipbot) and ping @N-Shar-ma to take a look once that's been fixed. |
d4bae1a
to
0ba0320
Compare
@zulipbot add "maintainer review" |
@N-Shar-ma could you have a look at this.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the frontend code and have left some comments.
Someone else who is familiar with the backend markdown processor will be much better suited to review those parts; sorry I've not worked on that part of the codebase so far
const html = render_widgets_poll_widget_results(widget_data); | ||
$elem.find("ul.poll-widget").html(html); | ||
|
||
render_poll_timestamp($elem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly pass $elem.find("ul.poll-widget")
instead to this function. That will make it more generalised, so also reusable by todo widgets, eliminating the near duplicate function in todo_widget.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be even better if you could extract this as a function in rendered_markdown
where this code is from, and call that here.
We always want to minimize code duplication as much as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt using the update_elements
of rendered_markdown
would be unreasonable since that method would try to look out for lot of other elements too apart form time
in $elem
like mentions, codehilite,... but those for sure won't be rendered inside the widget by the inline processor.
Moreover, importing rendered_markdown.js
method into poll_widget.ts
is causing Could not find a declaration file for module './rendered_markdown'. 'rendered_markdown.js' implicitly has an 'any' type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant extracting just the relevant code as a new function and calling that, not the pre existing whole update_elements
function.
But yes, the non typescript file import into this typescript file still remains an issue 🤔
web/styles/widgets.css
Outdated
@@ -166,7 +181,7 @@ | |||
.poll-names { | |||
color: hsl(0deg 0% 45%); | |||
padding-left: 4px; | |||
padding-top: 28px; | |||
padding-top: 2px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the 1st line being spaced extra from the rest due to the vote count button looks a little odd... I think we want to keep that button in its own column, but keep the option and voter names inline. Would this be possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -8,9 +8,9 @@ | |||
</div> | |||
<div> | |||
{{#if completed}} | |||
<strike><strong>{{ task }}</strong>{{#if desc }}: {{ desc }}{{/if}}</strike> | |||
<strike><strong class="task_complete">{{{ task }}}</strong>{{#if desc }}<span class="task_desc_complete"">: </span><span class="description_complete"">{{{ desc }}}</span>{{/if}}</strike> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra "
after the task_desc_complete
class... Also, can you explain why these new classes are needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra "
after description_complete
class too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry... I missed it. So the reason for these new classes was -- task
, :
and description
are now rendered as separate elements. So without them, sometimes the :
is not staying inline, while other times, all three of them go to the next line. So I thought I would enclose them within tags to make them inline separately.
0ba0320
to
8c1b86e
Compare
cf1080f
to
1197b5f
Compare
1197b5f
to
98539bd
Compare
This commit creates an inline only markdown processor, that renders inline patterns.
This commit allows polls to render inline patterns using the inline markdown processor. Fixes zulip#21917.
This commit allows todo to render inline patterns using the inline markdown processor.
Heads up @roanster007, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
Previously, markdown was not supported in widgets like polls and todo. This is fixed by adding an inline only backend processor ZulipInlineMarkdown, and using it to render the poll options or tasks and descriptions of todo before adding them to the database.
fbb12bc
): AddZulipInlineMarkdown
processor to render inline only patterns.e4ceba6
): Support inline markdown in polls.1197b5f
): Support inline markdown in todo widgets.Fixes: #21917
CZO
Screenshots and screen captures:
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: