mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Add footnote and endnote commands to the LaTeX grammar (#24939)
GitOrigin-RevId: f0342156fa22a1bcf73ae2e8afdcc6f330ba5d37
This commit is contained in:
+38
-37
@@ -1066,6 +1066,44 @@ export const atomicDecorations = (options: Options) => {
|
||||
)
|
||||
)
|
||||
}
|
||||
} else if (
|
||||
nodeRef.type.is('FootnoteCommand') ||
|
||||
nodeRef.type.is('EndnoteCommand')
|
||||
) {
|
||||
const textArgumentNode = nodeRef.node.getChild('TextArgument')
|
||||
if (textArgumentNode) {
|
||||
if (
|
||||
state.readOnly &&
|
||||
selectionIntersects(state.selection, nodeRef)
|
||||
) {
|
||||
// a special case for a read-only document:
|
||||
// always display the content, styled differently from the main content.
|
||||
decorations.push(
|
||||
...decorateArgumentBraces(
|
||||
new BraceWidget(),
|
||||
textArgumentNode,
|
||||
nodeRef.from
|
||||
),
|
||||
Decoration.mark({
|
||||
class: 'ol-cm-footnote ol-cm-footnote-view',
|
||||
}).range(textArgumentNode.from, textArgumentNode.to)
|
||||
)
|
||||
} else {
|
||||
if (shouldDecorate(state, nodeRef)) {
|
||||
// collapse the footnote when the selection is outside it
|
||||
decorations.push(
|
||||
Decoration.replace({
|
||||
widget: new FootnoteWidget(
|
||||
nodeRef.type.is('FootnoteCommand')
|
||||
? 'footnote'
|
||||
: 'endnote'
|
||||
),
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (nodeRef.type.is('UnknownCommand')) {
|
||||
// a command that's not defined separately by the grammar
|
||||
const commandNode = nodeRef.node
|
||||
@@ -1091,43 +1129,6 @@ export const atomicDecorations = (options: Options) => {
|
||||
)
|
||||
return false
|
||||
}
|
||||
} else if (
|
||||
commandName === '\\footnote' ||
|
||||
commandName === '\\endnote'
|
||||
) {
|
||||
if (textArgumentNode) {
|
||||
if (
|
||||
state.readOnly &&
|
||||
selectionIntersects(state.selection, nodeRef)
|
||||
) {
|
||||
// a special case for a read-only document:
|
||||
// always display the content, styled differently from the main content.
|
||||
decorations.push(
|
||||
...decorateArgumentBraces(
|
||||
new BraceWidget(),
|
||||
textArgumentNode,
|
||||
nodeRef.from
|
||||
),
|
||||
Decoration.mark({
|
||||
class: 'ol-cm-footnote ol-cm-footnote-view',
|
||||
}).range(textArgumentNode.from, textArgumentNode.to)
|
||||
)
|
||||
} else {
|
||||
if (shouldDecorate(state, nodeRef)) {
|
||||
// collapse the footnote when the selection is outside it
|
||||
decorations.push(
|
||||
Decoration.replace({
|
||||
widget: new FootnoteWidget(
|
||||
commandName === '\\footnote'
|
||||
? 'footnote'
|
||||
: 'endnote'
|
||||
),
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (commandName === '\\LaTeX') {
|
||||
if (shouldDecorate(state, nodeRef)) {
|
||||
decorations.push(
|
||||
|
||||
Reference in New Issue
Block a user