Skip to content

Commit d35eaa0

Browse files
committed
no message
1 parent 0e60b60 commit d35eaa0

File tree

2 files changed

+8
-42
lines changed

2 files changed

+8
-42
lines changed

markdown-toc-code/css/content.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
right: 0px;
77
top: 60px;
88
background: gainsboro;
9-
109
}
1110
#panel ul{
1211
list-style: none;
@@ -17,4 +16,4 @@
1716
#panel ul li a{
1817
display: block;
1918
text-overflow: ellipsis;
20-
}
19+
}

markdown-toc-code/js/content-script.js

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setTimeout(function () {
2121

2222
// 初始化
2323
function init(list) {
24-
var toc = document.createElement("ul");
24+
var toc = document.createElement("div");
2525
addStyle(toc, {
2626
"position": "fixed",
2727
"margin-right": "20px",
@@ -36,9 +36,11 @@ function init(list) {
3636
"bottom": "20px",
3737
"overflow-x": "hidden",
3838
"overflow": "auto",
39-
// "background": "gainsboro",
39+
"background-color": "#fafbfc",
4040
"border": "1px solid #d1d5da",
41+
"cursor":"e-resize"
4142
})
43+
var toc_ul = document.createElement("ul");
4244
var stack = new Array();
4345

4446

@@ -75,46 +77,11 @@ function init(list) {
7577
}
7678
a.setAttribute("href", hreftagname);
7779
// li.appendChild(a);
78-
toc.appendChild(li);
79-
toc.lastChild.appendChild(a);
80-
81-
82-
83-
// var level = parseInt(header.tagName.replace('H', ''), 10);
84-
// // 通过两个where循环对栈进行调整,确保stack中标题级数与当前标题级数相同
85-
// while (stack.length < level) {
86-
// stack.push(0);
87-
// }
88-
// while (stack.length > level) {
89-
// stack.pop();
90-
// }
91-
// // debugger;
92-
93-
94-
// // 最小一级标题标号步进 + 1
95-
// stack[stack.length - 1]++;
96-
// // 生成标题标号( 1.1,1.2.. )
97-
// var index = stack.join(".")
98-
// // 生成标题ID
99-
// var id = "title" + index;
100-
// header.setAttribute('id', id);
101-
// var li = document.createElement("li");
102-
// addStyle(li, {
103-
// "listStyle": "none",
104-
// })
105-
// toc.appendChild(li);
106-
// var a = document.createElement("a");
107-
// addStyle(a, {
108-
// "color": "#0366d6",
109-
// "textOverflow ": "ellipsis"
110-
// })
111-
// // 为目录项设置链接
112-
// a.setAttribute("href", "#" + id)
113-
// // 目录项文本前面放置缩进空格
114-
// a.innerHTML = new Array(level * 4).join('&nbsp;') + index + new Array(2).join('&nbsp;') + header.textContent;
115-
// toc.lastChild.appendChild(a);
80+
toc_ul.appendChild(li);
81+
toc_ul.lastChild.appendChild(a);
11682

11783
}
84+
toc.appendChild(toc_ul);
11885
return toc;
11986
}
12087

0 commit comments

Comments
 (0)