开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
feat(mobile): adapt mobile device
pubuzhixing87c0742fb9eca
diff --git a/package-lock.json b/package-lock.jsonindex 5d6bfd8..76e52f4 100644--- a/package-lock.json+++ b/package-lock.json@@ -19,6 +19,7 @@"ahooks": "^3.8.0","browser-fs-access": "^0.35.0","classnames": "^2.5.1",+ "mobile-detect": "^1.4.5","open-color": "^1.9.1","react": "18.3.1","react-dom": "18.3.1",@@ -12015,6 +12016,11 @@"ufo": "^1.5.3"}},+ "node_modules/mobile-detect": {+ "version": "1.4.5",+ "resolved": "https://registry.npmjs.org/mobile-detect/-/mobile-detect-1.4.5.tgz",+ "integrity": "sha512-yc0LhH6tItlvfLBugVUEtgawwFU2sIe+cSdmRJJCTMZ5GEJyLxNyC/NIOAOGk67Fa8GNpOttO3Xz/1bHpXFD/g=="+ },"node_modules/mrmime": {"version": "2.0.0","resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz",diff --git a/package.json b/package.jsonindex 263811b..212131c 100644--- a/package.json+++ b/package.json@@ -19,6 +19,7 @@"ahooks": "^3.8.0","browser-fs-access": "^0.35.0","classnames": "^2.5.1",+ "mobile-detect": "^1.4.5","open-color": "^1.9.1","react": "18.3.1","react-dom": "18.3.1",diff --git a/packages/drawnix/src/drawnix.tsx b/packages/drawnix/src/drawnix.tsxindex da93218..3de8ae9 100644--- a/packages/drawnix/src/drawnix.tsx+++ b/packages/drawnix/src/drawnix.tsx@@ -13,15 +13,16 @@ import React, { useState } from 'react';import { withGroup } from '@plait/common';import { DrawPointerType, withDraw } from '@plait/draw';import { MindPointerType, withMind } from '@plait/mind';+import MobileDetect from 'mobile-detect';import { withMindExtend } from './plugins/with-mind-extend';import { withCommonPlugin } from './plugins/with-common';import { CreationToolbar } from './components/toolbar/creation-toolbar';--import './styles/index.scss';-import { MainMenu } from './components/app-menu/main-menu';import { ZoomToolbar } from './components/toolbar/zoom-toolbar';import { PopupToolbar } from './components/toolbar/popup-toolbar/popup-toolbar';import { AppToolbar } from './components/toolbar/app-toolbar/app-toolbar';+import classNames from 'classnames';+import './styles/index.scss';+export type DrawnixProps = {value: PlaitElement[];@@ -41,6 +42,7 @@ export type DrawnixPointerType =export type DrawnixState = {pointer: DrawnixPointerType;+ isMobile: boolean;};export const Drawnix: React.FC<DrawnixProps> = ({@@ -59,11 +61,16 @@ export const Drawnix: React.FC<DrawnixProps> = ({const options: PlaitBoardOptions = {};const [appState, setAppState] = useState<DrawnixState>(() => {// TODO: need to consider how to maintenance the pointer state in future- return { pointer: PlaitPointerType.hand };+ const md = new MobileDetect(window.navigator.userAgent);+ return { pointer: PlaitPointerType.hand, isMobile: md.mobile() !== null };});return (- <div className="drawnix">+ <div+ className={classNames('drawnix', {+ 'drawnix--mobile': appState.isMobile,+ })}+ ><Wrappervalue={value}viewport={viewport}@@ -78,7 +85,7 @@ export const Drawnix: React.FC<DrawnixProps> = ({<AppToolbar></AppToolbar><CreationToolbarsetPointer={(pointer: DrawnixPointerType) => {- setAppState({ pointer });+ setAppState({ ...appState, pointer });}}></CreationToolbar><ZoomToolbar></ZoomToolbar>diff --git a/packages/drawnix/src/styles/index.scss b/packages/drawnix/src/styles/index.scssindex 244fe7e..dd8fcbc 100644--- a/packages/drawnix/src/styles/index.scss+++ b/packages/drawnix/src/styles/index.scss@@ -11,13 +11,18 @@top: 36px;left: 50%;transform: translateX(-50%);+ @include isMobile {+ top: 20px;+ }}.zoom-toolbar {cursor: default;position: absolute;top: 36px;right: 36px;-+ @include isMobile {+ display: none;+ }.zoom-out-button {border-top-right-radius: 0 !important;border-bottom-right-radius: 0 !important;@@ -46,8 +51,21 @@position: absolute;top: 40px;left: 36px;+ @include isMobile {+ bottom: 20px;+ top: auto;+ width: 86%;+ left: 50%;+ transform: translateX(-50%);+ }+ .stack {+ @include isMobile {+ display: flex;+ align-items: center;+ justify-content: space-between;+ }+ }}-.drawnix-link, a {font-weight: 500;text-decoration: none;