mirror of
https://github.com/doocs/md.git
synced 2025-01-22 20:04:39 +08:00
Compare commits
3 Commits
36dd217d92
...
f06cef1fbc
Author | SHA1 | Date | |
---|---|---|---|
|
f06cef1fbc | ||
|
13f5aad6ae | ||
|
67ef9dc21c |
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@ -9,7 +9,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: github.repository == 'doocs/md'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
1
.github/workflows/preview-build.yml
vendored
1
.github/workflows/preview-build.yml
vendored
@ -8,7 +8,6 @@ jobs:
|
||||
build-preview:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'doocs/md'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
@ -170,12 +170,15 @@ watch(isDark, () => {
|
||||
toRaw(editor.value)?.setOption?.(`theme`, theme)
|
||||
})
|
||||
|
||||
const charCount = ref(0)
|
||||
|
||||
// 初始化编辑器
|
||||
function initEditor() {
|
||||
const editorDom = document.querySelector<HTMLTextAreaElement>(`#editor`)!
|
||||
|
||||
if (!editorDom.value) {
|
||||
editorDom.value = store.posts[store.currentPostIndex].content
|
||||
charCount.value = store.posts[store.currentPostIndex].content.replace(/\s/g, ``).length
|
||||
}
|
||||
editor.value = CodeMirror.fromTextArea(editorDom, {
|
||||
mode: `text/x-markdown`,
|
||||
@ -222,7 +225,9 @@ function initEditor() {
|
||||
clearTimeout(changeTimer.value)
|
||||
changeTimer.value = setTimeout(() => {
|
||||
onEditorRefresh()
|
||||
store.posts[store.currentPostIndex].content = e.getValue()
|
||||
const value = e.getValue()
|
||||
store.posts[store.currentPostIndex].content = value
|
||||
charCount.value = value.replace(/\s/g, ``).length
|
||||
}, 300)
|
||||
})
|
||||
|
||||
@ -414,6 +419,7 @@ onMounted(() => {
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
</div>
|
||||
<div class="relative flex-1">
|
||||
<div
|
||||
id="preview"
|
||||
ref="preview"
|
||||
@ -432,6 +438,10 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-muted absolute bottom-0 left-0 p-2 text-xs shadow">
|
||||
{{ charCount }} 个字符
|
||||
</div>
|
||||
</div>
|
||||
<CssEditor class="flex-1" />
|
||||
</div>
|
||||
</main>
|
||||
|
Loading…
Reference in New Issue
Block a user