-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Move clipboard functions to a separate namespace #5237
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
Move clipboard functions to a separate namespace #5237
Conversation
alschmiedt
left a comment
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.
I agree with everything proposed in the PR description. We just also need to make an issue to update keyboard nav to use the new API before releasing.
| typeCounts = data.typeCounts; | ||
| } | ||
| }; | ||
| exports.copy = copy; |
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.
I think @Package is suppose to go above this line now.
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.
Done.
|
Tracking -samples update in RaspberryPiFoundation/blockly-samples#833 This PR also closes #4600 |
| Blockly.Blocks[typename] = { | ||
| init: Blockly.jsonInitFactory_(elem) | ||
| }; | ||
| Blockly.Blocks[typename] = {init: Blockly.jsonInitFactory_(elem)}; |
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.
Clang-format did this.
| Blockly.hideChaff(); | ||
| if (selected.outputConnection) { | ||
| // Do not attempt to heal rows (https://github.com/google/blockly/issues/4832) | ||
| // Do not attempt to heal rows |
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.
clang-format did this.
| 'Blockly.svgSize', | ||
| 'March 2021', | ||
| 'March 2022', | ||
| 'Blockly.svgSize', 'March 2021', 'March 2022', |
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.
clang-format did this.
core/blockly.js
Outdated
| * @type {Blockly.WorkspaceSvg} | ||
| * @private | ||
| * Get the current contents of the clipboard and associated metadata. | ||
| * @return {{xml: ?Element, source: ?Blockly.WorkspaceSvg, typeCounts: ?Object}} |
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.
If we could provide a better type for typeCounts now that this is public I think that would be really helpful.
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.
I switched all of this to ICopyable.CopyData, which is an existing type.
core/blockly.js
Outdated
| * Get the current contents of the clipboard and associated metadata. | ||
| * @return {{xml: ?Element, source: ?Blockly.WorkspaceSvg, typeCounts: ?Object}} | ||
| * An object containing the clipboard contents and associated metadata. | ||
| * @public |
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.
I think we aren't adding @public.
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.
Deleted function.
core/blockly.js
Outdated
| * @private | ||
| */ | ||
| Blockly.clipboardTypeCounts_ = null; | ||
| Blockly.getClipboardInfo = Blockly.clipboard.getClipboardInfo; |
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.
Do we need to add this here since it is a new API?
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.
I removed this for now. However, we will have to revisit when we remove declareLegacyNamespace in clipboard.js. Since the clipboard didn't exist at all before this quarter, and I prefer to keep it internal, I may end up adding this single function at the top level.
|
Just tagging this as something I was planning on switching over to the JSO system. But since this is such a big change it may be better to wait. |
|
@alschmiedt I made some significant changes, so please take another look. Changes:
|
copy,paste, andduplicateout ofblockly.js.clipboardXml_,clipboardTypeCounts_, andclipboardSource_out ofblockly.jsThis is part of #5208
There's an API question here: should clipboard xml, type counts, and source be exported? The keyboard nav plugin accesses them directly, but with a note that it needs a better way to do that.
I propose that there should instead be a getter for
clipboardInfothat returns an object containing all three of those properties, but as copies (and effectively read-only).I also propose that we remove
clipboardXml_,clipboardTypeCounts_, andclipboardSource_fromblockly.jsentirely and not export those three fromclipboard.