mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-08-28 05:56:42 +00:00
docs(markdown-editor): trim restatement/redundant comments
A comment audit against the zero-default policy: the module's comments are overwhelmingly genuine framework gotchas (undo → silent data corruption / crash / perf regression) and stay. Cut only the handful that fail the wrong-action test: - the "closures read latest props" reassurance (no wrong action it prevents), - two JSDoc lines that restated self-documenting function names (cycleTextareaToVariable, insertTextareaText — the caret gotcha stays inline), - two per-member handle JSDocs that restated method names (the interface-level mode contract stays), - tightened the 6-line undo-clear block to 2. No behavior change; 220 module tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
587d8a0ecf
commit
831d9b8be2
@@ -22,10 +22,8 @@ const MarkdownEditor = lazy(() => import('./markdown-editor').then((module) => (
|
||||
* each implement them — so a consumer drives the field the same way whether it renders raw source or rich.
|
||||
*/
|
||||
export interface MarkdownEditorFieldHandle {
|
||||
/** Select the next occurrence of `variable` and scroll it into view; `false` when it isn't used. */
|
||||
cycleToVariable: (variable: string) => boolean;
|
||||
focus: () => void;
|
||||
/** Insert `text` at the caret, replacing any selection. */
|
||||
insertAtCursor: (text: string) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { findVariableUseRanges, nextVariableRange } from './markdown-editor-variable-syntax';
|
||||
|
||||
/** Select the next occurrence of `variable` in the textarea and scroll it to the middle. Returns false if none. */
|
||||
export function cycleTextareaToVariable(textarea: HTMLTextAreaElement, variable: string): boolean {
|
||||
const ranges = findVariableUseRanges(textarea.value, variable).map(({ index, length }) => ({
|
||||
end: index + length,
|
||||
@@ -19,7 +18,6 @@ export function cycleTextareaToVariable(textarea: HTMLTextAreaElement, variable:
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Splice `text` over the textarea selection, emit through `onChange`, and restore the caret after the value round-trips. */
|
||||
export function insertTextareaText(
|
||||
textarea: HTMLTextAreaElement,
|
||||
text: string,
|
||||
|
||||
@@ -103,7 +103,6 @@ function MarkdownEditor({
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const extensions = useMemo(() => createMarkdownExtensions(placeholder), []);
|
||||
|
||||
// tiptap invokes onBlur/onUpdate from its live options ref, so these closures always read the latest props.
|
||||
const editor = useEditor({
|
||||
content: initialContent,
|
||||
contentType: 'markdown',
|
||||
@@ -207,12 +206,8 @@ function MarkdownEditor({
|
||||
// would re-emit the round-trip normalization as if it were an edit.
|
||||
lastEmittedRef.current = editor.getMarkdown();
|
||||
|
||||
// Clear the undo stack:
|
||||
// - on initial mount, to discard the construction-time
|
||||
// transactions dispatched by extensions like `trailingNode`;
|
||||
// - on every external `setContent` (e.g. parent calls
|
||||
// form.reset(serverDocument)), because that transaction is
|
||||
// not a user edit either.
|
||||
// Clear the undo stack of the construction-time transactions (mount) and each external setContent
|
||||
// (form.reset) — neither is a user edit, so neither should be undoable.
|
||||
if (!hasResetInitialHistoryRef.current || isExternalChange) {
|
||||
hasResetInitialHistoryRef.current = true;
|
||||
resetUndoHistory(editor);
|
||||
|
||||
Reference in New Issue
Block a user