Skip to content

Commit

Permalink
Update HtmlTraceAbleErrorRenderer.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayIterator authored Jul 15, 2024
1 parent 87a0411 commit ad22fcc
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions src/View/ErrorRenderer/HtmlTraceAbleErrorRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private function exceptionDetail(Throwable $exception): string
$exception->getLine()
);
$mainErrorInfo .= sprintf(
"<div class='current'><strong>Message</strong>: <code>%s</code></div>\n",
"<div class='current current-message'><strong>Message</strong>: <code>%s</code></div>\n",
htmlentities($message)
);
$mainErrorInfo .= '<div><br></div>';
Expand Down Expand Up @@ -569,6 +569,14 @@ private function exceptionDetail(Throwable $exception): string
display: flex;
flex-direction: column;
justify-content: flex-start;
scroll-behavior: smooth;
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, .3) transparent;
}
.current-message > code {
word-wrap:break-word;
white-space: normal
}
.tab-info {
Expand Down Expand Up @@ -744,6 +752,7 @@ private function exceptionDetail(Throwable $exception): string
min-height: 100%;
outline: none;
box-shadow: none;
flex: 0 0 auto;
/* margin-right: 1em; */
}
Expand Down Expand Up @@ -882,13 +891,39 @@ private function exceptionDetail(Throwable $exception): string
navigator.clipboard.writeText(content);
});
e.addEventListener('keydown', function(e) {
if (/^(Backspace|Delete)/i.test(e.code)) {
e.preventDefault();
return false;
}
if (e.code === 'Escape') {
window.getSelection()?.removeAllRanges();
return;
}
// if cut just select current select range
if (e.code === 'KeyX' && (e.ctrlKey || e.metaKey)) {
const selection = window.getSelection();
if (selection) {
const range = selection.getRangeAt(0);
const content = range.cloneContents();
const div = document.createElement('div');
div.appendChild(content);
const text = div.textContent;
try {
navigator.clipboard.writeText(text).catch(() => null);
} catch (err) {
// pass
}
return;
}
return;
}
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Tab'].includes(e.code)
|| (
(e.ctrlKey || e.metaKey) && (
['KeyA', 'KeyC', 'KeyV', 'KeyX', 'KeyR'].includes(e.code)
)
)
) {
return;
}
e.preventDefault();
return false;
});
});
let navTabs = document.querySelectorAll('.trace-tab-nav');
Expand Down

0 comments on commit ad22fcc

Please sign in to comment.