feat(import): one Import-file entry + vault notebooks
All checks were successful
CI / Windows build (push) Successful in 14m14s

Phase 3. Import becomes a single top-level action beside "Create
notebook" and the library is vault-backed.

- VaultService.createNotebook copies a picked file into a fresh
  (de-duplicated) notebook folder under the vault; its sidecar lives
  beside it, so annotations travel with the file.
- Home screen: one "Import file" action with a multi-extension picker
  (pdf / docx / pptx); routes to the editor by extension.
- The document list is now a vault scan (folders with a source file),
  not the SQLite documents table — no cache, always correct.
- PPTX soffice detection fix; DOCX convert-on-import is best-effort
  and fails gracefully when LibreOffice is unavailable.

analyze clean, tests green.
This commit is contained in:
2026-06-24 21:12:38 +08:00
parent 978111eeff
commit 2f0fda5f95
10 changed files with 654 additions and 97 deletions

View File

@@ -5,6 +5,19 @@
"search": "Search",
"importPdf": "Import PDF",
"importPpt": "Import PPT",
"importFile": "Import file",
"createNotebook": "Create notebook",
"noDocumentsYet": "No documents yet — tap Import file",
"processingImport": "Importing…",
"importFailed": "Couldn't import that file: {error}",
"@importFailed": {
"placeholders": { "error": { "type": "String" } }
},
"convertNeedsLibreOffice": "Importing Word documents needs LibreOffice installed. Convert to PDF first, or install LibreOffice.",
"unsupportedFileType": "Unsupported file type: {ext}",
"@unsupportedFileType": {
"placeholders": { "ext": { "type": "String" } }
},
"penCanvasBeta": "Pen Canvas (beta)",
"newNote": "New Note",
"open": "Open",

View File

@@ -128,6 +128,48 @@ abstract class AppLocalizations {
/// **'Import PPT'**
String get importPpt;
/// No description provided for @importFile.
///
/// In en, this message translates to:
/// **'Import file'**
String get importFile;
/// No description provided for @createNotebook.
///
/// In en, this message translates to:
/// **'Create notebook'**
String get createNotebook;
/// No description provided for @noDocumentsYet.
///
/// In en, this message translates to:
/// **'No documents yet — tap Import file'**
String get noDocumentsYet;
/// No description provided for @processingImport.
///
/// In en, this message translates to:
/// **'Importing…'**
String get processingImport;
/// No description provided for @importFailed.
///
/// In en, this message translates to:
/// **'Couldn\'t import that file: {error}'**
String importFailed(String error);
/// No description provided for @convertNeedsLibreOffice.
///
/// In en, this message translates to:
/// **'Importing Word documents needs LibreOffice installed. Convert to PDF first, or install LibreOffice.'**
String get convertNeedsLibreOffice;
/// No description provided for @unsupportedFileType.
///
/// In en, this message translates to:
/// **'Unsupported file type: {ext}'**
String unsupportedFileType(String ext);
/// No description provided for @penCanvasBeta.
///
/// In en, this message translates to:

View File

@@ -23,6 +23,32 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get importPpt => 'Import PPT';
@override
String get importFile => 'Import file';
@override
String get createNotebook => 'Create notebook';
@override
String get noDocumentsYet => 'No documents yet — tap Import file';
@override
String get processingImport => 'Importing…';
@override
String importFailed(String error) {
return 'Couldn\'t import that file: $error';
}
@override
String get convertNeedsLibreOffice =>
'Importing Word documents needs LibreOffice installed. Convert to PDF first, or install LibreOffice.';
@override
String unsupportedFileType(String ext) {
return 'Unsupported file type: $ext';
}
@override
String get penCanvasBeta => 'Pen Canvas (beta)';

View File

@@ -23,6 +23,32 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get importPpt => '导入 PPT';
@override
String get importFile => '导入文件';
@override
String get createNotebook => '新建笔记本';
@override
String get noDocumentsYet => '暂无文档——点按“导入文件”';
@override
String get processingImport => '正在导入…';
@override
String importFailed(String error) {
return '无法导入该文件:$error';
}
@override
String get convertNeedsLibreOffice =>
'导入 Word 文档需要安装 LibreOffice。请先转换为 PDF或安装 LibreOffice。';
@override
String unsupportedFileType(String ext) {
return '不支持的文件类型:$ext';
}
@override
String get penCanvasBeta => '手写画布(测试版)';

View File

@@ -5,6 +5,13 @@
"search": "搜索",
"importPdf": "导入 PDF",
"importPpt": "导入 PPT",
"importFile": "导入文件",
"createNotebook": "新建笔记本",
"noDocumentsYet": "暂无文档——点按“导入文件”",
"processingImport": "正在导入…",
"importFailed": "无法导入该文件:{error}",
"convertNeedsLibreOffice": "导入 Word 文档需要安装 LibreOffice。请先转换为 PDF或安装 LibreOffice。",
"unsupportedFileType": "不支持的文件类型:{ext}",
"penCanvasBeta": "手写画布(测试版)",
"newNote": "新建笔记",
"open": "打开",