完成创作页面编辑器布局与适配

This commit is contained in:
宇阳
2024-07-27 15:38:56 +08:00
parent dde612f88a
commit ac3642e1aa
9 changed files with 95 additions and 9 deletions

View File

@@ -0,0 +1,21 @@
#vditor {
border: none;
.vditor-toolbar {
display: none;
}
.vditor-reset {
background-color: transparent !important;
.vditor-ir__marker--heading{
color: #727cf5;
}
}
// 针对表单元素的光标样式
pre {
// 设置光标样式
caret-color: #727cf5; // 光标颜色
}
}

View File

@@ -0,0 +1,32 @@
import { useEffect, useState } from "react";
import Vditor from "vditor";
import "vditor/dist/index.css";
import "./index.scss"
const VditorEditor = () => {
const [vd, setVd] = useState<Vditor>();
useEffect(() => {
const vditor = new Vditor("vditor", {
minHeight: 500,
// outline: {
// enable: true,
// position: 'left'
// },
after: () => {
vditor.setValue("`Vditor` 最小代码示例");
// vditor.setTheme("classic","","github")
setVd(vditor);
}
})
// Clear the effect
return () => {
vd?.destroy();
setVd(undefined);
};
}, []);
return <div id="vditor" className="vditor"/>;
};
export default VditorEditor;

View File

@@ -1,14 +1,20 @@
import Breadcrumb from '@/components/Breadcrumbs/Breadcrumb';
import { Card } from 'antd';
import VditorEditor from './components/VditorMD';
import { useEffect, useState } from 'react';
const Create = () => {
const [content, setContent] = useState('');
useEffect(() => {
console.log(content);
}, [content])
return (
<>
<Card title={<Breadcrumb pageName="创作" />}>
<p>Card content</p>
<p>Card content</p>
<p>Card content</p>
<Card title={<Breadcrumb pageName="创作" />} className='border-stroke [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark dark:border-strokedark'>
<VditorEditor />
</Card>
</>
);

3
src/styles/custom.scss Normal file
View File

@@ -0,0 +1,3 @@
.vditor .vditor-reset {
@apply dark:text-white;
}

View File

@@ -1,3 +1,4 @@
@import url('./custom.scss');
@tailwind base;
@tailwind components;
@tailwind utilities;