Skip to main content

paste_anything_editor 0.1.0 copy "paste_anything_editor: ^0.1.0" to clipboard
paste_anything_editor: ^0.1.0 copied to clipboard

Rich text editor for Flutter web that pastes and copies Word, Excel, Google Docs, Markdown, HTML, tables, math formulas and images with formatting kept.

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
import 'package:paste_anything_editor/paste_anything_editor.dart';

void main() => runApp(const MaterialApp(home: ExamplePage()));

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  final controller = RichHtmlEditorController(
    allowImagePaste: true,
    // Upload and return a URL; without this, images are stored as data: URIs.
    // onImagePaste: (bytes, mimeType) async => myUpload(bytes, mimeType),
  );
  String html = '';

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('paste_anything_editor')),
      body: ListView(
        padding: const EdgeInsets.all(16),
        children: [
          RichHtmlEditor(
            controller: controller,
            initialText: r'<p>Paste from Word, Google Docs or Excel. '
                r'Euler: <span class="math-tex" data-latex="e^{i\pi}+1=0">'
                r'\(e^{i\pi}+1=0\)</span></p>',
            height: 400,
            onChanged: (value) => setState(() => html = value ?? ''),
          ),
          const SizedBox(height: 24),
          OutlinedButton.icon(
            icon: const Icon(Icons.functions),
            label: const Text('Standalone math dialog'),
            onPressed: () async {
              final result = await MathInputDialog.show(context);
              switch (result) {
                case MathSymbolInsertion(:final char):
                  await MathCodec.copySymbol(char);
                case MathFormulaInsertion(:final latex):
                  await MathCodec.copyFormula(latex);
                case null:
                  break;
              }
            },
          ),
          const SizedBox(height: 24),
          const Text('Preview (HtmlWidget):'),
          HtmlWidget(html, customWidgetBuilder: mathHtmlWidgetBuilder),
        ],
      ),
    );
  }
}
0
likes
0
points
182
downloads

Publisher

unverified uploader

Weekly Downloads

Rich text editor for Flutter web that pastes and copies Word, Excel, Google Docs, Markdown, HTML, tables, math formulas and images with formatting kept.

Repository (GitHub)
View/report issues

Topics

#editor #clipboard #html #quill #math

License

unknown (license)

Dependencies

flutter, flutter_math_fork, flutter_quill, flutter_quill_delta_from_html, flutter_widget_from_html_core, html, markdown, vsc_quill_delta_to_html, web

More

Packages that depend on paste_anything_editor