Feat/expose on math click for math node#89
Conversation
|
@FrankLiu007 is attempting to deploy a commit to the Alok Singh's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughChangesThe PR exports shared KaTeX options, adds optional Math click handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Host
participant createEditor
participant Mathematics
participant onMathClick
Host->>createEditor: pass onMathClick
createEditor->>Mathematics: configure block and inline click handlers
Mathematics->>onMathClick: provide node, position, block status, and editor
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/edra/extensions.ts`:
- Line 28: Align the KaTeX error behavior across the shared katexOptions
configuration and documentation: update src/lib/edra/extensions.ts lines 28-28
so the throwOnError setting and inline comment accurately describe the intended
default, then update src/routes/docs/extensions/mathematics/+page.svelte lines
47-53 to display that same behavior. Ensure both sites consistently indicate
whether invalid LaTeX throws.
In `@src/lib/edra/headless/editor.ts`:
- Line 61: The deferred editorRef declarations violate prefer-const because they
are assigned only once. In src/lib/edra/headless/editor.ts lines 61-61 and
src/lib/edra/shadcn/editor.ts lines 64-64, capture the useEditor(...) result
directly in a const and remove the later editorRef = editor assignment in each
file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 234cc22a-8b30-4100-ba6a-da49aed339be
📒 Files selected for processing (6)
src/lib/edra/extensions.tssrc/lib/edra/headless/editor.tssrc/lib/edra/headless/index.tssrc/lib/edra/shadcn/editor.tssrc/lib/edra/shadcn/index.tssrc/routes/docs/extensions/mathematics/+page.svelte
| * Shared KaTeX options for Mathematics (wired in createEditor so onMathClick can be injected). | ||
| */ | ||
| export const katexOptions: KatexOptions = { | ||
| throwOnError: true, // don't throw an error if the LaTeX code is invalid |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Align the documented KaTeX error behavior with the actual default.
katexOptions enables throwOnError, while the inline comment and displayed configuration indicate invalid LaTeX will not throw.
src/lib/edra/extensions.ts#L28-L28: correct the comment, or change the option if non-throwing rendering is intended.src/routes/docs/extensions/mathematics/+page.svelte#L47-L53: show the same behavior as the shared default.
📍 Affects 2 files
src/lib/edra/extensions.ts#L28-L28(this comment)src/routes/docs/extensions/mathematics/+page.svelte#L47-L53
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/edra/extensions.ts` at line 28, Align the KaTeX error behavior across
the shared katexOptions configuration and documentation: update
src/lib/edra/extensions.ts lines 28-28 so the throwOnError setting and inline
comment accurately describe the intended default, then update
src/routes/docs/extensions/mathematics/+page.svelte lines 47-53 to display that
same behavior. Ensure both sites consistently indicate whether invalid LaTeX
throws.
| export const createEditor = (props?: EdraEditorProps) => | ||
| useEditor({ | ||
| export const createEditor = (props?: EdraEditorProps) => { | ||
| let editorRef: Editor | undefined; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Remove the single-assignment let declarations.
The configured prefer-const rule reports both declarations as errors; capture the useEditor(...) result directly in a const and remove the later editorRef = editor assignment.
src/lib/edra/headless/editor.ts#L61-L61: replace the deferrededitorRefassignment pattern.src/lib/edra/shadcn/editor.ts#L64-L64: apply the same change.
🧰 Tools
🪛 ESLint
[error] 61-61: 'editorRef' is never reassigned. Use 'const' instead.
(prefer-const)
📍 Affects 2 files
src/lib/edra/headless/editor.ts#L61-L61(this comment)src/lib/edra/shadcn/editor.ts#L64-L64
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/edra/headless/editor.ts` at line 61, The deferred editorRef
declarations violate prefer-const because they are assigned only once. In
src/lib/edra/headless/editor.ts lines 61-61 and src/lib/edra/shadcn/editor.ts
lines 64-64, capture the useEditor(...) result directly in a const and remove
the later editorRef = editor assignment in each file.
Source: Linters/SAST tools
exposure onMathClick for math node
Summary by CodeRabbit
New Features
Documentation