开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
feat: bump plait into 0.76.0 and handle break changes (#90)
pubuzhixing86f80640d05bb
diff --git a/package-lock.json b/package-lock.jsonindex 30350b2..e9c6096 100644--- a/package-lock.json+++ b/package-lock.json@@ -10,12 +10,12 @@"license": "MIT","dependencies": {"@floating-ui/react": "^0.26.24",- "@plait/common": "^0.75.0",- "@plait/core": "^0.75.0",- "@plait/draw": "^0.75.0",- "@plait/layouts": "^0.75.0",- "@plait/mind": "^0.75.0",- "@plait/text-plugins": "^0.75.0",+ "@plait/common": "^0.76.0",+ "@plait/core": "^0.76.0",+ "@plait/draw": "^0.76.0",+ "@plait/layouts": "^0.76.0",+ "@plait/mind": "^0.76.0",+ "@plait/text-plugins": "^0.76.0","ahooks": "^3.8.0","browser-fs-access": "^0.35.0","classnames": "^2.5.1",@@ -4345,17 +4345,17 @@}},"node_modules/@plait/common": {- "version": "0.75.0",- "resolved": "https://registry.npmjs.org/@plait/common/-/common-0.75.0.tgz",- "integrity": "sha512-5mWY4t3dYI7IJ6U4V3iK2hPbTTpf74zV9sQKcxqUFJcevjItv/AB7FwDGVLBTco4qCqi8Ae01SugiI5itkudiw==",+ "version": "0.76.0",+ "resolved": "https://registry.npmjs.org/@plait/common/-/common-0.76.0.tgz",+ "integrity": "sha512-I6uJITS/8gcxn5+HGlskUd2VqGut/ZoBn02oOYLcBpFROGI5QwtXBVUdneOPAdmq+8FZDeo2HNTCYnjPQPRbgw==","dependencies": {"tslib": "^2.3.0"}},"node_modules/@plait/core": {- "version": "0.75.0",- "resolved": "https://registry.npmjs.org/@plait/core/-/core-0.75.0.tgz",- "integrity": "sha512-+aORVGlj4NOeDIBmt+O8avPVpnqcsuY+k6zFIW5+hUAxqpaRrfy8164NbwjKr97KV5l4d3cYAjhwHbMjNhWgXw==",+ "version": "0.76.0",+ "resolved": "https://registry.npmjs.org/@plait/core/-/core-0.76.0.tgz",+ "integrity": "sha512-8VG8h+sHEPZMSEsnq1zZCxVe9Ub9rx0AjLbIAkUi8MLZQ794a3adLWSrpOSkpYZ7IDo1jLXcSDFSUvlwidFMDA==","dependencies": {"tslib": "^2.3.0"},@@ -4368,33 +4368,33 @@}},"node_modules/@plait/draw": {- "version": "0.75.0",- "resolved": "https://registry.npmjs.org/@plait/draw/-/draw-0.75.0.tgz",- "integrity": "sha512-QRGFtr5nNNGlN1HPgQGFPZJHPaOB+QUxpK1PFcjDaYcObDtsg0HAl9P6C8eq3I95/gBJ3xjrReGdJAce4EzbYw==",+ "version": "0.76.0",+ "resolved": "https://registry.npmjs.org/@plait/draw/-/draw-0.76.0.tgz",+ "integrity": "sha512-zKLjs+g6RrALz7YymN6iLtEh+4QfSwrPAe6vp2qEa8msgdgLQgQkV2nwzHKQykeKgZlKajMlu16s3+Q3UFn/yQ==","dependencies": {"tslib": "^2.3.0"}},"node_modules/@plait/layouts": {- "version": "0.75.0",- "resolved": "https://registry.npmjs.org/@plait/layouts/-/layouts-0.75.0.tgz",- "integrity": "sha512-zSIc1B47HtEF53ESzEVgw0m9wpey0FRIuO4pgI9fgymsikze9hK66HfB8RB830cEF/7ycS2tTe0Z0J9WprVfUw==",+ "version": "0.76.0",+ "resolved": "https://registry.npmjs.org/@plait/layouts/-/layouts-0.76.0.tgz",+ "integrity": "sha512-fwT/SbcvYBxrJXIUY+WALOTm7tQ0trs7WD4Y6BqcqKHX50B9OB4plPwelzC+I2NjIvKgJmpQxE21Re2JuaoJow==","dependencies": {"tslib": "^2.3.0"}},"node_modules/@plait/mind": {- "version": "0.75.0",- "resolved": "https://registry.npmjs.org/@plait/mind/-/mind-0.75.0.tgz",- "integrity": "sha512-2PGiAVWVM7LsYoCBEUeuEfmdYSkYEAsPyzK9a13bG11Imihkv+Kw0SOMPhXtNw4BjTYlSdkwfBw7lshNBF0bfQ==",+ "version": "0.76.0",+ "resolved": "https://registry.npmjs.org/@plait/mind/-/mind-0.76.0.tgz",+ "integrity": "sha512-xfAsGrya/67fs+cX+1MyuPFBb3J61HgltLUpwZ0Dp+e4fEBCUK98+adpI2gDPF+KCgZbn0Pm6O16NtdeyKUwgQ==","dependencies": {"tslib": "^2.3.0"}},"node_modules/@plait/text-plugins": {- "version": "0.75.0",- "resolved": "https://registry.npmjs.org/@plait/text-plugins/-/text-plugins-0.75.0.tgz",- "integrity": "sha512-bbxxDCGWu3pE1mth18xHWQ9RAQuvV29+XNpV992TXjBDcCLhCzYKUt+d7uVPllqT4c5FvcVvHwWhYcD0feJLMg==",+ "version": "0.76.0",+ "resolved": "https://registry.npmjs.org/@plait/text-plugins/-/text-plugins-0.76.0.tgz",+ "integrity": "sha512-gbOBfKVDe77MaG06bfOhDHvSMSCn14P9kcdv1mDXHdAqjfiM0jY8lBDv+RoOugynqzS8tzzXfElFod7VWU+NmQ==","dependencies": {"tslib": "^2.3.0"}diff --git a/package.json b/package.jsonindex e6dfcfd..3e98585 100644--- a/package.json+++ b/package.json@@ -10,12 +10,12 @@"private": true,"dependencies": {"@floating-ui/react": "^0.26.24",- "@plait/common": "^0.75.0",- "@plait/core": "^0.75.0",- "@plait/draw": "^0.75.0",- "@plait/layouts": "^0.75.0",- "@plait/mind": "^0.75.0",- "@plait/text-plugins": "^0.75.0",+ "@plait/common": "^0.76.0",+ "@plait/core": "^0.76.0",+ "@plait/draw": "^0.76.0",+ "@plait/layouts": "^0.76.0",+ "@plait/mind": "^0.76.0",+ "@plait/text-plugins": "^0.76.0","ahooks": "^3.8.0","browser-fs-access": "^0.35.0","classnames": "^2.5.1",diff --git a/packages/drawnix/src/plugins/freehand/freehand.component.ts b/packages/drawnix/src/plugins/freehand/freehand.component.tsindex b26f6eb..867d641 100644--- a/packages/drawnix/src/plugins/freehand/freehand.component.ts+++ b/packages/drawnix/src/plugins/freehand/freehand.component.ts@@ -6,7 +6,12 @@ import {isSelectionMoving,ACTIVE_STROKE_WIDTH,} from '@plait/core';-import { ActiveGenerator, CommonElementFlavour, hasResizeHandle } from '@plait/common';+import {+ ActiveGenerator,+ CommonElementFlavour,+ createActiveGenerator,+ hasResizeHandle,+} from '@plait/common';import { Freehand } from './type';import { FreehandGenerator } from './freehand.generator';@@ -23,7 +28,7 @@ export class FreehandComponentgenerator!: FreehandGenerator;initializeGenerator() {- this.activeGenerator = new ActiveGenerator<Freehand>(this.board, {+ this.activeGenerator = createActiveGenerator(this.board, {getRectangle: (element: Freehand) => {return RectangleClient.getRectangleByPoints(element.points);},@@ -50,17 +55,17 @@ export class FreehandComponentthis.generator.processDrawing(this.element, this.getElementG());this.activeGenerator.processDrawing(this.element,- PlaitBoard.getElementActiveHost(this.board),+ PlaitBoard.getActiveHost(this.board),{selected: this.selected,});} else {const needUpdate = value.selected !== previous.selected;- if (needUpdate) {+ if (needUpdate || value.selected) {this.activeGenerator.processDrawing(this.element,- PlaitBoard.getElementActiveHost(this.board),+ PlaitBoard.getActiveHost(this.board),{selected: this.selected,}diff --git a/packages/drawnix/src/plugins/freehand/with-freehand-create.ts b/packages/drawnix/src/plugins/freehand/with-freehand-create.tsindex fbfd461..545cc5c 100644--- a/packages/drawnix/src/plugins/freehand/with-freehand-create.ts+++ b/packages/drawnix/src/plugins/freehand/with-freehand-create.ts@@ -94,7 +94,7 @@ export const withFreehandCreate = (board: PlaitBoard) => {temporaryElement = createFreehandElement(pointer, points);generator.processDrawing(temporaryElement,- PlaitBoard.getElementActiveHost(board)+ PlaitBoard.getElementTopHost(board));}return;diff --git a/packages/react-board/src/board.tsx b/packages/react-board/src/board.tsxindex 798d620..5fb8948 100644--- a/packages/react-board/src/board.tsx+++ b/packages/react-board/src/board.tsx@@ -44,7 +44,8 @@ export const Board: React.FC<PlaitBoardProps> = ({const elementLowerHostRef = useRef<SVGGElement>(null);const elementHostRef = useRef<SVGGElement>(null);const elementUpperHostRef = useRef<SVGGElement>(null);- const elementActiveHostRef = useRef<SVGGElement>(null);+ const elementTopHostRef = useRef<SVGGElement>(null);+ const activeHostRef = useRef<SVGGElement>(null);const viewportContainerRef = useRef<HTMLDivElement>(null);const boardContainerRef = useRef<HTMLDivElement>(null);@@ -62,7 +63,8 @@ export const Board: React.FC<PlaitBoardProps> = ({lowerHost: elementLowerHostRef.current!,host: elementHostRef.current!,upperHost: elementUpperHostRef.current!,- activeHost: elementActiveHostRef.current!,+ topHost: elementTopHostRef.current!,+ activeHost: activeHostRef.current!,container: boardContainerRef.current!,viewportContainer: viewportContainerRef.current!,});@@ -134,7 +136,10 @@ export const Board: React.FC<PlaitBoardProps> = ({<g className="element-lower-host" ref={elementLowerHostRef}></g><g className="element-host" ref={elementHostRef}></g><g className="element-upper-host" ref={elementUpperHostRef}></g>- <g className="element-active-host" ref={elementActiveHostRef}></g>+ <g className="element-top-host" ref={elementTopHostRef}></g>+ </svg>+ <svg width="100%" height="100%" className="board-active-svg">+ <g className="active-host-g" ref={activeHostRef}></g></svg>{children}</div>diff --git a/packages/react-board/src/styles/index.scss b/packages/react-board/src/styles/index.scssindex c6ae7cf..0281802 100644--- a/packages/react-board/src/styles/index.scss+++ b/packages/react-board/src/styles/index.scss@@ -95,5 +95,12 @@user-select: none;}+ .board-active-svg {+ position: absolute;+ left: 0;+ top: 0;+ pointer-events: none;+ }+@include mixins.board-background-color();}diff --git a/packages/react-board/src/wrapper.tsx b/packages/react-board/src/wrapper.tsxindex 9b8e54f..a21e6d9 100644--- a/packages/react-board/src/wrapper.tsx+++ b/packages/react-board/src/wrapper.tsx@@ -12,7 +12,6 @@ import {withOptions,withRelatedFragment,withSelection,- withViewport,PlaitBoard,type PlaitPlugin,type PlaitBoardOptions,@@ -21,11 +20,16 @@ import {BOARD_TO_AFTER_CHANGE,PlaitOperation,PlaitTheme,+ isFromScrolling,+ setIsFromScrolling,+ getSelectedElements,+ updateViewportOffset,+ initializeViewBox,} from '@plait/core';import { BoardChangeData } from './plugins/board';import { useCallback, useEffect, useState } from 'react';import { withReact } from './plugins/with-react';-import { withImage, withText } from '@plait/common';+import { PlaitCommonElementRef, withImage, withText } from '@plait/common';import { BoardContext, BoardContextValue } from './hooks/use-board';import React from 'react';import { withPinchZoom } from './plugins/with-pinch-zoom-plugin';@@ -90,12 +94,14 @@ export const Wrapper: React.FC<WrapperProps> = ({const hasThemeChanged = board.operations.some((o) =>PlaitOperation.isSetThemeOperation(o));- const hasChildrenChanged = board.operations.length > 0 && !board.operations.every(- (o) =>- PlaitOperation.isSetSelectionOperation(o) ||- PlaitOperation.isSetViewportOperation(o) ||- PlaitOperation.isSetThemeOperation(o)- );+ const hasChildrenChanged =+ board.operations.length > 0 &&+ !board.operations.every(+ (o) =>+ PlaitOperation.isSetSelectionOperation(o) ||+ PlaitOperation.isSetViewportOperation(o) ||+ PlaitOperation.isSetThemeOperation(o)+ );if (onValueChange && hasChildrenChanged) {onValueChange(board.children);@@ -122,11 +128,42 @@ export const Wrapper: React.FC<WrapperProps> = ({useEffect(() => {BOARD_TO_ON_CHANGE.set(board, () => {+ const isOnlySetSelection =+ board.operations.length &&+ board.operations.every((op) => op.type === 'set_selection');+ if (isOnlySetSelection) {+ listRender.update(board.children, {+ board: board,+ parent: board,+ parentG: PlaitBoard.getElementHost(board),+ });+ return;+ }+ const isSetViewport =+ board.operations.length &&+ board.operations.some((op) => op.type === 'set_viewport');+ if (isSetViewport && isFromScrolling(board)) {+ setIsFromScrolling(board, false);+ listRender.update(board.children, {+ board: board,+ parent: board,+ parentG: PlaitBoard.getElementHost(board),+ });+ return;+ }listRender.update(board.children, {board: board,parent: board,parentG: PlaitBoard.getElementHost(board),});+ initializeViewBox(board);+ updateViewportOffset(board);+ const selectedElements = getSelectedElements(board);+ selectedElements.forEach((element) => {+ const elementRef =+ PlaitElement.getElementRef<PlaitCommonElementRef>(element);+ elementRef.updateActiveSection();+ });});BOARD_TO_AFTER_CHANGE.set(board, () => {@@ -158,10 +195,8 @@ const initializeBoard = (withSelection(withMoving(withBoard(- withViewport(- withOptions(- withReact(withImage(withText(createBoard(value, options))))- )+ withOptions(+ withReact(withImage(withText(createBoard(value, options)))))))