BUG: Fix the new chat room header icons not producing text upon copy/pasting

This commit is contained in:
bananarama92 2025-03-29 21:47:36 +01:00
parent 1a185e0318
commit fe716f31c7
No known key found for this signature in database
GPG key ID: E83C7D3B5DA36248
2 changed files with 52 additions and 15 deletions
BondageClub
CSS
Screens/Online/ChatRoom

View file

@ -31,7 +31,7 @@
} }
.chat-room-sep-header { .chat-room-sep-header {
user-select: text !important; user-select: all !important;
align-content: center; align-content: center;
justify-content: center; justify-content: center;
display: flex; display: flex;
@ -47,6 +47,10 @@
margin-block: 0.1em; margin-block: 0.1em;
} }
.chat-room-no-copy {
user-select: none;
}
.chat-room-sep-collapse { .chat-room-sep-collapse {
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;

View file

@ -907,6 +907,25 @@ var ChatRoomSep = {
*/ */
ActiveElem: null, ActiveElem: null,
/**
* @private
* @type {(this: HTMLDivElement, event: ClipboardEvent) => void}
*/
_CopyHeader: function _CopyHeader(ev) {
let txt = "";
for (const el of this.childNodes) {
if (!(el instanceof Element)) {
txt += el.textContent;
continue;
} else if (el.classList.contains("chat-room-no-copy")) {
continue;
}
txt += el.textContent || (el.getAttribute("aria-label") ?? "");
}
ev.clipboardData.setData("text/plain", txt);
ev.preventDefault();
},
/** /**
* Click event listener for collapsing one or more chat room separators * Click event listener for collapsing one or more chat room separators
* @private * @private
@ -948,20 +967,34 @@ var ChatRoomSep = {
_GetDisplayName: function _GetDisplayName(button) { _GetDisplayName: function _GetDisplayName(button) {
const namespace = FriendListIconMapping[button.dataset.space]; const namespace = FriendListIconMapping[button.dataset.space];
return [ return [
namespace ? [ElementCreate({ namespace ? [
tag: "div", ElementCreate({
attributes: { role: "img", "aria-label": InterfaceTextGet(`ChatRoomSpace${button.dataset.space || "F"}`) }, tag: "div",
classList: ["chat-room-sep-image"], attributes: { role: "img", "aria-label": InterfaceTextGet(`ChatRoomSpace${button.dataset.space || "F"}`) },
style: { mask: `url(${namespace.src}) center/contain` }, classList: ["chat-room-sep-image"],
}), " - "] : undefined, style: { mask: `url(${namespace.src}) center/contain` },
button.dataset.private === "true" ? [ElementCreate({ eventListeners: { copy: ChatRoomSep._CopyImage },
tag: "div", }),
attributes: { role: "img", "aria-label": InterfaceTextGet("Private") }, " - ",
classList: ["chat-room-sep-image"], ] : undefined,
style: { mask: `url(${FriendListIconMapping.Private.src}) center/contain` }, button.dataset.private === "true" ? [
}), " - "] : undefined, ElementCreate({
tag: "div",
attributes: { role: "img", "aria-label": InterfaceTextGet("Private") },
classList: ["chat-room-sep-image"],
style: { mask: `url(${FriendListIconMapping.Private.src}) center/contain` },
eventListeners: { copy: ChatRoomSep._CopyImage },
}),
" - ",
] : undefined,
ChatRoomHTMLEntities(ChatSearchMuffle(button.dataset.room)), ChatRoomHTMLEntities(ChatSearchMuffle(button.dataset.room)),
button.dataset.messages ? ["✉", ElementCreate({ tag: "sup", children: [button.dataset.messages] })] : undefined, button.dataset.messages ? [
ElementCreate({
tag: "span",
classList: ["chat-room-no-copy"],
children: [" ✉", { tag: "sup", children: [button.dataset.messages] }],
}),
] : undefined,
].flat().filter(Boolean); ].flat().filter(Boolean);
}, },
@ -994,7 +1027,7 @@ var ChatRoomSep = {
), ),
ElementButton.Create( ElementButton.Create(
`chat-room-sep-header-${now}`, this._ClickScrollUp, { noStyling: true }, `chat-room-sep-header-${now}`, this._ClickScrollUp, { noStyling: true },
{ button: { classList: ["chat-room-sep-header"] } }, { button: { classList: ["chat-room-sep-header"], eventListeners: { copy: ChatRoomSep._CopyHeader } } },
), ),
], ],
}, },