Skip to content

Commit 54ff797

Browse files
committed
增加 bold 样式
感谢 @QuestionWorks 的贡献。
1 parent a85e7fa commit 54ff797

File tree

4 files changed

+170
-35
lines changed

4 files changed

+170
-35
lines changed

build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "floating-toc",
33
"name": "floating toc",
4-
"version": "2.4.9",
4+
"version": "2.5.2",
55
"minAppVersion": "0.14.0",
66
"description": "This is a floating Toc plugin that hovers a table of content containing a header level on the notes sidebar.",
77
"author": "Cuman",

src/components/floatingtocUI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export async function createLi(
140140
index: number
141141
) {
142142
// 检查是否是大型文档
143-
const isLargeDocument = plugin.headingdata && plugin.headingdata.length > 30;
143+
const isLargeDocument = plugin.headingdata && plugin.headingdata.length > 100;
144144
let li_dom = ul_dom.createEl("li");
145145
li_dom.addClass("heading-list-item");
146146
li_dom.setAttribute("data-level", heading.level.toString());

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export default class FloatingToc extends Plugin {
298298
view
299299
? refresh_node(this, view)
300300
? false
301-
: creatToc(app, this)
301+
: creatToc(this.app, this)
302302
: false;
303303
};
304304
// let isLoadOnMobile = this.settings.isLoadOnMobile;

styles.css

Lines changed: 167 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,22 @@ settings:
224224
label: line
225225
value: float-outline-style
226226
-
227-
id: enable-bar-icon
228-
title: Replace the indicator bar with an icon
229-
title.zh: 用图标代替指示条
230-
type: class-toggle
231-
default: false
227+
id: enable-bar-style
228+
title: enable bar style
229+
title.zh: 指示条样式
230+
type: class-select
231+
allowEmpty: false
232+
default: default-bar-style
233+
options:
234+
-
235+
label: Default
236+
value: default-bar-style
237+
-
238+
label: Icon
239+
value: enable-bar-icon
240+
-
241+
label: bold
242+
value: enable-bold-bar
232243
-
233244
id: enable-bar-heading-text
234245
title: Show heading text next to indicator bar (including parent)
@@ -394,7 +405,7 @@ font-weight: bold !important;
394405
.heading-list-item .line-wrap .line {
395406
position: absolute;
396407
top: 50%;
397-
margin-top: calc(2px / -2);
408+
398409
height: 2px;
399410
width: 1.5rem;
400411
background: var(--floating-toc-line-color);
@@ -483,11 +494,118 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
483494
margin-left: 2.5rem;
484495

485496
}
497+
body.enable-bold-bar .heading-list-item .text-wrap {
498+
margin-left: unset!important;
499+
}
500+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item[data-level="1"] .heading-rendered::before,
501+
body.enable-bold-bar .floating-toc-div.hover .heading-list-item[data-level="1"] .heading-rendered::before
502+
{
503+
margin-left: 1rem;
504+
}
505+
506+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item[data-level="2"] .heading-rendered::before,
507+
body.enable-bold-bar .floating-toc-div.hover .heading-list-item[data-level="2"] .heading-rendered::before
508+
{
509+
margin-left: 1.5rem;
510+
}
511+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item[data-level="3"] .heading-rendered::before,
512+
body.enable-bold-bar .floating-toc-div.hover .heading-list-item[data-level="3"] .heading-rendered::before
513+
{
514+
margin-left: 2rem;
515+
}
516+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item[data-level="4"] .heading-rendered::before,
517+
body.enable-bold-bar .floating-toc-div.hover .heading-list-item[data-level="4"] .heading-rendered::before
518+
{
519+
margin-left: 2.5rem;
520+
}
521+
522+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item[data-level="5"] .heading-rendered::before,
523+
body.enable-bold-bar .floating-toc-div.hover .heading-list-item[data-level="5"] .heading-rendered::before
524+
{
525+
margin-left: 3rem;
526+
}
527+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item[data-level="6"] .heading-rendered::before,
528+
body.enable-bold-bar .floating-toc-div.hover .heading-list-item[data-level="6"] .heading-rendered::before
529+
{
530+
margin-left: 3.5rem;
531+
}
532+
533+
534+
535+
486536

487-
.heading-list-item[data-level="1"] {
537+
538+
body.enable-bold-bar .heading-list-item[data-level="1"] .text-wrap .text {
539+
margin-left: 1.6rem;
540+
541+
}
542+
body.enable-bold-bar .heading-list-item[data-level="2"] .text-wrap .text {
543+
margin-left: 2rem;
544+
545+
}
546+
body.enable-bold-bar .heading-list-item[data-level="3"] .text-wrap .text {
547+
margin-left: 2.5rem;
548+
}
549+
body.enable-bold-bar .heading-list-item[data-level="4"] .text-wrap .text {
550+
margin-left: 3rem;
551+
}
552+
body.enable-bold-bar .heading-list-item[data-level="5"] .text-wrap .text {
553+
margin-left: 3.5rem;
554+
555+
}
556+
body.enable-bold-bar .heading-list-item[data-level="6"] .text-wrap .text {
557+
margin-left: 4rem;
558+
}
559+
560+
/*enable-bold-ba*/
561+
body.enable-bold-bar .heading-list-item[data-level="1"] .line-wrap .line {
562+
width: 20px;
563+
}
564+
body.enable-bold-bar .heading-list-item[data-level="2"] .line-wrap .line {
565+
width: 18px;
566+
}
567+
body.enable-bold-bar .heading-list-item[data-level="3"] .line-wrap .line {
568+
width: 16px;
569+
}
570+
body.enable-bold-bar .heading-list-item[data-level="4"] .line-wrap .line {
571+
width: 14px;
572+
}
573+
body.enable-bold-bar .heading-list-item[data-level="5"] .line-wrap .line {
574+
width: 12px;
575+
}
576+
body.enable-bold-bar .heading-list-item[data-level="6"] .line-wrap .line {
577+
width: 10px;
578+
}
579+
580+
body.enable-bold-bar .heading-list-item:hover .line-wrap .line
581+
{
582+
opacity: 0.8;
583+
}
584+
585+
.heading-list-item[data-level="1"] {
488586
padding-left: 0rem;
489587
}
490588

589+
.heading-list-item[data-level="2"] {
590+
padding-left: 0.5rem;
591+
}
592+
593+
.heading-list-item[data-level="3"] {
594+
padding-left: 1rem;
595+
}
596+
597+
.heading-list-item[data-level="4"] {
598+
padding-left: 1.5rem;
599+
}
600+
601+
.heading-list-item[data-level="5"] {
602+
padding-left: 1.6rem;
603+
}
604+
605+
.heading-list-item[data-level="6"] {
606+
padding-left: 1.8rem;
607+
}
608+
491609
.heading-list-item[data-level="1"] .text::after {
492610
content: "H1";
493611
font-size: 8px;
@@ -497,9 +615,6 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
497615
padding: 1px 2px 1px 2px;
498616
}
499617

500-
.heading-list-item[data-level="2"] {
501-
padding-left: 0.5rem;
502-
}
503618

504619
.heading-list-item[data-level="2"] .text::after {
505620
content: "H2";
@@ -510,10 +625,6 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
510625
padding: 1px 2px 1px 2px;
511626
}
512627

513-
.heading-list-item[data-level="3"] {
514-
padding-left: 1rem;
515-
}
516-
517628
.heading-list-item[data-level="3"] .text::after {
518629
content: "H3";
519630
font-size: 8px;
@@ -523,9 +634,7 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
523634
padding: 1px 2px 1px 2px;
524635
}
525636

526-
.heading-list-item[data-level="4"] {
527-
padding-left: 1.5rem;
528-
}
637+
529638

530639
.heading-list-item[data-level="4"] .text::after {
531640
content: "H4";
@@ -536,9 +645,7 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
536645
padding: 1px 2px 1px 2px;
537646
}
538647

539-
.heading-list-item[data-level="5"] {
540-
padding-left: 1.6rem;
541-
}
648+
542649

543650
.heading-list-item[data-level="5"] .text::after {
544651
content: "H5";
@@ -549,9 +656,6 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
549656
padding: 1px 2px 1px 2px;
550657
}
551658

552-
.heading-list-item[data-level="6"] {
553-
padding-left: 1.8rem;
554-
}
555659

556660
.heading-list-item[data-level="6"] .text::after {
557661
content: "H6";
@@ -562,6 +666,15 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
562666
padding: 1px 2px 1px 2px;
563667
}
564668

669+
body.enable-bold-bar .floating-toc-div.pin .heading-list-item>.line-wrap,
670+
body.enable-bold-bar .floating-toc:hover .heading-list-item>.line-wrap {
671+
display: block;
672+
673+
}
674+
675+
676+
677+
565678
.view-content:has(.markdown-source-view.hide-floating-toc) .floating-toc {
566679
display: none;
567680
}
@@ -587,7 +700,8 @@ body.enable-heading-nowrap .heading-list-item .text-wrap .text {
587700
-ms-overflow-style: none;
588701
scrollbar-width: none;
589702

590-
min-height: max-content;
703+
min-height: auto;
704+
height: fit-content;
591705
z-index: 2;
592706
}
593707

@@ -747,7 +861,11 @@ body.enable-heading-nowrap .floating-toc:hover .heading-list-item>.text-wrap {
747861
text-align: right;
748862
display: inline-flex;
749863
}
750-
864+
.floating-toc .heading-list-item
865+
{
866+
display: flex;
867+
align-items: center;
868+
}
751869
/****pin button***/
752870

753871
.floating-right.floating-toc-div .toolbar.pin {
@@ -925,15 +1043,27 @@ heading-list-item.focus .text {
9251043

9261044

9271045
/****enable-bar-heading-text**/
928-
1046+
body.enable-bold-bar .heading-list-item{
1047+
padding-left: 0.5rem;
1048+
}
1049+
body.enable-bold-bar .floating-toc-div:is(.hover, .pin) .floating-toc .heading-list-item
1050+
{
1051+
padding-left: 0.5rem;
1052+
}
9291053
body.enable-bar-heading-text .floating-toc-div:not(:is(.hover, .pin)) .heading-list-item:is(.located, .focus) {
9301054
width: unset;
1055+
overflow: visible;
1056+
}
1057+
body.enable-bar-heading-text .floating-toc-div:not(:is(.hover, .pin)) .floating-toc{
1058+
width: 2rem;
1059+
overflow: visible;
9311060
}
932-
9331061
body.enable-bar-heading-text .floating-toc-div:not(:is(.hover, .pin)) .heading-list-item:is(.located, .focus) .text-wrap {
9341062
opacity: 1;
935-
margin-left: 10px;
936-
1063+
1064+
}
1065+
body.enable-bar-heading-text .heading-list-item:is(.located, .focus) .text-wrap .text{
1066+
background-color: var(--background-secondary);
9371067
}
9381068

9391069
body.enable-bar-heading-text .floating-toc-div:not(:is(.hover, .pin)) .heading-list-item:is(.located, .focus) .text-wrap .text {
@@ -948,6 +1078,12 @@ body.enable-bar-heading-text .floating-toc-div:not(:is(.hover, .pin)) .heading-l
9481078
content: '';
9491079
margin-left: 0.2rem;
9501080
}
1081+
body.enable-bold-bar .floating-toc-div .heading-list-item .line-wrap .line
1082+
{
1083+
height: 4px;
1084+
max-width: 20px;
1085+
border-radius: 20px;
1086+
}
9511087

9521088
.heading-list-item.focus .text-wrap .text {
9531089
font-weight: bolder;
@@ -1395,6 +1531,7 @@ body.float-outline-style .heading-list-item[data-level='6']+.heading-list-item[d
13951531
} */
13961532

13971533
/* 对于折叠状态 */
1534+
13981535
.floating-toc-div.pin .heading-list-item[isCollapsed="true"] .heading-rendered::before,
13991536
.floating-toc-div.hover .heading-list-item[isCollapsed="true"] .heading-rendered::before {
14001537
/* content: '▶'; */
@@ -1444,6 +1581,4 @@ body.float-outline-style .heading-list-item[data-level='6']+.heading-list-item[d
14441581
align-items: center;
14451582
}
14461583

1447-
.floating-toc>.toolbar+.heading-list-item {
1448-
padding-top: 0.5rem;
1449-
}
1584+

0 commit comments

Comments
 (0)