Commit 099e92bd by Яков

update

parent fa148369
{
"name": "react-ag-qeditor",
"version": "1.1.5",
"version": "1.1.6",
"description": "WYSIWYG html editor",
"author": "atma",
"license": "MIT",
......
......@@ -1084,9 +1084,31 @@ const QEditor = ({
try {
switch (innerModalType) {
case 'image':
uploadedPaths.map((file, i) => {
editor.chain().focus().setImage({src: file.path}).run();
uploadedPaths.map(async (file) => {
const img = new Image()
img.src = file.path
img.onload = () => {
const maxWidth = editor.view.dom.clientWidth - 32 // учёт padding
const realWidth = Math.min(img.naturalWidth, maxWidth)
const realHeight = img.naturalHeight * (realWidth / img.naturalWidth)
editor
.chain()
.focus()
.setImage({
src: file.path,
width: Math.round(realWidth),
height: Math.round(realHeight),
align: 'center',
'data-node-id': `img-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
})
.run()
}
})
// uploadedPaths.map((file, i) => {
// editor.chain().focus().setImage({src: file.path}).run();
// })
break
case 'video':
uploadedPaths.map((file, i) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment