Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ export default defineESLintConfig(
'react-hooks/refs': 'error',
// https://github.com/facebook/react/blob/d083ec1da1e5252abd3ddfdde6dfbc09701a2c51/compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts#L981-L988
'react-hooks/todo': 'error',
'react-hooks/capitalized-calls': 'error',
'react-hooks/exhaustive-effect-dependencies': 'error',
'react-hooks/fbt': 'error',
'react-hooks/hooks': 'error',
'react-hooks/incompatible-library': 'error',
'react-hooks/invariant': 'error',
'react-hooks/memo-dependencies': 'error',
'react-hooks/memoized-effect-dependencies': 'error',
'react-hooks/no-deriving-state-in-effects': 'error',
'react-hooks/rule-suppression': 'error',
'react-hooks/syntax': 'error',
'react-hooks/unsupported-syntax': 'error',
},
},
meowdownConfig,
Expand Down
27 changes: 15 additions & 12 deletions website/src/components/selection-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ interface DemoRun {
cancelled: boolean
}

function streamText(run: DemoRun, text: string, append: (chunk: string) => void): void {
let offset = 0
const timer = setInterval(() => {
if (run.cancelled || offset >= text.length) {
clearInterval(timer)
return
}
append(text.slice(offset, offset + STREAM_CHUNK_SIZE))
offset += STREAM_CHUNK_SIZE
}, STREAM_INTERVAL_MS)
}

const ACTION_BUTTON_CLASS =
'inline-flex cursor-pointer items-center rounded-lg border-0 bg-transparent px-2.5 py-1 [font:inherit] whitespace-nowrap text-stone-600 hover:bg-stone-100 dark:text-stone-300 dark:hover:bg-stone-800'

Expand Down Expand Up @@ -143,18 +155,9 @@ export function useSelectionDemo(handleRef: RefObject<EditorHandle | null>): Sel
const run: DemoRun = { command, context, cancelled: false }
runRef.current = run

const result = command.transform(context.selectedText)
let offset = 0
const timer = setInterval(() => {
if (run.cancelled || offset >= result.length) {
clearInterval(timer)
return
}
handleRef.current?.appendPendingReplacementText(
result.slice(offset, offset + STREAM_CHUNK_SIZE),
)
offset += STREAM_CHUNK_SIZE
}, STREAM_INTERVAL_MS)
streamText(run, command.transform(context.selectedText), (chunk) => {
handleRef.current?.appendPendingReplacementText(chunk)
})
},
[handleRef],
)
Expand Down
Loading