diff --git a/shared/js/MessageFormatter.ts b/shared/js/MessageFormatter.ts index e022a08b..e890a561 100644 --- a/shared/js/MessageFormatter.ts +++ b/shared/js/MessageFormatter.ts @@ -215,6 +215,7 @@ export namespace bbcode { } }); + const load_callback = guid(); /* the image parse & displayer */ xbbcode.register.register_parser({ tag: ["img", "image"], @@ -237,10 +238,11 @@ export namespace bbcode { return fallback_value; } - sanitizer_escaped_map[uid] = "
"; + sanitizer_escaped_map[uid] = "
"; return sanitizer_escaped(uid); } - }) + }); + window[load_callback] = load_image; }, priority: 10 }); diff --git a/shared/js/ui/htmltags.ts b/shared/js/ui/htmltags.ts index c9180c0a..c890ef48 100644 --- a/shared/js/ui/htmltags.ts +++ b/shared/js/ui/htmltags.ts @@ -4,6 +4,7 @@ import {ChannelEntry} from "tc-shared/ui/channel"; import {ClientEntry} from "tc-shared/ui/client"; import {htmlEscape} from "tc-shared/ui/frames/chat"; import {server_connections} from "tc-shared/ui/frames/connection_handlers"; +import {guid} from "tc-shared/crypto/uid"; let mouse_coordinates: {x: number, y: number} = {x: 0, y: 0}; @@ -30,6 +31,7 @@ export interface ChannelProperties { add_braces?: boolean } +const callback_object_id = guid(); /* required for the bbcodes */ function generate_client_open(properties: ClientProperties) : string { let result = ""; @@ -57,7 +59,7 @@ function generate_client_open(properties: ClientProperties) : string { } /* add the click handler */ - result += "oncontextmenu='return htmltags.callbacks.callback_context_client($(this));'"; + result += "oncontextmenu='return window[\"" + callback_object_id + "\"].callback_context_client($(this));'"; result = result + ">"; return result; @@ -100,7 +102,7 @@ function generate_channel_open(properties: ChannelProperties) : string { result = result + "channel-name='" + encodeURIComponent(properties.channel_name) + "' "; /* add the click handler */ - result += "oncontextmenu='return htmltags.callbacks.callback_context_channel($(this));'"; + result += "oncontextmenu='return window[\"" + callback_object_id + "\"].callback_context_channel($(this));'"; result = result + ">"; return result; @@ -186,6 +188,7 @@ export namespace callbacks { return false; } } +window[callback_object_id] = callbacks; declare const xbbcode; namespace bbcodes {