Mache große IMAP-Fächer, die Paperless-Suche und die interne Markdown-Notiz über die gemeinsamen Schnittstellen benutzbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c3a07cee64
commit
7e39fbb2bd
29 files changed
+6053
-320
No files matched your search
@@ -1,10 +1,12 @@
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { SessionContext } from "../session.js";
|
||||
import { documentToText, downloadMailPart, fetchExternal, fetchFile, fetchMailPart, markDirty, textToDocument, api } from "../api.js";
|
||||
import { documentToText, downloadMailPart, fetchExternal, fetchFile, fetchMailPart, isDirty, markDirty, textToDocument, api } from "../api.js";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
import { NoteEditor } from "../notes.jsx";
|
||||
import { SourceAssignment, noteEditor, representationOf } from "../sources/registry.jsx";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import { UnitDetail } from "./correspondence.jsx";
|
||||
import { dateCaption, DateField, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
|
||||
import { dateCaption, DateField, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, sourceLabel } from "./content.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
@@ -95,6 +97,10 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
const [receivedOn, setReceivedOn] = useState("");
|
||||
const [notice, setNotice] = useState("");
|
||||
const [annotate, setAnnotate] = useState(false);
|
||||
const [editingNote, setEditingNote] = useState(false);
|
||||
const [noteSession, setNoteSession] = useState(0);
|
||||
const editingRef = useRef(false);
|
||||
const pendingNote = useRef("");
|
||||
const [letter, setLetter] = useState(null);
|
||||
const [shownFor, setShownFor] = useState(null);
|
||||
const shownIndex = shownFor?.elementId === element?.id ? shownFor.index : null;
|
||||
@@ -108,7 +114,13 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
|
||||
useEffect(() => {
|
||||
if (!element) return undefined;
|
||||
setText(element.kind === "note" ? documentToText(element.document) : "");
|
||||
if (!editingRef.current) {
|
||||
const saved = element.kind === "note" ? documentToText(element.document) : "";
|
||||
if (!pendingNote.current || pendingNote.current === saved) {
|
||||
pendingNote.current = "";
|
||||
setText(saved);
|
||||
}
|
||||
}
|
||||
setDocumentOn(element.dates?.document_on || "");
|
||||
setSentOn(element.dates?.sent_on || "");
|
||||
setReceivedOn(element.dates?.received_on || "");
|
||||
@@ -364,6 +376,9 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
context,
|
||||
document: textToDocument(text),
|
||||
});
|
||||
pendingNote.current = text;
|
||||
editingRef.current = false;
|
||||
setEditingNote(false);
|
||||
markDirty(false);
|
||||
setNotice(updated.notice || "Der gemeinsame Text ist gespeichert.");
|
||||
onReload();
|
||||
@@ -376,6 +391,31 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}
|
||||
}
|
||||
|
||||
function beginNote() {
|
||||
pendingNote.current = "";
|
||||
editingRef.current = true;
|
||||
setText(documentToText(element.document));
|
||||
setNoteSession((current) => current + 1);
|
||||
setEditingNote(true);
|
||||
setError("");
|
||||
setNotice("");
|
||||
}
|
||||
|
||||
function cancelNote() {
|
||||
pendingNote.current = "";
|
||||
editingRef.current = false;
|
||||
setText(documentToText(element.document));
|
||||
setEditingNote(false);
|
||||
markDirty(false);
|
||||
setError("");
|
||||
}
|
||||
|
||||
function requestClose() {
|
||||
if (editingRef.current && isDirty() && !window.confirm("Ungespeicherte Eingaben verwerfen?")) return;
|
||||
markDirty(false);
|
||||
onClose();
|
||||
}
|
||||
|
||||
async function saveSummary(event) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
@@ -533,7 +573,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
<NavIcon name="link" />
|
||||
</button>
|
||||
) : null}
|
||||
<button ref={closeRef} type="button" className="icon-button" aria-label="Leser schließen" onClick={onClose}>
|
||||
<button ref={closeRef} type="button" className="icon-button" aria-label="Leser schließen" onClick={requestClose}>
|
||||
<NavIcon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
@@ -587,12 +627,23 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
</article>
|
||||
) : null}
|
||||
{element.kind === "note" && noteEditor.available ? (
|
||||
<form className="reader-note" onSubmit={saveNote}>
|
||||
<MarkdownEditor value={text} disabled={!binding.rights.edit} onChange={(value) => { setText(value); markDirty(true); }} />
|
||||
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung. Gespeichert wird Markdown.</p>
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
{binding.rights.edit ? <button type="submit">Text speichern</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
|
||||
</form>
|
||||
editingNote && binding.rights.edit ? (
|
||||
<form className="reader-note" onSubmit={saveNote}>
|
||||
<NoteEditor key={noteSession} value={text} onChange={(value) => { setText(value); markDirty(true); }} />
|
||||
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung. Gespeichert wird Markdown.</p>
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
<div className="row">
|
||||
<button type="submit">Text speichern</button>
|
||||
<button type="button" className="quiet" onClick={cancelNote}>Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div className="reader-note">
|
||||
{text.trim() ? <MarkdownView text={text} /> : <p className="muted">Die Notiz ist leer.</p>}
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
{binding.rights.edit ? <button type="button" onClick={beginNote}>Bearbeiten</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
<form className="stack reader-direction" onSubmit={(event) => event.preventDefault()}>
|
||||
<DirectionChoice
|
||||
|
||||
Reference in new issue
Block a user