-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support duplicate elements #WIK-15134 (#828)
- Loading branch information
1 parent
43e1220
commit 2b08378
Showing
19 changed files
with
157 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'@plait/common': minor | ||
'@plait/core': minor | ||
'@plait/draw': minor | ||
'@plait/mind': minor | ||
--- | ||
|
||
rename setFragment to buildFragment | ||
|
||
remove DataTransfer param of setFragment and insertFragment | ||
|
||
support duplicate elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
import { PlaitBoard } from "../interfaces"; | ||
import { PlaitBoard, PlaitElement } from '../interfaces'; | ||
import { setClipboardData } from './clipboard/clipboard'; | ||
import { getRectangleByElements } from './element'; | ||
import { getSelectedElements } from './selected-element'; | ||
|
||
export const deleteFragment = (board: PlaitBoard) => { | ||
const elements = board.getDeletedFragment([]); | ||
board.deleteFragment(elements); | ||
} | ||
}; | ||
|
||
export const setFragment = (board: PlaitBoard, type: 'copy' | 'cut', clipboardData: DataTransfer | null) => { | ||
const selectedElements = getSelectedElements(board); | ||
const rectangle = getRectangleByElements(board, selectedElements, false); | ||
const clipboardContext = board.buildFragment(null, rectangle, type); | ||
clipboardContext && setClipboardData(clipboardData, clipboardContext); | ||
}; | ||
|
||
|
||
export const duplicateElements = (board: PlaitBoard, elements?: PlaitElement[]) => { | ||
const selectedElements = elements || getSelectedElements(board); | ||
const rectangle = getRectangleByElements(board, selectedElements, false); | ||
const clipboardContext = board.buildFragment(null, rectangle, 'copy'); | ||
clipboardContext && | ||
board.insertFragment( | ||
{ | ||
...clipboardContext, | ||
text: undefined | ||
}, | ||
[rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2] | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.