Fixed HTML link copy pasting

canary
WolverinDEV 2020-12-09 14:32:14 +01:00
parent e6bbb883e4
commit 9e90510b43
3 changed files with 29 additions and 3 deletions

View File

@ -3,6 +3,7 @@
- Fixed the private messages unread indicator
- Properly updating the private message unread count
- Improved channel conversation mode detection support
- Added support for HTML encoded links (Example would be when copying from Edge the URL)
* **08.12.20**
- Fixed the permission editor not resolving unique ids

View File

@ -363,8 +363,8 @@ export class ChannelConversationManager extends AbstractChatManager<ChannelConve
this.listenerConnection.push(connection.channelTree.events.on("notify_client_moved", event => {
if(event.client instanceof LocalClientEntry) {
const fromConversation = this.findConversation(event.oldChannel.channelId);
const targetConversation = this.findConversation(event.newChannel.channelId);
const fromConversation = this.findConversation(event.oldChannel?.channelId);
const targetConversation = this.findConversation(event.newChannel?.channelId);
fromConversation?.updateAccessState();
targetConversation?.updateAccessState();

View File

@ -89,6 +89,30 @@ const nodeToText = (element: Node) => {
return element.alt || element.title;
} else if(element instanceof HTMLBRElement) {
return '\n';
} else if(element instanceof HTMLAnchorElement) {
const content = [...element.childNodes].map(nodeToText).join("");
if(element.href) {
if(settings.static_global(Settings.KEY_CHAT_ENABLE_MARKDOWN)) {
if(content && element.title) {
return `[${content}](${element.href} "${element.title}")`;
} else if(content) {
return `[${content}](${element.href})`;
} else {
return `[${element.href}](${element.href})`;
}
} else if(settings.static_global(Settings.KEY_CHAT_ENABLE_BBCODE)) {
if(content) {
return `[url=${element.href}]${content}"[/url]`;
} else {
return `[url]${element.href}"[/url]`;
}
} else {
return element.href;
}
} else {
return content;
}
}
if(element.children.length > 0) {
@ -143,8 +167,9 @@ const TextInput = (props: { events: Registry<ChatBoxEvents>, enabled?: boolean,
const rawText = clipboard.getData('text/plain');
const selection = window.getSelection();
if (!selection.rangeCount)
if (!selection.rangeCount) {
return false;
}
let htmlXML = clipboard.getData('text/html');
if(!htmlXML) {