Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
折羽之殇
Awesome-Markdown-Editor
提交
1302ee2c
Awesome-Markdown-Editor
项目概览
折羽之殇
/
Awesome-Markdown-Editor
与 Fork 源项目一致
Fork自
gitcode_dev / Awesome-Markdown-Editor
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Awesome-Markdown-Editor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1302ee2c
编写于
11月 02, 2021
作者:
郭
郭维嘉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:优化目录生成规则
上级
4665e8e3
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
57 addition
and
36 deletion
+57
-36
dist/markdown-editor.js
dist/markdown-editor.js
+1
-1
src/App.vue
src/App.vue
+14
-11
src/assets/style/global.less
src/assets/style/global.less
+16
-16
src/components/content/components/help-doc.vue
src/components/content/components/help-doc.vue
+5
-0
src/components/content/components/toc-doc.vue
src/components/content/components/toc-doc.vue
+17
-3
src/components/content/mixins/render-mixins.js
src/components/content/mixins/render-mixins.js
+1
-4
src/components/header/md-header.vue
src/components/header/md-header.vue
+1
-1
webpack.config.js
webpack.config.js
+2
-0
未找到文件。
dist/markdown-editor.js
浏览文件 @
1302ee2c
此差异已折叠。
点击以展开。
src/App.vue
浏览文件 @
1302ee2c
...
...
@@ -325,6 +325,7 @@ export default {
text
:
this
.
text
,
html
:
this
.
html
});
this
.
addTocClickToBody
();
},
0
);
},
watch
:
{
...
...
@@ -488,22 +489,13 @@ export default {
tocEls
.
forEach
(
el
=>
{
el
.
innerHTML
=
`<ul class="md_toc_list">
${
dirTags
.
map
(
tag
=>
{
return
`<li class="md_toc_item
" data-type="
${
tag
.
tag
}
" data-id
="
${
tag
.
id
}
">
${
tag
.
text
}
</li>`
;
return
`<li class="md_toc_item
type_
${
tag
.
tag
}
" href
="
${
tag
.
id
}
">
${
tag
.
text
}
</li>`
;
})
.
join
(
""
)}
</ul>`
;
});
this
.
html
=
vDom
.
innerHTML
;
// console.log(document.querySelectorAll(".md_toc_list"));
document
.
querySelector
(
"
body
"
).
addEventListener
(
"
click
"
,
function
(
e
)
{
if
(
!
e
.
target
?.
className
.
includes
(
"
md_toc_item
"
))
return
;
console
.
log
(
e
.
target
.
dataset
.
id
);
const
targetEl
=
document
.
getElementById
(
e
.
target
?.
dataset
?.
id
);
if
(
!
targetEl
)
return
;
targetEl
.
scrollIntoView
({
behavior
:
"
smooth
"
});
});
},
renderLinksHtml
({
vDom
,
links
})
{
// 缓存里没有的链接,就发送请求获取信息
...
...
@@ -549,10 +541,21 @@ export default {
const
title
=
getLinkTitle
(
linkEl
,
item
);
linkEl
.
innerHTML
=
renderLinkCard
(
title
,
item
);
});
this
.
html
=
vDom
.
innerHTML
;
}
});
},
addTocClickToBody
()
{
document
.
querySelector
(
"
body
"
).
addEventListener
(
"
click
"
,
function
(
e
)
{
if
(
!
e
.
target
?.
className
.
includes
(
"
md_toc_item
"
))
return
;
const
targetEl
=
document
.
getElementById
(
e
.
target
?.
getAttribute
(
"
href
"
)
);
if
(
!
targetEl
)
return
;
targetEl
.
scrollIntoView
({
behavior
:
"
smooth
"
});
});
}
}
};
...
...
src/assets/style/global.less
浏览文件 @
1302ee2c
...
...
@@ -88,35 +88,35 @@ textarea {
.md_toc_list {
li.md_toc_item {
list-style-type: none;
list-style: disc;
// list-style-type: none;
cursor: pointer;
color: var(--md-editor-border-color-active);
position: relative;
margin: 12px 8px;
&::before {
content: "\·";
font-size: 20px;
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
&[data-type="h1"] {
// &::before {
// content: "\·";
// font-size: 20px;
// position: absolute;
// left: 0;
// top: 50%;
// transform: translateY(-50%);
// }
&.type_h1 {
padding-left: 20px;
}
&
[data-type="h2"]
{
&
.type_h2
{
padding-left: 30px;
}
&
[data-type="h3"]
{
&
.type_h3
{
padding-left: 40px;
}
&
[data-type="h4"]
{
&
.type_h4
{
padding-left: 50px;
}
&
[data-type="h5"]
{
&
.type_h5
{
padding-left: 60px;
}
&
[data-type="h6"]
{
&
.type_h6
{
padding-left: 70px;
}
}
...
...
src/components/content/components/help-doc.vue
浏览文件 @
1302ee2c
...
...
@@ -60,6 +60,11 @@ export default {
doc
:
"
[链接标题](url)
"
,
icon
:
"
lianjie
"
},
{
title
:
"
目录
"
,
doc
:
"
[toc](目录)
"
,
icon
:
"
dir
"
},
{
title
:
"
图片
"
,
doc
:
"
![alt](url)
"
,
...
...
src/components/content/components/toc-doc.vue
浏览文件 @
1302ee2c
...
...
@@ -72,10 +72,24 @@ export default {
scrollToTitle
(
item
)
{
const
targetEl
=
document
.
getElementById
(
item
.
id
);
if
(
!
targetEl
)
return
;
const
targetOffsetTop
=
targetEl
.
offsetTop
;
document
.
querySelector
(
const
scrollEl
=
document
.
querySelector
(
"
.md_preview .md_preview_scroll_container
"
).
scrollTop
=
targetOffsetTop
;
);
if
(
scrollEl
.
scrollHeight
>
scrollEl
.
clientHeight
||
scrollEl
.
offsetHeight
>
scrollEl
.
clientHeight
)
{
const
targetOffsetTop
=
targetEl
.
offsetTop
;
scrollEl
.
scrollTop
=
targetOffsetTop
;
}
else
{
targetEl
.
scrollIntoView
({
behavior
:
"
smooth
"
});
}
// const targetOffsetTop = targetEl.offsetTop;
// document.querySelector(
// ".md_preview .md_preview_scroll_container"
// ).scrollTop = targetOffsetTop;
},
dirItemActive
(
item
)
{
const
itemScrollTop
=
document
.
getElementById
(
item
.
id
)?.
offsetTop
;
...
...
src/components/content/mixins/render-mixins.js
浏览文件 @
1302ee2c
...
...
@@ -81,8 +81,6 @@ export default {
src="
${
href
}
"
></video></p>`
;
}
console
.
log
(
"
imgimgimg
"
);
// ![img](...)渲染图片
let
out
=
'
<p class="md_img_container"><img src="
'
+
...
...
@@ -144,7 +142,6 @@ export default {
return
"
<h
"
+
level
+
"
>
"
+
text
+
"
</h
"
+
level
+
"
>
\n
"
;
},
link
(
href
,
title
,
text
)
{
console
.
log
(
"
linklink
"
);
if
(
text
?.
toLowerCase
()
===
"
toc
"
)
{
return
`
<h1 class="toc_title">
${
href
}
</h1>
...
...
@@ -194,7 +191,7 @@ export default {
return
`<span style="display:inline-block;text-indent:2em;">
${
val
}
</span>`
;
})
.
replace
(
/
\[
TOC
\]
/i
,
/
@
?
\[
TOC
\]
/i
,
`<h1 class="toc_title">目录</h1><div class="tocEl"></div>`
);
...
...
src/components/header/md-header.vue
浏览文件 @
1302ee2c
...
...
@@ -197,7 +197,7 @@ export default {
{
name
:
"
call
"
,
icon
:
"
aite
"
,
tip
:
"
@
好友
"
,
tip
:
"
@
关注的人
"
,
startStr
:
"
@
"
,
endStr
:
""
},
...
...
webpack.config.js
浏览文件 @
1302ee2c
...
...
@@ -8,6 +8,8 @@ module.exports = {
},
devServer
:
{
contentBase
:
path
.
resolve
(
__dirname
,
"
dist
"
),
host
:
"
0.0.0.0
"
,
https
:
true
,
open
:
true
},
resolve
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录