gfm插件存在表格无法加载的问题
Wugensheng3 opened this issue · 5 comments
结果展示
项目环境
vue3+vite+ts,使用pnpm多次下载结果都一样
pnpm命令执行结果
`pnpm install @bytemd/plugin-gfm --force
WARN using --force I sure hope you know what you are doing
WARN 10 deprecated subdependencies found: @types/vfile-message@2.0.0, resolve-url@0.2.1, source-map-resolve@0.5.3, source-map-url@0.4.1, sourcemap-codec@1.4.8, stable@0.1.8, sv
go@1.3.2, trim@0.0.1, urix@0.1.0, uuid@3.4.0
Packages: +1415
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1415, reused 1407, downloaded 8, added 1415, done
WARN Issues with peer dependencies found
.
├─┬ stylelint-config-recommended-vue 1.4.0
│ └─┬ stylelint-config-recommended 11.0.0
│ └── ✕ unmet peer stylelint@^15.3.0: found 14.16.1
└─┬ vite-plugin-vue-svg 0.1.0
└── ✕ unmet peer vite@^2.0.0-beta.61: found 3.2.5
Done in 19.2s
`
对应代码展示
<script setup lang="ts">
import gfm from '@bytemd/plugin-gfm';
import breaks from '@bytemd/plugin-breaks';
import highlight from "@bytemd/plugin-highlight";
import math from '@bytemd/plugin-math-ssr';
import { Editor } from '@bytemd/vue-next';
import { ref } from 'vue';
import 'bytemd/dist/index.css'
const plugins = [
gfm(),
breaks(),
highlight(),
math(),
// Add more plugins here
];
interface Props {
value: string;
handleChange: (v: string) => void;
}
const props = withDefaults(defineProps<Props>(), {
value: '# 故事的结局由我来书写',
handleChange: (v: string) => {
console.log(v);
},
});
const uploadImages = async (files) => {
// 这里是你的图片上传逻辑
// 你需要返回一个字符串数组,数组中的每个字符串都是一个图片的URL
const urls = [];
return urls;
};
</script>
<template>
<Editor
:value="props.value"
:plugins="plugins"
@change="props.handleChange"
mode="auto"
:uploadImages="uploadImages"
/>
</template>
<style lang="less">
.bytemd-toolbar-icon.bytemd-tippy.bytemd-tippy-right:last-child {
display: none;
}
</style>
已解决,通过下载github的md css
已解决,通过下载github的md css
怎么弄
<script setup lang="ts"> import gfm from '@bytemd/plugin-gfm'; import breaks from '@bytemd/plugin-breaks'; import highlight from '@bytemd/plugin-highlight'; import math from '@bytemd/plugin-math-ssr'; import { Editor } from '@bytemd/vue-next'; import { ref } from 'vue'; import 'juejin-markdown-themes/dist/juejin.min.css'; import zhHans from 'bytemd/lib/locales/zh_Hans.json'; import highlightssr from '@bytemd/plugin-highlight-ssr'; import 'highlight.js/styles/vs.css'; import { getToken } from '@/utils/auth'; import { UserControllerService } from '../../../generated/user'; import { FileControllerService } from '../../../generated/post'; const plugins = [ gfm(), breaks(), highlight(), math(), highlightssr(), // Add more plugins here ]; interface Props { value: string; handleChange: (v: string) => void; } const props = withDefaults(defineProps(), { value: '# 故事的结局由我来书写', handleChange: (v: string) => { console.log(v); }, }); // const uploadImages = async (files) => { // if (!files.length) return[]; // // const formData = new FormData(); // formData.append('file', files[0]); // 将文件添加到formData中 // // // 准备UploadFileRequest对象 // const uploadFileRequest = { // biz: 'user_avatar', // 你的业务逻辑标识符 // }; // // // 如果需要,向formData添加其他数据 // formData.append('uploadFileRequest', JSON.stringify(uploadFileRequest)); // // // 使用fetch或Axios调用API,不手动设置Content-Type // try { // const response = await fetch('http://localhost:8888/api/user/file/upload', { // method: 'POST', // body: formData, // 直接使用formData // headers: { // 'Authorization':getToken(), // } // }); // // if (!response.ok) { // throw new Error('Network response was not ok.'); // } // // const data = await response.json(); // 假设响应是JSON // console.log('图片链接', data); // return [ // { // title: files.map(file => file.name), // data // } // ]; // } catch (error) { // console.error('上传失败', error); // return []; // } // }; const uploadImages = async (files) => { const formData = new FormData(); formData.append('file', files[0]); const { data } = await FileControllerService.uploadFile(formData); console.log(data); const temp = [ { title: files.map((file) => file.name), url: data, }, ]; console.log('temp', temp); return temp; }; </script> <style lang="less"> .bytemd-toolbar-icon.bytemd-tippy.bytemd-tippy-right:last-child { display: none; } </style>已解决,通过下载github的md css
怎么弄
关键代码在这里: import 'juejin-markdown-themes/dist/juejin.min.css';
你首先需要去找一些markdown的css依赖,然后我这里应该是直接导入就可以了,你可以去github找找我用的是掘金的,之前用过github的,你可以去找找看依赖(不太确定依赖这个说法对不对,我是写后端的)
下面是我的相关代码:
已解决,通过下载github的md css
怎么弄
核心是缺少依赖,因为这里是没有自带css样式的