Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Electron环境下无法渲染本地图片 #737

Closed
ch1ny opened this issue Dec 3, 2021 · 3 comments
Closed

[Question] Electron环境下无法渲染本地图片 #737

ch1ny opened this issue Dec 3, 2021 · 3 comments
Labels

Comments

@ch1ny
Copy link

ch1ny commented Dec 3, 2021

依赖版本

  • vue:2.6.11
  • mavon-editor:2.10.0
  • electron:16.0.2

问题描述

您好,我在一个 Electron 项目中引入了 Mavon-editor ,但是在上传图片的功能中遇到了一些问题。
在线的图片链接能够被成功解析:
image
但是使用本地图片上传时,d_render 无法正确渲染图片:
image
此处通过 imgAdd 回调得到的 imgfile 是正确的:
image
直接在 Markdown 文本里写上本地文件的路径和 Base64 也没有效果
也尝试过直接书写 html 标签,但是也无法解析:
image


请问有什么解决方案吗?
因为这个项目是自己想练练手,做一个本地的 Markdown 编辑器看看的,因此如果有可能的话,尽量不想使用将本地图片上传至服务器的解决方案。

@ch1ny
Copy link
Author

ch1ny commented Dec 3, 2021

补充

该项目为 electronBrowserWindow 配置了 webSecurity: false,因此并非由同源机制导致无法访问本地文件。
electron 的开发者工具中直接修改渲染的 <img /> 标签的 src 可以使图片展示出来:
image

jiawulin001 added a commit to jiawulin001/mavonEditor that referenced this issue Dec 4, 2021
@jiawulin001
Copy link
Contributor

这个问题是因为XSS防御过滤掉了高危属性,在新版本发布前,你可以通过 :xssOptions="false"关闭XSS来解决这个问题。

<mavon-editor :xssOptions="false"></mavon-editor>

This issue is due to the XSS filtering out high-risk attributes.
You can use :xssOptions="false" to turn off XSS until a new version is released to solve this issue.

@ygj6 ygj6 added the bug label Dec 4, 2021
@ch1ny
Copy link
Author

ch1ny commented Dec 4, 2021

非常感谢各位开发者,我的问题已经解决


Thanks very much to all the developers.
My problem has been solved.

@ch1ny ch1ny closed this as completed Dec 4, 2021
ygj6 added a commit that referenced this issue Dec 4, 2021
* fix: image cannot be previewed,issue #737

* fix test

* Update src/lib/core/rules.js

Co-authored-by: ygj6 <7699524+ygj6@users.noreply.github.com>

Co-authored-by: ygj6 <7699524+ygj6@users.noreply.github.com>
langren1353 pushed a commit to langren1353/mavonEditor that referenced this issue Aug 1, 2022
* fix: image cannot be previewed,issue hinesboy#737

* fix test

* Update src/lib/core/rules.js

Co-authored-by: ygj6 <7699524+ygj6@users.noreply.github.com>

Co-authored-by: ygj6 <7699524+ygj6@users.noreply.github.com>
(cherry picked from commit 9933119)

# Conflicts:
#	src/mavon-editor.vue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants