Skip to content

开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.

fix(toolbar): fix issue mentioned in #290 (#291)

Andy Lu (Lu, Yu-An)d9b637110303
diff --git a/packages/drawnix/src/components/arrow-picker.tsx b/packages/drawnix/src/components/arrow-picker.tsx
index f895da3..3f54d74 100644
--- a/packages/drawnix/src/components/arrow-picker.tsx
+++ b/packages/drawnix/src/components/arrow-picker.tsx
@@ -5,7 +5,7 @@ import { ToolButton } from './tool-button';
import { StraightArrowIcon, ElbowArrowIcon, CurveArrowIcon } from './icons';
import { useBoard } from '@plait-board/react-board';
import { Translations, useI18n } from '../i18n';
-import { BoardTransforms } from '@plait/core';
+import { BoardTransforms , PlaitBoard } from '@plait/core';
import React from 'react';
import { BoardCreationMode, setCreationMode } from '@plait/common';
import { ArrowLineShape, DrawPointerType } from '@plait/draw';
@@ -52,6 +52,7 @@ export const ArrowPicker: React.FC<ArrowPickerProps> = ({ onPointerUp }) => {
type="icon"
size={'small'}
visible={true}
+ selected={PlaitBoard.isPointer(board, arrow.pointer)}
icon={arrow.icon}
title={t(arrow.title as keyof Translations)}
aria-label={t(arrow.title as keyof Translations)}
diff --git a/packages/drawnix/src/components/shape-picker.tsx b/packages/drawnix/src/components/shape-picker.tsx
index 61a616d..7691be6 100644
--- a/packages/drawnix/src/components/shape-picker.tsx
+++ b/packages/drawnix/src/components/shape-picker.tsx
@@ -11,7 +11,7 @@ import {
RoundRectangleIcon,
TerminalIcon,
} from './icons';
-import { BoardTransforms } from '@plait/core';
+import { BoardTransforms , PlaitBoard } from '@plait/core';
import React from 'react';
import { BoardCreationMode, setCreationMode } from '@plait/common';
import { BasicShapes, DrawPointerType, FlowchartSymbols } from '@plait/draw';
@@ -88,6 +88,7 @@ export const ShapePicker: React.FC<ShapePickerProps> = ({
type="icon"
size={'small'}
visible={true}
+ selected={PlaitBoard.isPointer(board, shape.pointer)}
icon={shape.icon}
title={t((shape.title || 'toolbar.shape') as keyof Translations)}
aria-label={t((shape.title || 'toolbar.shape') as keyof Translations)}
diff --git a/packages/drawnix/src/components/toolbar/creation-toolbar.tsx b/packages/drawnix/src/components/toolbar/creation-toolbar.tsx
index b5861b0..6d542cf 100644
--- a/packages/drawnix/src/components/toolbar/creation-toolbar.tsx
+++ b/packages/drawnix/src/components/toolbar/creation-toolbar.tsx
@@ -243,6 +243,11 @@ export const CreationToolbar = () => {
aria-label={button.titleKey ? t(button.titleKey) : 'Shape'}
onPointerDown={() => {
setShapeOpen(!shapeOpen);
+ if (isShapePointer(board)) {
+ BoardTransforms.updatePointerType(board, board.pointer);
+ } else {
+ BoardTransforms.updatePointerType(board, button.pointer!);
+ }
}}
/>
</PopoverTrigger>
@@ -277,6 +282,11 @@ export const CreationToolbar = () => {
aria-label={button.titleKey ? t(button.titleKey) : ''}
onPointerDown={() => {
setArrowOpen(!arrowOpen);
+ if (isArrowLinePointer(board)) {
+ BoardTransforms.updatePointerType(board, board.pointer);
+ } else {
+ BoardTransforms.updatePointerType(board, button.pointer!);
+ }
}}
/>
</PopoverTrigger>