WIP: markdown reader, data migration, 编辑器增强等

This commit is contained in:
DelLevin-Home
2026-05-22 03:24:17 +08:00
parent edf35c5844
commit 8d5e1642d6
19 changed files with 2371 additions and 1177 deletions

View File

@@ -294,6 +294,7 @@ class Book {
/// 笔记模型
class Note {
final String id;
final String title;
final String content;
final String contentType; // markdown / plain_text
final List<String> tags;
@@ -304,6 +305,7 @@ class Note {
Note({
required this.id,
required this.title,
required this.content,
this.contentType = 'markdown',
this.tags = const [],
@@ -316,6 +318,7 @@ class Note {
factory Note.fromJson(Map<String, dynamic> json) {
return Note(
id: json['id']?.toString() ?? '',
title: json['title'] ?? '',
content: json['content'] ?? '',
contentType: json['content_type'] ?? 'markdown',
tags: Movie.parseStringList(json['tags']),
@@ -333,6 +336,7 @@ class Note {
Map<String, dynamic> toJson() {
return {
'id': id,
'title': title,
'content': content,
'content_type': contentType,
'tags': jsonEncode(tags),
@@ -346,6 +350,7 @@ class Note {
/// 复制并修改
Note copyWith({
String? id,
String? title,
String? content,
String? contentType,
List<String>? tags,
@@ -356,6 +361,7 @@ class Note {
}) {
return Note(
id: id ?? this.id,
title: title ?? this.title,
content: content ?? this.content,
contentType: contentType ?? this.contentType,
tags: tags ?? this.tags,

View File

@@ -84,6 +84,7 @@ extension NoteExtension on Note {
/// 创建副本并允许修改部分属性
Note copyWith({
String? id,
String? title,
String? content,
String? contentType,
List<String>? tags,
@@ -94,6 +95,7 @@ extension NoteExtension on Note {
}) {
return Note(
id: id ?? this.id,
title: title ?? this.title,
content: content ?? this.content,
contentType: contentType ?? this.contentType,
tags: tags ?? this.tags,