mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 15:59:15 +00:00
Show default menu when right click on text (#5826)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
3090ae6032
commit
11904d4138
@ -109,6 +109,7 @@ li {
|
|||||||
|
|
||||||
p {
|
p {
|
||||||
user-select: text;
|
user-select: text;
|
||||||
|
cursor: auto;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
@ -359,6 +359,7 @@ table.proseTable {
|
|||||||
border-radius: .25rem;
|
border-radius: .25rem;
|
||||||
padding: .5rem;
|
padding: .5rem;
|
||||||
user-select: text;
|
user-select: text;
|
||||||
|
cursor: auto;
|
||||||
|
|
||||||
pre { white-space: pre-wrap; }
|
pre { white-space: pre-wrap; }
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$: isShort = canDisplayShort(type, isSaved)
|
$: isShort = canDisplayShort(type, isSaved)
|
||||||
|
|
||||||
|
function isInside (x: number, y: number, rect: DOMRect): boolean {
|
||||||
|
return x >= rect.left && y >= rect.top && x <= rect.right && y <= rect.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTextClicked (element: HTMLElement | null, x: number, y: number): boolean {
|
||||||
|
if (element == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const nodes = element.childNodes
|
||||||
|
const range = document.createRange()
|
||||||
|
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
const node = nodes[i]
|
||||||
|
|
||||||
|
if (node.nodeType !== Node.TEXT_NODE) continue
|
||||||
|
|
||||||
|
range.selectNodeContents(node)
|
||||||
|
|
||||||
|
if (isInside(x, y, range.getBoundingClientRect())) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleContextMenu (event: MouseEvent): void {
|
||||||
|
const showCustomPopup = !isTextClicked(event.target as HTMLElement, event.clientX, event.clientY)
|
||||||
|
if (showCustomPopup) {
|
||||||
|
showMenu(event, { object: message, baseMenuClass: activity.class.ActivityMessage }, () => {
|
||||||
|
isActionsOpened = false
|
||||||
|
})
|
||||||
|
isActionsOpened = true
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !isHidden}
|
{#if !isHidden}
|
||||||
@ -123,12 +159,7 @@
|
|||||||
class:borderedHover={hoverStyles === 'borderedHover'}
|
class:borderedHover={hoverStyles === 'borderedHover'}
|
||||||
class:filledHover={hoverStyles === 'filledHover'}
|
class:filledHover={hoverStyles === 'filledHover'}
|
||||||
on:click={onClick}
|
on:click={onClick}
|
||||||
on:contextmenu={(evt) => {
|
on:contextmenu={handleContextMenu}
|
||||||
showMenu(evt, { object: message, baseMenuClass: activity.class.ActivityMessage }, () => {
|
|
||||||
isActionsOpened = false
|
|
||||||
})
|
|
||||||
isActionsOpened = true
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{#if showNotify && !embedded && !isShort}
|
{#if showNotify && !embedded && !isShort}
|
||||||
<div class="notify" />
|
<div class="notify" />
|
||||||
|
Loading…
Reference in New Issue
Block a user