Skip to content

Commit

Permalink
Size equations to surrounding text
Browse files Browse the repository at this point in the history
closes LS-2845
flag=scale_equation_images

test plan:
  - turn on site admin flag scale_equation_images
  - in the rce, create some content with a large font
  - with the text caret in the large font area (you can tell by
    looking at the blinking cursor) insert a math equation
  > expect the equation to be scaled to match the surrounding font size
  - click on the equation image and change its font size using the rce toolbar
  - edit equation and save. you don't have to change anything
  > expect the equation to be in the new font size
  (some day we'll detect the change in font size and automagically fix it)

Change-Id: I323bf4162521cf88d2a993b8e62ef697114f8959
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278299
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Weston Dransfield <[email protected]>
QA-Review: Weston Dransfield <[email protected]>
Product-Review: Ed Schiebel <[email protected]>
  • Loading branch information
eschiebel committed Nov 15, 2021
1 parent d91a392 commit 66cbbf1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/canvas-rce/src/rce/RCEWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,9 @@ class RCEWrapper extends React.Component {
parseFloat(
ed.dom.doc.defaultView.getComputedStyle(ed.dom.doc.body).getPropertyValue('font-size')
) || 1
const imgParent = ed.selection.getNode()?.parentElement
const imgSz = imgParent
? parseFloat(
ed.dom.doc.defaultView.getComputedStyle(imgParent).getPropertyValue('font-size')
) || 1
const sel = ed.selection.getNode()
const imgSz = sel
? parseFloat(ed.dom.doc.defaultView.getComputedStyle(sel).getPropertyValue('font-size')) || 1
: docSz
let scale = imgSz / docSz

Expand Down

0 comments on commit 66cbbf1

Please sign in to comment.