feat: integrate Flutter Quill for rich text editing and update note handling
- Added Flutter Quill package for rich text editing capabilities. - Refactored note body handling to support Quill's Document format. - Updated note editor screen to use QuillEditor and QuillController. - Enhanced note search functionality to convert note body to plain text. - Modified note card display to show plain text from note body. - Updated localization support for Quill in the app. - Registered necessary plugins for URL launching and file selection on all platforms. - Updated app icons and other assets for consistency across platforms. - Updated pubspec.yaml and pubspec.lock to include new dependencies and versions.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:notas/data/note_body.dart';
|
||||
import 'package:notas/models/note.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
|
||||
@@ -77,26 +78,27 @@ class _NoteCardState extends State<NoteCard> {
|
||||
// running the expensive TextPainter layout. This heuristic counts
|
||||
// newline characters and estimates wrapped lines based on an
|
||||
// average characters-per-line to handle many short lines well.
|
||||
final List<String> rawLines = widget.note.body.split('\n');
|
||||
final String bodyText = noteBodyToPlainText(widget.note.body);
|
||||
final List<String> rawLines = bodyText.split('\n');
|
||||
const int avgCharsPerLine = 40;
|
||||
int estimatedLines = 0;
|
||||
for (final String line in rawLines) {
|
||||
estimatedLines += (line.trim().length ~/ avgCharsPerLine) + 1;
|
||||
}
|
||||
|
||||
final bool needsPreciseMeasurement = estimatedLines > 20;
|
||||
final bool needsPreciseMeasurement = estimatedLines > 15;
|
||||
final bool isBodyTruncated;
|
||||
|
||||
if (needsPreciseMeasurement) {
|
||||
final TextPainter textPainter = TextPainter(
|
||||
text: TextSpan(
|
||||
text: widget.note.body,
|
||||
text: bodyText,
|
||||
style: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
maxLines: 20,
|
||||
maxLines: 15,
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout(maxWidth: constraints.maxWidth);
|
||||
|
||||
@@ -121,12 +123,12 @@ class _NoteCardState extends State<NoteCard> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
widget.note.body,
|
||||
bodyText,
|
||||
style: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 20,
|
||||
maxLines: 15,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
if (isBodyTruncated) ...[
|
||||
|
||||
Reference in New Issue
Block a user