mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Remove completion and shortcut event logging (#15633)
GitOrigin-RevId: 35eedb7b18200badef8226eecc58b3c35344f256
This commit is contained in:
parent
8abf8ba956
commit
54c55360c4
6 changed files with 6 additions and 76 deletions
|
@ -1,10 +1,5 @@
|
|||
import { EditorView } from '@codemirror/view'
|
||||
import {
|
||||
EditorSelection,
|
||||
EditorState,
|
||||
SelectionRange,
|
||||
TransactionSpec,
|
||||
} from '@codemirror/state'
|
||||
import { EditorSelection, EditorState, SelectionRange } from '@codemirror/state'
|
||||
import {
|
||||
ensureSyntaxTree,
|
||||
foldedRanges,
|
||||
|
@ -413,10 +408,7 @@ function bubbleUpRange(
|
|||
return range
|
||||
}
|
||||
|
||||
export function toggleRanges(
|
||||
command: string,
|
||||
annotations?: TransactionSpec['annotations']
|
||||
) {
|
||||
export function toggleRanges(command: string) {
|
||||
/* There are a number of situations we need to handle in this function.
|
||||
* In the following examples, the selection range is marked within <>
|
||||
|
||||
|
@ -761,7 +753,7 @@ export function toggleRanges(
|
|||
// Shouldn't happen, but default to just wrapping the content
|
||||
return wrapRangeInCommand(view.state, range, command)
|
||||
}),
|
||||
{ scrollIntoView: true, annotations }
|
||||
{ scrollIntoView: true }
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
import { ViewPlugin } from '@codemirror/view'
|
||||
import { pickedCompletion } from '@codemirror/autocomplete'
|
||||
import { emitCompletionEvent } from './toolbar/utils/analytics'
|
||||
|
||||
/**
|
||||
* A custom view plugin that watches for transactions with the `pickedCompletion` annotation.
|
||||
* If the completion label starts with a command, log that command for analytics.
|
||||
*/
|
||||
export const completionLogger = ViewPlugin.define(view => {
|
||||
return {
|
||||
update(update) {
|
||||
for (const tr of update.transactions) {
|
||||
const completion = tr.annotation(pickedCompletion)
|
||||
if (completion) {
|
||||
const command = completionCommand(completion.label)
|
||||
if (command) {
|
||||
emitCompletionEvent(view, command)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const completionCommand = (label: string): string | null => {
|
||||
const matches = label.match(/^\\(\w+)/)
|
||||
return matches ? matches[1] : null
|
||||
}
|
|
@ -47,8 +47,6 @@ import { effectListeners } from './effect-listeners'
|
|||
import { highlightSpecialChars } from './highlight-special-chars'
|
||||
import { toolbarPanel } from './toolbar/toolbar-panel'
|
||||
import { geometryChangeEvent } from './geometry-change-event'
|
||||
import { completionLogger } from './completion-logger'
|
||||
import { shortcutLogger } from './shortcut-logger'
|
||||
|
||||
const moduleExtensions: Array<() => Extension> = importOverleafModules(
|
||||
'sourceEditorExtensions'
|
||||
|
@ -130,8 +128,6 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
|
|||
// The built-in extension that highlights the active line in the gutter.
|
||||
highlightActiveLineGutter(),
|
||||
inlineBackground(options.visual.visual),
|
||||
completionLogger,
|
||||
shortcutLogger,
|
||||
codemirrorDevTools(),
|
||||
exceptionLogger(),
|
||||
// CodeMirror extensions provided by modules
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
import { ViewPlugin } from '@codemirror/view'
|
||||
import { emitShortcutEvent } from './toolbar/utils/analytics'
|
||||
import { runShortcut } from '../languages/latex/shortcuts'
|
||||
|
||||
/**
|
||||
* A custom view plugin that watches for transactions with the `runShortcut` annotation,
|
||||
* and logs the shortcut name for analytics.
|
||||
*/
|
||||
export const shortcutLogger = ViewPlugin.define(view => {
|
||||
return {
|
||||
update(update) {
|
||||
for (const tr of update.transactions) {
|
||||
const action = tr.annotation(runShortcut)
|
||||
if (action) {
|
||||
emitShortcutEvent(view, action)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
|
@ -14,11 +14,3 @@ export function emitCommandEvent(
|
|||
export function emitToolbarEvent(view: EditorView, command: string) {
|
||||
emitCommandEvent(view, 'codemirror-toolbar-event', command)
|
||||
}
|
||||
|
||||
export function emitCompletionEvent(view: EditorView, command: string) {
|
||||
emitCommandEvent(view, 'codemirror-completion-event', command)
|
||||
}
|
||||
|
||||
export function emitShortcutEvent(view: EditorView, command: string) {
|
||||
emitCommandEvent(view, 'codemirror-shortcut-event', command)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Annotation, Prec } from '@codemirror/state'
|
||||
import { Prec } from '@codemirror/state'
|
||||
import { keymap } from '@codemirror/view'
|
||||
import { toggleRanges } from '../../commands/ranges'
|
||||
|
||||
|
@ -9,16 +9,14 @@ export const shortcuts = () => {
|
|||
key: 'Ctrl-b',
|
||||
mac: 'Mod-b',
|
||||
preventDefault: true,
|
||||
run: toggleRanges('\\textbf', runShortcut.of('toggle-bold')),
|
||||
run: toggleRanges('\\textbf'),
|
||||
},
|
||||
{
|
||||
key: 'Ctrl-i',
|
||||
mac: 'Mod-i',
|
||||
preventDefault: true,
|
||||
run: toggleRanges('\\textit', runShortcut.of('toggle-italic')),
|
||||
run: toggleRanges('\\textit'),
|
||||
},
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
export const runShortcut = Annotation.define<string>()
|
||||
|
|
Loading…
Reference in a new issue