Implementation:Infiniflow Ragflow UseChangeDocumentParser Hook
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Knowledge_Base |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Hook for managing document parser change operations with modal state and API integration.
Description
useChangeDocumentParser combines useSetDocumentParser for the API call with useSetModalState for modal visibility. It maintains the target document record in local state. showChangeParserModal sets the record and opens the modal. onChangeParserOk calls setDocumentParser with the new parser ID, pipeline ID, and parser config, then closes the modal on success (return code 0). The hook also exports a UseChangeDocumentParserShowType utility type that extracts just the showChangeParserModal function for type-safe prop passing.
Usage
Used by DatasetTable to manage the chunk method change dialog lifecycle for individual documents.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: web/src/pages/dataset/dataset/use-change-document-parser.ts
- Lines: 1-55
Signature
export const useChangeDocumentParser = () => {
changeParserLoading, onChangeParserOk, changeParserVisible,
hideChangeParserModal, showChangeParserModal, changeParserRecord,
};
export type UseChangeDocumentParserShowType = Pick<
ReturnType<typeof useChangeDocumentParser>, 'showChangeParserModal'
>;
Import
import { useChangeDocumentParser, UseChangeDocumentParserShowType } from './use-change-document-parser';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | - | - | Hook manages state internally |
Outputs
| Name | Type | Description |
|---|---|---|
| showChangeParserModal | function | Open modal with a document record |
| onChangeParserOk | function | Submit parser change with IChangeParserRequestBody |
| changeParserRecord | IDocumentInfo | Currently targeted document |
Usage Examples
const { showChangeParserModal, onChangeParserOk, changeParserVisible } = useChangeDocumentParser();