mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: support vertical text align for bound containers (#4852)
* feat: support vertical text align for bound containers * update icons * use const * fix lint * rename to and show when text editor active * don't update vertical align if not center * fix svgs * fix y coords when vertical align bottm Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
c5a7723185
commit
8e26d5b500
13 changed files with 222 additions and 66 deletions
|
@ -29,7 +29,13 @@ import { isPathALoop } from "../math";
|
|||
import rough from "roughjs/bin/rough";
|
||||
import { AppState, BinaryFiles, Zoom } from "../types";
|
||||
import { getDefaultAppState } from "../appState";
|
||||
import { MAX_DECIMALS_FOR_SVG_EXPORT, MIME_TYPES, SVG_NS } from "../constants";
|
||||
import {
|
||||
BOUND_TEXT_PADDING,
|
||||
MAX_DECIMALS_FOR_SVG_EXPORT,
|
||||
MIME_TYPES,
|
||||
SVG_NS,
|
||||
VERTICAL_ALIGN,
|
||||
} from "../constants";
|
||||
import { getStroke, StrokeOptions } from "perfect-freehand";
|
||||
import { getApproxLineHeight } from "../element/textElement";
|
||||
|
||||
|
@ -264,7 +270,11 @@ const drawElementOnCanvas = (
|
|||
const lineHeight = element.containerId
|
||||
? getApproxLineHeight(getFontString(element))
|
||||
: element.height / lines.length;
|
||||
const verticalOffset = element.height - element.baseline;
|
||||
let verticalOffset = element.height - element.baseline;
|
||||
if (element.verticalAlign === VERTICAL_ALIGN.BOTTOM) {
|
||||
verticalOffset = BOUND_TEXT_PADDING;
|
||||
}
|
||||
|
||||
const horizontalOffset =
|
||||
element.textAlign === "center"
|
||||
? element.width / 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue