diff --git a/package-lock.json b/package-lock.json index 87925dc6db..d300d9cbbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3274,9 +3274,9 @@ }, "node_modules/@codemirror/autocomplete": { "version": "6.12.0", - "resolved": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#51ba3679f062cd0d216095bc1dc0b0cf64576939", + "resolved": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#7af69bc097a328a123f116c05787436e34e5b572", + "integrity": "sha512-cjfnTZXLQJ19SFIzsdW6HEVUgiZ9vJu16KwbfLIXu8pEz5B5stubsSFrYUw/vyFuvllaT7xVIEF+tiUaqwdVVA==", "dev": true, - "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", "@codemirror/state": "^6.0.0", @@ -44276,7 +44276,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.23.2", "@babel/register": "^7.22.15", - "@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-1", + "@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-2", "@codemirror/commands": "^6.4.0", "@codemirror/lang-markdown": "^6.2.4", "@codemirror/language": "^6.10.0", @@ -47881,9 +47881,10 @@ "dev": true }, "@codemirror/autocomplete": { - "version": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#51ba3679f062cd0d216095bc1dc0b0cf64576939", + "version": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#7af69bc097a328a123f116c05787436e34e5b572", + "integrity": "sha512-cjfnTZXLQJ19SFIzsdW6HEVUgiZ9vJu16KwbfLIXu8pEz5B5stubsSFrYUw/vyFuvllaT7xVIEF+tiUaqwdVVA==", "dev": true, - "from": "@codemirror/autocomplete@github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-1", + "from": "@codemirror/autocomplete@github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-2", "requires": { "@codemirror/language": "^6.0.0", "@codemirror/state": "^6.0.0", @@ -52596,7 +52597,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.23.2", "@babel/register": "^7.22.15", - "@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-1", + "@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-2", "@codemirror/commands": "^6.4.0", "@codemirror/lang-markdown": "^6.2.4", "@codemirror/language": "^6.10.0", diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index f866e3b30f..13923a46da 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -338,6 +338,7 @@ const _ProjectController = { 'track-pdf-download', !anonymous && 'writefull-oauth-promotion', 'ieee-stylesheet', + 'write-and-cite', ].filter(Boolean) const getUserValues = async userId => diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 841188a7a0..72c6c09301 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -1152,6 +1152,7 @@ "saving_notification_with_seconds": "", "search": "", "search_bib_files": "", + "search_by_citekey_author_year_title": "", "search_command_find": "", "search_command_replace": "", "search_in_all_projects": "", diff --git a/services/web/frontend/js/features/source-editor/languages/latex/complete.ts b/services/web/frontend/js/features/source-editor/languages/latex/complete.ts index db8cd73e18..6c61d149a8 100644 --- a/services/web/frontend/js/features/source-editor/languages/latex/complete.ts +++ b/services/web/frontend/js/features/source-editor/languages/latex/complete.ts @@ -167,7 +167,7 @@ export const makeMultipleArgumentCompletionSource = ( CompletionBuilderOptions, 'completions' | 'context' | 'existingKeys' | 'from' | 'validFor' > - ) => CompletionResult | null + ) => ReturnType ): CompletionSource => { const completionSource: CompletionSource = (context: CompletionContext) => { const token = context.tokenBefore(ifInSpec) diff --git a/services/web/frontend/js/features/source-editor/languages/latex/completions/references.ts b/services/web/frontend/js/features/source-editor/languages/latex/completions/references.ts index 1e994481a2..42db5829d0 100644 --- a/services/web/frontend/js/features/source-editor/languages/latex/completions/references.ts +++ b/services/web/frontend/js/features/source-editor/languages/latex/completions/references.ts @@ -21,6 +21,10 @@ export function buildReferenceCompletions( type: 'reference', label: referenceKey, extend: extendRequiredParameter, + deduplicate: { + key: referenceKey, + priority: 1, + }, }) } } diff --git a/services/web/frontend/js/features/source-editor/utils/tree-operations/completions.ts b/services/web/frontend/js/features/source-editor/utils/tree-operations/completions.ts index 997eddb403..706b4e962f 100644 --- a/services/web/frontend/js/features/source-editor/utils/tree-operations/completions.ts +++ b/services/web/frontend/js/features/source-editor/utils/tree-operations/completions.ts @@ -21,7 +21,7 @@ export const ifInType = ( } } -export function isInEmptyArgumentNodeForAutocomplete(state: EditorState) { +function isInEmptyArgumentNodeOfType(state: EditorState, types: string[]) { const main = state.selection.main if (!main.empty) { return false @@ -44,8 +44,16 @@ export function isInEmptyArgumentNodeForAutocomplete(state: EditorState) { return false } - const ancestor = ancestorOfNodeWithType( - nodeLeft, + const ancestor = ancestorOfNodeWithType(nodeLeft, ...types) + if (!ancestor) { + return false + } + + return ancestor.from === nodeLeft.from && ancestor.to === nodeRight.to +} + +export function isInEmptyArgumentNodeForAutocomplete(state: EditorState) { + return isInEmptyArgumentNodeOfType(state, [ 'EnvNameGroup', 'BibliographyStyleArgument', 'BibliographyArgument', @@ -53,11 +61,10 @@ export function isInEmptyArgumentNodeForAutocomplete(state: EditorState) { 'DocumentClassArgument', 'FilePathArgument', 'RefArgument', - 'PackageArgument' - ) - if (!ancestor) { - return false - } - - return ancestor.from === nodeLeft.from && ancestor.to === nodeRight.to + 'PackageArgument', + ]) +} + +export function isInEmptyCiteArgumentNode(state: EditorState) { + return isInEmptyArgumentNodeOfType(state, ['BibKeyArgument']) } diff --git a/services/web/locales/en.json b/services/web/locales/en.json index a953a01a1d..158b889a8f 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1692,6 +1692,7 @@ "saving_notification_with_seconds": "Saving __docname__... (__seconds__ seconds of unsaved changes)", "search": "Search", "search_bib_files": "Search by author, title, year", + "search_by_citekey_author_year_title": "Search by citation key, author, title, year", "search_command_find": "Find", "search_command_replace": "Replace", "search_in_all_projects": "Search in all projects", diff --git a/services/web/package.json b/services/web/package.json index a52bbcf048..1b3143673f 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -182,7 +182,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.23.2", "@babel/register": "^7.22.15", - "@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-1", + "@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#v6.12.0-overleaf-2", "@codemirror/commands": "^6.4.0", "@codemirror/lang-markdown": "^6.2.4", "@codemirror/language": "^6.10.0",