Skip to content

Commit

Permalink
feat: add more style option (doocs#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
YangFong authored Sep 17, 2024
1 parent ecb51c1 commit d8a3d06
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ function showPicker() {
// 自定义CSS样式
function customStyle() {
toggleShowCssEditor()
nextTick(() => {
if (!cssEditor.value) {
cssEditor.value!.refresh()
}
})
setTimeout(() => {
cssEditor.value!.refresh()
}, 50)
Expand Down
46 changes: 45 additions & 1 deletion src/components/CodemirrorEditor/EditorHeader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover
import { Button } from '@/components/ui/button'
import { mergeCss, solveWeChatImage } from '@/utils'
import { useStore } from '@/stores'
import { useDisplayStore, useStore } from '@/stores'
const emit = defineEmits([`addFormat`, `formatContent`, `startCopy`, `endCopy`])
Expand Down Expand Up @@ -81,6 +81,7 @@ const formatItems = [
] as const
const store = useStore()
const displayStore = useDisplayStore()
const { isDark, isCiteStatus, output, primaryColor } = storeToRefs(store)
Expand Down Expand Up @@ -153,6 +154,13 @@ function copy() {
})
}, 350)
}
function customStyle() {
displayStore.toggleShowCssEditor()
setTimeout(() => {
store.cssEditor!.refresh()
}, 50)
}
</script>

<template>
Expand Down Expand Up @@ -371,6 +379,31 @@ function copy() {
</Button>
</div>
</div>
<div class="space-y-2">
<h2>自定义 CSS 面板</h2>
<div class="grid grid-cols-5 justify-items-center gap-2">
<Button
class="w-full"
variant="outline"
:class="{
'border-black dark:border-white': displayStore.isShowCssEditor,
}"
@click="!displayStore.isShowCssEditor && customStyle()"
>
开启
</Button>
<Button
class="w-full"
variant="outline"
:class="{
'border-black dark:border-white': !displayStore.isShowCssEditor,
}"
@click="displayStore.isShowCssEditor && customStyle()"
>
关闭
</Button>
</div>
</div>
<div class="space-y-2">
<h2>编辑区位置</h2>
<div class="grid grid-cols-5 justify-items-center gap-2">
Expand Down Expand Up @@ -421,6 +454,17 @@ function copy() {
</Button>
</div>
</div>
<div class="space-y-2">
<h2>样式配置</h2>
<div>
<Button
class="w-full"
@click="store.resetStyleConfirm()"
>
重置
</Button>
</div>
</div>
</div>
</PopoverContent>
</Popover>
Expand Down
2 changes: 0 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ export function css2json(css: string): Partial<Record<Block | Inline, Properties
css = css.slice(rbracket + 1).trim()
}

console.log(`json`, json)

return json
}

Expand Down

0 comments on commit d8a3d06

Please sign in to comment.