mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Switch to getter for keyboard contents.
This commit is contained in:
@@ -93,25 +93,12 @@ Blockly.selected = null;
|
||||
Blockly.draggingConnections = [];
|
||||
|
||||
/**
|
||||
* Contents of the local clipboard.
|
||||
* @type {Element}
|
||||
* @private
|
||||
* Get the current contents of the clipboard and associated metadata.
|
||||
* @return {{xml: Element, source: WorkspaceSvg, typeCounts: Object}} An object
|
||||
* containing the clipboard contents and associated metadata.
|
||||
* @public
|
||||
*/
|
||||
Blockly.clipboardXml_ = Blockly.clipboard.xml;
|
||||
|
||||
/**
|
||||
* Source of the local clipboard.
|
||||
* @type {Blockly.WorkspaceSvg}
|
||||
* @private
|
||||
*/
|
||||
Blockly.clipboardSource_ = Blockly.clipboard.source;
|
||||
|
||||
/**
|
||||
* Map of types to type counts for the clipboard object and descendants.
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
Blockly.clipboardTypeCounts_ = Blockly.clipboard.typeCounts;
|
||||
Blockly.getClipboardInfo = Blockly.common.getClipboardInfo;
|
||||
|
||||
/**
|
||||
* Cached value for whether 3D is supported.
|
||||
@@ -137,9 +124,7 @@ Blockly.svgSize = function(svg) {
|
||||
// When removing this function, remove svg.cachedWidth_ and svg.cachedHeight_
|
||||
// from setCachedParentSvgSize.
|
||||
Blockly.utils.deprecation.warn(
|
||||
'Blockly.svgSize',
|
||||
'March 2021',
|
||||
'March 2022',
|
||||
'Blockly.svgSize', 'March 2021', 'March 2022',
|
||||
'workspace.getCachedParentSvgSize');
|
||||
svg = /** @type {?} */ (svg);
|
||||
return new Blockly.utils.Size(svg.cachedWidth_, svg.cachedHeight_);
|
||||
@@ -221,7 +206,8 @@ Blockly.deleteBlock = function(selected) {
|
||||
Blockly.Events.setGroup(true);
|
||||
Blockly.hideChaff();
|
||||
if (selected.outputConnection) {
|
||||
// Do not attempt to heal rows (https://github.com/google/blockly/issues/4832)
|
||||
// Do not attempt to heal rows
|
||||
// (https://github.com/google/blockly/issues/4832)
|
||||
selected.dispose(false, true);
|
||||
} else {
|
||||
selected.dispose(/* heal */ true, true);
|
||||
@@ -366,9 +352,7 @@ Blockly.defineBlocksWithJsonArray = function(jsonArray) {
|
||||
'Block definition #' + i + ' in JSON array' +
|
||||
' overwrites prior definition of "' + typename + '".');
|
||||
}
|
||||
Blockly.Blocks[typename] = {
|
||||
init: Blockly.jsonInitFactory_(elem)
|
||||
};
|
||||
Blockly.Blocks[typename] = {init: Blockly.jsonInitFactory_(elem)};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
|
||||
* @private
|
||||
*/
|
||||
let xml = null;
|
||||
exports.xml = xml;
|
||||
|
||||
/**
|
||||
* Source of the local clipboard.
|
||||
@@ -34,7 +33,6 @@ exports.xml = xml;
|
||||
* @private
|
||||
*/
|
||||
let source = null;
|
||||
exports.source = source;
|
||||
|
||||
/**
|
||||
* Map of types to type counts for the clipboard object and descendants.
|
||||
@@ -42,12 +40,20 @@ exports.source = source;
|
||||
* @private
|
||||
*/
|
||||
let typeCounts = null;
|
||||
exports.typeCounts = typeCounts;
|
||||
|
||||
/**
|
||||
* Get the current contents of the clipboard and associated metadata.
|
||||
* @return {{xml: Element, source: WorkspaceSvg, typeCounts: Object}} An object
|
||||
* containing the clipboard contents and associated metadata.
|
||||
*/
|
||||
const getClipboardInfo = function() {
|
||||
return {xml: xml, source: source, typeCounts: typeCounts};
|
||||
};
|
||||
exports.getClipboardInfo = getClipboardInfo;
|
||||
|
||||
/**
|
||||
* Copy a block or workspace comment onto the local clipboard.
|
||||
* @param {!ICopyable} toCopy Block or Workspace Comment to be copied.
|
||||
* @package
|
||||
*/
|
||||
const copy = function(toCopy) {
|
||||
var data = toCopy.toCopyData();
|
||||
@@ -57,12 +63,12 @@ const copy = function(toCopy) {
|
||||
typeCounts = data.typeCounts;
|
||||
}
|
||||
};
|
||||
/** @package */
|
||||
exports.copy = copy;
|
||||
|
||||
/**
|
||||
* Paste a block or workspace comment on to the main workspace.
|
||||
* @return {boolean} True if the paste was successful, false otherwise.
|
||||
* @package
|
||||
*/
|
||||
const paste = function() {
|
||||
if (!xml) {
|
||||
@@ -82,13 +88,13 @@ const paste = function() {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/** @package */
|
||||
exports.paste = paste;
|
||||
|
||||
/**
|
||||
* Duplicate this block and its children, or a workspace comment.
|
||||
* @param {!ICopyable} toDuplicate Block or Workspace Comment to be
|
||||
* copied.
|
||||
* @package
|
||||
* duplicated.
|
||||
*/
|
||||
const duplicate = function(toDuplicate) {
|
||||
// Save the clipboard.
|
||||
@@ -103,4 +109,5 @@ const duplicate = function(toDuplicate) {
|
||||
xml = oldXml;
|
||||
source = oldSource;
|
||||
};
|
||||
/** @package */
|
||||
exports.duplicate = duplicate;
|
||||
|
||||
Reference in New Issue
Block a user