开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
build: fix es-lint errors (#43)
pubuzhixing82a99535113d4
diff --git a/packages/drawnix/src/components/color-picker.tsx b/packages/drawnix/src/components/color-picker.tsxindex 0f9a5c2..7e907ba 100644--- a/packages/drawnix/src/components/color-picker.tsx+++ b/packages/drawnix/src/components/color-picker.tsx@@ -31,8 +31,7 @@ export const ColorPicker = React.forwardRef((props: ColorPickerProps, ref) => {hexAlphaToOpacity(currentColor || ROWS_CLASSIC_COLORS[0][0].value));return (- <>- <Stack.Col gap={3}>+ <Stack.Col gap={3}><SizeSliderstep={5}defaultValue={opacity}@@ -81,6 +80,5 @@ export const ColorPicker = React.forwardRef((props: ColorPickerProps, ref) => {))}</Stack.Col></Stack.Col>- </>);});diff --git a/packages/drawnix/src/components/toolbar/app-toolbar/app-menu-items.tsx b/packages/drawnix/src/components/toolbar/app-toolbar/app-menu-items.tsxindex 6d097f8..edc174d 100644--- a/packages/drawnix/src/components/toolbar/app-toolbar/app-menu-items.tsx+++ b/packages/drawnix/src/components/toolbar/app-toolbar/app-menu-items.tsx@@ -86,15 +86,13 @@ SaveAsImage.displayName = 'SaveAsImage';export const Socials = () => {return (- <>- <MenuItemLink+ <MenuItemLinkicon={GithubIcon}href="https://github.com/plait-board/drawnix"aria-label="GitHub">GitHub</MenuItemLink>- </>);};Socials.displayName = 'Socials';diff --git a/packages/drawnix/src/components/toolbar/app-toolbar/app-toolbar.tsx b/packages/drawnix/src/components/toolbar/app-toolbar/app-toolbar.tsxindex 25896ef..abb09a8 100644--- a/packages/drawnix/src/components/toolbar/app-toolbar/app-toolbar.tsx+++ b/packages/drawnix/src/components/toolbar/app-toolbar/app-toolbar.tsx@@ -23,7 +23,7 @@ import { OpenFile, SaveAsImage, SaveToFile, Socials } from './app-menu-items';import Menu from '../../menu/menu';import MenuSeparator from '../../menu/menu-separator';-export const AppToolbar: React.FC<{}> = () => {+export const AppToolbar: React.FC<null> = () => {const board = useBoard();const container = PlaitBoard.getBoardContainer(board);const selectedElements = getSelectedElements(board);diff --git a/packages/drawnix/src/components/toolbar/popup-toolbar/fill-button.tsx b/packages/drawnix/src/components/toolbar/popup-toolbar/fill-button.tsxindex 8a5e7b4..133a65a 100644--- a/packages/drawnix/src/components/toolbar/popup-toolbar/fill-button.tsx+++ b/packages/drawnix/src/components/toolbar/popup-toolbar/fill-button.tsx@@ -27,7 +27,7 @@ export const PopupFillButton: React.FC<PopupFillButtonProps> = ({const hexColor = currentColor && removeHexAlpha(currentColor);const container = PlaitBoard.getBoardContainer(board);- let icon =+ const icon =!hexColor || isTransparent(hexColor) ? BackgroundColorIcon : undefined;return (diff --git a/packages/drawnix/src/components/toolbar/popup-toolbar/font-color-button.tsx b/packages/drawnix/src/components/toolbar/popup-toolbar/font-color-button.tsxindex dee75d9..57c25d2 100644--- a/packages/drawnix/src/components/toolbar/popup-toolbar/font-color-button.tsx+++ b/packages/drawnix/src/components/toolbar/popup-toolbar/font-color-button.tsx@@ -25,8 +25,7 @@ export const PopupFontColorButton: React.FC<PopupFontColorButtonProps> = ({const container = PlaitBoard.getBoardContainer(board);return (- <>- <Popover+ <PopoversideOffset={12}open={isFontColorPropertyOpen}onOpenChange={(open) => {@@ -62,6 +61,5 @@ export const PopupFontColorButton: React.FC<PopupFontColorButtonProps> = ({</Island></PopoverContent></Popover>- </>);};diff --git a/packages/drawnix/src/components/toolbar/popup-toolbar/popup-toolbar.tsx b/packages/drawnix/src/components/toolbar/popup-toolbar/popup-toolbar.tsxindex 498ba01..e3aaf2a 100644--- a/packages/drawnix/src/components/toolbar/popup-toolbar/popup-toolbar.tsx+++ b/packages/drawnix/src/components/toolbar/popup-toolbar/popup-toolbar.tsx@@ -44,9 +44,9 @@ import { PopupFillButton } from './fill-button';import { isWhite, removeHexAlpha } from '../../../utils/color';import { TRANSPARENT } from '../../../constants/color';-export type PopupToolbarProps = {};+export type PopupToolbarProps = null;-export const PopupToolbar: React.FC<PopupToolbarProps> = ({}) => {+export const PopupToolbar: React.FC<PopupToolbarProps> = () => {const board = useBoard();const selectedElements = getSelectedElements(board);const [movingOrDragging, setMovingOrDragging] = useState(false);diff --git a/packages/drawnix/src/components/toolbar/popup-toolbar/stroke-button.tsx b/packages/drawnix/src/components/toolbar/popup-toolbar/stroke-button.tsxindex 1ade1b7..79300e7 100644--- a/packages/drawnix/src/components/toolbar/popup-toolbar/stroke-button.tsx+++ b/packages/drawnix/src/components/toolbar/popup-toolbar/stroke-button.tsx@@ -38,7 +38,7 @@ export const PopupStrokeButton: React.FC<PopupStrokeButtonProps> = ({const hexColor = currentColor && removeHexAlpha(currentColor);const container = PlaitBoard.getBoardContainer(board);- let icon = isTransparent(hexColor)+ const icon = isTransparent(hexColor)? StrokeIcon: isWhite(hexColor)? StrokeWhiteIcon@@ -49,84 +49,82 @@ export const PopupStrokeButton: React.FC<PopupStrokeButtonProps> = ({};return (- <>- <Popover- sideOffset={12}- open={isStrokePropertyOpen}- onOpenChange={(open) => {- setIsStrokePropertyOpen(open);- }}- placement={'top'}- >- <PopoverTrigger asChild>- <ToolButton- className={classNames(`property-button`)}- visible={true}- icon={icon}- type="button"- title={title}- aria-label={title}- onPointerUp={() => {- setIsStrokePropertyOpen(!isStrokePropertyOpen);- }}- >- {!icon && children}- </ToolButton>- </PopoverTrigger>- <PopoverContent container={container}>- <Island- padding={4}- className={classNames(- `${ATTACHED_ELEMENT_CLASS_NAME}`,- 'stroke-setting',- { 'has-stroke-style': hasStrokeStyle }+ <Popover+ sideOffset={12}+ open={isStrokePropertyOpen}+ onOpenChange={(open) => {+ setIsStrokePropertyOpen(open);+ }}+ placement={'top'}+ >+ <PopoverTrigger asChild>+ <ToolButton+ className={classNames(`property-button`)}+ visible={true}+ icon={icon}+ type="button"+ title={title}+ aria-label={title}+ onPointerUp={() => {+ setIsStrokePropertyOpen(!isStrokePropertyOpen);+ }}+ >+ {!icon && children}+ </ToolButton>+ </PopoverTrigger>+ <PopoverContent container={container}>+ <Island+ padding={4}+ className={classNames(+ `${ATTACHED_ELEMENT_CLASS_NAME}`,+ 'stroke-setting',+ { 'has-stroke-style': hasStrokeStyle }+ )}+ >+ <Stack.Col>+ {hasStrokeStyle && (+ <Stack.Row className={classNames('stroke-style-picker')}>+ <ToolButton+ visible={true}+ icon={StrokeStyleNormalIcon}+ type="button"+ title={title}+ aria-label={title}+ onPointerUp={() => {+ setStrokeStyle(StrokeStyle.solid);+ }}+ ></ToolButton>+ <ToolButton+ visible={true}+ icon={StrokeStyleDashedIcon}+ type="button"+ title={title}+ aria-label={title}+ onPointerUp={() => {+ setStrokeStyle(StrokeStyle.dashed);+ }}+ ></ToolButton>+ <ToolButton+ visible={true}+ icon={StrokeStyleDotedIcon}+ type="button"+ title={title}+ aria-label={title}+ onPointerUp={() => {+ setStrokeStyle(StrokeStyle.dotted);+ }}+ ></ToolButton>+ </Stack.Row>)}- >- <Stack.Col>- {hasStrokeStyle && (- <Stack.Row className={classNames('stroke-style-picker')}>- <ToolButton- visible={true}- icon={StrokeStyleNormalIcon}- type="button"- title={title}- aria-label={title}- onPointerUp={() => {- setStrokeStyle(StrokeStyle.solid);- }}- ></ToolButton>- <ToolButton- visible={true}- icon={StrokeStyleDashedIcon}- type="button"- title={title}- aria-label={title}- onPointerUp={() => {- setStrokeStyle(StrokeStyle.dashed);- }}- ></ToolButton>- <ToolButton- visible={true}- icon={StrokeStyleDotedIcon}- type="button"- title={title}- aria-label={title}- onPointerUp={() => {- setStrokeStyle(StrokeStyle.dotted);- }}- ></ToolButton>- </Stack.Row>- )}- <ColorPicker- onSelect={(selectedColor) => {- onColorSelect(selectedColor);- }}- currentColor={currentColor}- ></ColorPicker>- </Stack.Col>- </Island>- </PopoverContent>- </Popover>- </>+ <ColorPicker+ onSelect={(selectedColor) => {+ onColorSelect(selectedColor);+ }}+ currentColor={currentColor}+ ></ColorPicker>+ </Stack.Col>+ </Island>+ </PopoverContent>+ </Popover>);};diff --git a/packages/drawnix/src/components/toolbar/zoom-toolbar.tsx b/packages/drawnix/src/components/toolbar/zoom-toolbar.tsxindex ad901f1..44806f8 100644--- a/packages/drawnix/src/components/toolbar/zoom-toolbar.tsx+++ b/packages/drawnix/src/components/toolbar/zoom-toolbar.tsx@@ -14,7 +14,7 @@ import { useState } from 'react';import Menu from '../menu/menu';import MenuItem from '../menu/menu-item';-export const ZoomToolbar: React.FC<{}> = () => {+export const ZoomToolbar: React.FC<null> = () => {const board = useBoard();const container = PlaitBoard.getBoardContainer(board);const [zoomMenuOpen, setZoomMenuOpen] = useState(false);@@ -31,7 +31,6 @@ export const ZoomToolbar: React.FC<{}> = () => {visible={true}title={`缩小 — Cmd+-`}aria-label={`缩小 — Cmd+-`}- onPointerDown={() => {}}onPointerUp={() => {BoardTransforms.updateZoom(board, board.viewport.zoom - 0.1);}}@@ -92,7 +91,6 @@ export const ZoomToolbar: React.FC<{}> = () => {visible={true}title={`放大 — Cmd++`}aria-label={`放大 — Cmd++`}- onPointerDown={() => {}}onPointerUp={() => {BoardTransforms.updateZoom(board, board.viewport.zoom + 0.1);}}diff --git a/packages/drawnix/src/data/blob.ts b/packages/drawnix/src/data/blob.tsindex d9c5ca5..1cb391e 100644--- a/packages/drawnix/src/data/blob.ts+++ b/packages/drawnix/src/data/blob.ts@@ -7,11 +7,7 @@ export const loadFromBlob = async (board: PlaitBoard, blob: Blob | File) => {const contents = await parseFileContents(blob);let data;try {- try {- data = JSON.parse(contents);- } catch (error: any) {- throw error;- }+ data = JSON.parse(contents);if (isValidDrawnixData(data)) {return data;}diff --git a/packages/drawnix/src/errors.ts b/packages/drawnix/src/errors.tsindex 0db99dc..e3680a4 100644--- a/packages/drawnix/src/errors.ts+++ b/packages/drawnix/src/errors.ts@@ -1,5 +1,5 @@export class AbortError extends DOMException {- constructor(message: string = 'Request Aborted') {+ constructor(message = 'Request Aborted') {super(message, 'AbortError');}}diff --git a/packages/drawnix/src/plugins/freehand/freehand.generator.ts b/packages/drawnix/src/plugins/freehand/freehand.generator.tsindex e52ca1e..81468c7 100644--- a/packages/drawnix/src/plugins/freehand/freehand.generator.ts+++ b/packages/drawnix/src/plugins/freehand/freehand.generator.ts@@ -3,20 +3,15 @@ import { PlaitBoard, setStrokeLinecap } from '@plait/core';import { Options } from 'roughjs/bin/core';import { DefaultFreehand, Freehand } from './type';-export interface FreehandData {}--export class FreehandGenerator extends Generator<Freehand, FreehandData> {- protected draw(- element: Freehand,- data?: FreehandData | undefined- ): SVGGElement | undefined {- let option: Options = { ...DefaultFreehand };+export class FreehandGenerator extends Generator<Freehand> {+ protected draw(element: Freehand): SVGGElement | undefined {+ const option: Options = { ...DefaultFreehand };const g = PlaitBoard.getRoughSVG(this.board).curve(element.points, option);setStrokeLinecap(g, 'round');return g;}- canDraw(element: Freehand, data: FreehandData): boolean {+ canDraw(element: Freehand): boolean {return true;}}diff --git a/packages/drawnix/src/plugins/freehand/type.ts b/packages/drawnix/src/plugins/freehand/type.tsindex 8c7649a..50c3d74 100644--- a/packages/drawnix/src/plugins/freehand/type.ts+++ b/packages/drawnix/src/plugins/freehand/type.ts@@ -15,8 +15,7 @@ export enum FreehandShape {export const FREEHAND_TYPE = 'freehand';-export interface Freehand- extends PlaitCustomGeometry<typeof FREEHAND_TYPE, Point[], FreehandShape> {}+export type Freehand = PlaitCustomGeometry<typeof FREEHAND_TYPE, Point[], FreehandShape>export const Freehand = {isFreehand: (value: any): value is Freehand => {diff --git a/packages/drawnix/src/plugins/freehand/with-freehand-create.ts b/packages/drawnix/src/plugins/freehand/with-freehand-create.tsindex a40162a..4c6a6ec 100644--- a/packages/drawnix/src/plugins/freehand/with-freehand-create.ts+++ b/packages/drawnix/src/plugins/freehand/with-freehand-create.ts@@ -14,7 +14,7 @@ import { FreehandGenerator } from './freehand.generator';export const withFreehandCreate = (board: PlaitBoard) => {const { pointerDown, pointerMove, pointerUp, globalPointerUp } = board;- let isDrawing: boolean = false;+ let isDrawing = false;let points: Point[] = [];diff --git a/packages/drawnix/src/utils/common.ts b/packages/drawnix/src/utils/common.tsindex 24f8d98..f75765d 100644--- a/packages/drawnix/src/utils/common.ts+++ b/packages/drawnix/src/utils/common.ts@@ -33,11 +33,11 @@ export const composeEventHandlers = <E>(};export const base64ToBlob = (base64: string) => {- let arr = base64.split(','),- fileType = arr[0].match(/:(.*?);/)![1],- bstr = atob(arr[1]),- l = bstr.length,- u8Arr = new Uint8Array(l);+ const arr = base64.split(',');+ const fileType = arr[0].match(/:(.*?);/)![1];+ const bstr = atob(arr[1]);+ let l = bstr.length;+ const u8Arr = new Uint8Array(l);while (l--) {u8Arr[l] = bstr.charCodeAt(l);@@ -72,7 +72,7 @@ export function download(blob: Blob | MediaSource, filename: string) {}export const splitRows = <T>(shapes: T[], cols: number) => {- let result = [];+ const result = [];for (let i = 0; i < shapes.length; i += cols) {result.push(shapes.slice(i, i + cols));}