* chore: update Flutter SDK to version 3.38.5 Upgrade Flutter from 3.32.4 to 3.38.5 to meet awesome_lints requirement for Dart SDK 3.10.0+. Update CI workflow to use the new Flutter version and add custom_lint verification step. * chore: integrate awesome_lints with custom lint rules Add awesome_lints and custom_lint dependencies, configure analysis_options.yaml to enable newline lint rules: newline_before_case, newline_before_constructor, newline_before_method, and newline_before_return. * style: apply newline formatting per awesome_lints rules Add blank lines before case clauses, return statements, method declarations, and constructors throughout the codebase to comply with awesome_lints newline rules. * fix: replace deprecated translate with leftTranslateByDouble Update Matrix4.translate() calls to use the new leftTranslateByDouble() API to resolve deprecation warnings in Flutter SDK 3.38.5. * chore: improve code readability with blank line formatting
67 lines
1.8 KiB
Dart
67 lines
1.8 KiB
Dart
import 'package:appflowy_editor/appflowy_editor.dart';
|
|
|
|
import 'typedef_util.dart';
|
|
|
|
extension NodeExtension on Node {
|
|
void addParagraphs(
|
|
int count, {
|
|
TextBuilder? builder,
|
|
String? initialText,
|
|
NodeDecorator? decorator,
|
|
}) {
|
|
final builder0 = builder ??
|
|
(index) => Delta()
|
|
..insert(initialText ?? '🔥 $index. Welcome to AppFlowy Editor!');
|
|
final decorator0 = decorator ?? (index, node) {};
|
|
final nodes = List.generate(
|
|
count,
|
|
(index) {
|
|
final node = Node(type: 'paragraph');
|
|
decorator0(index, node);
|
|
node.updateAttributes({
|
|
'delta': builder0(index).toJson(),
|
|
});
|
|
|
|
return node;
|
|
},
|
|
);
|
|
nodes.forEach(insert);
|
|
}
|
|
|
|
void addParagraph({
|
|
TextBuilder? builder,
|
|
String? initialText,
|
|
NodeDecorator? decorator,
|
|
}) {
|
|
addParagraphs(
|
|
1,
|
|
builder: builder,
|
|
initialText: initialText,
|
|
decorator: decorator,
|
|
);
|
|
}
|
|
|
|
bool everyAttributeValue(
|
|
Selection selection,
|
|
String key,
|
|
bool Function(dynamic value) test,
|
|
) {
|
|
return allSatisfyInSelection(
|
|
selection,
|
|
(delta) => delta.whereType<TextInsert>().every(
|
|
(element) => test(element.attributes?[key]),
|
|
),
|
|
);
|
|
}
|
|
|
|
bool allBold(Selection selection) =>
|
|
everyAttributeValue(selection, 'bold', (value) => value == true);
|
|
bool allItalic(Selection selection) =>
|
|
everyAttributeValue(selection, 'italic', (value) => value == true);
|
|
bool allCode(Selection selection) =>
|
|
everyAttributeValue(selection, 'code', (value) => value == true);
|
|
bool allStrikethrough(Selection selection) =>
|
|
everyAttributeValue(selection, 'strikethrough', (value) => value == true);
|
|
bool allUnderline(Selection selection) =>
|
|
everyAttributeValue(selection, 'underline', (value) => value == true);
|
|
}
|