mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 16:30:49 +00:00
UBERF-8233 Hide editor menu while user selecting (#6690)
This commit is contained in:
parent
a4379d72d1
commit
56280dc3a4
@ -23,6 +23,7 @@
|
|||||||
} from '@hcengineering/text-editor'
|
} from '@hcengineering/text-editor'
|
||||||
import { createQuery } from '@hcengineering/presentation'
|
import { createQuery } from '@hcengineering/presentation'
|
||||||
import { getResource } from '@hcengineering/platform'
|
import { getResource } from '@hcengineering/platform'
|
||||||
|
import { onDestroy, onMount } from 'svelte'
|
||||||
|
|
||||||
import { inlineToolbarKey } from './extension/inlineToolbar'
|
import { inlineToolbarKey } from './extension/inlineToolbar'
|
||||||
import TextActionButton from './TextActionButton.svelte'
|
import TextActionButton from './TextActionButton.svelte'
|
||||||
@ -93,11 +94,40 @@
|
|||||||
$: categories.forEach((category) => {
|
$: categories.forEach((category) => {
|
||||||
category.sort((a, b) => a[0] - b[0])
|
category.sort((a, b) => a[0] - b[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let selecting = false
|
||||||
|
|
||||||
|
function handleMouseDown (): void {
|
||||||
|
function handleMouseMove (): void {
|
||||||
|
if (!editor.state.selection.empty) {
|
||||||
|
selecting = true
|
||||||
|
document.removeEventListener('mousemove', handleMouseMove)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseUp (): void {
|
||||||
|
selecting = false
|
||||||
|
|
||||||
|
document.removeEventListener('mousemove', handleMouseMove)
|
||||||
|
document.removeEventListener('mouseup', handleMouseUp)
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('mousemove', handleMouseMove)
|
||||||
|
document.addEventListener('mouseup', handleMouseUp)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
document.addEventListener('mousedown', handleMouseDown)
|
||||||
|
})
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
document.removeEventListener('mousedown', handleMouseDown)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={toolbar} style="visibility: hidden;">
|
<div bind:this={toolbar} class="p-2" style="visibility: hidden;">
|
||||||
{#if editor && visible && visibleActions.length > 0}
|
{#if editor && visible && !selecting && visibleActions.length > 0}
|
||||||
<div class="text-editor-toolbar buttons-group xsmall-gap mb-4">
|
<div class="text-editor-toolbar buttons-group xsmall-gap">
|
||||||
{#each Object.values(categories) as category, index}
|
{#each Object.values(categories) as category, index}
|
||||||
{#if index > 0}
|
{#if index > 0}
|
||||||
<div class="buttons-divider" />
|
<div class="buttons-divider" />
|
||||||
@ -113,8 +143,7 @@
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.text-editor-toolbar {
|
.text-editor-toolbar {
|
||||||
margin: -0.5rem -0.25rem 0.5rem;
|
padding: 0.25rem;
|
||||||
padding: 0.375rem;
|
|
||||||
background-color: var(--theme-comp-header-color);
|
background-color: var(--theme-comp-header-color);
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
box-shadow: var(--button-shadow);
|
box-shadow: var(--button-shadow);
|
||||||
|
Loading…
Reference in New Issue
Block a user