feat(notes): rich-text editor with tiptap (task 85)
Replace plain textarea with shared tiptap editor and sanitized html rendering. Adds interactive checklists on read surfaces and mobile overflow fixes.
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
import { FileText, Pin } from "lucide-react";
|
||||
import type { NoteShareData } from "../server/share-queries";
|
||||
import { ShareEyebrow } from "@/components/share/share-eyebrow";
|
||||
"use client";
|
||||
|
||||
export function NoteSharedView({ data }: { data: NoteShareData }) {
|
||||
import { FileText, Pin } from "lucide-react";
|
||||
import { RichTextContent } from "@/components/rich-text";
|
||||
import { ShareEyebrow } from "@/components/share/share-eyebrow";
|
||||
import type { NoteShareData } from "../server/share-queries";
|
||||
import { toggleShareNoteChecklistItem } from "../server/checklist-actions";
|
||||
|
||||
type Props = {
|
||||
data: NoteShareData;
|
||||
canWrite?: boolean;
|
||||
token?: string;
|
||||
};
|
||||
|
||||
export function NoteSharedView({ data, canWrite = false, token }: Props) {
|
||||
const updated = new Date(data.updatedAt).toLocaleDateString(undefined, {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
@@ -39,20 +49,19 @@ export function NoteSharedView({ data }: { data: NoteShareData }) {
|
||||
<span>Updated {updated}</span>
|
||||
</p>
|
||||
|
||||
{data.body && (
|
||||
<div
|
||||
className="serif"
|
||||
style={{
|
||||
fontSize: 16,
|
||||
lineHeight: 1.7,
|
||||
color: "var(--ink-2)",
|
||||
whiteSpace: "pre-wrap",
|
||||
textWrap: "pretty",
|
||||
}}
|
||||
>
|
||||
{data.body}
|
||||
</div>
|
||||
)}
|
||||
{data.body ? (
|
||||
<RichTextContent
|
||||
html={data.body}
|
||||
interactiveChecklists={canWrite && !!token}
|
||||
onToggleChecklist={
|
||||
canWrite && token
|
||||
? async (taskIndex, checked) => {
|
||||
await toggleShareNoteChecklistItem(token, data.id, taskIndex, checked);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user