mirror of https://github.com/zulip/zulip.git
refactor: Move `replace_emoji_with_text` from `ui` to `ui_util`.
This commit is contained in:
parent
e132a68193
commit
b55ee161e2
|
@ -23,7 +23,6 @@ import * as settings_config from "./settings_config";
|
|||
import * as spoilers from "./spoilers";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_ui_updates from "./stream_ui_updates";
|
||||
import * as ui from "./ui";
|
||||
import * as ui_util from "./ui_util";
|
||||
import * as unread from "./unread";
|
||||
import * as unread_ops from "./unread_ops";
|
||||
|
@ -258,7 +257,7 @@ export function process_notification(notification) {
|
|||
let notification_source;
|
||||
// Convert the content to plain text, replacing emoji with their alt text
|
||||
const $content = $("<div>").html(message.content);
|
||||
ui.replace_emoji_with_text($content);
|
||||
ui_util.replace_emoji_with_text($content);
|
||||
spoilers.hide_spoilers_in_notification($content);
|
||||
|
||||
if (
|
||||
|
|
|
@ -3,15 +3,6 @@ import SimpleBar from "simplebar";
|
|||
|
||||
// What, if anything, obscures the home tab?
|
||||
|
||||
export function replace_emoji_with_text($element) {
|
||||
$element.find(".emoji").replaceWith(function () {
|
||||
if ($(this).is("img")) {
|
||||
return $(this).attr("alt");
|
||||
}
|
||||
return $(this).text();
|
||||
});
|
||||
}
|
||||
|
||||
export function get_content_element($element) {
|
||||
const element = $element.expectOne()[0];
|
||||
const sb = SimpleBar.instances.get(element);
|
||||
|
|
|
@ -21,6 +21,15 @@ export function place_caret_at_end(el: HTMLElement): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function replace_emoji_with_text($element: JQuery): void {
|
||||
$element.find(".emoji").replaceWith(function () {
|
||||
if ($(this).is("img")) {
|
||||
return $(this).attr("alt") ?? "";
|
||||
}
|
||||
return $(this).text();
|
||||
});
|
||||
}
|
||||
|
||||
export function blur_active_element(): void {
|
||||
// this blurs anything that may perhaps be actively focused on.
|
||||
if (document.activeElement instanceof HTMLElement) {
|
||||
|
|
Loading…
Reference in New Issue