diff --git a/src/components/editor-page/splitter/hooks/use-adjusted-relative-split-value.ts b/src/components/editor-page/splitter/hooks/use-adjusted-relative-split-value.ts index 98f3127a7..60c0a5c8f 100644 --- a/src/components/editor-page/splitter/hooks/use-adjusted-relative-split-value.ts +++ b/src/components/editor-page/splitter/hooks/use-adjusted-relative-split-value.ts @@ -20,14 +20,11 @@ export const useAdjustedRelativeSplitValue = ( relativeSplitValue: number ): number => useMemo(() => { - let splitValue: number if (!showLeft && showRight) { - splitValue = 0 + return 0 } else if (showLeft && !showRight) { - splitValue = 100 + return 100 } else { - splitValue = relativeSplitValue + return Math.min(100, Math.max(0, relativeSplitValue)) } - - return Math.min(100, Math.max(0, splitValue)) }, [relativeSplitValue, showLeft, showRight]) diff --git a/src/components/markdown-renderer/markdown-extension/highlighted-fence/highlighted-code-replacer.tsx b/src/components/markdown-renderer/markdown-extension/highlighted-fence/highlighted-code-replacer.tsx index 560df4ce8..b9923591c 100644 --- a/src/components/markdown-renderer/markdown-extension/highlighted-fence/highlighted-code-replacer.tsx +++ b/src/components/markdown-renderer/markdown-extension/highlighted-fence/highlighted-code-replacer.tsx @@ -30,17 +30,9 @@ export class HighlightedCodeReplacer extends ComponentReplacer { const language = codeNode.attribs['data-highlight-language'] const extraData = codeNode.attribs['data-extra'] const extraInfos = /(=(\d+|\+)?)?(!?)/.exec(extraData) - - let showLineNumbers = false - let startLineNumberAttribute = '' - let wrapLines = false - - if (extraInfos) { - showLineNumbers = extraInfos[1]?.startsWith('=') || false - startLineNumberAttribute = extraInfos[2] - wrapLines = extraInfos[3] === '!' - } - + const showLineNumbers = extraInfos ? extraInfos[1]?.startsWith('=') : false + const startLineNumberAttribute = extraInfos?.[2] ?? '' + const wrapLines = extraInfos?.[3] === '!' const startLineNumber = startLineNumberAttribute === '+' ? this.lastLineNumber : parseInt(startLineNumberAttribute) || 1 diff --git a/src/components/markdown-renderer/node-preprocessors/node-processor.ts b/src/components/markdown-renderer/node-preprocessors/node-processor.ts index 8c631ac6c..020de40a2 100644 --- a/src/components/markdown-renderer/node-preprocessors/node-processor.ts +++ b/src/components/markdown-renderer/node-preprocessors/node-processor.ts @@ -7,5 +7,5 @@ import type { Document } from 'domhandler' export abstract class NodeProcessor { - public abstract process(nodes: Document): Document + public abstract process(document: Document): Document }