novident_editor_rich_text 1.0.2
novident_editor_rich_text: ^1.0.2 copied to clipboard
Rich text paragraph rendering for Novident Editor — widget, selection mixin, and abstract editor config. Usable without the full editor for lightweight node rendering.
Novident Editor Rich Text #
Paragraph rendering widget for the Novident Editor.
NovidentRichText, DefaultSelectableMixin, and abstract configuration interfaces.
Features #
- NovidentRichText — the primary paragraph-rendering widget. Renders
RichTextfrom node deltas, resolves styles throughNovidentEditorStyles.maybeOf(), and provides cursor/selection rect measurements viaSelectableMixin. - DefaultSelectableMixin — proxy mixin that wraps a forward
SelectableMixinwith coordinate offset shifting (used by list items, quotes, and nested blocks). - RichTextEditorConfig — abstract interface (12 getters) that replaces the
EditorStatedependency. Any object implementing this interface can driveNovidentRichText. - RichTextAttributes — extension on
Attributesfor reading delta formatting (bold, italic, underline, strikethrough, colour, background, href, font family, font size, code, auto-complete). - Lightweight — depends only on
novident_editor_document,novident_editor_core,novident_editor_styles,novident_editor_selection, and Flutter. No editor services or infrastructure.
Getting started #
Add to your pubspec.yaml:
dependencies:
novident_editor_rich_text: <latest>
Usage #
Basic paragraph #
import 'package:novident_editor_rich_text/novident_editor_rich_text.dart';
NovidentRichText(
node: paragraphNode,
delegate: this, // your SelectableMixin
editorConfig: myConfig, // implements RichTextEditorConfig
);
Implementing RichTextEditorConfig #
import 'package:novident_editor_rich_text/novident_editor_rich_text.dart';
class MyConfig implements RichTextEditorConfig {
@override double get textScaleFactor => 1.0;
@override double? get firstLineIndentFallback => null;
@override Color get cursorColor => Colors.black;
@override Color get selectionColor => Colors.blue.withValues(alpha: 0.2);
@override double get cursorWidth => 2.0;
@override TextSpanDecoratorForAttribute? get textSpanDecorator => null;
@override NovidentTextSpanOverlayBuilder? get textSpanOverlayBuilder => null;
@override bool get enableAutoComplete => false;
@override NovidentAutoCompleteTextProvider? get autoCompleteTextProvider => null;
@override TextStyleConfiguration get textStyleConfiguration => const TextStyleConfiguration();
}
DefaultSelectableMixin #
class _MyListItemState extends State<MyListItem>
with SelectableMixin<MyListItem>, DefaultSelectableMixin<MyListItem> {
@override
SelectableMixin<MyListItem> get forward =>
forwardKey.currentState as SelectableMixin<MyListItem>;
@override
double baseOffset() => 24.0; // bullet/number width
// All SelectableMixin methods are delegated to `forward` with
// coordinate offset adjustment.
}
RichTextAttributes #
final attrs = node.delta?.first.attributes ?? {};
print(attrs.bold); // true / false / null
print(attrs.italic);
print(attrs.textColor); // '#000000'
print(attrs.fontSize); // 12.0
print(attrs.href); // 'https://example.com'
Additional information #
- Repository: github.com/Novident/novident-editor
- Issue tracker: github.com/Novident/novident-editor/issues
- License: Mozilla Public License 2.0
This package is extracted from novident_editor (the full rich-text editor widget). Use it to render rich-text paragraphs in document previews, export tools, or any surface that needs paragraph-level text rendering without the full editor infrastructure.