mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-26 18:51:50 +02:00
[rich text] Add "Insert Citation" and "Insert Cross-reference" buttons (#12529)
GitOrigin-RevId: fde2f1a281318afede138ccae12f73ade3fa9f65
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user