Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
璃白.
markdown-editor
提交
9c635990
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,发现更多精彩内容 >>
提交
9c635990
编写于
6月 29, 2021
作者:
璃白.
🌻
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
44c32ed7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
54 deletion
+33
-54
src/App.vue
src/App.vue
+1
-0
src/components/content/md-preview.vue
src/components/content/md-preview.vue
+0
-36
src/components/content/md-textarea.vue
src/components/content/md-textarea.vue
+18
-15
src/components/header/md-header.vue
src/components/header/md-header.vue
+14
-3
未找到文件。
src/App.vue
浏览文件 @
9c635990
...
...
@@ -48,6 +48,7 @@
:rows=
"rows"
:html.sync=
"html"
:id=
"textareaId"
:ref=
"'md_textarea' + id"
@
tab=
"$refs['md_header' + id].tab()"
@
submit=
"submit"
v-else
...
...
src/components/content/md-preview.vue
浏览文件 @
9c635990
...
...
@@ -31,9 +31,6 @@ export default {
}
},
mounted
()
{
setTimeout
(()
=>
{
// this.resetMinHeight();
},
0
);
this
.
addClass
();
},
updated
()
{
...
...
@@ -46,39 +43,6 @@ export default {
if
(
!
previewDom
)
return
;
previewDom
.
className
=
"
md_hljs
"
;
},
0
);
},
transferMarkdown
(
val
)
{
marked
.
setOptions
({
highlight
:
function
(
code
,
lang
,
callback
)
{
const
html
=
require
(
"
highlight.js
"
).
highlightAuto
(
code
).
value
;
return
html
;
}
});
const
str
=
val
+
""
;
// if (!str.trim()) return;
const
html
=
marked
(
str
);
this
.
$emit
(
"
update:html
"
,
html
);
},
resetMinHeight
()
{
console
.
log
(
"
resetHeight
"
);
const
textEl
=
document
.
getElementById
(
this
.
id
);
if
(
!
textEl
)
return
;
const
height
=
textEl
.
offsetHeight
;
console
.
log
(
"
编辑区高度
"
,
height
);
this
.
htmlMinHeight
=
height
;
}
},
watch
:
{
text
:
{
immediate
:
true
,
handler
:
function
(
val
)
{
setTimeout
(()
=>
{
// this.resetMinHeight();
},
0
);
// this.transferMarkdown(val);
}
}
}
};
...
...
src/components/content/md-textarea.vue
浏览文件 @
9c635990
...
...
@@ -88,11 +88,16 @@ export default {
document
.
addEventListener
(
"
mouseup
"
,
this
.
checkSelection
);
},
mounted
()
{
setTimeout
(()
=>
{
this
.
resetMinHeight
();
},
0
);
this
.
resetPreviewMinHeight
();
},
watch
:
{
isFocus
:
{
handler
:
function
(
val
)
{
if
(
val
)
{
this
.
resetPreviewMinHeight
();
}
}
},
text
:
{
immediate
:
true
,
handler
:
function
(
val
)
{
...
...
@@ -111,7 +116,7 @@ export default {
document
.
body
.
style
.
overflow
=
"
auto
"
;
}
setTimeout
(()
=>
{
this
.
reSizeHeight
();
this
.
reSize
Textarea
Height
();
},
0
);
}
},
...
...
@@ -120,7 +125,7 @@ export default {
handler
:
function
()
{
setTimeout
(()
=>
{
if
(
!
this
.
autoSize
)
return
;
this
.
reSizeHeight
();
this
.
reSize
Textarea
Height
();
},
0
);
}
}
...
...
@@ -139,15 +144,13 @@ export default {
}
},
methods
:
{
resetMinHeight
()
{
console
.
log
(
"
resetHeight
"
);
const
textEl
=
document
.
getElementById
(
this
.
id
);
if
(
!
textEl
)
return
;
const
height
=
textEl
.
offsetHeight
;
console
.
log
(
"
编辑区高度
"
,
height
);
this
.
$emit
(
"
update:htmlMinHeight
"
,
height
);
// this.htmlMinHeight = height;
resetPreviewMinHeight
()
{
setTimeout
(()
=>
{
const
textEl
=
document
.
getElementById
(
this
.
id
);
if
(
!
textEl
)
return
;
const
height
=
textEl
.
offsetHeight
;
this
.
$emit
(
"
update:htmlMinHeight
"
,
height
);
},
0
);
},
transferMarkdown
(
val
)
{
marked
.
setOptions
({
...
...
@@ -165,7 +168,7 @@ export default {
this
.
$emit
(
"
update:textLength
"
,
this
.
textContent
.
length
);
this
.
emitText
();
},
reSizeHeight
()
{
reSize
Textarea
Height
()
{
const
textEl
=
document
.
getElementById
(
this
.
id
);
if
(
!
textEl
)
return
;
const
fontSize
=
getComputedStyle
(
textEl
).
getPropertyValue
(
"
font-size
"
);
...
...
src/components/header/md-header.vue
浏览文件 @
9c635990
...
...
@@ -205,10 +205,21 @@ export default {
const
startStr
=
"
"
;
const
endStr
=
""
;
const
originalText
=
this
.
text
;
const
selectionInfo
=
this
.
selectionInfo
;
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
);
},
setShowPreview
(
val
)
{
...
...
@@ -222,8 +233,8 @@ export default {
this
.
$emit
(
"
update:selectionInfo
"
,
{
selectorId
:
""
,
selectionStart
:
cursorPoint
,
selectionEnd
:
cursorPoint
selectionStart
:
""
,
selectionEnd
:
""
});
console
.
log
(
cursorPoint
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录