fix: center align text when wrapped in container via context menu (#6480)
* rename action to wrapTextInContainer * fix: center align text when wrapped in container via context menu * revert translation key * fix tests
This commit is contained in:
parent
4d0d844e39
commit
979312f779
@ -196,8 +196,8 @@ const pushContainerBelowText = (
|
|||||||
return updatedElements;
|
return updatedElements;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actionCreateContainerFromText = register({
|
export const actionWrapTextInContainer = register({
|
||||||
name: "createContainerFromText",
|
name: "wrapTextInContainer",
|
||||||
contextItemLabel: "labels.createContainerFromText",
|
contextItemLabel: "labels.createContainerFromText",
|
||||||
trackEvent: { category: "element" },
|
trackEvent: { category: "element" },
|
||||||
predicate: (elements, appState) => {
|
predicate: (elements, appState) => {
|
||||||
@ -286,6 +286,7 @@ export const actionCreateContainerFromText = register({
|
|||||||
containerId: container.id,
|
containerId: container.id,
|
||||||
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
||||||
boundElements: null,
|
boundElements: null,
|
||||||
|
textAlign: TEXT_ALIGN.CENTER,
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -115,7 +115,7 @@ export type ActionName =
|
|||||||
| "toggleLinearEditor"
|
| "toggleLinearEditor"
|
||||||
| "toggleEraserTool"
|
| "toggleEraserTool"
|
||||||
| "toggleHandTool"
|
| "toggleHandTool"
|
||||||
| "createContainerFromText";
|
| "wrapTextInContainer";
|
||||||
|
|
||||||
export type PanelComponentProps = {
|
export type PanelComponentProps = {
|
||||||
elements: readonly ExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
|
@ -295,7 +295,7 @@ import {
|
|||||||
} from "../actions/actionCanvas";
|
} from "../actions/actionCanvas";
|
||||||
import { jotaiStore } from "../jotai";
|
import { jotaiStore } from "../jotai";
|
||||||
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
|
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
|
||||||
import { actionCreateContainerFromText } from "../actions/actionBoundText";
|
import { actionWrapTextInContainer } from "../actions/actionBoundText";
|
||||||
import BraveMeasureTextError from "./BraveMeasureTextError";
|
import BraveMeasureTextError from "./BraveMeasureTextError";
|
||||||
|
|
||||||
const deviceContextInitialValue = {
|
const deviceContextInitialValue = {
|
||||||
@ -6364,7 +6364,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
actionGroup,
|
actionGroup,
|
||||||
actionUnbindText,
|
actionUnbindText,
|
||||||
actionBindText,
|
actionBindText,
|
||||||
actionCreateContainerFromText,
|
actionWrapTextInContainer,
|
||||||
actionUngroup,
|
actionUngroup,
|
||||||
CONTEXT_MENU_SEPARATOR,
|
CONTEXT_MENU_SEPARATOR,
|
||||||
actionAddToLibrary,
|
actionAddToLibrary,
|
||||||
|
@ -1506,7 +1506,7 @@ describe("textWysiwyg", () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
text: "Excalidraw is an opensource virtual collaborative whiteboard",
|
text: "Excalidraw is an opensource virtual collaborative whiteboard",
|
||||||
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
||||||
textAlign: TEXT_ALIGN.LEFT,
|
textAlign: TEXT_ALIGN.CENTER,
|
||||||
boundElements: null,
|
boundElements: null,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -121,7 +121,7 @@ Object {
|
|||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"contextItemLabel": "labels.createContainerFromText",
|
"contextItemLabel": "labels.createContainerFromText",
|
||||||
"name": "createContainerFromText",
|
"name": "wrapTextInContainer",
|
||||||
"perform": [Function],
|
"perform": [Function],
|
||||||
"predicate": [Function],
|
"predicate": [Function],
|
||||||
"trackEvent": Object {
|
"trackEvent": Object {
|
||||||
@ -4518,7 +4518,7 @@ Object {
|
|||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"contextItemLabel": "labels.createContainerFromText",
|
"contextItemLabel": "labels.createContainerFromText",
|
||||||
"name": "createContainerFromText",
|
"name": "wrapTextInContainer",
|
||||||
"perform": [Function],
|
"perform": [Function],
|
||||||
"predicate": [Function],
|
"predicate": [Function],
|
||||||
"trackEvent": Object {
|
"trackEvent": Object {
|
||||||
@ -5068,7 +5068,7 @@ Object {
|
|||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"contextItemLabel": "labels.createContainerFromText",
|
"contextItemLabel": "labels.createContainerFromText",
|
||||||
"name": "createContainerFromText",
|
"name": "wrapTextInContainer",
|
||||||
"perform": [Function],
|
"perform": [Function],
|
||||||
"predicate": [Function],
|
"predicate": [Function],
|
||||||
"trackEvent": Object {
|
"trackEvent": Object {
|
||||||
@ -5917,7 +5917,7 @@ Object {
|
|||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"contextItemLabel": "labels.createContainerFromText",
|
"contextItemLabel": "labels.createContainerFromText",
|
||||||
"name": "createContainerFromText",
|
"name": "wrapTextInContainer",
|
||||||
"perform": [Function],
|
"perform": [Function],
|
||||||
"predicate": [Function],
|
"predicate": [Function],
|
||||||
"trackEvent": Object {
|
"trackEvent": Object {
|
||||||
@ -6263,7 +6263,7 @@ Object {
|
|||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"contextItemLabel": "labels.createContainerFromText",
|
"contextItemLabel": "labels.createContainerFromText",
|
||||||
"name": "createContainerFromText",
|
"name": "wrapTextInContainer",
|
||||||
"perform": [Function],
|
"perform": [Function],
|
||||||
"predicate": [Function],
|
"predicate": [Function],
|
||||||
"trackEvent": Object {
|
"trackEvent": Object {
|
||||||
|
@ -4,7 +4,7 @@ import { UI, Pointer, Keyboard } from "./helpers/ui";
|
|||||||
import { getTransformHandles } from "../element/transformHandles";
|
import { getTransformHandles } from "../element/transformHandles";
|
||||||
import { API } from "./helpers/api";
|
import { API } from "./helpers/api";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { actionCreateContainerFromText } from "../actions/actionBoundText";
|
import { actionWrapTextInContainer } from "../actions/actionBoundText";
|
||||||
|
|
||||||
const { h } = window;
|
const { h } = window;
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ describe("element binding", () => {
|
|||||||
|
|
||||||
expect(h.state.selectedElementIds[text1.id]).toBe(true);
|
expect(h.state.selectedElementIds[text1.id]).toBe(true);
|
||||||
|
|
||||||
h.app.actionManager.executeAction(actionCreateContainerFromText);
|
h.app.actionManager.executeAction(actionWrapTextInContainer);
|
||||||
|
|
||||||
// new text container will be placed before the text element
|
// new text container will be placed before the text element
|
||||||
const container = h.elements.at(-2)!;
|
const container = h.elements.at(-2)!;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user