How to use the react-diff-view.useSourceExpansion function in react-diff-view

To help you get started, we’ve selected a few react-diff-view examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github otakustay / react-diff-view / site / components / DiffView / index.js View on Github external
const useEnhance = (hunks, oldSource, {language, editsType}) => {
    const [hunksWithSourceExpanded, expandRange] = useSourceExpansion(hunks, oldSource);
    const hunksWithMinLinesCollapsed = useMinCollapsedLines(5, hunksWithSourceExpanded, oldSource);
    const [selection, toggleSelection] = useChangeSelect(hunksWithMinLinesCollapsed, {multiple: true});
    const tokenizePayload = {
        oldSource,
        language,
        editsType,
        hunks: hunksWithMinLinesCollapsed,
    };
    const {tokens} = useTokenizeWorker(tokenize, tokenizePayload);
    return {
        expandRange,
        selection,
        toggleSelection,
        tokens,
        hunks: hunksWithMinLinesCollapsed,
    };