Novident Editor Styles
Named paragraph style system for the Novident Editor.
basedOn inheritance chains, table styles, registry resolution, and a font provider —
usable independently of the full editor.
Features
- NovidentStyleDefinition — named style with font family, font size, weight,
italic, underline, spacing (before/after/line-height), indentation, alignment,
colour, and more. Supports
basedOninheritance andnext(auto-style for the following paragraph). - Style registry —
NovidentStyleRegistryresolvesbasedOnchains (with cycle detection via a configurableonWarningcallback).copyWith()for immutable updates. - StylesConfig —
NovidentStylesConfigpairs a registry with adefaultStyleanddefaultStylesByTypemap (e.g.'paragraph' → body,'heading' → heading-1). - EditorStyles (InheritedWidget) —
NovidentEditorStylesexposes the resolved style for any node throughmaybeOf(context)?.resolveStyle(node). - Table styles —
NovidentTableStyleDefinitionwith zebra striping, coloured headers, border colours, width, weight-based column layout, and row-level overrides (NovidentTableRowStyle). - BlockStyleResolver — resolves the effective
NovidentStyleDefinitionfor a node by checking itsstyleRefattribute, then the type-based default, then the global default. - FontProvider —
NovidentFontProvidersupplies the list of available font families and a guaranteed non-null default font. Customisable viaNovidentFontProvider.fromList().
Getting started
Add to your pubspec.yaml:
dependencies:
novident_editor_styles: <latest>
Usage
Define named styles
import 'package:novident_editor_styles/novident_editor_styles.dart';
final registry = NovidentStyleRegistry({
'base': NovidentStyleDefinition(
id: 'base',
name: 'Base',
fontSize: 12,
fontFamily: 'Arial',
indent: NovidentStyleIndent.defaultLineFilter(),
),
'body': NovidentStyleDefinition.nextSame(
id: 'body',
name: 'Body',
basedOn: 'base',
spacing: NovidentStyleSpacing(after: 8),
),
'heading-1': NovidentStyleDefinition(
id: 'heading-1',
name: 'Heading 1',
basedOn: 'base',
fontSize: 32,
bold: true,
spacing: NovidentStyleSpacing(before: 24, after: 12),
next: 'body',
),
});
final config = NovidentStylesConfig(
registry: registry,
defaultStyle: /* your base style */,
defaultStylesByType: {
'paragraph': /* body style */,
'heading': /* heading-1 style */,
},
);
Resolve a style for a node
final resolver = NovidentBlockStyleResolver(config);
final style = resolver.resolveStyle(node); // walks basedOn chain
Table styles
final tableStyle = NovidentTableStyleDefinition(
defaultRowStyle: NovidentTableRowStyle(
backgroundColor: Colors.white,
borderColor: Colors.grey.shade300,
),
headerStyle: NovidentTableRowStyle(
backgroundColor: Colors.blue.shade50,
bold: true,
),
zebraStripe: true,
zebraStripeColor: Colors.grey.shade100,
borderWidth: 1.0,
);
Font provider
final fontProvider = NovidentFontProvider.fromList(
['Arial', 'Times New Roman', 'Georgia'],
defaultFamily: 'Arial',
);
final resolvedFont = fontProvider.resolve('NonExistentFont');
// → 'Arial' (the guaranteed non-null fallback)
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 build style configuration UIs, document previews, or any tool that needs to resolve paragraph styles without the full editor.