mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #34512 from overleaf/mj-floating-toolbar-option
[web] Add setting for floating toolbar menu GitOrigin-RevId: bd28f1f287f2011535c7fd530f1217f01e0cfbbc
This commit is contained in:
committed by
Copybot
parent
106dd1b07b
commit
5f79c2dd10
@@ -159,7 +159,10 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
|
||||
trackDetachedComments(options.currentDoc),
|
||||
visual(options.docName, options.visual),
|
||||
mathPreview(options.settings.mathPreview),
|
||||
reviewTooltip(options.editorContextMenuEnabled),
|
||||
reviewTooltip(
|
||||
options.settings.floatingMenu,
|
||||
options.editorContextMenuEnabled
|
||||
),
|
||||
contextMenu(options.editorContextMenuEnabled),
|
||||
toolbarPanel(),
|
||||
breadcrumbPanel(),
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
SelectionRange,
|
||||
EditorState,
|
||||
Transaction,
|
||||
Compartment,
|
||||
TransactionSpec,
|
||||
} from '@codemirror/state'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { isContextMenuMouseEvent } from '../utils/context-menu-mouse-event'
|
||||
@@ -52,7 +54,29 @@ export const buildAddNewCommentRangeEffect = (range: SelectionRange) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const reviewTooltip = (editorContextMenuEnabled = false): Extension => {
|
||||
const reviewTooltipCompartment = new Compartment()
|
||||
|
||||
export const reviewTooltip = (
|
||||
enabled: boolean,
|
||||
editorContextMenuEnabled: boolean = false
|
||||
): Extension => {
|
||||
return reviewTooltipCompartment.of(
|
||||
enabled ? reviewTooltipEnabled(editorContextMenuEnabled) : []
|
||||
)
|
||||
}
|
||||
|
||||
export const setReviewTooltip = (
|
||||
enabled: boolean,
|
||||
editorContextMenuEnabled: boolean
|
||||
): TransactionSpec => ({
|
||||
effects: reviewTooltipCompartment.reconfigure(
|
||||
enabled ? reviewTooltipEnabled(editorContextMenuEnabled) : []
|
||||
),
|
||||
})
|
||||
|
||||
export const reviewTooltipEnabled = (
|
||||
editorContextMenuEnabled = false
|
||||
): Extension => {
|
||||
let mouseUpListener: null | (() => void) = null
|
||||
const disableMouseUpListener = () => {
|
||||
if (mouseUpListener) {
|
||||
|
||||
Reference in New Issue
Block a user