Commit Graph

7 Commits

Author SHA1 Message Date
Anders Kaseorg 41e8872b0f realm_playground: Stop using Map incorrectly.
Commit ad76df25ac (#18405) uses Map
incorrectly.  A JavaScript Map needs to be indexed with .get() and
.set(), not with [].

Also, clean up the API: ‘lookup_table’ is a meaningless variable name,
and there was no information in the array that wasn’t also in the Map.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-09 22:01:00 -07:00
Sumanth V Rao ad8f27e20c playgrounds: Display the typeahead before the user starts typing.
We display the 5 most popular Pygment languages in the typeahead
when the user clicks on the `pygments_name` field and before they
start typing.
2021-05-09 16:13:19 -07:00
Sumanth V Rao 9c4ed43d6b playgrounds: Add an option to select "Custom language" in typeahead.
Since we support hooking up code playgrounds for custom languages
outside of the list of languages supported by Pygments, we display
an option to select a "Custom language" in the typeahead.
2021-05-09 16:13:04 -07:00
Sumanth V Rao ad76df25ac playgrounds: Add pygment aliases into a parenthetical in the typeahead.
The `pygments_name` field typeahead shows a list of human-readable
`pretty_name`to pick from. However, the Pygment aliases which are
used for code highlighting within a code block are different from
these. This mismatch might be confusing for folks unfamiliar with
technical details of the "code playgrounds" feature.

To bridge the gap, we now include the Pygment aliases within
parenthesis along with its human-readable name, in the typeaheads.

E.g: Python 2.x (py2, python2).
2021-05-09 16:11:30 -07:00
Sumanth V Rao 215320bc72 settings_playground: Add typeaheads for `pygments_name` field.
The typeahead suggests a human-readable `pretty_name` for the
`language` field in the add-playgrounds form.

The suggestions are sorted based on the popularity of these
languages.

E.g: A `py` prefix would match with `Python` first before
matching with others like `Python 2.x` based on priority.
2021-05-04 11:39:33 -07:00
Sumanth V Rao a510dac024 settings_playground: Add UI to create a new playground.
The design of the form is similar to the linkifiers page
and is styled similarly.

The introduction text for "Code playgrounds" is improved
with more details and examples.

Also, we can remove the hardcoded playground and the fix
we had previously done to prevent breaking the hardcoded
playground.
2021-05-04 11:39:33 -07:00
Sumanth V Rao 32390e0c87 playgrounds: Hook up configured playgrounds to be used in code blocks.
To prevent breaking of the hardcoded playgrounds, we resort
to checking if realm_playgrounds is empty and falling back
to the hard-coded list if so. This logic is removed in the
followup commit which introduces the UI to add a playground.
2021-04-19 11:23:10 -07:00