提交 27cebeb2 编写于 作者: D DCloud_LXH

fix: editor setContents image.src link.href

上级 7bec00ff
import getRealPath from 'uni-platform/helpers/get-real-path'
export default function (Quill) {
const Image = Quill.import('formats/image')
const ATTRIBUTES = [
......@@ -8,7 +10,7 @@ export default function (Quill) {
'class',
'data-local'
]
Image.sanitize = url => url
Image.sanitize = url => url ? getRealPath(url) : url
Image.formats = function formats (domNode) {
return ATTRIBUTES.reduce(function (formats, attribute) {
if (domNode.hasAttribute(attribute)) {
......
......@@ -8,6 +8,7 @@ import box from './box'
import font from './font'
import text from './text'
import image from './image'
import link from './link'
export function register (Quill) {
const formats = {
......@@ -20,7 +21,8 @@ export function register (Quill) {
box,
font,
text,
image
image,
link
}
const options = {}
Object.values(formats).forEach(value => Object.assign(options, value(Quill)))
......
export default function (Quill) {
const Link = Quill.import('formats/link')
Link.sanitize = url => {
const anchor = document.createElement('a')
anchor.href = url
const protocol = anchor.href.slice(0, anchor.href.indexOf(':'))
return Link.PROTOCOL_WHITELIST.concat('file').indexOf(protocol) > -1 ? url : Link.SANITIZED_URL
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册