All Projects → bytedance → Realrichtext

bytedance / Realrichtext

Licence: other
A Tricky Solution for Implementing Inline-Image-In-Text Feature in Flutter.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Realrichtext

mobility-actiontext
Translate Rails Action Text rich text with Mobility.
Stars: ✭ 27 (-95.66%)
Mutual labels:  rich-text
richTextParse
微信小程序富文本解析(仅支持HTML),在rich-text标签引用结果“树”
Stars: ✭ 53 (-91.48%)
Mutual labels:  rich-text
Slate
A completely customizable framework for building rich text editors. (Currently in beta.)
Stars: ✭ 23,104 (+3614.47%)
Mutual labels:  rich-text
rich-text
A set of companion packages for GraphCMS's Rich Text Field
Stars: ✭ 62 (-90.03%)
Mutual labels:  rich-text
richvariables
DEPRECATED Allows you to easily use Craft Globals as variables in Rich Text fields
Stars: ✭ 44 (-92.93%)
Mutual labels:  rich-text
Spedittool
An efficient and scalable library for inputing and displaying gif or @mention on graph-text mixed TextView/EditText
Stars: ✭ 292 (-53.05%)
Mutual labels:  rich-text
we-rich
HTML转微信富文本节点, we just need rich, no text.
Stars: ✭ 36 (-94.21%)
Mutual labels:  rich-text
Element Tiptap
🌸A modern WYSIWYG rich-text editor using tiptap and Element UI for Vue.js
Stars: ✭ 481 (-22.67%)
Mutual labels:  rich-text
html2any
🌀 parse and convert html string to anything
Stars: ✭ 43 (-93.09%)
Mutual labels:  rich-text
Angular Editor
A simple native WYSIWYG editor component for Angular 6 -10+
Stars: ✭ 428 (-31.19%)
Mutual labels:  rich-text
Taro-ParserRichText
适用于 Taro 的小程序富文本组件
Stars: ✭ 32 (-94.86%)
Mutual labels:  rich-text
unity-rich-text
🌈 Forget about rich text tags pain
Stars: ✭ 14 (-97.75%)
Mutual labels:  rich-text
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-52.73%)
Mutual labels:  rich-text
textbus
Textbus 是一个组件化的、数据驱动的富文本框架,支持在线协同编辑,同时也可以作为一个开箱即用的富文本编辑器,拥有非常好的扩展性和可定制性,是构建复杂富文本的不二之选!
Stars: ✭ 642 (+3.22%)
Mutual labels:  rich-text
Nudein
An easy-to-use attributed text view for iOS Apps,use like masonry
Stars: ✭ 450 (-27.65%)
Mutual labels:  rich-text
unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (-95.02%)
Mutual labels:  rich-text
Text
📑 Collaborative document editing using Markdown
Stars: ✭ 282 (-54.66%)
Mutual labels:  rich-text
Simpletext
A simple spannable string helper
Stars: ✭ 526 (-15.43%)
Mutual labels:  rich-text
Dante
A sane rich text parsing and styling library.
Stars: ✭ 450 (-27.65%)
Mutual labels:  rich-text
Hricheditor
Android端富文本编辑器HEichEditor
Stars: ✭ 311 (-50%)
Mutual labels:  rich-text

RealRichText

A Tricky Solution for Implementing Inline-Image-In-Text Feature in Flutter.

Getting Started

According to the related Flutter Issues(#2022) , Inline-Image-In-Text is a long-time(2 years) missing feature since RichText(or the underlying Paragraph) does only support pure text. But we can solve this problem in a simple/tricky way:

  1. Regard the images as a particular blank TextSpan, convert image's width and height to textspan's letterSpacing and fontSize. the origin paragraph will do the layout operation and leave the desired image space for us.
  2. Override the paint function,calculate the right offset via the getOffsetForCaret() api to draw the image over the space.

For more details, please refer to the source code.

Usage

The only thing you have to do is converting your origin text to a TextSpan/ImageSpan List first.

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:real_rich_text/real_rich_text.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: RealRichText([
            TextSpan(
              text: "A Text Link",
              style: TextStyle(color: Colors.red, fontSize: 14),
              recognizer: TapGestureRecognizer()
                ..onTap = () {
                  debugPrint("Link Clicked.");
                },
            ),
            ImageSpan(
              AssetImage("packages/real_rich_text/images/emoji_9.png"),
              imageWidth: 24,
              imageHeight: 24,
            ),
            ImageSpan(AssetImage("packages/real_rich_text/images/emoji_10.png"),
                imageWidth: 24,
                imageHeight: 24,
                margin: EdgeInsets.symmetric(horizontal: 10)),
            TextSpan(
              text: "哈哈哈",
              style: TextStyle(color: Colors.yellow, fontSize: 14),
            ),
            TextSpan(
              text: "@Somebody",
              style: TextStyle(
                  color: Colors.black,
                  fontSize: 14,
                  fontWeight: FontWeight.bold),
              recognizer: TapGestureRecognizer()
                ..onTap = () {
                  debugPrint("Link Clicked");
                },
            ),
            TextSpan(
              text: " #RealRichText# ",
              style: TextStyle(color: Colors.blue, fontSize: 14),
              recognizer: TapGestureRecognizer()
                ..onTap = () {
                  debugPrint("Link Clicked");
                },
            ),
            TextSpan(
              text: "showing a bigger image",
              style: TextStyle(color: Colors.black, fontSize: 14),
            ),
            ImageSpan(AssetImage("packages/real_rich_text/images/emoji_10.png"),
                imageWidth: 24,
                imageHeight: 24,
                margin: EdgeInsets.symmetric(horizontal: 5)),
            TextSpan(
              text: "and seems working perfect……",
              style: TextStyle(color: Colors.black, fontSize: 14),
            ),
          ]),
        ),
      ),
    );
  }
}

Note

ImageSpan must set the width & height properties.

if your image's width or height is not specific, you can wrap two RealRichText in a StatefulWidget, one for showing placeholder image and the other for showing the actual image when it is ready.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].