Commit a123742c authored by Яков's avatar Яков
Browse files

update

parent 82b42d2a
Pipeline #9940 failed with stages
in 0 seconds
{ {
"name": "react-ag-qeditor", "name": "react-ag-qeditor",
"version": "1.1.34", "version": "1.1.35",
"description": "WYSIWYG html editor", "description": "WYSIWYG html editor",
"author": "atma", "author": "atma",
"license": "MIT", "license": "MIT",
......
...@@ -103,8 +103,9 @@ export const DragAndDrop = Extension.create({ ...@@ -103,8 +103,9 @@ export const DragAndDrop = Extension.create({
const fl = (style.match(/float\s*:\s*([^;]+)/i) || [])[1]?.trim(); const fl = (style.match(/float\s*:\s*([^;]+)/i) || [])[1]?.trim();
if (ml === 'auto' && mr === 'auto') result.align = 'center'; if (ml === 'auto' && mr === 'auto') result.align = 'center';
else if (fl === 'right' || ml === 'auto') result.align = 'right'; else if (fl === 'right') result.align = 'right';
else result.align = 'left'; else if (fl === 'left') result.align = 'left';
else result.align = 'center'; // нет float → блочный элемент
return result; return result;
} catch { } catch {
...@@ -284,12 +285,15 @@ export const DragAndDrop = Extension.create({ ...@@ -284,12 +285,15 @@ export const DragAndDrop = Extension.create({
const upload = uploads[i]; const upload = uploads[i];
if (upload) { if (upload) {
img.setAttribute('src', upload.filePath); img.setAttribute('src', upload.filePath);
// Сохраняем data-align для parseHTML Image.jsx // Определяем выравнивание из inline-стилей картинки
const ml = (upload.style.match(/margin-left\s*:\s*([^;]+)/i) || [])[1]?.trim(); const ml = (upload.style.match(/margin-left\s*:\s*([^;]+)/i) || [])[1]?.trim();
const mr = (upload.style.match(/margin-right\s*:\s*([^;]+)/i) || [])[1]?.trim(); const mr = (upload.style.match(/margin-right\s*:\s*([^;]+)/i) || [])[1]?.trim();
const fl = (upload.style.match(/float\s*:\s*([^;]+)/i) || [])[1]?.trim(); const fl = (upload.style.match(/float\s*:\s*([^;]+)/i) || [])[1]?.trim();
// Нет float → блочный элемент → center; есть float → left/right
const align = (ml === 'auto' && mr === 'auto') ? 'center' const align = (ml === 'auto' && mr === 'auto') ? 'center'
: (fl === 'right' || ml === 'auto') ? 'right' : 'left'; : fl === 'right' ? 'right'
: fl === 'left' ? 'left'
: 'center'; // Google Docs / большинство источников — блок без float
img.setAttribute('data-align', align); img.setAttribute('data-align', align);
if (upload.width) img.setAttribute('width', String(upload.width)); if (upload.width) img.setAttribute('width', String(upload.width));
if (upload.height) img.setAttribute('height', String(upload.height)); if (upload.height) img.setAttribute('height', String(upload.height));
......
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