Skip to content

Commit

Permalink
doctree_line (#5)
Browse files Browse the repository at this point in the history
* doctree_line

* doctree_front_line
  • Loading branch information
zxkmm authored Jan 23, 2024
1 parent fe6cd14 commit 13f1b3c
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 19 deletions.
16 changes: 15 additions & 1 deletion src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,19 @@
"displayIconButDisableIconClick":"Disable icon click",

"disableDocumentButtonsPopup":"Disable document buttons popup",
"disableDocumentButtonsPopupDesc":"Disable document buttons popup when mouse hovering"
"disableDocumentButtonsPopupDesc":"Disable document buttons popup when mouse hovering",

"enableDoctreeFrontLine": "Enable Doctree Front Line",
"enableDoctreeFrontLineDesc": "Enable Doctree Front Line, you must turn off custom padding and flow layout to take effect",
"doctreeFrontLinePosition": "Doctree Front Line Position",
"doctreeFrontLinePositionDesc": "Define doctree Front Line Position, default is 20, unit: px",
"doctreeFrontLinePadding": "Doctree Front Line Padding",
"doctreeFrontLinePaddingDesc": "Define doctree Front Line Padding, default is 20, unit: px",
"doctreeFrontLineBorder": "Doctree Front Line Border",
"doctreeFrontLineBorderDesc": "Define doctree Front Line Border, default is 2, unit: px",
"enableDoctreeSeperateLine": "Enable Doctree Seperate Line",
"enableDoctreeSeperateLineDesc": "Enable Doctree Seperate Line",
"doctreeSeperateLineBorder": "Doctree Seperate Line Border",
"doctreeSeperateLineBorderDesc": "Define doctree Seperate Line Border, default is 2, unit: px"

}
15 changes: 14 additions & 1 deletion src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,18 @@
"displayIconButDisableIconClickDesc": "显示文档图标但禁用图标点击",
"displayIconButDisableIconClick": "禁用文档图标点击",
"disableDocumentButtonsPopup": "禁用文档按钮气泡",
"disableDocumentButtonsPopupDesc": "禁用鼠标悬停时文档按钮弹出的气泡"
"disableDocumentButtonsPopupDesc": "禁用鼠标悬停时文档按钮弹出的气泡",

"enableDoctreeFrontLine": "文档树层级指示竖线",
"enableDoctreeFrontLineDesc": "启用文档树前线,必须关闭自定义填充和流布局才能生效",
"doctreeFrontLinePosition": "文档树层级竖线位置",
"doctreeFrontLinePositionDesc": "定义文档树层级竖线位置,默认为20,单位:像素",
"doctreeFrontLinePadding": "文档树层级竖线缩进",
"doctreeFrontLinePaddingDesc": "定义文档树层级竖线缩进,默认为20,单位:像素",
"doctreeFrontLineBorder": "文档树层级指示竖线厚度",
"doctreeFrontLineBorderDesc": "定义文档树层级指示竖线厚度,默认为2,单位:像素",
"enableDoctreeSeperateLine": "文档项目树分隔线",
"enableDoctreeSeperateLineDesc": "启用项目间分割线",
"doctreeSeperateLineBorder": "文档树分隔线厚度",
"doctreeSeperateLineBorderDesc": "定义文档树分隔线厚度,默认为2,单位:像素"
}
171 changes: 154 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,48 @@ export default class siyuan_doctree_compress extends Plugin {

}

addFrontLine(_line_location_, _padding_, _border_) {

if (_padding_ >= _line_location_ ){

_padding_ = _line_location_

}

const css = `
.layout-tab-container .b3-list-item > .b3-list-item__toggle {
padding-left: 4px !important;
}
.layout-tab-container ul ul:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: ${_line_location_}px;
border-left: ${_border_}px solid var(--b3-theme-background-light);
}
.layout-tab-container ul ul {
position: relative;
padding-left: ${_padding_}px;
}
`
this.applyStyles(css);
}


addSeperateLine(_border_) {
const css = `
.layout-tab-container .b3-list-item__text {
border-top: ${_border_}px solid #eaecef;
}
`
this.applyStyles(css);
}

