Comments (19)
补充:
粘贴图片时没有问题,
from md-editor-v3.
我把server弄成直接可在浏览器中打开的那种方式了,而且ctrl+v可以上传成功,返回数据也成功,但是预览的时候还是上面的问题。
求指教。
from md-editor-v3.
麻烦提供一下完整的图片链接呢
from md-editor-v3.
我是本地的前端和后端。。。
给你截个图吧 浏览器显示要正常的 http://localhost:8000/static/2eda95b7bd744acb8daad3bc9044c041.png
:
前端跑在localhost:3000上,后端跑在localhost:8000上,后端已经开启了 CORS,按说应该没问题呀。。。。
from md-editor-v3.
好的谢谢,我尝试下还原这个问题。
from md-editor-v3.
我尝试了一下,把这个地址写在页面里,是可以显示出来的:
另外,这是lock里面的dependencies:
"dependencies": {
"axios": "^0.26.0",
"element-plus": "^2.0.2",
"md-editor-v3": "^1.10.1",
"pinia": "^2.0.11",
"qs": "^6.10.3",
"sanitize-html": "^2.7.0",
"scss": "^0.2.4",
"vue": "^3.2.25",
"vue-router": "^4.0.12"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.2.0",
"unplugin-auto-import": "^0.5.11",
"unplugin-vue-components": "^0.17.18",
"vite": "^2.8.0"
}
},
感谢感谢
from md-editor-v3.
这个看起来是内部生命周期函数对已卸载的元素访问的错误,不是图片的问题。但是这边没法还原问题,这边方便提供一个最简版的可还原这个问题太的代码吗?
from md-editor-v3.
你看下下面代码能不能跑起来。
<template>
<el-row :gutter="20">
<el-col :span="16">
<div class="vulnmain">
<!-- the main-->
<h1>Sumbit Vulnerability</h1>
<el-form
ref="ruleFormRef"
:model="ruleForm"
class="demo-ruleForm"
size="large"
label-position="left"
>
<el-form-item label="描述" prop="details">
<!-- <el-input v-model="ruleForm.version"></el-input> -->
<md-editor
editor-id="details"
v-model="ruleForm.details"
preview-theme="github"
:sanitize="sanitize"
:preview="false"
:toolbars="toolbars"
@onUploadImg="onUploadImg"
/>
</el-form-item>
<el-form-item>
<el-button @click="submitForm" type="primary">Save</el-button>
</el-form-item>
</el-form>
</div>
</el-col>
<el-col :span="8">
<!-- the tip-->
<div class="tips">
<h1>some tips</h1>
</div>
</el-col>
</el-row>
</template>
<script setup>
const ruleForm = ref({
details: "",
});
const toolbars = ref([
"italic",
"underline",
"bold",
"image",
"table",
"preview",
]);
const onUploadImg = async (files, callback) => {
const res = await Promise.all(
Array.from(files).map((file) => {
return new Promise((rev, rej) => {
const form = new FormData();
form.append("file", file);
api
.post("/uploads/", form, {
headers: {
"Content-Type": "multipart/form-data",
},
})
.then((res) => rev(res))
.catch((error) => rej(error));
});
})
);
callback(res.map((item) => item.data.url));
};
onMounted({
ruleForm: loadDetail(route.query.id),
});
</script>
The backend is based on fastapi, here's the code if you need:
mport shutil
from pathlib import Path
from fastapi import APIRouter, Depends, HTTPException, status, UploadFile, File
from pathvalidate import sanitize_filename, sanitize_filepath
from fastapi.responses import FileResponse
from backend.core.config import settings
app = FastAPI(
# dependencies=[Depends(get_current_active_user)]
)
app.mount("/static", StaticFiles(directory="uploads"), name="static")
upload_dir = "./uploads"
def generate_file_name() -> str:
import uuid
filename = uuid.uuid4().hex
return filename
@app.post("/")
async def upload_file(
file: UploadFile = File(...)
):
upload_filename = generate_file_name()
suffix = Path(file.filename).suffix
full_filename = f"{upload_filename}{suffix}"
saved_file = f"{upload_dir}/{upload_filename}{suffix}"
with open(saved_file, "wb") as buffer:
shutil.copyfileobj(file.file, buffer)
return {
"url": "http://localhost:8000/static/"+full_filename
}
我精简了一下,应该能跑起来。
谢谢大佬。
from md-editor-v3.
用这个代码这边也不能还原问题,之前遇到过没有正确使用vue-router产生的vue3钩子函数重复执行的bug,这边帮你解决这个问题可能需要给一个最小的可运行项目才行哈。
from md-editor-v3.
没有正确使用router?能不能给些正确使用的建议?
from md-editor-v3.
没有正确使用router?能不能给些正确使用的建议?
你看看 #40 这个。
from md-editor-v3.
你给我个邮箱吧 我把前端源码给你发过去吧 我也不能确定问题。这个界面是在几次跳转之后的,但没有keepalive的设置。
from md-editor-v3.
from md-editor-v3.
大佬,那天给你发过去了,担心你没留意,在这儿提醒下
from md-editor-v3.
大佬,那天给你发过去了,担心你没留意,在这儿提醒下
收到的,需要后面抽时间看下哈。
from md-editor-v3.
好的 谢谢
from md-editor-v3.
在用其他的一个md插件,关闭这个issue了
from md-editor-v3.
很抱歉,最近处理私事耽搁了。这边找到的问题是,不显示图片是因为sanitizeHtml
在分析图片代码时,认为不安全,给删除了。md报错的原因是多个组件冲突了,这边会在1.10.1之后的版本修正。
from md-editor-v3.
@imzbf 感谢大佬,项目比较紧,暂时用其他方案替代,希望这个插件越做越好。
from md-editor-v3.
Related Issues (20)
- Copy code tooltip in code blocks is in chinese when using en-US locale HOT 2
- 是否可以添加一个开关,让展示区把用户手动输入的html代码转成普通字符串渲染 HOT 4
- css在小程序相关错误 HOT 1
- defToolbars slot no render HOT 1
- 同步滚动问题 HOT 7
- md-editor-v3二次编辑 HOT 1
- 一个好玩的问题 HOT 3
- 4.10.0版本代码块存在多余的行号 HOT 4
- Nuxt: MdPreview渲染完成,浏览器未加载完毕时,修改theme无效 HOT 7
- Elscrollbar里放MdCatalog,标题高亮总是显示第一个标题 HOT 1
- 无法扩展工具栏 HOT 2
- 可不可以加一个 获取当前选择的文本的方法呢 HOT 5
- 自定义导航栏问题 HOT 1
- 是否可以提供个方法重置undoredo队列 HOT 3
- `editorRef.value?.insert`返回值`select`为`false`仍然选中了插入的文本 HOT 1
- 添加on-change后,v-model双向绑定失效 HOT 2
- 代码块头部加入自定义按钮 HOT 3
- 关于ESM和CJS的问题,Uncaught Error: Dynamic require of "punycode" is not supported HOT 6
- 能否支持内网使用 HOT 1
- 导出pdf时候如果图片跨域,会导致图片空白问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from md-editor-v3.