Skip to main content

paste_anything 0.1.1 copy "paste_anything: ^0.1.1" to clipboard
paste_anything: ^0.1.1 copied to clipboard

Platformweb

Copy and paste rich content on the web: reads Word, Excel, Google Docs, web pages, Markdown, LaTeX and images from the clipboard as clean HTML. Pure Dart, works with any editor.

example/example.md

paste_anything example #

Wire the paste logic into any editor by implementing PaeTarget:

import 'package:paste_anything/paste_anything.dart';

class MyEditorTarget implements PaeTarget {
  MyEditorTarget(this.editor);

  final MyEditor editor;

  @override
  void insertHtml(String html) => editor.insertHtml(html);

  @override
  void insertText(String text) => editor.insertText(text);

  @override
  void insertImage(PaeImage image) => editor.insertHtml(
        '<img src="${image.toDataUri()}">',
      );
}

Future<void> onPaste(MyEditor editor) async {
  final inserted = await const PaePaster(allowImages: true)
      .pasteInto(MyEditorTarget(editor));
  if (inserted is PaeEmptyContent) print('Nothing to paste');
}

Future<void> onCopy(String html) async {
  await PaeClipboard.writeHtml(html, plainText: PaeHtml.toPlainText(html));
}

Clean HTML without touching the clipboard:

final clean = PaeHtml.normalize(wordHtml, keepImages: false);
final fromMd = PaeHtml.fromMarkdown('# Title\n\n**bold** and $x^2$');
final formulas = PaeMath.formulasFromHtml(katexHtml); // ['x^2', ...]
0
likes
160
points
88
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Copy and paste rich content on the web: reads Word, Excel, Google Docs, web pages, Markdown, LaTeX and images from the clipboard as clean HTML. Pure Dart, works with any editor.

Repository (GitHub)
View/report issues

Topics

#clipboard #html #paste #markdown #latex

License

MIT (license)

Dependencies

html, markdown, web

More

Packages that depend on paste_anything