Skip to content

Conversation

@rachel-fenichel
Copy link
Collaborator

  • Moves clipboard functions copy, paste, and duplicate out of blockly.js.
  • Moves clipboard state clipboardXml_, clipboardTypeCounts_, and clipboardSource_ out of blockly.js
  • Aliases old functions and properties to refer to new ones.
  • Updates tests that spy on specific functions.
  • Updates callers inside core.

This 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 clipboardInfo that returns an object containing all three of those properties, but as copies (and effectively read-only).

I also propose that we remove clipboardXml_, clipboardTypeCounts_, and clipboardSource_ from blockly.js entirely and not export those three from clipboard.

@rachel-fenichel rachel-fenichel requested a review from a team as a code owner July 28, 2021 19:02
@rachel-fenichel rachel-fenichel requested review from alschmiedt and maribethb and removed request for maribethb July 28, 2021 19:02
@github-actions github-actions bot added this to the 2021_q3_release milestone Jul 28, 2021
Copy link
Contributor

@alschmiedt alschmiedt left a 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;
Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rachel-fenichel rachel-fenichel added the breaking change Used to mark a PR or issue that changes our public APIs. label Jul 29, 2021
@github-actions github-actions bot removed the breaking change Used to mark a PR or issue that changes our public APIs. label Jul 29, 2021
@rachel-fenichel
Copy link
Collaborator Author

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)};
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format did this.

@rachel-fenichel rachel-fenichel added the breaking change Used to mark a PR or issue that changes our public APIs. label Jul 29, 2021
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}}
Copy link
Contributor

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.

Copy link
Collaborator Author

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
Copy link
Contributor

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.

Copy link
Collaborator Author

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;
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@BeksOmega
Copy link
Contributor

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.

@github-actions github-actions bot removed the breaking change Used to mark a PR or issue that changes our public APIs. label Jul 30, 2021
@rachel-fenichel
Copy link
Collaborator Author

@alschmiedt I made some significant changes, so please take another look.

Changes:

  • Switched to storing data as an ICopyable.CopyData instead of storing each component individually.
  • Got rid of the exported function getClipboardInfo and also removed it from blockly.js--it's not clear that it's the right API, and we have an issue tracking that.

@rachel-fenichel rachel-fenichel merged commit 73582c9 into RaspberryPiFoundation:goog_module Jul 30, 2021
@rachel-fenichel rachel-fenichel deleted the clipboard branch July 30, 2021 18:10
@rachel-fenichel rachel-fenichel mentioned this pull request Jul 30, 2021
33 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants