Vertically expand/collapse in steps in dom inspector

Additionally, lock the inspected page to the item under
the mouse in the dom inspector.
This commit is contained in:
Raymond Hill 2023-12-07 20:59:45 -05:00
parent 77b33c47b3
commit 885bc3875b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
6 changed files with 57 additions and 13 deletions

View File

@ -19,6 +19,9 @@ html#ublock0-inspector,
top: 0; top: 0;
width: 100%; width: 100%;
} }
#ublock0-inspector svg > path {
stroke-width: 1px;
}
#ublock0-inspector svg > path:nth-of-type(1) { #ublock0-inspector svg > path:nth-of-type(1) {
fill: rgba(255,0,0,0.2); fill: rgba(255,0,0,0.2);
stroke: #F00; stroke: #F00;
@ -33,6 +36,5 @@ html#ublock0-inspector,
} }
#ublock0-inspector svg > path:nth-of-type(4) { #ublock0-inspector svg > path:nth-of-type(4) {
fill: rgba(0,0,255,0.1); fill: rgba(0,0,255,0.1);
stroke: #FFF; stroke: #00F;
stroke-width: 0.5px;
} }

View File

@ -7,6 +7,12 @@
#domInspector .permatoolbar .highlightMode.invert { #domInspector .permatoolbar .highlightMode.invert {
transform: rotate(180deg); transform: rotate(180deg);
} }
#domInspector button.vExpandToggler > .fa-icon {
transform: scaleY(-1)
}
#domInspector button.vCompactToggler > .fa-icon {
transform: scaleY(1)
}
#domInspector .vscrollable { #domInspector .vscrollable {
overflow-x: auto; overflow-x: auto;
} }
@ -84,7 +90,7 @@
display: none; display: none;
} }
#domInspector:not(.vExpanded) li:not(.hasCosmeticHide):not(.isCosmeticHide) { #domInspector li:not(.hasCosmeticHide):not(.isCosmeticHide):not(.show) {
display: none; display: none;
} }
#domInspector #domTree > li { #domInspector #domTree > li {

View File

@ -8,7 +8,8 @@ body {
textarea { textarea {
box-sizing: border-box; box-sizing: border-box;
direction: ltr; direction: ltr;
resize: none; min-height: 6rem;
resize: vertical;
width: 100%; width: 100%;
} }
.permatoolbar { .permatoolbar {
@ -78,6 +79,9 @@ textarea {
overflow-y: auto; overflow-y: auto;
} }
#domInspector button.vExpandToggler > .fa-icon {
transform: scaleY(1)
}
.inspector:not(.vExpanded) button.vCompactToggler > .fa-icon { .inspector:not(.vExpanded) button.vCompactToggler > .fa-icon {
transform: scaleY(-1) transform: scaleY(-1)
} }

View File

@ -613,11 +613,33 @@ const onTabIdChanged = ( ) => {
/******************************************************************************/ /******************************************************************************/
const toggleVCompactView = ( ) => { const toggleVExpandView = ( ) => {
const state = dom.cl.toggle(inspector, 'vExpanded'); const branches = qsa$('#domTree li.branch.show > ul > li.branch:not(.show)');
const branches = qsa$('#domInspector li.branch');
for ( const branch of branches ) { for ( const branch of branches ) {
dom.cl.toggle(branch, 'show', state); dom.cl.add(branch, 'show');
}
};
const toggleVCompactView = ( ) => {
const branches = qsa$('#domTree li.branch.show > ul > li:not(.show)');
const tohideSet = new Set();
for ( const branch of branches ) {
const node = branch.closest('li.branch.show');
if ( node.id === 'n1' ) { continue; }
tohideSet.add(node);
}
const tohideList = Array.from(tohideSet);
let i = tohideList.length - 1;
while ( i > 0 ) {
if ( tohideList[i-1].contains(tohideList[i]) ) {
tohideList.splice(i-1, 1);
} else if ( tohideList[i].contains(tohideList[i-1]) ) {
tohideList.splice(i, 1);
}
i -= 1;
}
for ( const node of tohideList ) {
dom.cl.remove(node, 'show');
} }
}; };
@ -642,6 +664,7 @@ const toggleOn = ( ) => {
document.addEventListener('tabIdChanged', onTabIdChanged); document.addEventListener('tabIdChanged', onTabIdChanged);
domTree.addEventListener('click', onClicked, true); domTree.addEventListener('click', onClicked, true);
domTree.addEventListener('mouseover', onMouseOver, true); domTree.addEventListener('mouseover', onMouseOver, true);
dom.on('#domInspector .vExpandToggler', 'click', toggleVExpandView);
dom.on('#domInspector .vCompactToggler', 'click', toggleVCompactView); dom.on('#domInspector .vCompactToggler', 'click', toggleVCompactView);
dom.on('#domInspector .hCompactToggler', 'click', toggleHCompactView); dom.on('#domInspector .hCompactToggler', 'click', toggleHCompactView);
dom.on('#domInspector .permatoolbar .revert', 'click', revert); dom.on('#domInspector .permatoolbar .revert', 'click', revert);
@ -660,6 +683,7 @@ const toggleOff = ( ) => {
document.removeEventListener('tabIdChanged', onTabIdChanged); document.removeEventListener('tabIdChanged', onTabIdChanged);
domTree.removeEventListener('click', onClicked, true); domTree.removeEventListener('click', onClicked, true);
domTree.removeEventListener('mouseover', onMouseOver, true); domTree.removeEventListener('mouseover', onMouseOver, true);
dom.off('#domInspector .vExpandToggler', 'click', toggleVExpandView);
dom.off('#domInspector .vCompactToggler', 'click', toggleVCompactView); dom.off('#domInspector .vCompactToggler', 'click', toggleVCompactView);
dom.off('#domInspector .hCompactToggler', 'click', toggleHCompactView); dom.off('#domInspector .hCompactToggler', 'click', toggleHCompactView);
dom.off('#domInspector .permatoolbar .revert', 'click', revert); dom.off('#domInspector .permatoolbar .revert', 'click', revert);

View File

@ -151,7 +151,7 @@ const domLayout = (( ) => {
layout.push(domNode); layout.push(domNode);
} }
// children // children
if ( node.firstElementChild !== null ) { if ( domNode !== null && node.firstElementChild !== null ) {
stack.push(node); stack.push(node);
lvl += 1; lvl += 1;
node = node.firstElementChild; node = node.firstElementChild;
@ -704,6 +704,13 @@ const onMessage = request => {
case 'highlightOne': case 'highlightOne':
blueNodes = selectNodes(request.selector, request.nid); blueNodes = selectNodes(request.selector, request.nid);
if ( blueNodes.length !== 0 ) {
blueNodes[0].scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'nearest',
});
}
highlightElements(); highlightElements();
break; break;
@ -728,8 +735,8 @@ const onMessage = request => {
if ( nodes.length !== 0 ) { if ( nodes.length !== 0 ) {
nodes[0].scrollIntoView({ nodes[0].scrollIntoView({
behavior: 'smooth', behavior: 'smooth',
block: 'center', block: 'nearest',
inline: 'center', inline: 'nearest',
}); });
} }
toggleExceptions(nodesFromFilter(request.filter), request.target); toggleExceptions(nodesFromFilter(request.filter), request.target);
@ -741,8 +748,8 @@ const onMessage = request => {
if ( nodes.length !== 0 ) { if ( nodes.length !== 0 ) {
nodes[0].scrollIntoView({ nodes[0].scrollIntoView({
behavior: 'smooth', behavior: 'smooth',
block: 'center', block: 'nearest',
inline: 'center', inline: 'nearest',
}); });
} }
toggleFilter(nodes, request.target); toggleFilter(nodes, request.target);

View File

@ -34,6 +34,7 @@
<div id="domInspector" class="inspector hCompact"> <div id="domInspector" class="inspector hCompact">
<div class="permatoolbar"> <div class="permatoolbar">
<div> <div>
<button class="iconified notext vExpandToggler"><span class="fa-icon">double-angle-up</span><span class="hover"></span></button>
<button class="iconified notext vCompactToggler"><span class="fa-icon">double-angle-up</span><span class="hover"></span></button> <button class="iconified notext vCompactToggler"><span class="fa-icon">double-angle-up</span><span class="hover"></span></button>
<button class="iconified notext hCompactToggler"><span class="fa-icon">double-angle-left</span><span class="hover"></span></button> <button class="iconified notext hCompactToggler"><span class="fa-icon">double-angle-left</span><span class="hover"></span></button>
<button class="iconified notext revert disabled"><span class="fa-icon">eraser</span><span class="hover"></span></button> <button class="iconified notext revert disabled"><span class="fa-icon">eraser</span><span class="hover"></span></button>