File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -716,10 +716,13 @@ function PptxPreview({
716716
717717function toggleMarkdownCheckbox ( markdown : string , targetIndex : number , checked : boolean ) : string {
718718 let currentIndex = 0
719- return markdown . replace ( / ^ ( \s * [ - * + ] \s + ) \[ ( [ x X ] ) \] / gm, ( match , prefix : string ) => {
720- if ( currentIndex ++ !== targetIndex ) return match
721- return `${ prefix } [${ checked ? 'x' : ' ' } ]`
722- } )
719+ return markdown . replace (
720+ / ^ ( \s * (?: [ - * + ] | \d + [ . ) ] ) + ) \[ ( [ x X ] ) \] / gm,
721+ ( match , prefix : string ) => {
722+ if ( currentIndex ++ !== targetIndex ) return match
723+ return `${ prefix } [${ checked ? 'x' : ' ' } ]`
724+ }
725+ )
723726}
724727
725728const UnsupportedPreview = memo ( function UnsupportedPreview ( {
Original file line number Diff line number Diff line change @@ -237,6 +237,11 @@ const MarkdownPreview = memo(function MarkdownPreview({
237237 [ onCheckboxToggle ]
238238 )
239239
240+ const committedCheckboxCount = useMemo (
241+ ( ) => ( committed ? ( committed . match ( / ^ [ \t ] * (?: [ - * + ] | \d + [ . ) ] ) + \[ [ x X ] \] / gm) ?? [ ] ) . length : 0 ) ,
242+ [ committed ]
243+ )
244+
240245 checkboxCounterRef . current = 0
241246
242247 const committedMarkdown = useMemo (
@@ -249,6 +254,8 @@ const MarkdownPreview = memo(function MarkdownPreview({
249254 [ committed , components ]
250255 )
251256
257+ checkboxCounterRef . current = committedCheckboxCount
258+
252259 return (
253260 < div ref = { scrollRef } className = 'h-full overflow-auto p-6' >
254261 { committedMarkdown }
You can’t perform that action at this time.
0 commit comments