Merge pull request #20987 from overleaf/mj-write-and-cite-settings-icons

[web] Add setting icons to Write and Cite section headers

GitOrigin-RevId: 18e5eefeb1271d17812b83f152e4d464a66185f8
This commit is contained in:
Mathias Jakobsen 2024-10-10 11:33:44 +01:00 committed by Copybot
parent 7f6c2afc92
commit ee2e95ec01
3 changed files with 28 additions and 0 deletions

View file

@ -964,6 +964,7 @@ module.exports = {
offlineModeToolbarButtons: [],
settingsEntries: [],
autoCompleteExtensions: [],
sectionTitleGenerators: [],
},
moduleImportSequence: [

View file

@ -5,6 +5,7 @@ import { CompletionContext } from '@codemirror/autocomplete'
import { Completions } from './types'
import { metadataState } from '../../../extensions/language'
import { extendRequiredParameter } from './apply'
import { maybeGetSectionForOption } from './sections'
export function buildReferenceCompletions(
completions: Completions,
@ -21,6 +22,7 @@ export function buildReferenceCompletions(
type: 'reference',
label: referenceKey,
extend: extendRequiredParameter,
section: maybeGetSectionForOption(context, 'references'),
deduplicate: {
key: referenceKey,
priority: 1,

View file

@ -0,0 +1,25 @@
import { CompletionContext, CompletionSection } from '@codemirror/autocomplete'
import importOverleafModules from '../../../../../../macros/import-overleaf-module.macro'
type SectionGenerator = (
context: CompletionContext,
type: string
) => CompletionSection | string | undefined
const sectionTitleGenerators: Array<SectionGenerator> = importOverleafModules(
'sectionTitleGenerators'
).map(
(item: { import: { getSection: SectionGenerator } }) => item.import.getSection
)
export function maybeGetSectionForOption(
context: CompletionContext,
type: string
) {
for (const generator of sectionTitleGenerators) {
const section = generator(context, type)
if (section !== undefined) {
return section
}
}
return undefined
}