mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[rich text] Add "Insert Citation" and "Insert Cross-reference" buttons (#12529)
GitOrigin-RevId: fde2f1a281318afede138ccae12f73ade3fa9f65
This commit is contained in:
parent
39df55787c
commit
dda9230c6c
5 changed files with 34 additions and 0 deletions
|
@ -867,6 +867,8 @@
|
|||
"toolbar_format_bold": "",
|
||||
"toolbar_format_italic": "",
|
||||
"toolbar_increase_indent": "",
|
||||
"toolbar_insert_citation": "",
|
||||
"toolbar_insert_cross_reference": "",
|
||||
"toolbar_insert_display_math": "",
|
||||
"toolbar_insert_figure": "",
|
||||
"toolbar_insert_inline_math": "",
|
||||
|
|
|
@ -129,6 +129,18 @@ export const ToolbarItems: FC<{
|
|||
command={commands.wrapInHref}
|
||||
icon="link"
|
||||
/>
|
||||
<ToolbarButton
|
||||
id="toolbar-ref"
|
||||
label={t('toolbar_insert_cross_reference')}
|
||||
command={commands.insertRef}
|
||||
icon="tag"
|
||||
/>
|
||||
<ToolbarButton
|
||||
id="toolbar-cite"
|
||||
label={t('toolbar_insert_citation')}
|
||||
command={commands.insertCite}
|
||||
icon="book"
|
||||
/>
|
||||
<ToolbarButton
|
||||
id="toolbar-add-comment"
|
||||
label={t('toolbar_add_comment')}
|
||||
|
|
|
@ -60,6 +60,22 @@ export const insertTable: Command = view => {
|
|||
return true
|
||||
}
|
||||
|
||||
export const insertCite: Command = view => {
|
||||
const { state, dispatch } = view
|
||||
const pos = state.selection.main.anchor
|
||||
const template = snippets.cite
|
||||
snippet(template)({ state, dispatch }, { label: 'Cite' }, pos, pos)
|
||||
return true
|
||||
}
|
||||
|
||||
export const insertRef: Command = view => {
|
||||
const { state, dispatch } = view
|
||||
const pos = state.selection.main.anchor
|
||||
const template = snippets.ref
|
||||
snippet(template)({ state, dispatch }, { label: 'Ref' }, pos, pos)
|
||||
return true
|
||||
}
|
||||
|
||||
export const indentDecrease: Command = view => {
|
||||
if (minimumListDepthForSelection(view.state) < 2) {
|
||||
return false
|
||||
|
|
|
@ -4,4 +4,6 @@ import { prepareSnippetTemplate } from '../../languages/latex/snippets'
|
|||
export const snippets = {
|
||||
figure: prepareSnippetTemplate(environments.get('figure') as string),
|
||||
table: prepareSnippetTemplate(environments.get('table') as string),
|
||||
cite: prepareSnippetTemplate('\\cite{${}}'),
|
||||
ref: prepareSnippetTemplate('\\ref{${}}'),
|
||||
}
|
||||
|
|
|
@ -1540,6 +1540,8 @@
|
|||
"toolbar_format_bold": "Format Bold",
|
||||
"toolbar_format_italic": "Format Italic",
|
||||
"toolbar_increase_indent": "Increase Indent",
|
||||
"toolbar_insert_citation": "Insert Citation",
|
||||
"toolbar_insert_cross_reference": "Insert Cross-reference",
|
||||
"toolbar_insert_display_math": "Insert Display Math",
|
||||
"toolbar_insert_figure": "Insert Figure",
|
||||
"toolbar_insert_inline_math": "Insert Inline Math",
|
||||
|
|
Loading…
Reference in a new issue