@@ -28,12 +28,15 @@ class AutoFormats {
2828 : _autoFormats = autoFormats;
2929
3030 /// Default set of auto formats.
31- factory AutoFormats .fallback () {
31+ ///
32+ /// Use [additionalFormats] to add your autoformats to the default set.
33+ factory AutoFormats .fallback ([List <AutoFormat >? additionalFormats]) {
3234 return AutoFormats (autoFormats: [
33- const _AutoFormatLinks (),
34- const _MarkdownInlineShortcuts (),
35- const _MarkdownLineShortcuts (),
36- const _AutoTextDirection (),
35+ const AutoFormatLinks (),
36+ const MarkdownInlineShortcuts (),
37+ const MarkdownLineShortcuts (),
38+ const AutoTextDirection (),
39+ ...? additionalFormats,
3740 ]);
3841 }
3942
@@ -119,11 +122,11 @@ class AutoFormatResult {
119122 final int undoPositionCandidate;
120123}
121124
122- class _AutoFormatLinks extends AutoFormat {
125+ class AutoFormatLinks extends AutoFormat {
123126 static final _urlRegex =
124127 RegExp (r'^(.?)((?:https?://|www\.)[^\s/$.?#].[^\s]*)' );
125128
126- const _AutoFormatLinks ();
129+ const AutoFormatLinks ();
127130
128131 @override
129132 AutoFormatResult ? apply (
@@ -166,15 +169,15 @@ class _AutoFormatLinks extends AutoFormat {
166169}
167170
168171// Replaces certain Markdown shortcuts with actual inline styles.
169- class _MarkdownInlineShortcuts extends AutoFormat {
172+ class MarkdownInlineShortcuts extends AutoFormat {
170173 static final rules = < String , ParchmentAttribute > {
171174 '**' : ParchmentAttribute .bold,
172175 '*' : ParchmentAttribute .italic,
173176 '`' : ParchmentAttribute .inlineCode,
174177 '~~' : ParchmentAttribute .strikethrough,
175178 };
176179
177- const _MarkdownInlineShortcuts ();
180+ const MarkdownInlineShortcuts ();
178181
179182 @override
180183 AutoFormatResult ? apply (
@@ -222,7 +225,7 @@ class _MarkdownInlineShortcuts extends AutoFormat {
222225}
223226
224227// Replaces certain Markdown shortcuts with actual line or block styles.
225- class _MarkdownLineShortcuts extends AutoFormat {
228+ class MarkdownLineShortcuts extends AutoFormat {
226229 static final rules = < String , ParchmentAttribute > {
227230 '-' : ParchmentAttribute .block.bulletList,
228231 '*' : ParchmentAttribute .block.bulletList,
@@ -236,7 +239,7 @@ class _MarkdownLineShortcuts extends AutoFormat {
236239 '###' : ParchmentAttribute .h3,
237240 };
238241
239- const _MarkdownLineShortcuts ();
242+ const MarkdownLineShortcuts ();
240243
241244 String ? _getLinePrefix (DeltaIterator iter, int index) {
242245 final prefixOps = skipToLineAt (iter, index);
@@ -383,8 +386,8 @@ class _MarkdownLineShortcuts extends AutoFormat {
383386
384387// Infers text direction from the input when happens in the beginning of a line.
385388// This rule also removes alignment and sets it based on inferred direction.
386- class _AutoTextDirection extends AutoFormat {
387- const _AutoTextDirection ();
389+ class AutoTextDirection extends AutoFormat {
390+ const AutoTextDirection ();
388391
389392 final _isRTL = intl.Bidi .startsWithRtl;
390393
0 commit comments