Skip to content

Commit

Permalink
Merge branch 'fix-small-issues'
Browse files Browse the repository at this point in the history
  • Loading branch information
schlagmichdoch committed Jan 3, 2024
2 parents b620328 + bea0fa5 commit 3454eeb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
29 changes: 22 additions & 7 deletions public/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,15 @@ class ReceiveTextDialog extends Dialog {
this._receiveTextQueue = [];
}

selectionEmpty() {
return !window.getSelection().toString()
}

async _onKeyDown(e) {
if (!this.isShown()) return

if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) {
if (e.code === "KeyC" && (e.ctrlKey || e.metaKey) && this.selectionEmpty()) {
await this._onCopy()
this.hide();
}
else if (e.code === "Escape") {
this.hide();
Expand Down Expand Up @@ -2014,10 +2017,19 @@ class ReceiveTextDialog extends Dialog {

// Beautify text if text is short
if (text.length < 2000) {
// replace urls with actual links
this.$text.innerHTML = this.$text.innerHTML.replace(/((https?:\/\/|www)[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\-._~:\/?#\[\]@!$&'()*+,;=]+)/g, url => {
return `<a href="${url}" target="_blank">${url}</a>`;
});
// replace URLs with actual links
this.$text.innerHTML = this.$text.innerHTML
.replace(/(^|(?<=(<br>|\s)))(https?:\/\/|www.)(([a-z]|[A-Z]|[0-9]|[\-_~:\/?#\[\]@!$&'()*+,;=%]){2,}\.)(([a-z]|[A-Z]|[0-9]|[\-_~:\/?#\[\]@!$&'()*+,;=%.]){2,})/g,
(url) => {
let link = url;

// prefix www.example.com with http protocol to prevent it from being a relative link
if (link.startsWith('www')) {
link = "http://" + link
}

return `<a href="${link}" target="_blank">${url}</a>`;
});
}

this._evaluateOverflowing(this.$text);
Expand Down Expand Up @@ -2049,7 +2061,10 @@ class ReceiveTextDialog extends Dialog {

hide() {
super.hide();
setTimeout(() => this._dequeueRequests(), 500);
setTimeout(() => {
this._dequeueRequests();
this.$text.innerHTML = "";
}, 500);
}
}

Expand Down
12 changes: 7 additions & 5 deletions public/styles/styles-deferred.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
max-height: 350px;
word-break: break-word;
word-wrap: anywhere;
white-space: pre-wrap;
}

.textarea:before {
Expand Down Expand Up @@ -335,6 +336,7 @@ x-dialog x-paper {
display: flex;
margin: auto;
flex-direction: column;
width: 100%;
max-width: 450px;
z-index: 3;
border-radius: 30px;
Expand Down Expand Up @@ -382,10 +384,6 @@ x-dialog:not([show]) x-paper {
transform: scale(0.1);
}

x-dialog a {
color: var(--primary-color);
}

/* Pair Devices Dialog & Public Room Dialog */

.input-key-container {
Expand Down Expand Up @@ -784,7 +782,7 @@ x-dialog x-paper {
background-color: var(--bg-color-secondary) !important;
}

.textarea * {
.textarea *:not(a) {
margin: 0 !important;
padding: 0 !important;
color: unset !important;
Expand All @@ -797,6 +795,10 @@ x-dialog x-paper {
font-weight: unset !important;
}

x-dialog a {
color: var(--primary-color);
}

/* Image/Video/Audio Preview */
.file-preview {
margin-bottom: 15px;
Expand Down

0 comments on commit 3454eeb

Please sign in to comment.