rmvDoctreeIcons(_force_) {

const css = _force_ ? `
Expand Down Expand Up @@ -393,6 +435,74 @@ export default class siyuan_doctree_compress extends Plugin {
}
});

this.settingUtils.addItem({
key: "enableDoctreeFrontLine",
value: false,
type: "checkbox",
title: this.i18n.enableDoctreeFrontLine,
description: this.i18n.enableDoctreeFrontLineDesc,
});

this.settingUtils.addItem({
key: "doctreeFrontLinePosition",
value: 20,
type: "slider",
title: this.i18n.doctreeFrontLinePosition,
description: this.i18n.doctreeFrontLinePositionDesc,
slider: {
min: 0,
max: 60,
step: 1,
}
});

this.settingUtils.addItem({
key: "doctreeFrontLinePadding",
value: 20,
type: "slider",
title: this.i18n.doctreeFrontLinePadding,
description: this.i18n.doctreeFrontLinePaddingDesc,
slider: {
min: 6,
max: 60,
step: 1,
}
});

this.settingUtils.addItem({
key: "doctreeFrontLineBorder",
value: 2,
type: "slider",
title: this.i18n.doctreeFrontLineBorder,
description: this.i18n.doctreeFrontLineBorderDesc,
slider: {
min: 1,
max: 20,
step: 1,
}
});

this.settingUtils.addItem({
key: "enableDoctreeSeperateLine",
value: false,
type: "checkbox",
title: this.i18n.enableDoctreeSeperateLine,
description: this.i18n.enableDoctreeSeperateLineDesc,
});

this.settingUtils.addItem({
key: "doctreeSeperateLineBorder",
value: 2,
type: "slider",
title: this.i18n.doctreeSeperateLineBorder,
description: this.i18n.doctreeSeperateLineBorderDesc,
slider: {
min: 1,
max: 20,
step: 1,
}
});

this.settingUtils.addItem({
key: "hideIcon",
value: false,
Expand Down Expand Up @@ -584,23 +694,41 @@ export default class siyuan_doctree_compress extends Plugin {
const _overloadLineHeight_ = this.settingUtils.get("overloadLineHeight");
const _overloadLineHeightForce_ = this.settingUtils.get("overloadLineHeightForce");
const _overloadLineHeightPx_ = this.settingUtils.get("overloadLineHeightPx");

// 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_
// });
const _enableDoctreeFrontLine_ = this.settingUtils.get("enableDoctreeFrontLine");
const _doctreeFrontLinePosition_ = this.settingUtils.get("doctreeFrontLinePosition");
const _doctreeFrontLinePadding_ = this.settingUtils.get("doctreeFrontLinePadding");
const _doctreeFrontLineBorder_ = this.settingUtils.get("doctreeFrontLineBorder");
const _enableDoctreeSeperateLine_ = this.settingUtils.get("enableDoctreeSeperateLine");
const _doctreeSeperateLineBorder_ = this.settingUtils.get("doctreeSeperateLineBorder");

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_,
});


/*条件列表:
Expand All @@ -613,6 +741,7 @@ export default class siyuan_doctree_compress extends Plugin {

if ((_currentDeviceInList_ || !_onlyEnableListedDevices_) && _mainSwitchStat_) { //main swtich and per deivce condition selecter


if (_overloadLineHeight_) { //overload line height sel
this.overloadLineHeight(_overloadLineHeightForce_, _overloadLineHeightPx_);
}
Expand Down Expand Up @@ -660,6 +789,14 @@ export default class siyuan_doctree_compress extends Plugin {
this.disableDocumentButtonsPopup();
}

if(_enableDoctreeFrontLine_ && !_mouseoverZeroPadding_&& !_enableAdjustStaticDoctreePadding_){
this.addFrontLine(_doctreeFrontLinePosition_, _doctreeFrontLinePadding_, _doctreeFrontLineBorder_);
}

if(_enableDoctreeSeperateLine_){
this.addSeperateLine(_doctreeSeperateLineBorder_);
}


if (!_mouseoverZeroPadding_ && _enableAdjustStaticDoctreePadding_) { //主开关打开 && 鼠标悬停零缩进关闭 && 分别缩进开关启用

Expand Down

0 comments on commit 13f1b3c

Please sign in to comment.