fix
This commit is contained in:
parent
80e40003f8
commit
54e5532004
@ -1,10 +1,37 @@
|
|||||||
|
import { newElementWith } from "..";
|
||||||
|
import { isTextElement, redrawTextBoundingBox } from "../element";
|
||||||
import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types";
|
import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { AppClassProperties, AppState } from "../types";
|
import { AppClassProperties, AppState } from "../types";
|
||||||
|
import { changeProperty } from "./actionProperties";
|
||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
|
|
||||||
const FONT_SIZE_RELATIVE_INCREASE_STEP = 0.1;
|
const FONT_SIZE_RELATIVE_INCREASE_STEP = 0.1;
|
||||||
|
|
||||||
|
const offsetElementAfterFontResize = (
|
||||||
|
prevElement: ExcalidrawTextElement,
|
||||||
|
nextElement: ExcalidrawTextElement,
|
||||||
|
) => {
|
||||||
|
if (isBoundToContainer(nextElement)) {
|
||||||
|
return nextElement;
|
||||||
|
}
|
||||||
|
return mutateElement(
|
||||||
|
nextElement,
|
||||||
|
{
|
||||||
|
x:
|
||||||
|
prevElement.textAlign === "left"
|
||||||
|
? prevElement.x
|
||||||
|
: prevElement.x +
|
||||||
|
(prevElement.width - nextElement.width) /
|
||||||
|
(prevElement.textAlign === "center" ? 2 : 1),
|
||||||
|
// centering vertically is non-standard, but for Excalidraw I think
|
||||||
|
// it makes sense
|
||||||
|
y: prevElement.y + (prevElement.height - nextElement.height) / 2,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const changeFontSize = (
|
const changeFontSize = (
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AppClassProperties, AppState, Primitive } from "../types";
|
import { AppState, Primitive } from "../types";
|
||||||
import {
|
import {
|
||||||
DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE,
|
DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE,
|
||||||
DEFAULT_ELEMENT_BACKGROUND_PICKS,
|
DEFAULT_ELEMENT_BACKGROUND_PICKS,
|
||||||
@ -83,7 +83,6 @@ import {
|
|||||||
VerticalAlign,
|
VerticalAlign,
|
||||||
} from "../element/types";
|
} from "../element/types";
|
||||||
import { getLanguage, t } from "../i18n";
|
import { getLanguage, t } from "../i18n";
|
||||||
import { KEYS } from "../keys";
|
|
||||||
import { randomInteger } from "../random";
|
import { randomInteger } from "../random";
|
||||||
import {
|
import {
|
||||||
canHaveArrowheads,
|
canHaveArrowheads,
|
||||||
@ -159,30 +158,6 @@ export const getFormValue = function <T extends Primitive>(
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
const offsetElementAfterFontResize = (
|
|
||||||
prevElement: ExcalidrawTextElement,
|
|
||||||
nextElement: ExcalidrawTextElement,
|
|
||||||
) => {
|
|
||||||
if (isBoundToContainer(nextElement)) {
|
|
||||||
return nextElement;
|
|
||||||
}
|
|
||||||
return mutateElement(
|
|
||||||
nextElement,
|
|
||||||
{
|
|
||||||
x:
|
|
||||||
prevElement.textAlign === "left"
|
|
||||||
? prevElement.x
|
|
||||||
: prevElement.x +
|
|
||||||
(prevElement.width - nextElement.width) /
|
|
||||||
(prevElement.textAlign === "center" ? 2 : 1),
|
|
||||||
// centering vertically is non-standard, but for Excalidraw I think
|
|
||||||
// it makes sense
|
|
||||||
y: prevElement.y + (prevElement.height - nextElement.height) / 2,
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
export const actionChangeStrokeColor = register({
|
export const actionChangeStrokeColor = register({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user