if (_seperateHidingPolicy_ == 3) {
// test seperate and hide if two meet each other
// TODO: didn't handle the situation that more than two seperators meet each other....
// 烧脑。。。
let startSeparatorIndex = -1;
let previousSeparatorHidden = false;
for (let i = 0; i < _items_.length; i++) {
if (_items_[i].classList.contains('b3-menu__separator')) {
if (startSeparatorIndex === -1) {
startSeparatorIndex = i;
} else {
let allButtonsHidden = true;
for (let j = startSeparatorIndex + 1; j < i; j++) {
if (_items_[j].style.display !== 'none') {
allButtonsHidden = false;
break;
}
}
if (allButtonsHidden && !previousSeparatorHidden) {
_items_[startSeparatorIndex].style.display = 'none';
previousSeparatorHidden = true;
} else {
previousSeparatorHidden = false;
}
startSeparatorIndex = i;
}
}
}
}
上下文: https://github.com/zxkmm/siyuan_rmv_btn/commit/9ee250e787e856535e33c23ef5dddbc10ec31726
感谢大佬!