A simple implementation of a Markdown WYSIWYG editor for flutter.
Note that it's not a proper editor implementation, just a Markdown content editing feature that I've switched to a different way of thinking.
The idea of implementation is simple.
Split the content into paragraphs, render each paragraph using flutter_markdown, use TextField to edit the content when clicking on the paragraph, and then re-render the content using flutter_markdown when the focus is removed from the TextField.
So it's simple and not for everyone, if you need complex functionality, flutter_quill might be a better choice!
Allows you to type Markdown content directly into the editor and see the rendered result directly.
Nothing else.
To use this package, add simple_markdown_editor
as a dependency in your pubspec.yaml
file:
dependencies:
simple_markdown_editor: ^0.0.1
Then, run flutter pub get
in your terminal.
To use the SimpleMarkdownEditor in your Flutter app, import the package and use the widget as follows:
import 'package:flutter/material.dart';
import 'package:simple_markdown_editor/simple_markdown_editor.dart';
class MyMarkdownEditorPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Markdown Editor')),
body: SimpleMarkdownEditor(
content: '# Initial content\n\nStart editing here...',
/// Whether to show the line number
showLineNumber: true,
onContentChange: (String newContent) {
// Handle content changes here
print('New content: $newContent');
},
),
);
}
}
Due to a bug in the SelectionArea component, the copied content is now not line-breaking, see flutter/flutter#104549 and flutter/flutter#104548 for details.
This package is still in early development and may have limitations or bugs. Contributions, feature requests, and bug reports are welcome on the GitHub repository.
For more advanced Markdown editing features, consider using other packages like flutter_quill or markdown_editable_textinput.
If you encounter any issues or have questions, please file an issue on the GitHub repository. We'll do our best to address them in a timely manner.
This project is licensed under the MIT License - see the LICENSE file for details.