Aligns arrowhead schemas (#2517)
This commit is contained in:
parent
9cf54041dc
commit
9cfe7b45e5
@ -667,10 +667,9 @@ export const actionChangeArrowhead = register({
|
||||
}),
|
||||
appState: {
|
||||
...appState,
|
||||
currentItemArrowheads: {
|
||||
...appState.currentItemArrowheads,
|
||||
[value.position]: value.type,
|
||||
},
|
||||
[value.position === "start"
|
||||
? "currentItemStartArrowhead"
|
||||
: "currentItemEndArrowhead"]: value.type,
|
||||
},
|
||||
commitToHistory: true,
|
||||
};
|
||||
@ -731,8 +730,8 @@ export const actionChangeArrowhead = register({
|
||||
(element) =>
|
||||
isLinearElement(element) && canHaveArrowheads(element.type)
|
||||
? element.startArrowhead
|
||||
: appState.currentItemArrowheads.start,
|
||||
appState.currentItemArrowheads.start,
|
||||
: appState.currentItemStartArrowhead,
|
||||
appState.currentItemStartArrowhead,
|
||||
)}
|
||||
onChange={(value) => updateData({ position: "start", type: value })}
|
||||
/>
|
||||
@ -786,8 +785,8 @@ export const actionChangeArrowhead = register({
|
||||
(element) =>
|
||||
isLinearElement(element) && canHaveArrowheads(element.type)
|
||||
? element.endArrowhead
|
||||
: appState.currentItemArrowheads.end,
|
||||
appState.currentItemArrowheads.end,
|
||||
: appState.currentItemEndArrowhead,
|
||||
appState.currentItemEndArrowhead,
|
||||
)}
|
||||
onChange={(value) => updateData({ position: "end", type: value })}
|
||||
/>
|
||||
|
@ -39,7 +39,8 @@ export const getDefaultAppState = (): Omit<
|
||||
currentItemTextAlign: DEFAULT_TEXT_ALIGN,
|
||||
currentItemStrokeSharpness: "sharp",
|
||||
currentItemLinearStrokeSharpness: "round",
|
||||
currentItemArrowheads: { start: null, end: "arrow" },
|
||||
currentItemStartArrowhead: null,
|
||||
currentItemEndArrowhead: "arrow",
|
||||
viewBackgroundColor: oc.white,
|
||||
scrollX: 0 as FlooredNumber,
|
||||
scrollY: 0 as FlooredNumber,
|
||||
@ -104,7 +105,8 @@ const APP_STATE_STORAGE_CONF = (<
|
||||
currentItemTextAlign: { browser: true, export: false },
|
||||
currentItemStrokeSharpness: { browser: true, export: false },
|
||||
currentItemLinearStrokeSharpness: { browser: true, export: false },
|
||||
currentItemArrowheads: { browser: true, export: false },
|
||||
currentItemStartArrowhead: { browser: true, export: false },
|
||||
currentItemEndArrowhead: { browser: true, export: false },
|
||||
cursorButton: { browser: true, export: false },
|
||||
cursorX: { browser: true, export: false },
|
||||
cursorY: { browser: true, export: false },
|
||||
|
@ -2578,12 +2578,16 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
||||
elementType === "draw" ? null : this.state.gridSize,
|
||||
);
|
||||
|
||||
// If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.
|
||||
// If so, we want it to be null/"arrow". If the linear item is not an arrow, we want it
|
||||
// to be null/null. Otherwise, we want it to use the currentItemArrowheads values.
|
||||
const { start, end } = this.state.currentItemArrowheads;
|
||||
/* If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.
|
||||
If so, we want it to be null for start and "arrow" for end. If the linear item is not
|
||||
an arrow, we want it to be null for both. Otherwise, we want it to use the
|
||||
values from appState. */
|
||||
|
||||
const { currentItemStartArrowhead, currentItemEndArrowhead } = this.state;
|
||||
const [startArrowhead, endArrowhead] =
|
||||
elementType === "arrow" ? [start, end] : [null, null];
|
||||
elementType === "arrow"
|
||||
? [currentItemStartArrowhead, currentItemEndArrowhead]
|
||||
: [null, null];
|
||||
|
||||
const element = newLinearElement({
|
||||
type: elementType,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -61,10 +61,8 @@ export type AppState = {
|
||||
currentItemFontSize: number;
|
||||
currentItemTextAlign: TextAlign;
|
||||
currentItemStrokeSharpness: ExcalidrawElement["strokeSharpness"];
|
||||
currentItemArrowheads: {
|
||||
start: Arrowhead | null;
|
||||
end: Arrowhead | null;
|
||||
};
|
||||
currentItemStartArrowhead: Arrowhead | null;
|
||||
currentItemEndArrowhead: Arrowhead | null;
|
||||
currentItemLinearStrokeSharpness: ExcalidrawElement["strokeSharpness"];
|
||||
viewBackgroundColor: string;
|
||||
scrollX: FlooredNumber;
|
||||
|
Loading…
x
Reference in New Issue
Block a user