mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
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:
parent
7f6c2afc92
commit
ee2e95ec01
3 changed files with 28 additions and 0 deletions
|
@ -964,6 +964,7 @@ module.exports = {
|
||||||
offlineModeToolbarButtons: [],
|
offlineModeToolbarButtons: [],
|
||||||
settingsEntries: [],
|
settingsEntries: [],
|
||||||
autoCompleteExtensions: [],
|
autoCompleteExtensions: [],
|
||||||
|
sectionTitleGenerators: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
moduleImportSequence: [
|
moduleImportSequence: [
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { CompletionContext } from '@codemirror/autocomplete'
|
||||||
import { Completions } from './types'
|
import { Completions } from './types'
|
||||||
import { metadataState } from '../../../extensions/language'
|
import { metadataState } from '../../../extensions/language'
|
||||||
import { extendRequiredParameter } from './apply'
|
import { extendRequiredParameter } from './apply'
|
||||||
|
import { maybeGetSectionForOption } from './sections'
|
||||||
|
|
||||||
export function buildReferenceCompletions(
|
export function buildReferenceCompletions(
|
||||||
completions: Completions,
|
completions: Completions,
|
||||||
|
@ -21,6 +22,7 @@ export function buildReferenceCompletions(
|
||||||
type: 'reference',
|
type: 'reference',
|
||||||
label: referenceKey,
|
label: referenceKey,
|
||||||
extend: extendRequiredParameter,
|
extend: extendRequiredParameter,
|
||||||
|
section: maybeGetSectionForOption(context, 'references'),
|
||||||
deduplicate: {
|
deduplicate: {
|
||||||
key: referenceKey,
|
key: referenceKey,
|
||||||
priority: 1,
|
priority: 1,
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in a new issue