Files
zulip/static/js/markdown_config.js
m-e-l-u-h-a-n 2699048208 markdown: Extend user mention syntax to support user_id for mentioning.
Extend our markdown system to support mentioning of users
by id also. Following these changes, it would be possible
to mention users with @**|user_id** and silently mention
using @_**|user_id**.

Main intention for extending the mention syntax is to make
it convenient for bots to mention a users using their ids. It
is to be noted that previous syntax are also supported.

Documentation tweaked by tabbott for better readability.

The changes were tested manually in development server, and also
by adding some new backend and frontend tests.

Fixes: #17487.
2021-03-25 00:44:56 -07:00

48 lines
1.5 KiB
JavaScript

import * as hash_util from "./hash_util";
import * as people from "./people";
import * as stream_data from "./stream_data";
import * as user_groups from "./user_groups";
/*
This config is in a separate file for partly
tactical reasons. We want the webapp to
configure this one way, but we don't want to
share this code with mobile.
I also wanted to make some diffs clear before
doing any major file moves.
Also, I want the unit tests for Markdown to
be able to reuse this code easily (and therefore
didn't just put this in ui_init.js).
Once the first steps of making Markdown be a
shared library are complete, we may tweak
the file organization a bit.
Most functions here that are looking up data
follow the convention of returning `undefined`
when the lookups fail.
*/
export const get_helpers = () => ({
// user stuff
get_actual_name_from_user_id: people.get_actual_name_from_user_id,
get_user_id_from_name: people.get_user_id_from_name,
is_valid_full_name_and_user_id: people.is_valid_full_name_and_user_id,
my_user_id: people.my_current_user_id,
is_valid_user_id: people.is_known_user_id,
// user groups
get_user_group_from_name: user_groups.get_user_group_from_name,
is_member_of_user_group: user_groups.is_member_of,
// stream hashes
get_stream_by_name: stream_data.get_sub,
stream_hash: hash_util.by_stream_uri,
stream_topic_hash: hash_util.by_stream_topic_uri,
// settings
should_translate_emoticons: () => page_params.translate_emoticons,
});