diff --git a/quill_html_converter/lib/quill_html_converter.dart b/quill_html_converter/lib/quill_html_converter.dart index d8c6082f..0075bcb5 100644 --- a/quill_html_converter/lib/quill_html_converter.dart +++ b/quill_html_converter/lib/quill_html_converter.dart @@ -85,7 +85,9 @@ final _defaultConverterOptions = ConverterOptions( } if (op.isImage()) { // Fit images within restricted parent width - return ['max-width: 100%', 'object-fit: contain']; + final String? styles = op.attributes['style']; + final listStyles = styles?.split(';') ?? []; + return ['max-width: 100%', 'object-fit: contain', ...listStyles]; } return null; }, diff --git a/quill_html_converter/test/quill_html_converter_test.dart b/quill_html_converter/test/quill_html_converter_test.dart index aefe3822..7996c696 100644 --- a/quill_html_converter/test/quill_html_converter_test.dart +++ b/quill_html_converter/test/quill_html_converter_test.dart @@ -28,15 +28,16 @@ void main() { expect(Delta.fromJson(quillDelta).toHtml().trim(), html.trim()); }); - test('should parse block image embed to html', () { + test("should parse block image embed with it's attributes to html", () { const html = - '

'; + '

'; final quillDelta = [ { 'insert': { 'image': 'https://img.freepik.com/foto-gratis/belleza-otonal-abstracta-patron-venas-hoja-multicolor-generado-ia_188544-9871.jpg' }, + 'attributes': {'style': 'width: 40vh; height:350px; margin: 20px;'} }, {'insert': '\n'} ];