Commit 484527bb by Яков

update

parent 2a0e3c7e
{
"name": "react-ag-qeditor",
"version": "1.1.2",
"version": "1.1.3",
"description": "WYSIWYG html editor",
"author": "atma",
"license": "MIT",
......
......@@ -183,7 +183,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
requestAnimationFrame(() => {
const maxWidth = node.attrs.align === 'center' ? initialEditorWidth : initialAvailableSpace;
console.log(maxWidth);
const deltaX = e.clientX - startX;
const deltaY = e.clientY - startY;
......@@ -450,6 +449,47 @@ const ResizableImageExtension = TipTapImage.extend({
}
};
},
renderHTML({ node, HTMLAttributes }) {
const {
src,
alt = '',
title = '',
width,
height,
...rest
} = HTMLAttributes;
const align = node.attrs.align || 'left';
const style = [];
if (align === 'center') {
style.push('display: block', 'margin-left: auto', 'margin-right: auto');
} else if (align === 'left') {
style.push('display: inline-block', 'vertical-align: top', 'margin-right: 1rem');
} else if (align === 'right') {
style.push('display: inline-block', 'vertical-align: top', 'margin-left: 1rem');
} else if (align === 'text') {
style.push('display: inline-block', 'vertical-align: middle', 'margin: 0 0.2rem');
}
if (width) style.push(`width: ${width}px`);
if (height) style.push(`height: ${height}px`);
return [
'img',
{
src,
alt,
title,
width,
height,
'data-align': align,
style: style.join('; '),
...rest,
}
];
},
addNodeView() {
return ReactNodeViewRenderer(ResizableImageTemplate);
......
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