Formula alignment gets ignored when Math: Updated Equation flag is on

When replacing the image for the math_equation_latex wrapper, the
style from the image is copied to the wrapper before removing the
Image from the DOM, with this the new wrapper will keep the style
including the alignment.

fixes LS-1941
flag=none

Test Plan:
- Enable the feature flag Math: Updated equation handling on the
account level
- Edit or create a page in a course to see the RCE
- Use the "insert math equation" button on the toolbar to insert an
equation image
- Use the "Align" button on the toolbar to center the image on the
page and save the content
- Notice the formula gets rendered in the expected position keeping
the alignment.

Change-Id: Ie2a90dc4b24236dacb34d8183b7c0066eaa8b196
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/260985
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Nate Armstrong <narmstrong@instructure.com>
QA-Review: Nate Armstrong <narmstrong@instructure.com>
Product-Review: Jonathan Guardado <jonathan.guardado@instructure.com>
This commit is contained in:
Jonathan Guardado 2021-03-17 19:07:20 -06:00
parent db04ff762e
commit 69934d22a9
1 changed files with 1 additions and 0 deletions

View File

@ -229,6 +229,7 @@ const mathImageHelper = {
if (equation_text) {
const mathtex = document.createElement('span')
mathtex.setAttribute('class', 'math_equation_latex')
mathtex.setAttribute('style', img.getAttribute('style'))
mathtex.textContent = `\\(${equation_text}\\)`
if (img.nextSibling) {
img.parentElement.insertBefore(mathtex, img.nextSibling)