feat/ability to change the alignment of the text (#1213)

* feat: add the ability to change the alignement of the text

* test: update the snapshots to included the newely textAlign state

* style: use explicit key assignment to object

* test: add missing new key textAlign to newElement.test.ts

* style: make the text on the buttons start with uppercase

* Update src/locales/en.json

* add types

* add migration

* remove incorrect update

Co-authored-by: Youness Fkhach <younessfkhach@porotonmail.com>
Co-authored-by: Lipis <lipiridis@gmail.com>
Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Youness Fkhach 2020-04-08 21:00:27 +01:00 committed by GitHub
parent 3fd6f3023f
commit ff82d1cfa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 357 additions and 9 deletions

View file

@ -3,9 +3,14 @@ import { Point } from "../types";
import { ExcalidrawElement } from "../element/types";
import { AppState } from "../types";
import { DataState } from "./types";
import { isInvisiblySmallElement, normalizeDimensions } from "../element";
import {
isInvisiblySmallElement,
normalizeDimensions,
isTextElement,
} from "../element";
import { calculateScrollCenter } from "../scene";
import { randomId } from "../random";
import { DEFAULT_TEXT_ALIGN } from "../appState";
export function restore(
// we're making the elements mutable for this API because we want to
@ -51,6 +56,10 @@ export function restore(
}
element.points = points;
} else {
if (isTextElement(element)) {
element.textAlign = DEFAULT_TEXT_ALIGN;
}
normalizeDimensions(element);
// old spec, where non-linear elements used to have empty points arrays
if ("points" in element) {