Class: CrossTabCopyPaste
Defined in: index.ts:93
A Blockly plugin that adds context menu items and keyboard shortcuts to allow users to copy and paste copyable objects between tabs.
Properties index
| Property | Description |
|---|---|
| localStorageKey | Key in which store copy data in the browser's local storage. |
Methods index
| Method | Description |
|---|---|
| blockCopyToStorageContextMenu | Adds a copy command to the context menu for copyable items. |
| blockCopyToStorageShortcut | Adds a keyboard shortcut that will store copy information for a copyable in localStorage. |
| blockCutToStorageShortcut | Adds a keyboard shortcut that will store copy information for copyable items in local storage and delete the item. |
| blockPasteFromStorageContextMenu | Adds a paste command to the context menu for copyable items. |
| blockPasteFromStorageShortcut | Adds a keyboard shortcut that will paste the copyable stored in localStorage. |
| copyCallback | Copy callback called by both keyboard shortcut and context menu item. Copies the copy data to local storage. |
| copyPrecondition | Copy precondition called by both keyboard shortcut and context menu item. Allows copying out of the flyout, as long as they could be pasted into the main workspace. |
| getContextMenuText | v12.0.0 of Blockly included the keyboard shortcut in Msg string, but it was removed in v12.2.0. This function can be removed when this plugin's minimum version of Blockly is >=12.2.0. |
| getCopyData | Parses copy data from JSON in local storage, if it exists. |
| init | Initializes the cross tab copy paste plugin. If no options are selected then both context menu items and keyboard shortcuts are added. |
| pastePrecondition | Paste precondition called by both keyboard shortcut and context menu item. |
Constructors
Constructor
new CrossTabCopyPaste(): CrossTabCopyPaste;
Returns
CrossTabCopyPaste
Properties
localStorageKey
localStorageKey: string = 'blocklyStash';
Defined in: index.ts:95
Key in which store copy data in the browser's local storage.
Methods
blockCopyToStorageContextMenu()
blockCopyToStorageContextMenu(): void;
Defined in: index.ts:265
Adds a copy command to the context menu for copyable items.
Returns
void
blockCopyToStorageShortcut()
blockCopyToStorageShortcut(): void;
Defined in: index.ts:344
Adds a keyboard shortcut that will store copy information for a copyable in localStorage.
Returns
void
blockCutToStorageShortcut()
blockCutToStorageShortcut(): void;
Defined in: index.ts:375
Adds a keyboard shortcut that will store copy information for copyable items in local storage and delete the item.
Returns
void
blockPasteFromStorageContextMenu()
blockPasteFromStorageContextMenu(typeErrorCallback?): void;
Defined in: index.ts:295
Adds a paste command to the context menu for copyable items.
Parameters
| Parameter | Type | Description |
|---|---|---|
typeErrorCallback? | TypeErrorCallback | callback function to handle type errors |
Returns
void
blockPasteFromStorageShortcut()
blockPasteFromStorageShortcut(typeErrorCallback?): void;
Defined in: index.ts:435
Adds a keyboard shortcut that will paste the copyable stored in localStorage.
Parameters
| Parameter | Type | Description |
|---|---|---|
typeErrorCallback? | TypeErrorCallback | callback function to handle type errors |
Returns
void
copyCallback()
copyCallback(scope, workspace): boolean;
Defined in: index.ts:195
Copy callback called by both keyboard shortcut and context menu item. Copies the copy data to local storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | Scope | scope for copy action. |
workspace | Workspace | workspace where shortcut or context menu was activated. |
Returns
boolean
true if copy happened, false otherwise.
copyPrecondition()
copyPrecondition(scope, workspace?): ContextMenuState;
Defined in: index.ts:162
Copy precondition called by both keyboard shortcut and context menu item. Allows copying out of the flyout, as long as they could be pasted into the main workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | Scope | scope for copy action. |
workspace? | Workspace | explicit workspace for keyboard shortcuts, undefined to get the workspace from the focused node. |
Returns
ContextMenuState
whether the option should be shown/hidden/disabled.
getContextMenuText()
getContextMenuText(labelText): string;
Defined in: index.ts:253
v12.0.0 of Blockly included the keyboard shortcut in Msg string, but it was removed in v12.2.0. This function can be removed when this plugin's minimum version of Blockly is >=12.2.0.
Parameters
| Parameter | Type | Description |
|---|---|---|
labelText | string | Blockly.Msg for the shortcut |
Returns
string
trimmed label for the context menu item.
getCopyData()
getCopyData(): ICopyData | undefined;
Defined in: index.ts:146
Parses copy data from JSON in local storage, if it exists.
Returns
ICopyData | undefined
copy data parsed from local storage, or undefined
init()
init(
options?,
typeErrorCallback?,
localStorageKey?
): void;
Defined in: index.ts:108
Initializes the cross tab copy paste plugin. If no options are selected then both context menu items and keyboard shortcuts are added.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | { contextMenu?: true; shortcut?: true; } | - |
options.contextMenu? | true | Register copy and paste in the context menu. |
options.shortcut? | true | Register cut (ctr + x), copy (ctr + c) and paste (ctr + v) in the shortcut. |
typeErrorCallback? | TypeErrorCallback | callback function to handle type errors |
localStorageKey? | string | custom key for local storage |
Returns
void
pastePrecondition()
pastePrecondition(workspace): ContextMenuState;
Defined in: index.ts:225
Paste precondition called by both keyboard shortcut and context menu item.
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | workspace to paste in. should not be a flyout workspace. |
Returns
ContextMenuState
true if paste happened, false otherwise.