Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
璃白.
markdown-editor
提交
7274a5e1
M
markdown-editor
项目概览
璃白.
/
markdown-editor
上一次同步 接近 2 年
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
markdown-editor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7274a5e1
编写于
6月 17, 2021
作者:
璃白.
🌻
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:添加深夜模式
上级
02f55966
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
124 addition
and
18 deletion
+124
-18
dist/index.html
dist/index.html
+18
-3
dist/markdown-editor.js
dist/markdown-editor.js
+1
-1
package.json
package.json
+1
-1
src/App.vue
src/App.vue
+24
-1
src/assets/js/utils.js
src/assets/js/utils.js
+35
-1
src/assets/style/markdown.less
src/assets/style/markdown.less
+3
-3
src/assets/style/variable.less
src/assets/style/variable.less
+3
-0
src/components/content/md-preview.vue
src/components/content/md-preview.vue
+1
-1
src/components/content/md-textarea.vue
src/components/content/md-textarea.vue
+17
-2
src/components/footer/md-footer.vue
src/components/footer/md-footer.vue
+9
-5
src/main.js
src/main.js
+12
-0
未找到文件。
dist/index.html
浏览文件 @
7274a5e1
...
...
@@ -5,7 +5,12 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
Document
</title>
<style></style>
<style>
.md_container
{
width
:
600px
!important
;
margin
:
40px
auto
;
}
</style>
</head>
<body>
<div
id=
"app"
></div>
...
...
@@ -13,8 +18,9 @@
<script>
new
MdEditor
({
el
:
"
#app
"
,
// required
value
:
""
,
value
:
"
34567567567
"
,
themeOptions
:
{
dark
:
true
,
borderColor
:
"
#dbdbdb
"
,
borderColorActive
:
"
#409eff
"
,
textColor
:
"
#303030
"
,
...
...
@@ -30,14 +36,23 @@
ol
:
true
,
task
:
true
,
table
:
true
,
full
s
creen
:
true
full
S
creen
:
true
},
canPreview
:
true
,
canAttachFile
:
true
,
placeholder
:
"
请输入内容
"
,
onFocus
:
function
(
res
)
{
console
.
log
(
res
);
},
onBlur
:
function
(
res
)
{
console
.
log
(
res
);
},
onChange
:
function
(
res
)
{
console
.
log
(
res
);
},
onSubmit
:
function
(
res
)
{
console
.
log
(
res
);
},
onUpload
:
function
(
file
,
callback
)
{
new
Promise
((
res
,
rej
)
=>
{
setTimeout
(()
=>
{
...
...
dist/markdown-editor.js
浏览文件 @
7274a5e1
此差异已折叠。
点击以展开。
package.json
浏览文件 @
7274a5e1
{
"name"
:
"markdown-editor"
,
"description"
:
" A open source markdown editor of csdn codechina team contributed"
,
"version"
:
"0.
1
.1"
,
"version"
:
"0.
3
.1"
,
"publisher"
:
"guoweijia"
,
"scripts"
:
{
"start"
:
"webpack serve --mode=development"
,
...
...
src/App.vue
浏览文件 @
7274a5e1
...
...
@@ -9,7 +9,7 @@
:toolsOptions=
"toolsOptions"
:fullScreen.sync=
"fullScreen"
/>
<markdownPreview
:text=
"text"
:html.sync=
"html"
v-show=
"showPreview"
/>
<markdownPreview
:text=
"text"
:html.sync=
"html"
v-show=
"showPreview"
/>
<markdown-editor
:selectionInfo.sync=
"selectionInfo"
:text.sync=
"text"
...
...
@@ -17,6 +17,7 @@
:placeholder=
"placeholder"
:isFocus.sync=
"isFocus"
:fullScreen.sync=
"fullScreen"
@
submit=
"submit"
v-show=
"!showPreview"
/>
<markdown-footer
...
...
@@ -88,6 +89,19 @@ export default {
});
}
},
isFocus
:
{
handler
:
function
(
val
)
{
const
value
=
{
text
:
this
.
text
,
html
:
this
.
html
};
if
(
val
)
{
this
.
$emit
(
"
focus
"
,
value
);
}
else
{
this
.
$emit
(
"
blur
"
,
value
);
}
}
},
value
:
{
immediate
:
true
,
handler
:
function
(
val
)
{
...
...
@@ -117,12 +131,21 @@ export default {
this
.
fileList
=
[];
}
}
},
methods
:
{
submit
()
{
this
.
$emit
(
"
submit
"
,
{
text
:
this
.
text
,
html
:
this
.
html
});
}
}
};
</
script
>
<
style
lang=
"less"
scoped
>
.md_container {
width: 100%;
background: var(--md-editor-frame-bg-color);
// margin: 200px auto;
border: 1px solid var(--md-editor-border-color);
border-radius: 4px;
...
...
src/assets/js/utils.js
浏览文件 @
7274a5e1
...
...
@@ -40,11 +40,45 @@ export function formatText(text, selectionInfo, startStr = "", endStr = "") {
// 初始化样式
export
function
initStyle
({
dark
,
borderColor
,
borderColorActive
,
textColor
,
textColorActive
textColorActive
,
frameBgColor
,
contentBgColor
,
codeBgColor
})
{
// 夜晚模式
if
(
dark
)
{
borderColor
=
"
#b2b2b2
"
;
borderColorActive
=
"
#fff
"
;
textColor
=
"
#fff
"
;
textColorActive
=
"
#fff
"
;
frameBgColor
=
"
#343434
"
;
codeBgColor
=
"
#484848
"
;
contentBgColor
=
"
#484848
"
;
}
if
(
frameBgColor
)
{
document
.
documentElement
.
style
.
setProperty
(
"
--md-editor-frame-bg-color
"
,
frameBgColor
);
}
if
(
contentBgColor
)
{
document
.
documentElement
.
style
.
setProperty
(
"
--md-editor-content-bg-color
"
,
contentBgColor
);
}
if
(
codeBgColor
)
{
document
.
documentElement
.
style
.
setProperty
(
"
--md-editor-code-bg-color
"
,
codeBgColor
);
}
if
(
borderColor
)
{
document
.
documentElement
.
style
.
setProperty
(
"
--md-editor-border-color
"
,
...
...
src/assets/style/markdown.less
浏览文件 @
7274a5e1
...
...
@@ -106,7 +106,7 @@
}
p {
font-size: 18px;
color:
#4d4d4d
;
color:
var(--md-editor-text-color-active)
;
font-weight: 400;
line-height: 26px !important;
margin: 0 0 16px;
...
...
@@ -244,14 +244,14 @@
}
}
&:not(.hljs) {
background-color:
#f3f4f5
;
background-color:
var(--md-editor-code-bg-color)
;
}
}
}
code {
border-radius: 4px;
display: inline-block;
background-color:
#f3f4f5
;
background-color:
var(--md-editor-code-bg-color)
;
padding: 2px 6px;
font-family: -apple-system, SF UI Text, Arial, PingFang SC, Hiragino Sans GB,
Microsoft YaHei, WenQuanYi Micro Hei, sans-serif, SimHei, SimSun;
...
...
src/assets/style/variable.less
浏览文件 @
7274a5e1
...
...
@@ -3,4 +3,7 @@
--md-editor-border-color-active: #409eff;
--md-editor-text-color: #303030;
--md-editor-text-color-active: #000;
--md-editor-frame-bg-color: #fff;
--md-editor-content-bg-color: #fff;
--md-editor-code-bg-color: #f3f4f5;
}
src/components/content/md-preview.vue
浏览文件 @
7274a5e1
...
...
@@ -29,7 +29,7 @@ export default {
}
});
const
str
=
val
+
""
;
if
(
!
str
.
trim
())
return
;
//
if (!str.trim()) return;
const
html
=
marked
(
str
);
this
.
$emit
(
"
update:html
"
,
html
);
}
...
...
src/components/content/md-textarea.vue
浏览文件 @
7274a5e1
<
template
>
<div
:class=
"['md_textarea',
{ fullScreen }]">
<div
:class=
"['md_textarea',
{ fullScreen
, isFocus
}]">
<textarea
:id=
"id"
@
change=
"$emit('update:text', textContent)"
@
focus=
"setFocus(true)"
@
blur=
"setFocus(false)"
@
paste=
"pasteFile"
@
keydown.meta.enter.exact=
"submit"
@
keydown.ctrl.enter.exact=
"submit"
v-model=
"textContent"
:placeholder=
"placeholder"
rows=
"10"
...
...
@@ -69,6 +71,9 @@ export default {
},
methods
:
{
submit
()
{
this
.
$emit
(
"
submit
"
);
},
setFocus
(
val
)
{
this
.
$emit
(
"
update:isFocus
"
,
val
);
},
...
...
@@ -104,7 +109,16 @@ export default {
.md_textarea {
position: relative;
padding: 10px 0;
background: #fff;
background: var(--md-editor-content-bg-color);
border-left: 1px solid var(--md-editor-border-color);
border-right: 1px solid var(--md-editor-border-color);
transition: border 0.3s;
padding: 14px;
box-sizing: border-box;
&.isFocus {
border-left: 1px solid var(--md-editor-border-color-active);
border-right: 1px solid var(--md-editor-border-color-active);
}
&.fullScreen {
position: fixed;
width: 100vw;
...
...
@@ -124,6 +138,7 @@ export default {
width: 100%;
height: 100%;
box-sizing: border-box;
background: var(--md-editor-content-bg-color);
color: var(--md-editor-text-color);
resize: none;
font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas",
...
...
src/components/footer/md-footer.vue
浏览文件 @
7274a5e1
<
template
>
<div
:class=
"['md_footer',
{ active: isFocus }]">
<div
class=
"doc"
></div>
<upload-files
@
changeFileList=
"$emit('update:fileList', $event)"
:fileList=
"fileList"
v-if=
"canAttachFile"
/>
<upload-files
@
changeFileList=
"$emit('update:fileList', $event)"
:fileList=
"fileList"
v-if=
"canAttachFile"
/>
</div>
</
template
>
<
script
>
...
...
@@ -9,19 +13,19 @@ import uploadFiles from "./upload-files";
export
default
{
components
:
{
uploadFiles
},
props
:
{
isFocus
:
{
isFocus
:
{
type
:
Boolean
,
default
:
false
},
canAttachFile
:
{
canAttachFile
:
{
type
:
Boolean
,
default
:
false
},
fileList
:
{
type
:
Array
,
default
:
()
=>
[]
default
:
()
=>
[]
}
}
,
}
};
</
script
>
<
style
lang=
"less"
scoped
>
...
...
src/main.js
浏览文件 @
7274a5e1
...
...
@@ -12,6 +12,9 @@ function initMdEditor(obj) {
el
,
onChange
,
onUpload
,
onFocus
,
onBlur
,
onSubmit
,
placeholder
,
value
,
canPreview
,
...
...
@@ -29,6 +32,15 @@ function initMdEditor(obj) {
change
(
val
)
{
onChange
(
val
);
},
focus
(
val
)
{
onFocus
(
val
);
},
blur
(
val
)
{
onBlur
(
val
);
},
submit
(
val
)
{
onSubmit
(
val
);
},
upload
({
val
,
callback
})
{
onUpload
(
val
,
function
(
res
)
{
callback
(
res
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录