chore(editor): trim comments that restate code or defend implementation

Review follow-ups:
- knowledge-form.tsx: drop the DirtyFlags comment (restates the type) and the
  "backend also wipes subtypes" parenthetical (defends a redundant path).
- markdown-editor-extensions.test.ts: drop the roundTrip narration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Sergey Kozyrenko
2026-06-30 13:21:54 +07:00
co-authored by Claude Opus 4.8
parent 26441bfd5a
commit 52ec6667b6
2 changed files with 2 additions and 9 deletions
@@ -12,8 +12,6 @@ beforeAll(() => {
({ item: () => null, length: 0, [Symbol.iterator]: [][Symbol.iterator] }) as unknown as DOMRectList;
});
// Runs the EXACT production extension set (createMarkdownExtensions) through the official
// @tiptap/markdown round-trip: markdown string -> marked parse -> ProseMirror doc -> getMarkdown().
const roundTrip = (content: string): string => {
const editor = new Editor({ content, contentType: 'markdown', extensions: createMarkdownExtensions() });
const out = editor.getMarkdown();
@@ -119,9 +119,6 @@ export const documentToFormValues = (k: KnowledgeDocumentFragmentFragment): Form
question: k.question,
});
// react-hook-form's `dirtyFields` is a partial map of the same shape as
// `FormValues`, with `true` for fields the user actually changed compared to
// `defaultValues`. We project it onto the (flat) FormValues keys here.
export type DirtyFlags = Partial<Record<keyof FormValues, boolean>>;
// CREATE: send all required fields and only non-empty optional fields. There
@@ -142,10 +139,8 @@ export const formValuesToCreateInput = (values: FormValues): CreateKnowledgeDocu
// every other field is gated by `dirty`. This way:
// - untouched fields stay `undefined` and the backend keeps the existing value;
// - cleared fields go out as `""` so the backend wipes them;
// - subtype-related fields cleared by `setValue` on docType change are
// marked dirty by the form, so they reach the backend with the right
// "clear me" value (the backend additionally wipes mismatching subtypes
// itself, but we mirror the user-visible state explicitly).
// - subtype-related fields cleared by `setValue` on docType change are marked
// dirty by the form, so they reach the backend with the right "clear me" value.
export const formValuesToUpdateInput = (values: FormValues, dirty: DirtyFlags): UpdateKnowledgeDocumentInput => {
const input: UpdateKnowledgeDocumentInput = { content: values.content };