mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Bump prettier from 1.19.1 to 2.0.1 (#1060)
* Bump prettier from 1.19.1 to 2.0.1 Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/1.19.1...2.0.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Update formatting Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
This commit is contained in:
parent
251fa27c65
commit
722c498abe
46 changed files with 170 additions and 170 deletions
|
@ -26,7 +26,7 @@ export const actionChangeViewBackgroundColor = register({
|
|||
label={t("labels.canvasBackground")}
|
||||
type="canvasBackground"
|
||||
color={appState.viewBackgroundColor}
|
||||
onChange={color => updateData(color)}
|
||||
onChange={(color) => updateData(color)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -35,9 +35,9 @@ export const actionChangeViewBackgroundColor = register({
|
|||
|
||||
export const actionClearCanvas = register({
|
||||
name: "clearCanvas",
|
||||
perform: elements => {
|
||||
perform: (elements) => {
|
||||
return {
|
||||
elements: elements.map(element =>
|
||||
elements: elements.map((element) =>
|
||||
newElementWith(element, { isDeleted: true }),
|
||||
),
|
||||
appState: getDefaultAppState(),
|
||||
|
@ -97,7 +97,7 @@ export const actionZoomIn = register({
|
|||
}}
|
||||
/>
|
||||
),
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
(event.code === KEY_CODES.EQUAL || event.code === KEY_CODES.NUM_ADD) &&
|
||||
(event[KEYS.CTRL_OR_CMD] || event.shiftKey),
|
||||
});
|
||||
|
@ -124,7 +124,7 @@ export const actionZoomOut = register({
|
|||
}}
|
||||
/>
|
||||
),
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
(event.code === KEY_CODES.MINUS || event.code === KEY_CODES.NUM_SUBTRACT) &&
|
||||
(event[KEYS.CTRL_OR_CMD] || event.shiftKey),
|
||||
});
|
||||
|
@ -151,7 +151,7 @@ export const actionResetZoom = register({
|
|||
}}
|
||||
/>
|
||||
),
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
(event.code === KEY_CODES.ZERO || event.code === KEY_CODES.NUM_ZERO) &&
|
||||
(event[KEYS.CTRL_OR_CMD] || event.shiftKey),
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ export const actionDeleteSelected = register({
|
|||
},
|
||||
contextItemLabel: "labels.delete",
|
||||
contextMenuOrder: 3,
|
||||
keyTest: event => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE,
|
||||
keyTest: (event) => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE,
|
||||
PanelComponent: ({ elements, appState, updateData }) => (
|
||||
<ToolButton
|
||||
type="button"
|
||||
|
|
|
@ -27,5 +27,5 @@ export const actionDuplicateSelection = register({
|
|||
};
|
||||
},
|
||||
contextItemLabel: "labels.duplicateSelection",
|
||||
keyTest: event => event[KEYS.CTRL_OR_CMD] && event.key === "d",
|
||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === "d",
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ export const actionChangeExportBackground = register({
|
|||
<input
|
||||
type="checkbox"
|
||||
checked={appState.exportBackground}
|
||||
onChange={event => updateData(event.target.checked)}
|
||||
onChange={(event) => updateData(event.target.checked)}
|
||||
/>{" "}
|
||||
{t("labels.withBackground")}
|
||||
</label>
|
||||
|
@ -44,7 +44,7 @@ export const actionChangeExportBackground = register({
|
|||
export const actionSaveScene = register({
|
||||
name: "saveScene",
|
||||
perform: (elements, appState, value) => {
|
||||
saveAsJSON(elements, appState).catch(error => console.error(error));
|
||||
saveAsJSON(elements, appState).catch((error) => console.error(error));
|
||||
return { commitToHistory: false };
|
||||
},
|
||||
PanelComponent: ({ updateData }) => (
|
||||
|
@ -84,7 +84,7 @@ export const actionLoadScene = register({
|
|||
.then(({ elements, appState }) => {
|
||||
updateData({ elements: elements, appState: appState });
|
||||
})
|
||||
.catch(error => console.error(error));
|
||||
.catch((error) => console.error(error));
|
||||
}}
|
||||
/>
|
||||
),
|
||||
|
|
|
@ -35,7 +35,7 @@ const writeData = (
|
|||
const nextElementMap = getElementMap(nextElements);
|
||||
return {
|
||||
elements: nextElements
|
||||
.map(nextElement =>
|
||||
.map((nextElement) =>
|
||||
newElementWith(
|
||||
prevElementMap[nextElement.id] || nextElement,
|
||||
nextElement,
|
||||
|
@ -44,9 +44,9 @@ const writeData = (
|
|||
.concat(
|
||||
prevElements
|
||||
.filter(
|
||||
prevElement => !nextElementMap.hasOwnProperty(prevElement.id),
|
||||
(prevElement) => !nextElementMap.hasOwnProperty(prevElement.id),
|
||||
)
|
||||
.map(prevElement =>
|
||||
.map((prevElement) =>
|
||||
newElementWith(prevElement, { isDeleted: true }),
|
||||
),
|
||||
),
|
||||
|
@ -62,7 +62,7 @@ const testUndo = (shift: boolean) => (event: KeyboardEvent) =>
|
|||
|
||||
type ActionCreator = (history: SceneHistory) => Action;
|
||||
|
||||
export const createUndoAction: ActionCreator = history => ({
|
||||
export const createUndoAction: ActionCreator = (history) => ({
|
||||
name: "undo",
|
||||
perform: (elements, appState) =>
|
||||
writeData(elements, appState, () => history.undoOnce()),
|
||||
|
@ -78,7 +78,7 @@ export const createUndoAction: ActionCreator = history => ({
|
|||
commitToHistory: () => false,
|
||||
});
|
||||
|
||||
export const createRedoAction: ActionCreator = history => ({
|
||||
export const createRedoAction: ActionCreator = (history) => ({
|
||||
name: "redo",
|
||||
perform: (elements, appState) =>
|
||||
writeData(elements, appState, () => history.redoOnce()),
|
||||
|
|
|
@ -18,7 +18,7 @@ const changeProperty = (
|
|||
appState: AppState,
|
||||
callback: (element: ExcalidrawElement) => ExcalidrawElement,
|
||||
) => {
|
||||
return elements.map(element => {
|
||||
return elements.map((element) => {
|
||||
if (appState.selectedElementIds[element.id]) {
|
||||
return callback(element);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ const changeProperty = (
|
|||
});
|
||||
};
|
||||
|
||||
const getFormValue = function<T>(
|
||||
const getFormValue = function <T>(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
getAttribute: (element: ExcalidrawElement) => T,
|
||||
|
@ -46,7 +46,7 @@ export const actionChangeStrokeColor = register({
|
|||
name: "changeStrokeColor",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el =>
|
||||
elements: changeProperty(elements, appState, (el) =>
|
||||
newElementWith(el, {
|
||||
strokeColor: value,
|
||||
}),
|
||||
|
@ -64,7 +64,7 @@ export const actionChangeStrokeColor = register({
|
|||
color={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => element.strokeColor,
|
||||
(element) => element.strokeColor,
|
||||
appState.currentItemStrokeColor,
|
||||
)}
|
||||
onChange={updateData}
|
||||
|
@ -77,7 +77,7 @@ export const actionChangeBackgroundColor = register({
|
|||
name: "changeBackgroundColor",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el =>
|
||||
elements: changeProperty(elements, appState, (el) =>
|
||||
newElementWith(el, {
|
||||
backgroundColor: value,
|
||||
}),
|
||||
|
@ -95,7 +95,7 @@ export const actionChangeBackgroundColor = register({
|
|||
color={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => element.backgroundColor,
|
||||
(element) => element.backgroundColor,
|
||||
appState.currentItemBackgroundColor,
|
||||
)}
|
||||
onChange={updateData}
|
||||
|
@ -108,7 +108,7 @@ export const actionChangeFillStyle = register({
|
|||
name: "changeFillStyle",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el =>
|
||||
elements: changeProperty(elements, appState, (el) =>
|
||||
newElementWith(el, {
|
||||
fillStyle: value,
|
||||
}),
|
||||
|
@ -130,10 +130,10 @@ export const actionChangeFillStyle = register({
|
|||
value={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => element.fillStyle,
|
||||
(element) => element.fillStyle,
|
||||
appState.currentItemFillStyle,
|
||||
)}
|
||||
onChange={value => {
|
||||
onChange={(value) => {
|
||||
updateData(value);
|
||||
}}
|
||||
/>
|
||||
|
@ -145,7 +145,7 @@ export const actionChangeStrokeWidth = register({
|
|||
name: "changeStrokeWidth",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el =>
|
||||
elements: changeProperty(elements, appState, (el) =>
|
||||
newElementWith(el, {
|
||||
strokeWidth: value,
|
||||
}),
|
||||
|
@ -167,10 +167,10 @@ export const actionChangeStrokeWidth = register({
|
|||
value={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => element.strokeWidth,
|
||||
(element) => element.strokeWidth,
|
||||
appState.currentItemStrokeWidth,
|
||||
)}
|
||||
onChange={value => updateData(value)}
|
||||
onChange={(value) => updateData(value)}
|
||||
/>
|
||||
</fieldset>
|
||||
),
|
||||
|
@ -180,7 +180,7 @@ export const actionChangeSloppiness = register({
|
|||
name: "changeSloppiness",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el =>
|
||||
elements: changeProperty(elements, appState, (el) =>
|
||||
newElementWith(el, {
|
||||
roughness: value,
|
||||
}),
|
||||
|
@ -202,10 +202,10 @@ export const actionChangeSloppiness = register({
|
|||
value={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => element.roughness,
|
||||
(element) => element.roughness,
|
||||
appState.currentItemRoughness,
|
||||
)}
|
||||
onChange={value => updateData(value)}
|
||||
onChange={(value) => updateData(value)}
|
||||
/>
|
||||
</fieldset>
|
||||
),
|
||||
|
@ -215,7 +215,7 @@ export const actionChangeOpacity = register({
|
|||
name: "changeOpacity",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el =>
|
||||
elements: changeProperty(elements, appState, (el) =>
|
||||
newElementWith(el, {
|
||||
opacity: value,
|
||||
}),
|
||||
|
@ -232,8 +232,8 @@ export const actionChangeOpacity = register({
|
|||
min="0"
|
||||
max="100"
|
||||
step="10"
|
||||
onChange={event => updateData(+event.target.value)}
|
||||
onWheel={event => {
|
||||
onChange={(event) => updateData(+event.target.value)}
|
||||
onWheel={(event) => {
|
||||
event.stopPropagation();
|
||||
const target = event.target as HTMLInputElement;
|
||||
const STEP = 10;
|
||||
|
@ -251,7 +251,7 @@ export const actionChangeOpacity = register({
|
|||
getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => element.opacity,
|
||||
(element) => element.opacity,
|
||||
appState.currentItemOpacity,
|
||||
) ?? undefined
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ export const actionChangeFontSize = register({
|
|||
name: "changeFontSize",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el => {
|
||||
elements: changeProperty(elements, appState, (el) => {
|
||||
if (isTextElement(el)) {
|
||||
const element: ExcalidrawTextElement = newElementWith(el, {
|
||||
font: `${value}px ${el.font.split("px ")[1]}`,
|
||||
|
@ -298,10 +298,10 @@ export const actionChangeFontSize = register({
|
|||
value={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => isTextElement(element) && +element.font.split("px ")[0],
|
||||
(element) => isTextElement(element) && +element.font.split("px ")[0],
|
||||
+(appState.currentItemFont || DEFAULT_FONT).split("px ")[0],
|
||||
)}
|
||||
onChange={value => updateData(value)}
|
||||
onChange={(value) => updateData(value)}
|
||||
/>
|
||||
</fieldset>
|
||||
),
|
||||
|
@ -311,7 +311,7 @@ export const actionChangeFontFamily = register({
|
|||
name: "changeFontFamily",
|
||||
perform: (elements, appState, value) => {
|
||||
return {
|
||||
elements: changeProperty(elements, appState, el => {
|
||||
elements: changeProperty(elements, appState, (el) => {
|
||||
if (isTextElement(el)) {
|
||||
const element: ExcalidrawTextElement = newElementWith(el, {
|
||||
font: `${el.font.split("px ")[0]}px ${value}`,
|
||||
|
@ -344,10 +344,10 @@ export const actionChangeFontFamily = register({
|
|||
value={getFormValue(
|
||||
elements,
|
||||
appState,
|
||||
element => isTextElement(element) && element.font.split("px ")[1],
|
||||
(element) => isTextElement(element) && element.font.split("px ")[1],
|
||||
(appState.currentItemFont || DEFAULT_FONT).split("px ")[1],
|
||||
)}
|
||||
onChange={value => updateData(value)}
|
||||
onChange={(value) => updateData(value)}
|
||||
/>
|
||||
</fieldset>
|
||||
),
|
||||
|
|
|
@ -16,5 +16,5 @@ export const actionSelectAll = register({
|
|||
};
|
||||
},
|
||||
contextItemLabel: "labels.selectAll",
|
||||
keyTest: event => event[KEYS.CTRL_OR_CMD] && event.key === "a",
|
||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === "a",
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ let copiedStyles: string = "{}";
|
|||
export const actionCopyStyles = register({
|
||||
name: "copyStyles",
|
||||
perform: (elements, appState) => {
|
||||
const element = elements.find(el => appState.selectedElementIds[el.id]);
|
||||
const element = elements.find((el) => appState.selectedElementIds[el.id]);
|
||||
if (element) {
|
||||
copiedStyles = JSON.stringify(element);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export const actionCopyStyles = register({
|
|||
};
|
||||
},
|
||||
contextItemLabel: "labels.copyStyles",
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
event[KEYS.CTRL_OR_CMD] && event.shiftKey && event.key === "C",
|
||||
contextMenuOrder: 0,
|
||||
});
|
||||
|
@ -35,7 +35,7 @@ export const actionPasteStyles = register({
|
|||
return { elements, commitToHistory: false };
|
||||
}
|
||||
return {
|
||||
elements: elements.map(element => {
|
||||
elements: elements.map((element) => {
|
||||
if (appState.selectedElementIds[element.id]) {
|
||||
const newElement = newElementWith(element, {
|
||||
backgroundColor: pastedElement?.backgroundColor,
|
||||
|
@ -59,7 +59,7 @@ export const actionPasteStyles = register({
|
|||
};
|
||||
},
|
||||
contextItemLabel: "labels.pasteStyles",
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
event[KEYS.CTRL_OR_CMD] && event.shiftKey && event.key === "V",
|
||||
contextMenuOrder: 1,
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ export const actionSendBackward = register({
|
|||
},
|
||||
contextItemLabel: "labels.sendBackward",
|
||||
keyPriority: 40,
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
event[KEYS.CTRL_OR_CMD] && !event.shiftKey && event.code === "BracketLeft",
|
||||
PanelComponent: ({ updateData }) => (
|
||||
<button
|
||||
|
@ -59,7 +59,7 @@ export const actionBringForward = register({
|
|||
},
|
||||
contextItemLabel: "labels.bringForward",
|
||||
keyPriority: 40,
|
||||
keyTest: event =>
|
||||
keyTest: (event) =>
|
||||
event[KEYS.CTRL_OR_CMD] && !event.shiftKey && event.code === "BracketRight",
|
||||
PanelComponent: ({ updateData }) => (
|
||||
<button
|
||||
|
@ -86,7 +86,7 @@ export const actionSendToBack = register({
|
|||
};
|
||||
},
|
||||
contextItemLabel: "labels.sendToBack",
|
||||
keyTest: event => {
|
||||
keyTest: (event) => {
|
||||
return isDarwin
|
||||
? event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === "BracketLeft"
|
||||
: event[KEYS.CTRL_OR_CMD] &&
|
||||
|
@ -122,7 +122,7 @@ export const actionBringToFront = register({
|
|||
};
|
||||
},
|
||||
contextItemLabel: "labels.bringToFront",
|
||||
keyTest: event => {
|
||||
keyTest: (event) => {
|
||||
return isDarwin
|
||||
? event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === "BracketRight"
|
||||
: event[KEYS.CTRL_OR_CMD] &&
|
||||
|
@ -133,7 +133,7 @@ export const actionBringToFront = register({
|
|||
<button
|
||||
type="button"
|
||||
className="zIndexButton"
|
||||
onClick={event => updateData(null)}
|
||||
onClick={(event) => updateData(null)}
|
||||
title={`${t("labels.bringToFront")} ${
|
||||
isDarwin
|
||||
? getShortcutKey("CtrlOrCmd+Alt+]")
|
||||
|
|
|
@ -33,14 +33,14 @@ export class ActionManager implements ActionsManagerInterface {
|
|||
}
|
||||
|
||||
registerAll(actions: readonly Action[]) {
|
||||
actions.forEach(action => this.registerAction(action));
|
||||
actions.forEach((action) => this.registerAction(action));
|
||||
}
|
||||
|
||||
handleKeyDown(event: KeyboardEvent) {
|
||||
const data = Object.values(this.actions)
|
||||
.sort((a, b) => (b.keyPriority || 0) - (a.keyPriority || 0))
|
||||
.filter(
|
||||
action =>
|
||||
(action) =>
|
||||
action.keyTest &&
|
||||
action.keyTest(event, this.getAppState(), this.getElements()),
|
||||
);
|
||||
|
@ -58,16 +58,16 @@ export class ActionManager implements ActionsManagerInterface {
|
|||
this.updater(action.perform(this.getElements(), this.getAppState(), null));
|
||||
}
|
||||
|
||||
getContextMenuItems(actionFilter: ActionFilterFn = action => action) {
|
||||
getContextMenuItems(actionFilter: ActionFilterFn = (action) => action) {
|
||||
return Object.values(this.actions)
|
||||
.filter(actionFilter)
|
||||
.filter(action => "contextItemLabel" in action)
|
||||
.filter((action) => "contextItemLabel" in action)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
(a.contextMenuOrder !== undefined ? a.contextMenuOrder : 999) -
|
||||
(b.contextMenuOrder !== undefined ? b.contextMenuOrder : 999),
|
||||
)
|
||||
.map(action => ({
|
||||
.map((action) => ({
|
||||
label: action.contextItemLabel ? t(action.contextItemLabel) : "",
|
||||
action: () => {
|
||||
this.updater(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue