Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
风云海OL
Awesome-Markdown-Editor
提交
5bf8ed03
Awesome-Markdown-Editor
项目概览
风云海OL
/
Awesome-Markdown-Editor
与 Fork 源项目一致
Fork自
gitcode_dev / Awesome-Markdown-Editor
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Awesome-Markdown-Editor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5bf8ed03
编写于
6月 29, 2021
作者:
璃白.
🌻
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
419e5679
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
30 deletion
+58
-30
src/App.vue
src/App.vue
+7
-0
src/components/content/md-preview.vue
src/components/content/md-preview.vue
+5
-3
src/components/content/md-textarea.vue
src/components/content/md-textarea.vue
+1
-1
src/components/header/md-header.vue
src/components/header/md-header.vue
+27
-22
src/components/header/tool-button.vue
src/components/header/tool-button.vue
+16
-4
src/main.js
src/main.js
+2
-0
未找到文件。
src/App.vue
浏览文件 @
5bf8ed03
...
...
@@ -13,6 +13,7 @@
:canPreview=
"canPreview"
:toolsOptions=
"toolsOptions"
:zIndex=
"zIndex"
:tabSize=
"tabSize"
:fullScreen.sync=
"fullScreen"
:themeOptions=
"themeOptions"
@
upload=
"$refs.mdUploadFile.click()"
...
...
@@ -51,6 +52,7 @@
:ref=
"'md_textarea' + id"
@
tab=
"$refs['md_header' + id].tab()"
@
submit=
"submit"
@
enter=
"$refs['md_header' + id].resetUlNum()"
v-else
/>
<div
v-if=
"maxLength && showWordLimit && !showPreview"
class=
"word_limit"
>
...
...
@@ -88,6 +90,10 @@ export default {
type
:
String
,
default
:
""
},
tabSize
:
{
type
:
[
String
,
Number
],
default
:
""
},
// canAttachFile: {
// type: Boolean,
// default: true
...
...
@@ -168,6 +174,7 @@ export default {
fileList
:
[],
text
:
""
,
html
:
""
,
ulNum
:
1
,
htmlMinHeight
:
150
,
textLength
:
""
,
selectionInfo
:
{
...
...
src/components/content/md-preview.vue
浏览文件 @
5bf8ed03
...
...
@@ -39,9 +39,11 @@ export default {
methods
:
{
addClass
()
{
setTimeout
(()
=>
{
const
previewDom
=
document
.
querySelector
(
"
.md_preview code
"
);
if
(
!
previewDom
)
return
;
previewDom
.
className
=
"
md_hljs
"
;
const
previewDomList
=
document
.
querySelectorAll
(
"
.md_preview code
"
);
if
(
!
previewDomList
.
length
)
return
;
previewDomList
.
forEach
(
item
=>
{
item
.
className
=
"
md_hljs
"
;
});
},
0
);
}
}
...
...
src/components/content/md-textarea.vue
浏览文件 @
5bf8ed03
...
...
@@ -7,6 +7,7 @@
@
focus=
"setFocus(true)"
@
blur=
"setFocus(false)"
@
paste=
"pasteFile"
@
keydown.enter=
"$emit('enter')"
@
keydown.meta.enter.exact=
"submit"
@
keydown.ctrl.enter.exact=
"submit"
@
keydown.tab.prevent=
"$emit('tab')"
...
...
@@ -102,7 +103,6 @@ export default {
immediate
:
true
,
handler
:
function
(
val
)
{
const
cursorPoint
=
getPosition
(
this
.
id
);
console
.
log
(
cursorPoint
);
this
.
textContent
=
val
;
this
.
transferMarkdown
(
val
);
}
...
...
src/components/header/md-header.vue
浏览文件 @
5bf8ed03
...
...
@@ -17,11 +17,12 @@
</div>
<div
class=
"header_tools"
v-if=
"!showPreview"
>
<tool-button
ref=
"tool_button"
:ref=
"item.name"
:ulNum.sync=
"ulNum"
:info=
"item"
:fullScreen=
"fullScreen"
@
setFullScreen=
"$emit('update:fullScreen', $event)"
@
updateText=
"
u
pdateText"
@
updateText=
"
handleU
pdateText"
@
upload=
"$emit('upload')"
v-for=
"(item, index) in toolsShow"
:key=
"index"
...
...
@@ -71,6 +72,10 @@ export default {
type
:
[
String
,
Number
],
default
:
""
},
tabSize
:
{
type
:
[
String
,
Number
],
default
:
""
},
text
:
{
type
:
[
String
,
Number
],
default
:
""
...
...
@@ -109,11 +114,13 @@ export default {
},
data
()
{
return
{
cursorPoint
:
""
,
cancelFullScreenBtn
:
{
name
:
"
cancelFullScreen
"
,
icon
:
"
quxiaoquanping_o
"
,
tip
:
"
退出全屏
"
},
ulNum
:
1
,
fullScreenBtn
:
{
name
:
"
fullScreen
"
,
icon
:
"
fullScreen
"
,
...
...
@@ -201,48 +208,46 @@ export default {
},
methods
:
{
resetUlNum
()
{
this
.
ulNum
=
1
;
},
tab
()
{
const
startStr
=
"
"
;
let
startStr
=
""
;
const
tabSize
=
parseInt
(
this
.
tabSize
);
Array
.
from
({
length
:
tabSize
}).
forEach
(()
=>
{
startStr
+=
"
"
;
});
const
endStr
=
""
;
const
originalText
=
this
.
text
;
const
cursorPoint
=
getPosition
(
this
.
id
);
console
.
log
(
cursorPoint
);
const
selectionInfo
=
{
selectionStart
:
cursorPoint
,
selectionEnd
:
cursorPoint
};
const
newText
=
formatText
(
originalText
,
selectionInfo
,
startStr
,
endStr
);
const
len
=
newText
.
length
-
originalText
.
length
;
// const len = 0;
this
.
$emit
(
"
update:selectionInfo
"
,
{
selectorId
:
""
,
selectionStart
:
cursorPoint
.
selectionStart
+
len
,
selectionEnd
:
cursorPoint
.
selectionEnd
+
len
});
this
.
updateText
(
newText
,
len
);
this
.
updateText
(
newText
,
len
,
cursorPoint
);
},
setShowPreview
(
val
)
{
this
.
$emit
(
"
update:showPreview
"
,
val
);
},
handleUpdateText
({
val
,
len
})
{
const
cursorPoint
=
getPosition
(
this
.
id
);
this
.
updateText
(
val
,
len
,
cursorPoint
);
},
updateText
(
val
,
len
=
0
)
{
cons
ole
.
log
(
val
);
t
his
.
$emit
(
"
update:text
"
,
val
);
cons
t
textEl
=
document
.
getElementById
(
this
.
id
);
t
extEl
.
blur
(
);
const
cursorPoint
=
getPosition
(
this
.
id
);
console
.
log
(
cursorPoint
);
this
.
$emit
(
"
update:text
"
,
val
);
this
.
$emit
(
"
update:selectionInfo
"
,
{
selectorId
:
""
,
selectionStart
:
""
,
selectionEnd
:
""
});
console
.
log
(
cursorPoint
);
setTimeout
(()
=>
{
// document.getElementById(this.id).setSelectionRange(0, 0);
document
.
getElementById
(
this
.
id
)
.
setSelectionRange
(
cursorPoint
+
len
,
cursorPoint
+
len
);
textEl
.
focus
();
textEl
.
setSelectionRange
(
cursorPoint
+
len
,
cursorPoint
+
len
);
},
0
);
}
}
...
...
src/components/header/tool-button.vue
浏览文件 @
5bf8ed03
...
...
@@ -42,11 +42,15 @@ export default {
selectionInfo
:
{
type
:
Object
,
default
:
()
=>
{}
},
ulNum
:
{
type
:
Number
,
default
:
1
}
},
data
()
{
return
{
ulNum
:
1
//
ulNum: 1
};
},
computed
:
{
...
...
@@ -66,6 +70,9 @@ export default {
}
},
methods
:
{
// resetUlNum() {
// this.ulNum = 1;
// },
handleTool
(
type
,
startStr
,
endStr
)
{
switch
(
type
)
{
case
"
bold
"
:
...
...
@@ -80,8 +87,8 @@ export default {
break
;
case
"
ol
"
:
let
ulNum
=
this
.
ulNum
;
this
.
updateText
(
`\n
${
ulNum
}
. `
,
""
);
this
.
ulNum
++
;
this
.
updateText
(
`\n
${
ulNum
++
}
. `
,
""
);
this
.
$emit
(
"
update:ulNum
"
,
ulNum
)
;
break
;
case
"
file
"
:
this
.
$emit
(
"
upload
"
);
...
...
@@ -100,7 +107,12 @@ export default {
const
originalText
=
this
.
text
;
const
selectionInfo
=
this
.
selectionInfo
;
const
newText
=
formatText
(
originalText
,
selectionInfo
,
startStr
,
endStr
);
this
.
$emit
(
"
updateText
"
,
newText
);
const
len
=
selectionInfo
.
selectionEnd
-
selectionInfo
.
selectionStart
+
startStr
.
length
+
endStr
.
length
;
this
.
$emit
(
"
updateText
"
,
{
val
:
newText
,
len
});
}
}
};
...
...
src/main.js
浏览文件 @
5bf8ed03
...
...
@@ -27,6 +27,7 @@ function initMdEditor(obj) {
zIndex
=
2000
,
filePathRule
,
rows
=
6
,
tabSize
=
2
,
maxLength
,
showWordLimit
,
throttle
=
600
,
...
...
@@ -53,6 +54,7 @@ function initMdEditor(obj) {
placeholder
,
maxLength
,
zIndex
,
tabSize
,
setPreview
:
false
,
setFullScreen
:
false
,
focus
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录