Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ff2balex
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lex gaMe
ff2balex
Commits
0fb286e1
Commit
0fb286e1
authored
5 months ago
by
Lucie Bader
Browse files
Options
Downloads
Patches
Plain Diff
Décalage affichage menu contextuel personnalisé
parent
50560505
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
menu_contextuel/custom_context_menu.js
+15
-7
15 additions, 7 deletions
menu_contextuel/custom_context_menu.js
with
15 additions
and
7 deletions
menu_contextuel/custom_context_menu.js
+
15
−
7
View file @
0fb286e1
...
...
@@ -28,7 +28,7 @@ function injectWhiteBox() {
const
getDefinitionWikiPath
=
browser
.
runtime
.
getURL
(
"
icons/definition_wiktionnaire.png
"
);
const
loginPath
=
browser
.
runtime
.
getURL
(
"
icons/connexion.png
"
);
// Construction du HTML
avec interpolation
// Construction du HTML
whiteBox
.
innerHTML
=
`
<p id="selectedWord">Mot sélectionné : Aucun</p>
<hr style="border: 0; height: 1px; background-color: #323046; margin: 8px 0;">
...
...
@@ -159,12 +159,20 @@ function showWhiteBox(event, selectedText) {
// Met à jour l'affichage du mot sélectionné
const
selectedWordElement
=
document
.
getElementById
(
"
selectedWord
"
);
selectedWordElement
.
textContent
=
`
${
selectedText
}
`
;
// Positionne la whiteBox près du clic
whiteBox
.
style
.
left
=
`
${
event
.
pageX
}
px`
;
whiteBox
.
style
.
top
=
`
${
event
.
pageY
}
px`
;
whiteBox
.
style
.
display
=
"
block
"
;
console
.
log
(
"
Affichage du menu contextuel avec le mot :
"
,
selectedText
);
// Récupère la position de la sélection
const
selection
=
window
.
getSelection
();
const
range
=
selection
.
getRangeAt
(
0
);
const
rect
=
range
.
getBoundingClientRect
();
// Obtenez la position et taille du mot sélectionné
// Calcule la position du menu en bas à droite du mot sélectionné
const
top
=
rect
.
bottom
+
window
.
scrollY
;
// Bas du mot + défilement vertical
const
left
=
rect
.
right
+
window
.
scrollX
;
// Droite du mot + défilement horizontal
// Positionne la whiteBox
whiteBox
.
style
.
left
=
`
${
left
}
px`
;
whiteBox
.
style
.
top
=
`
${
top
}
px`
;
whiteBox
.
style
.
display
=
"
block
"
;
nsole
.
log
(
"
Affichage du menu contextuel avec le mot :
"
,
selectedText
);
// Mettre à jour la visibilité des boutons
updateMenuVisibility
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment