Compare commits

..
Author SHA1 Message Date
zsviczianandGitHub 3c6dc4fd6d fixed test 2023-11-18 18:41:47 +01:00
zsviczianandGitHub e9ab51c30e Update textElement.ts
tim spaces at the end of fragments to improve center and right alignment.
2023-11-18 18:32:19 +01:00
3 changed files with 36 additions and 23 deletions
+34 -21
View File
@@ -8238,8 +8238,27 @@ class App extends React.Component<AppProps, AppState> {
event[KEYS.CTRL_OR_CMD] ? null : this.state.gridSize, event[KEYS.CTRL_OR_CMD] ? null : this.state.gridSize,
); );
const resizingSingleFrameOnly = const frameElementsOffsetsMap = new Map<
selectedElements.length === 1 && selectedFrames.length === 1; string,
{
x: number;
y: number;
}
>();
selectedFrames.forEach((frame) => {
const elementsInFrame = getFrameChildren(
this.scene.getNonDeletedElements(),
frame.id,
);
elementsInFrame.forEach((element) => {
frameElementsOffsetsMap.set(frame.id + element.id, {
x: element.x - frame.x,
y: element.y - frame.y,
});
});
});
// check needed for avoiding flickering when a key gets pressed // check needed for avoiding flickering when a key gets pressed
// during dragging // during dragging
@@ -8280,12 +8299,7 @@ class App extends React.Component<AppProps, AppState> {
transformElements( transformElements(
pointerDownState, pointerDownState,
transformHandleType, transformHandleType,
resizingSingleFrameOnly selectedElements,
? selectedElements
: this.scene.getSelectedElements({
selectedElementIds: this.state.selectedElementIds,
includeElementsInFrames: true,
}),
pointerDownState.resize.arrowDirection, pointerDownState.resize.arrowDirection,
shouldRotateWithDiscreteAngle(event), shouldRotateWithDiscreteAngle(event),
shouldResizeFromCenter(event), shouldResizeFromCenter(event),
@@ -8301,19 +8315,18 @@ class App extends React.Component<AppProps, AppState> {
) { ) {
this.maybeSuggestBindingForAll(selectedElements); this.maybeSuggestBindingForAll(selectedElements);
// highlight frame children ONLY when resizing a single frame const elementsToHighlight = new Set<ExcalidrawElement>();
if (resizingSingleFrameOnly) { selectedFrames.forEach((frame) => {
const selectedFrame = selectedFrames[0]; getElementsInResizingFrame(
if (selectedFrame) { this.scene.getNonDeletedElements(),
this.setState({ frame,
elementsToHighlight: getElementsInResizingFrame( this.state,
this.scene.getNonDeletedElements(), ).forEach((element) => elementsToHighlight.add(element));
selectedFrame, });
this.state,
), this.setState({
}); elementsToHighlight: [...elementsToHighlight],
} });
}
return true; return true;
} }
+1 -1
View File
@@ -461,7 +461,7 @@ export const wrapText = (text: string, font: FontString, maxWidth: number) => {
const push = (str: string) => { const push = (str: string) => {
if (str.trim()) { if (str.trim()) {
lines.push(str); lines.push(str.trim());
} }
}; };
+1 -1
View File
@@ -1173,7 +1173,7 @@ describe("textWysiwyg", () => {
); );
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text).toBe( expect((h.elements[1] as ExcalidrawTextElementWithContainer).text).toBe(
"Online \nwhitebo\nard \ncollabo\nration \nmade \neasy", "Online\nwhitebo\nard\ncollabo\nration\nmade\neasy",
); );
fireEvent.contextMenu(GlobalTestState.interactiveCanvas, { fireEvent.contextMenu(GlobalTestState.interactiveCanvas, {
button: 2, button: 2,