-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Mcq UI #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
feat: Mcq UI #19
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
31aeb1c
Update README.md
shirsho-12 d06f420
Disable editor on mcq
shirsho-12 9d77218
feat: add MCQ interface
shirsho-12 0e29e52
Merge branch 'main' into mcq-ui
shirsho-12 6aca711
Refactor McqPanel
shirsho-12 69d7bb2
Refactor message handling
shirsho-12 1c85379
Refactor messageHandler: singleton
shirsho-12 6e929ff
Merge branch 'main' into mcq-ui
shirsho-12 46b9ad9
Merge branch 'main' into mcq-ui
shirsho-12 8a0c9fb
Merge branch 'mcq-ui' of https://github.com/source-academy/vscode int…
shirsho-12 567ce60
Update MCQQuestion object
shirsho-12 7132497
Add MCQAnswer message handling
shirsho-12 bbc4a15
Feat: cache mcq answers
shirsho-12 e0a3ee4
Fix: functional backend communication
shirsho-12 12f42d0
Rename: MCQ - > Mcq
shirsho-12 19ec0a8
Refactor: remove question info from McqQuestion
shirsho-12 cb0952e
Add markdown renderer
shirsho-12 837906a
Fix mcq UI
shirsho-12 10a2453
Merge main into mcq-ui
shirsho-12 24f4865
Merge branch 'main' into mcq-ui
shirsho-12 c8fbad1
Merge branch 'main' into mcq-ui
shirsho-12 b802d79
Merge branch 'main' into mcq-ui
heyzec ad257bb
Revert: merge deletes
shirsho-12 9708311
Merge branch 'main' into mcq-ui
shirsho-12 fea8f7d
Merge branch 'main' into mcq-ui
heyzec b1af460
update outdated yarn.lock
heyzec a711ded
Change MCQ panel title
shirsho-12 d372c72
Merge branch 'main' into mcq-ui
heyzec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import * as vscode from "vscode"; | ||
import Messages from "../utils/messages"; | ||
import { activeEditor, sendToFrontendWrapped } from "./showPanel"; | ||
import { sendToFrontendWrapped } from "./showPanel"; | ||
import { MessageHandler } from "../utils/messageHandler"; | ||
|
||
let messageHandler = MessageHandler.getInstance(); | ||
|
||
export async function evalEditor(context: vscode.ExtensionContext) { | ||
if (!activeEditor) { | ||
if (!messageHandler.activeEditor) { | ||
vscode.window.showErrorMessage( | ||
"Cannot evaluate code when there is no active editor!", | ||
); | ||
return; | ||
} | ||
const message = Messages.EvalEditor(activeEditor.workspaceLocation); | ||
const message = Messages.EvalEditor( | ||
messageHandler.activeEditor.workspaceLocation, | ||
); | ||
sendToFrontendWrapped(message); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Lightweight Markdown → HTML helper for the VS Code Webview. | ||
// Uses `showdown` (≈12 kB gzipped, no React peer-deps) for robust CommonMark | ||
// conversion | ||
// Keeps dependency surface minimal (one package) | ||
|
||
import { Converter } from "showdown"; | ||
|
||
// A singleton converter instance (Showdown initialisation is expensive) | ||
const converter = new Converter({ | ||
tables: true, | ||
simplifiedAutoLink: true, | ||
strikethrough: true, | ||
tasklists: true, | ||
openLinksInNewWindow: true, | ||
}); | ||
|
||
// Very small sanitiser: strips <script> tags and dangerous inline event attrs. | ||
const sanitize = (html: string): string => { | ||
// Remove script/style tags completely | ||
let safe = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi, ""); | ||
// Remove on*="..." inline event handlers | ||
safe = safe.replace(/ on\w+="[^"]*"/g, ""); | ||
return safe; | ||
}; | ||
|
||
export function markdownToHtml(markdown: string): string { | ||
const rawHtml = converter.makeHtml(markdown); | ||
return sanitize(rawHtml); | ||
} | ||
|
||
export default markdownToHtml; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.