Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Decode issue with <img> tag #373

Open
VaarunSinha opened this issue Jun 27, 2024 · 3 comments
Open

HTML Decode issue with <img> tag #373

VaarunSinha opened this issue Jun 27, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@VaarunSinha
Copy link

Steps to Reproduce

import 'package:flutter/material.dart';
import 'package:fleather/fleather.dart';
import 'package:parchment/codecs.dart';

void main() {
  runApp(FleatherApp());
}

class FleatherApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
    home: HomePage()
  );
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    const codec = ParchmentHtmlCodec();
    // String html = '<img src="abcd.png">'; // fails
    // String html = '<p><img src="abcd.png"></p>'; // fails
    String html = '<p>hello</p>'; // works

    final ParchmentDocument doc = codec.decode(html);
    FleatherController? controller = FleatherController(document: doc);

    return Scaffold(body: FleatherEditor(controller: controller));
    // return Scaffold(body: FleatherField(controller: controller)); // same behaviour
  }
}

Environment

  • Web
  • Flutter version 3.22.2
  • Fleather version 1.16.1

Logs

Blog Content: <p><strong><em><u> lknn kjfnk nfkj kjfkn kjjf</u></em></strong></p><p><br></p><p><span class="ql-cursor"></span><img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAABcCAYAAABZYJh9AAAMP2lDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnltSIbQAAlJCb4KIlABSQmgBpBfBRkgChBJiIKjYkUUF14KKBWzoqohiB8SO2FkUe19QUVDWxYJdeZMCuu4r35vv
mzv//efMf86cO3PvHQDUT3LF4mxUA4AcUb4kJtifMS4pmUHqBhigAjIwAGQuL0/MiooKB7AMtn8v724CRNZec5Bp/bP/vxZNviCPBwASBXEqP4+XA/FBAPAqnliSDwBRxptPzRfLMKxAWwIDhHih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DRQzQgEBwxKAoA2bWgRmRgIQtBmzjpgNSwCCNmxqEZgZCUDQZsw6YjYsAQjasKlFYG
YkAEGbMeuI2bAEIGjDphaBmZEABG3GrCNmwxKAoA2bWgRmRgIQtBmzjpgNSwCCNmxqEZgZCUDQZsw6YjYsAQjasKlFYGYk8C9rgNGwsVGMkwAAAABJRU5ErkJggg=="><br></p>

Another exception was thrown: UnimplementedError: Embeddable type "image" is not supported by default embed builder of FleatherEditor. You must pass your own builder function to embedBuilder property
of FleatherEditor or FleatherField widgets.```
@VaarunSinha
Copy link
Author

Widget _embedBuilder(BuildContext context, fleather.EmbedNode node) {
  if (node.value.type == 'image') {
    final String sourceType = node.value.data['source_type'];
    final String source = node.value.data['source'];

    if (sourceType == 'assets') {
      return Padding(
        // Caret takes 2 pixels, hence not symmetric padding values.
        padding: const EdgeInsets.only(left: 4, right: 2, top: 2, bottom: 2),
        child: Container(
          width: 300,
          height: 300,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage(source),
              fit: BoxFit.cover,
            ),
          ),
        ),
      );
    } else if (source.startsWith('data:image')) {
      final base64String = source.split(',').last;
      final decodedBytes = base64Decode(base64String);

      return Padding(
        // Caret takes 2 pixels, hence not symmetric padding values.
        padding: const EdgeInsets.only(left: 4, right: 2, top: 2, bottom: 2),
        child: Container(
          width: 300,
          height: 300,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: MemoryImage(decodedBytes),
              fit: BoxFit.cover,
            ),
          ),
        ),
      );
    }
  }

  throw UnimplementedError();
}

It doesnt work with my own custom embed builder

@amantoux amantoux added the enhancement New feature or request label Jun 27, 2024
@svjetlanovicF
Copy link

I faced same/similar issue, @VaarunSinha did you maybe find some workaround?

@amantoux
Copy link
Member

@svjetlanovicF @VaarunSinha indeed, it is not possible to convert embeds at the moment, this PR should adress it when it lands #371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants