changing new shape property sets it as default (#520)
* changing new shape property sets it as default * set correct opacity while editing new test Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
This commit is contained in:
parent
69061e20ac
commit
1bae203a78
@ -102,6 +102,7 @@ export const actionChangeFillStyle: Action = {
|
|||||||
shape: null,
|
shape: null,
|
||||||
fillStyle: value,
|
fillStyle: value,
|
||||||
})),
|
})),
|
||||||
|
appState: { ...appState, currentItemFillStyle: value },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData, t }) => (
|
PanelComponent: ({ elements, appState, updateData, t }) => (
|
||||||
@ -136,6 +137,7 @@ export const actionChangeStrokeWidth: Action = {
|
|||||||
shape: null,
|
shape: null,
|
||||||
strokeWidth: value,
|
strokeWidth: value,
|
||||||
})),
|
})),
|
||||||
|
appState: { ...appState, currentItemStrokeWidth: value },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData, t }) => (
|
PanelComponent: ({ elements, appState, updateData, t }) => (
|
||||||
@ -168,6 +170,7 @@ export const actionChangeSloppiness: Action = {
|
|||||||
shape: null,
|
shape: null,
|
||||||
roughness: value,
|
roughness: value,
|
||||||
})),
|
})),
|
||||||
|
appState: { ...appState, currentItemRoughness: value },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData, t }) => (
|
PanelComponent: ({ elements, appState, updateData, t }) => (
|
||||||
@ -200,6 +203,7 @@ export const actionChangeOpacity: Action = {
|
|||||||
shape: null,
|
shape: null,
|
||||||
opacity: value,
|
opacity: value,
|
||||||
})),
|
})),
|
||||||
|
appState: { ...appState, currentItemOpacity: value },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData, t }) => (
|
PanelComponent: ({ elements, appState, updateData, t }) => (
|
||||||
@ -240,6 +244,12 @@ export const actionChangeFontSize: Action = {
|
|||||||
|
|
||||||
return el;
|
return el;
|
||||||
}),
|
}),
|
||||||
|
appState: {
|
||||||
|
...appState,
|
||||||
|
currentItemFont: `${value}px ${
|
||||||
|
appState.currentItemFont.split("px ")[1]
|
||||||
|
}`,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData, t }) => (
|
PanelComponent: ({ elements, appState, updateData, t }) => (
|
||||||
@ -281,6 +291,12 @@ export const actionChangeFontFamily: Action = {
|
|||||||
|
|
||||||
return el;
|
return el;
|
||||||
}),
|
}),
|
||||||
|
appState: {
|
||||||
|
...appState,
|
||||||
|
currentItemFont: `${
|
||||||
|
appState.currentItemFont.split("px ")[0]
|
||||||
|
}px ${value}`,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData, t }) => (
|
PanelComponent: ({ elements, appState, updateData, t }) => (
|
||||||
|
@ -13,6 +13,10 @@ export function getDefaultAppState(): AppState {
|
|||||||
exportBackground: true,
|
exportBackground: true,
|
||||||
currentItemStrokeColor: "#000000",
|
currentItemStrokeColor: "#000000",
|
||||||
currentItemBackgroundColor: "transparent",
|
currentItemBackgroundColor: "transparent",
|
||||||
|
currentItemFillStyle: "hachure",
|
||||||
|
currentItemStrokeWidth: 1,
|
||||||
|
currentItemRoughness: 1,
|
||||||
|
currentItemOpacity: 100,
|
||||||
currentItemFont: "20px Virgil",
|
currentItemFont: "20px Virgil",
|
||||||
viewBackgroundColor: "#ffffff",
|
viewBackgroundColor: "#ffffff",
|
||||||
scrollX: 0,
|
scrollX: 0,
|
||||||
|
@ -7,6 +7,7 @@ type TextWysiwygParams = {
|
|||||||
y: number;
|
y: number;
|
||||||
strokeColor: string;
|
strokeColor: string;
|
||||||
font: string;
|
font: string;
|
||||||
|
opacity: number;
|
||||||
onSubmit: (text: string) => void;
|
onSubmit: (text: string) => void;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
};
|
};
|
||||||
@ -23,6 +24,7 @@ export function textWysiwyg({
|
|||||||
y,
|
y,
|
||||||
strokeColor,
|
strokeColor,
|
||||||
font,
|
font,
|
||||||
|
opacity,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onCancel,
|
onCancel,
|
||||||
}: TextWysiwygParams) {
|
}: TextWysiwygParams) {
|
||||||
@ -38,6 +40,7 @@ export function textWysiwyg({
|
|||||||
Object.assign(editable.style, {
|
Object.assign(editable.style, {
|
||||||
color: strokeColor,
|
color: strokeColor,
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
|
opacity: opacity / 100,
|
||||||
top: y + "px",
|
top: y + "px",
|
||||||
left: x + "px",
|
left: x + "px",
|
||||||
transform: "translate(-50%, -50%)",
|
transform: "translate(-50%, -50%)",
|
||||||
|
@ -126,6 +126,10 @@ function pickAppStatePropertiesForHistory(
|
|||||||
exportBackground: appState.exportBackground,
|
exportBackground: appState.exportBackground,
|
||||||
currentItemStrokeColor: appState.currentItemStrokeColor,
|
currentItemStrokeColor: appState.currentItemStrokeColor,
|
||||||
currentItemBackgroundColor: appState.currentItemBackgroundColor,
|
currentItemBackgroundColor: appState.currentItemBackgroundColor,
|
||||||
|
currentItemFillStyle: appState.currentItemFillStyle,
|
||||||
|
currentItemStrokeWidth: appState.currentItemStrokeWidth,
|
||||||
|
currentItemRoughness: appState.currentItemRoughness,
|
||||||
|
currentItemOpacity: appState.currentItemOpacity,
|
||||||
currentItemFont: appState.currentItemFont,
|
currentItemFont: appState.currentItemFont,
|
||||||
viewBackgroundColor: appState.viewBackgroundColor,
|
viewBackgroundColor: appState.viewBackgroundColor,
|
||||||
name: appState.name,
|
name: appState.name,
|
||||||
@ -791,10 +795,10 @@ export class App extends React.Component<any, AppState> {
|
|||||||
y,
|
y,
|
||||||
this.state.currentItemStrokeColor,
|
this.state.currentItemStrokeColor,
|
||||||
this.state.currentItemBackgroundColor,
|
this.state.currentItemBackgroundColor,
|
||||||
"hachure",
|
this.state.currentItemFillStyle,
|
||||||
1,
|
this.state.currentItemStrokeWidth,
|
||||||
1,
|
this.state.currentItemRoughness,
|
||||||
100,
|
this.state.currentItemOpacity,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isTextElement(element)) {
|
if (isTextElement(element)) {
|
||||||
@ -892,6 +896,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
x: textX,
|
x: textX,
|
||||||
y: textY,
|
y: textY,
|
||||||
strokeColor: this.state.currentItemStrokeColor,
|
strokeColor: this.state.currentItemStrokeColor,
|
||||||
|
opacity: this.state.currentItemOpacity,
|
||||||
font: this.state.currentItemFont,
|
font: this.state.currentItemFont,
|
||||||
onSubmit: text => {
|
onSubmit: text => {
|
||||||
if (text) {
|
if (text) {
|
||||||
@ -1234,10 +1239,10 @@ export class App extends React.Component<any, AppState> {
|
|||||||
y,
|
y,
|
||||||
this.state.currentItemStrokeColor,
|
this.state.currentItemStrokeColor,
|
||||||
this.state.currentItemBackgroundColor,
|
this.state.currentItemBackgroundColor,
|
||||||
"hachure",
|
this.state.currentItemFillStyle,
|
||||||
1,
|
this.state.currentItemStrokeWidth,
|
||||||
1,
|
this.state.currentItemRoughness,
|
||||||
100,
|
this.state.currentItemOpacity,
|
||||||
),
|
),
|
||||||
"", // default text
|
"", // default text
|
||||||
this.state.currentItemFont, // default font
|
this.state.currentItemFont, // default font
|
||||||
@ -1296,6 +1301,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
y: textY,
|
y: textY,
|
||||||
strokeColor: element.strokeColor,
|
strokeColor: element.strokeColor,
|
||||||
font: element.font,
|
font: element.font,
|
||||||
|
opacity: this.state.currentItemOpacity,
|
||||||
onSubmit: text => {
|
onSubmit: text => {
|
||||||
if (text) {
|
if (text) {
|
||||||
elements = [
|
elements = [
|
||||||
|
@ -11,6 +11,10 @@ export type AppState = {
|
|||||||
exportBackground: boolean;
|
exportBackground: boolean;
|
||||||
currentItemStrokeColor: string;
|
currentItemStrokeColor: string;
|
||||||
currentItemBackgroundColor: string;
|
currentItemBackgroundColor: string;
|
||||||
|
currentItemFillStyle: string;
|
||||||
|
currentItemStrokeWidth: number;
|
||||||
|
currentItemRoughness: number;
|
||||||
|
currentItemOpacity: number;
|
||||||
currentItemFont: string;
|
currentItemFont: string;
|
||||||
viewBackgroundColor: string;
|
viewBackgroundColor: string;
|
||||||
scrollX: number;
|
scrollX: number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user