-
-
Notifications
You must be signed in to change notification settings - Fork 213
fix: add type definitions, extract hook, and implement security harde… #705
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
Open
HardikTi13
wants to merge
10
commits into
accordproject:main
Choose a base branch
from
HardikTi13:fix/build-security-type-issues
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
336c2da
fix: add type definitions, extract hook, and implement security harde…
HardikTi13 b2da04a
Merge upstream/main into fix/build-security-type-issues
HardikTi13 418bf33
refactor: remove circular dependency from useCodeSelection hook
HardikTi13 d5fac52
DCO Remediation Commit for Hardik Tiwari <tiwarihardik131105@gmail.com>
HardikTi13 5608361
Merge branch 'main' into fix/build-security-type-issues
HardikTi13 dae227d
fix: move @types/dompurify to devDependencies only
HardikTi13 8611740
Merge branch 'main' into fix/build-security-type-issues
mttrbrts 368875b
Merge branch 'main' into fix/build-security-type-issues
mttrbrts b025235
Merge branch 'main' into fix/build-security-type-issues
HardikTi13 4b4cd1c
Merge branch 'main' into fix/build-security-type-issues
HardikTi13 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
Binary file not shown.
Binary file not shown.
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 |
|---|---|---|
|
|
@@ -108,4 +108,4 @@ | |
| "not ie <= 11", | ||
| "Safari >= 10" | ||
| ] | ||
| } | ||
| } | ||
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
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,61 @@ | ||
| import { useState } from 'react'; | ||
| import * as monaco from 'monaco-editor'; | ||
| import useAppStore from '../store/store'; | ||
|
|
||
| export const useCodeSelection = () => { | ||
| const [selectedText, setSelectedText] = useState(''); | ||
| const [menuPosition, setMenuPosition] = useState<{ x: number; y: number } | null>(null); | ||
| const [showMenu, setShowMenu] = useState(false); | ||
| const enableCodeSelectionMenu = useAppStore((state) => state.aiConfig?.enableCodeSelectionMenu ?? true); | ||
|
|
||
| const handleSelection = (editor: monaco.editor.IStandaloneCodeEditor) => { | ||
| const selection = editor.getSelection(); | ||
| if (selection && !selection.isEmpty()) { | ||
| const selectedText = editor.getModel()?.getValueInRange(selection).trim(); | ||
| if (selectedText && selectedText.length > 0) { | ||
| const position = editor.getScrolledVisiblePosition(selection.getStartPosition()); | ||
| const editorContainer = editor.getDomNode()?.closest('.editorwrapper'); | ||
| const editorRect = editorContainer?.getBoundingClientRect(); | ||
|
|
||
| let x: number, y: number; | ||
|
|
||
| if (editorRect && position) { | ||
| x = Math.max(editorRect.left + 20, Math.min(position.left, editorRect.right - 150)); | ||
| y = Math.max(editorRect.top + 20, Math.min(position.top, editorRect.bottom - 50)); | ||
|
|
||
| x = Math.max(10, Math.min(x, window.innerWidth - 150)); | ||
| y = Math.max(10, Math.min(y, window.innerHeight - 50)); | ||
| } else if (position) { | ||
| x = Math.max(10, Math.min(position.left, window.innerWidth - 150)); | ||
| y = Math.max(10, Math.min(position.top, window.innerHeight - 50)); | ||
| } else { | ||
| return; | ||
| } | ||
|
|
||
| setSelectedText(selectedText); | ||
| setMenuPosition({ | ||
| x: x, | ||
| y: y | ||
| }); | ||
| setShowMenu(true); | ||
| } | ||
| } else { | ||
| setShowMenu(false); | ||
| } | ||
| } | ||
|
|
||
| const closeMenu = () => { | ||
| setShowMenu(false); | ||
| setSelectedText(''); | ||
| setMenuPosition(null); | ||
| }; | ||
|
|
||
| return { | ||
| handleSelection, | ||
| closeMenu, | ||
| showMenu, | ||
| selectedText, | ||
| menuPosition, | ||
| enableCodeSelectionMenu, | ||
| }; | ||
| }; |
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,18 @@ | ||
| declare module '@accordproject/markdown-template' { | ||
| import { ModelManager } from '@accordproject/concerto-core'; | ||
|
|
||
| export class TemplateMarkTransformer { | ||
| fromMarkdownTemplate(options: { | ||
| fileName: string; | ||
| content: string; | ||
| modelManager: ModelManager; | ||
| templateKind?: string; | ||
| }): { getModelManager: () => ModelManager }; | ||
|
|
||
| toMarkdownTemplate(parserManager: { getModelManager: () => ModelManager }): string; | ||
|
|
||
| generate(data: Record<string, unknown>, parserManager: { getModelManager: () => ModelManager }): string; | ||
|
|
||
| getVariables(parserManager: { getModelManager: () => ModelManager }): Record<string, unknown>; | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move typescript typedef upstream to the @accordproject/markdown-template package.
There is an example in the concerto repository for creating typedefs from jsdocs.
accordproject/markdown-transform#648