Skip to content

Commit

Permalink
v0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
zxkmm committed Jan 27, 2024
1 parent 8bc9259 commit 879beac
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 65 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@
- fix deadly bug
- textual/ interface change

## 0.3.4
- notebook outline support tight mode
- notebook outline support dark/ night theme
- fix fetching null in setting dialog
- fix unexpected console print

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ This makes it difficult or even impossible to click on multi-level subdirectorie
- add disable icon click but keep icon
- add line height setting

## 0.3.3
- add notebook outline by @TCOTC
- fix deadly bug
- textual/ interface change
## 0.3.4
- notebook outline support tight mode
- notebook outline support dark/ night theme
- fix fetching null in setting dialog
- fix unexpected console print


## Links
Expand Down
9 changes: 5 additions & 4 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
- 添加了禁用图标点击但保留图标的功能
- 添加了行高设置功能

## 0.3.3
- add notebook outline by @TCOTC
- fix deadly bug
- textual/ interface change
## 0.3.4
- notebook outline support tight mode
- notebook outline support dark/ night theme
- fix fetching null in setting dialog
- fix unexpected console print


## 链接
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "siyuan_doctree_compress",
"version": "0.3.3",
"version": "0.3.4",
"type": "module",
"description": "fully customs your doctree",
"repository": "https://github.com/zxkmm/siyuan_doctree_compress",
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "siyuan_doctree_compress",
"author": "zxkmm",
"url": "https://github.com/zxkmm/siyuan_doctree_compress",
"version": "0.3.3",
"version": "0.3.4",
"minAppVersion": "2.12.1",
"backends": [
"windows",
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
"doctreeSeperateLineBorder": "Doctree Seperate Line Border",
"doctreeSeperateLineBorderDesc": "Define doctree Seperate Line Border, default is 2, unit: px",
"addNotebookOutline": "Notebook Outline",
"addNotebookOutlineDesc": "Add notebook outline to the document tree. <br>by https://github.com/TCOTC aka @Jeffrey Chen"
"addNotebookOutlineDesc": "Add notebook outline to the document tree. <br>by https://github.com/TCOTC aka @Jeffrey Chen",
"notebookOutlineTightMode": "Notebook Outline Tight Mode",
"notebookOutlineTightModeDesc": "Tight mode for notebook outline"

}
4 changes: 3 additions & 1 deletion src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@
"doctreeSeperateLineBorder": "文档树分隔线厚度",
"doctreeSeperateLineBorderDesc": "定义文档树分隔线厚度,默认为2,单位:像素",
"addNotebookOutline": "笔记本外框",
"addNotebookOutlineDesc": "在笔记本和其覆盖范围内增加外框,方便区分笔记本 <br>此功能由 https://github.com/TCOTC 也就是 @Jeffrey Chen 设计"
"addNotebookOutlineDesc": "在笔记本和其覆盖范围内增加外框,方便区分笔记本 <br>此功能由 https://github.com/TCOTC 也就是 @Jeffrey Chen 设计",
"notebookOutlineTightMode": "笔记本外框紧凑模式",
"notebookOutlineTightModeDesc": "启用后,笔记本外框将会更加紧凑"
}
122 changes: 69 additions & 53 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ zxkmm naming style:
_inFuncMember_
_funcArgument_
funcName
_privateClassMember
privateClassMember_
_publicClassMember
*/


Expand Down Expand Up @@ -157,12 +158,19 @@ export default class siyuan_doctree_compress extends Plugin {
this.applyStyles(css);
}

addNotebookOutline(){ //by https://github.com/TCOTC aka @Jeffrey Chen
const css = `
addNotebookOutline(_tight_){ //by https://github.com/TCOTC aka @Jeffrey Chen
const css = _tight_ ? `
.sy__file ul.b3-list.b3-list--background {
border-radius: 0.1em;
margin: 7px 4px 7px 4px;
outline: 1.9px solid var(--b3-theme-background-light);
overflow: hidden;
}
` : `
.sy__file ul.b3-list.b3-list--background {
border-radius: 0.3em;
margin: 6px 10px 6px 12px;
outline: 1.5px double #8e9ba3;
margin: 7px 10px 6px 10px;
outline: 2px solid var(--b3-theme-background-light);
overflow: hidden;
}
`
Expand Down Expand Up @@ -606,6 +614,14 @@ export default class siyuan_doctree_compress extends Plugin {
description: this.i18n.addNotebookOutlineDesc,
});

this.settingUtils.addItem({
key: "notebookOutlineTightMode",
value: false,
type: "checkbox",
title: "🖼️ " + this.i18n.notebookOutlineTightMode,
description: this.i18n.notebookOutlineTightModeDesc,
});

this.settingUtils.addItem({
key: "hintDeviceSpecificSettings",
value: "",
Expand Down Expand Up @@ -721,35 +737,38 @@ export default class siyuan_doctree_compress extends Plugin {
const _enableDoctreeSeperateLine_ = this.settingUtils.get("enableDoctreeSeperateLine");
const _doctreeSeperateLineBorder_ = this.settingUtils.get("doctreeSeperateLineBorder");
const _addNotebookOutline_ = this.settingUtils.get("addNotebookOutline");

console.log({
mouseoverZeroPadding: _mouseoverZeroPadding_,
mainSwitchStat: _mainSwitchStat_,
hideIcon: _hideIcon_,
compressionPercentage: _compressionPercentage_,
overloadFontSizeSwitch: _overloadFontSizeSwitch_,
mouseHoverZeroPaddingForce: _mouseHoverZeroPaddingForce_,
mouseHoverZeroPaddingPx: _mouseHoverZeroPaddingPx_,
mouseOverLineUnclamp: _mouseOverLineUnclamp_,
mouseOverLineUnclampForce: _mouseOverLineUnclampForce_,
mouseOverReduceFontSize: _mouseOverReduceFontSize_,
mouseOverReduceFontSizeForce: _mouseOverReduceFontSizeForce_,
mouseHoverReduceFontSizePx: _mouseHoverReduceFontSizePx_,
onlyEnableListedDevices: _onlyEnableListedDevices_,
currentDeviceInList: _currentDeviceInList_,
hideContextualLabel: _hideContextualLabel_,
displayIconButDIsableIconClick: _displayIconButDIsableIconClick_,
disableDocumentButtonsPopup: _disableDocumentButtonsPopup_,
overloadLineHeight: _overloadLineHeight_,
overloadLineHeightForce: _overloadLineHeightForce_,
overloadLineHeightPx: _overloadLineHeightPx_,
enableDoctreeFrontLine: _enableDoctreeFrontLine_,
doctreeFrontLinePosition: _doctreeFrontLinePosition_,
doctreeFrontLinePadding: _doctreeFrontLinePadding_,
doctreeFrontLineBorder: _doctreeFrontLineBorder_,
enableDoctreeSeperateLine: _enableDoctreeSeperateLine_,
doctreeSeperateLineBorder: _doctreeSeperateLineBorder_,
});
const _notebookOutlineTightMode_ = this.settingUtils.get("notebookOutlineTightMode");

// console.log({
// mouseoverZeroPadding: _mouseoverZeroPadding_,
// mainSwitchStat: _mainSwitchStat_,
// hideIcon: _hideIcon_,
// compressionPercentage: _compressionPercentage_,
// overloadFontSizeSwitch: _overloadFontSizeSwitch_,
// mouseHoverZeroPaddingForce: _mouseHoverZeroPaddingForce_,
// mouseHoverZeroPaddingPx: _mouseHoverZeroPaddingPx_,
// mouseOverLineUnclamp: _mouseOverLineUnclamp_,
// mouseOverLineUnclampForce: _mouseOverLineUnclampForce_,
// mouseOverReduceFontSize: _mouseOverReduceFontSize_,
// mouseOverReduceFontSizeForce: _mouseOverReduceFontSizeForce_,
// mouseHoverReduceFontSizePx: _mouseHoverReduceFontSizePx_,
// onlyEnableListedDevices: _onlyEnableListedDevices_,
// currentDeviceInList: _currentDeviceInList_,
// hideContextualLabel: _hideContextualLabel_,
// displayIconButDIsableIconClick: _displayIconButDIsableIconClick_,
// disableDocumentButtonsPopup: _disableDocumentButtonsPopup_,
// overloadLineHeight: _overloadLineHeight_,
// overloadLineHeightForce: _overloadLineHeightForce_,
// overloadLineHeightPx: _overloadLineHeightPx_,
// enableDoctreeFrontLine: _enableDoctreeFrontLine_,
// doctreeFrontLinePosition: _doctreeFrontLinePosition_,
// doctreeFrontLinePadding: _doctreeFrontLinePadding_,
// doctreeFrontLineBorder: _doctreeFrontLineBorder_,
// enableDoctreeSeperateLine: _enableDoctreeSeperateLine_,
// doctreeSeperateLineBorder: _doctreeSeperateLineBorder_,
// addNotebookOutline: _addNotebookOutline_,
// notebookOutlineTightMode: _notebookOutlineTightMode_,
// });


/*条件列表:
Expand Down Expand Up @@ -819,7 +838,7 @@ export default class siyuan_doctree_compress extends Plugin {
}

if (_addNotebookOutline_) {
this.addNotebookOutline();
this.addNotebookOutline(_notebookOutlineTightMode_);
}


Expand All @@ -841,24 +860,21 @@ export default class siyuan_doctree_compress extends Plugin {
//

function handleDomChanges() {

const elements = document.querySelectorAll('.b3-list-item');

elements.forEach(element => {
const isCompressed = element.querySelector('.b3-list-item__toggle').getAttribute('data-compressed');

if (!isCompressed) {
const originalPadding = parseFloat(window.getComputedStyle(element.querySelector('.b3-list-item__toggle')).paddingLeft);

const compressedPadding = originalPadding * (1 - _compressionPercentage_ / 100);

if (element.getAttribute('data-type') != 'navigation-root') { //prevent compress notebook

console.dir(element.getAttribute('data-type'));

element.querySelector('.b3-list-item__toggle').style.paddingLeft = `${compressedPadding}px`;

element.querySelector('.b3-list-item__toggle').setAttribute('data-compressed', 'true'); //mark as compressed prevent nested compression
const _elements_ = document.querySelectorAll('.b3-list-item');

_elements_.forEach(element => {
const _toggleElement_ = element.querySelector('.b3-list-item__toggle');
if (_toggleElement_) { // Check if the element exists
const _isCompressed_ = _toggleElement_.getAttribute('data-compressed');

if (!_isCompressed_) {
const _originalPadding_ = parseFloat(window.getComputedStyle(_toggleElement_).paddingLeft);
const _compressedPadding_ = _originalPadding_ * (1 - _compressionPercentage_ / 100);

if (element.getAttribute('data-type') != 'navigation-root') { //prevent compress notebook
_toggleElement_.style.paddingLeft = `${_compressedPadding_}px`;
_toggleElement_.setAttribute('data-compressed', 'true'); //mark as compressed prevent nested compression
}
}
}
});
Expand Down

0 comments on commit 879beac

Please sign in to comment.