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:
@@ -0,0 +1,38 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_quill/flutter_quill.dart';
|
||||
|
||||
Document noteBodyToDocument(String storedBody) {
|
||||
final String trimmedBody = storedBody.trimLeft();
|
||||
|
||||
if (trimmedBody.startsWith('[')) {
|
||||
try {
|
||||
final dynamic decoded = jsonDecode(storedBody);
|
||||
if (decoded is List) {
|
||||
return Document.fromJson(decoded);
|
||||
}
|
||||
} catch (_) {
|
||||
// Fall back to plain text for legacy notes or malformed JSON.
|
||||
}
|
||||
}
|
||||
|
||||
if (storedBody.isEmpty) {
|
||||
return Document();
|
||||
}
|
||||
|
||||
final String plainText = storedBody.endsWith('\n')
|
||||
? storedBody
|
||||
: '$storedBody\n';
|
||||
|
||||
return Document.fromJson(<dynamic>[
|
||||
<String, String>{'insert': plainText},
|
||||
]);
|
||||
}
|
||||
|
||||
String noteBodyToPlainText(String storedBody) {
|
||||
return noteBodyToDocument(storedBody).toPlainText();
|
||||
}
|
||||
|
||||
String noteDocumentToStorageJson(Document document) {
|
||||
return jsonEncode(document.toDelta().toJson());
|
||||
}
|
||||
Reference in New Issue
Block a user