-
Notifications
You must be signed in to change notification settings - Fork 199
refactor: remove clipboard fallback for old browsers #645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: remove clipboard fallback for old browsers #645
Conversation
Browsers supported by maxGraph support the asynchronous clipboard API.
In addition, the fallback function used the obsolete `document.execCommand('copy')` function.
Also improve the clipboard JSDoc and used the standard clipboard import in the editor (a mx prefix was left over from
mxGraph).
WalkthroughThe pull request introduces modifications to clipboard-related functionality across multiple files in the project. The changes primarily focus on updating the Changes
Sequence DiagramsequenceDiagram
participant Editor
participant Clipboard
participant Graph
Editor->>Clipboard: copy(graph)
Clipboard-->>Graph: canExportCell check
Clipboard->>Clipboard: setCells(copied cells)
Editor->>Clipboard: paste(graph)
Clipboard-->>Graph: canImportCell check
Clipboard->>Graph: insert copied cells
The sequence diagram illustrates the high-level interaction between the Editor, Clipboard, and Graph components during copy and paste operations, highlighting the key steps in the clipboard functionality. ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/src/util/Clipboard.ts (1)
100-100: Type annotations improve code safety and clarity.The addition of explicit return types to method signatures enhances type safety and makes the API contract clearer. Consider adding JSDoc
@returnstags to complement the TypeScript return types for better documentation.Example improvement for the
setCellsmethod:/** * Sets the cells in the clipboard. Fires a {@link InternalEvent.CHANGE} event. + * @returns void */ static setCells(cells: Cell[]): void {Also applies to: 107-107, 114-114, 126-126, 140-140, 152-152, 167-167
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/core/src/editor/Editor.ts(2 hunks)packages/core/src/util/Clipboard.ts(5 hunks)packages/core/src/util/Utils.ts(0 hunks)
💤 Files with no reviewable changes (1)
- packages/core/src/util/Utils.ts
🔇 Additional comments (4)
packages/core/src/editor/Editor.ts (1)
985-997: LGTM! Clean refactor of clipboard usage.The changes correctly update the clipboard method calls to use the modernized Clipboard class directly, aligning with the PR's objective of removing legacy clipboard handling.
packages/core/src/util/Clipboard.ts (3)
28-34: Documentation improvements look good.The updated documentation provides clearer examples and references to Graph methods using the correct notation (e.g.,
Graph.canExportCellinstead ofgraph.canExportCell).Also applies to: 36-38
Line range hint
39-76: Example code is well-structured and documented.The example code demonstrates proper usage of the Clipboard class with TypeScript types and includes helpful comments explaining the workflow.
Line range hint
1-1: Verify removal of old browser fallback code.The PR objective mentions removing clipboard fallback for old browsers, but the changes shown focus on type annotations and documentation. Let's verify the actual removal of fallback code.
Browsers supported by maxGraph support the asynchronous clipboard API.
In addition, the fallback function used the obsolete
document.execCommand('copy')function.Also improve the clipboard JSDoc and used the standard clipboard import in the editor (a mx prefix was left over from mxGraph).
Notes
No impact on the ts-example (with or without defaults) as the clipboard is not used in the 2 examples.
https://caniuse.com/async-clipboard
Summary by CodeRabbit
Release Notes
Refactor
Bug Fixes
The changes focus on enhancing the clipboard and utility functions with more robust type checking and cleaner implementation.