搜索插件、代码仓与 APP 分类

rich_editor 封面
插件详情v0.5.0

rich_editor

适用于 Flutter 的 WYSIWYG 编辑器,支持丰富的格式化选项。

AndroidiOSmacOSWindows
近 30 天下载
1030
喜欢数
93
Pub 分数
150

安装插件

flutter pub add rich_editor

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个适用于 Flutter 的 WYSIWYG 编辑器,支持粗体、斜体、列表、链接等富文本格式。专为需要高级文本输入的应用程序设计,提供简洁直观的界面,用于创建格式化内容。该编辑器注重可扩展性,支持自定义样式和插件。该包持续维护,并兼容 Android、iOS、macOS 和 Windows 平台。

适合场景

  • 在笔记应用中创建富文本内容
  • 构建博客或文章编辑器
  • 实施用户生成内容表单
  • 开发协作文档工具
  • 启用格式化消息接口

主要特点

  • 实时所见即所得编辑
  • 丰富的格式选项(粗体、斜体、下划线等)
  • 对链接、图片和列表的支持
  • 可自定义的工具栏和主题
  • 跨平台兼容性

适合对象

  • 开发内容丰富的Flutter应用程序的开发者
  • 需要用户友好文本编辑的应用程序
  • 需要 Markdown 或 HTML 输出的项目
  • 致力于跨平台文本编辑器的团队

使用建议

  • 可能需要额外配置以实现复杂样式
  • 性能可能因大型文档而异
  • 有限的内建图像上传处理
  • 需要理解 Flutter 的渲染模型

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

✨ rich_editor

pub package pub points

WYSIWYG editor for Flutter with a rich set of supported formatting options.

Based on https://github.com/dankito/RichTextEditor, but for Flutter.

✨ Features

  • [x] Bold, Italic, Underline, Strike through, Subscript, Superscript
  • [x] Heading 1 - 6, Text body, Preformatted, Block quote
  • [x] Font (reads all system fonts) (Android only)
  • [x] Font Size
  • [x] Text Color
  • [x] Text Background Color
  • [x] Highlight text
  • [x] Justify Left, Center, Right, Blockquote
  • [x] Indent, Outdent
  • [x] Undo, Redo
  • [x] Unordered List (Bullets)
  • [x] Ordered List (Numbers)
  • [x] Insert local or remote Image
  • [x] Insert Link
  • [x] Insert Checkbox
  • [ ] Search
  • [ ] Icon indicators

📸 Screenshots

Usage

      // Insert widget into tree
      RichEditor(
        key: keyEditor,
        value: 'initial html here',
        editorOptions: RichEditorOptions(
          placeholder: 'Start typing',
          // backgroundColor: Colors.blueGrey, // Editor's bg color
          // baseTextColor: Colors.white,
          // editor padding
          padding: EdgeInsets.symmetric(horizontal: 5.0),
          // font name
          baseFontFamily: 'sans-serif',
          // Position of the editing bar (BarPosition.TOP or BarPosition.BOTTOM)
          barPosition: BarPosition.TOP,
        ),
        // You can return a Link (maybe you need to upload the image to your
        // storage before displaying in the editor or you can also use base64
        getImageUrl: (image) {
          String link = 'https://avatars.githubusercontent.com/u/24323581?v=4';
          String base64 = base64Encode(image.readAsBytesSync());
          String base64String = 'data:image/png;base64, $base64';
          return base64String;
        },
      )

Get current HTML from editor

String? html = await keyEditor.currentState?.getHtml();
print(html);

Set Focus and Unfocus

await keyEditor.currentState?.focus();
await keyEditor.currentState?.unFocus();

Clear Editor content

await keyEditor.currentState?.clear();
Custom Toolbar

If you're interested in creating your own toolbar check the custom_toolbar_demo.dart in the example

License

Copyright 2021 JideGuru

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目