This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Storing DOM changes #27
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3eca34c
v1 of storing DOM changes
NicoMorenoSirius f5e87db
removed unused consts
NicoMorenoSirius f1b4ae8
biome fixes
NicoMorenoSirius b12c3a4
fixed crash when text is not selected
NicoMorenoSirius c2a9f47
removed commented code
NicoMorenoSirius ada2b64
added some comments to explain logic
NicoMorenoSirius 0fd8cae
added some comments to explain logic
NicoMorenoSirius 29b4c3e
fixed loading modification on a different situation
NicoMorenoSirius 79701ba
moved loadModificaations function to load changes
NicoMorenoSirius 649aeb2
biome fixes
NicoMorenoSirius 19ebd56
Merge remote-tracking branch 'origin' into CU-86b0mugf1-storing-changes
NicoMorenoSirius 54f795f
biome fixes
NicoMorenoSirius 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 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 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 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,5 +1,6 @@ | ||||||||||||||||||
import ReactDOM from "react-dom/client"; | ||||||||||||||||||
import { MOCKSI_RECORDING_STATE, RecordingState } from "../consts"; | ||||||||||||||||||
import { saveModification } from "../utils"; | ||||||||||||||||||
import ContentApp from "./ContentApp"; | ||||||||||||||||||
|
||||||||||||||||||
let root: ReactDOM.Root; | ||||||||||||||||||
|
@@ -133,6 +134,10 @@ function elementWithBorder( | |||||||||||||||||
document.createTextNode(newValue), | ||||||||||||||||||
selectedText, | ||||||||||||||||||
); | ||||||||||||||||||
saveModification( | ||||||||||||||||||
parentElement as HTMLElement, | ||||||||||||||||||
parentElement?.innerHTML || parentElement?.innerText || "", | ||||||||||||||||||
); | ||||||||||||||||||
Comment on lines
+137
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent handling of DOM content. Consider using - parentElement?.innerHTML || parentElement?.innerText || "",
+ parentElement?.textContent || "", Committable suggestion
Suggested change
|
||||||||||||||||||
parentElement?.normalize(); | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -157,13 +162,12 @@ function onDoubleClickText(event: MouseEvent) { | |||||||||||||||||
parentElement?.normalize(); | ||||||||||||||||||
} | ||||||||||||||||||
const targetedElement: HTMLElement = event.target as HTMLElement; | ||||||||||||||||||
const { startOffset, endOffset } = | ||||||||||||||||||
window.getSelection()?.getRangeAt(0) || {}; | ||||||||||||||||||
if (startOffset !== undefined && endOffset !== undefined) { | ||||||||||||||||||
applyEditor(targetedElement, window.getSelection(), event.shiftKey); | ||||||||||||||||||
const selection = window.getSelection(); | ||||||||||||||||||
if (selection?.toString()) { | ||||||||||||||||||
applyEditor(targetedElement, selection, event.shiftKey); | ||||||||||||||||||
document.getElementById("mocksiTextArea")?.focus(); | ||||||||||||||||||
} else { | ||||||||||||||||||
console.log("ERROR! no offset detected", targetedElement); | ||||||||||||||||||
console.log("ERROR! no selection detected", targetedElement); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
This file contains 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
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.
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.
Tip
Codebase Verification
The
loadModifications
function retrieves modifications fromlocalStorage
and applies them to the DOM elements. This functionality is different fromsetEditorMode(false)
, which likely had a different purpose related to editor state management.loadModifications
focuses on applying stored modifications to the DOM.setEditorMode(false)
likely managed the editor's state, such as toggling the editor mode off.These functions serve different purposes, and replacing
setEditorMode(false)
withloadModifications
might lead to unintended behavior if the editor state management is still required.setEditorMode(false)
is removed.Analysis chain
Change in
onClick
handler to useloadModifications
.Ensure that
loadModifications
is properly handling all expected scenarios since it replacessetEditorMode(false)
, which likely had a different purpose.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 75
Script:
Length of output: 434
Script:
Length of output: 1525