mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
This reverts commit a68af023b24fcf87bbc608395f2898df8e9b41a5. GitOrigin-RevId: c0dd9ae3f6a0e12e6ba7d1e856327ea89eae8157
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import { EditorView } from '@codemirror/view'
|
||||
import { startCompletion } from '@codemirror/autocomplete'
|
||||
import { ancestorNodeOfType } from '@/features/source-editor/utils/tree-operations/ancestors'
|
||||
import { containsDOI } from '../utils/doi'
|
||||
|
||||
// open autocomplete when a DOI is pasted into a \cite argument
|
||||
export const autocompleteOnPaste = EditorView.domEventHandlers({
|
||||
paste(event, view) {
|
||||
const text = event.clipboardData?.getData('text/plain')
|
||||
if (text && containsDOI(text)) {
|
||||
const node = ancestorNodeOfType(
|
||||
view.state,
|
||||
view.state.selection.main.from,
|
||||
'BibKeyArgument',
|
||||
-1
|
||||
)
|
||||
|
||||
if (node) {
|
||||
// allow time for the pasted content to appear in the state
|
||||
window.setTimeout(() => {
|
||||
startCompletion(view)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -55,7 +55,6 @@ import { trackDetachedComments } from './track-detached-comments'
|
||||
import { reviewTooltip } from './review-tooltip'
|
||||
import { tooltipsReposition } from './tooltips-reposition'
|
||||
import { selectionListener } from '@/features/source-editor/extensions/selection-listener'
|
||||
import { autocompleteOnPaste } from '@/features/source-editor/extensions/autocomplete-on-paste'
|
||||
|
||||
const moduleExtensions: Array<(options: Record<string, any>) => Extension> =
|
||||
importOverleafModules('sourceEditorExtensions').map(
|
||||
@@ -175,5 +174,4 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
|
||||
fileTreeItemDrop(),
|
||||
tooltipsReposition(),
|
||||
selectionListener(options.setEditorSelection),
|
||||
autocompleteOnPaste,
|
||||
]
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
const doiRe = /10\.\d{4,}\/\S+/
|
||||
|
||||
export const containsDOI = (text: string) =>
|
||||
doiRe.test(decodeURIComponent(text))
|
||||
Reference in New Issue
Block a user