mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 17:03:43 -05:00
[visual] Decorate \ce
command (#16459)
GitOrigin-RevId: 0eab030489f97e43874e41d6d4895dc4de46521a
This commit is contained in:
parent
ded18dd09b
commit
ace673b95a
1 changed files with 27 additions and 0 deletions
|
@ -1108,6 +1108,33 @@ export const atomicDecorations = (options: Options) => {
|
|||
widget: new TeXWidget(),
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
return false
|
||||
}
|
||||
} else if (commandName === '\\ce') {
|
||||
// Chemical equation/formula, from the `mhchem` CTAN package.
|
||||
// Handled by the MathJaX mhchem extension:
|
||||
// https://docs.mathjax.org/en/latest/input/tex/extensions/mhchem.html
|
||||
if (textArgumentNode && shouldDecorate(state, nodeRef)) {
|
||||
const innerContent = state.doc
|
||||
.sliceString(
|
||||
textArgumentNode.from + 1,
|
||||
textArgumentNode.to - 1
|
||||
)
|
||||
.trim()
|
||||
|
||||
if (innerContent.length) {
|
||||
const outerContent = state.doc.sliceString(
|
||||
nodeRef.from,
|
||||
nodeRef.to
|
||||
)
|
||||
|
||||
decorations.push(
|
||||
Decoration.replace({
|
||||
widget: new MathWidget(outerContent, false),
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
} else if (hasCharacterSubstitution(commandName)) {
|
||||
|
|
Loading…
Reference in a new issue