Skip to content

Commit 980797c

Browse files
committed
chore: update readme
1 parent 9c1f7d7 commit 980797c

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ on this repository! Include information about how to reproduce the bug, what
4343
the bad behaviour was, and what you expected it to do. The Blockly team will
4444
triage the bug and add it to the roadmap.
4545

46-
## Testing in your app
46+
## Using in your app
4747

4848
### Installation
4949

@@ -67,7 +67,7 @@ npm install @blockly/keyboard-navigation --save
6767

6868
```js
6969
import * as Blockly from 'blockly';
70-
import {KeyboardNavigation} from '@blockly/keyboard-experiment';
70+
import {KeyboardNavigation} from '@blockly/keyboard-navigation';
7171
// Inject Blockly.
7272
const workspace = Blockly.inject('blocklyDiv', {
7373
toolbox: toolboxCategories,
@@ -76,6 +76,41 @@ const workspace = Blockly.inject('blocklyDiv', {
7676
const keyboardNav = new KeyboardNavigation(workspace);
7777
```
7878

79+
### Usage with cross-tab-copy-paste plugin
80+
81+
This plugin adds context menu items for copying & pasting. It also adds feedback to copying & pasting as toasts that are shown to the user upon successful copy or cut. It is compatible with the `@blockly/plugin-cross-tab-copy-paste` by following these steps:
82+
83+
```js
84+
import * as Blockly from 'blockly';
85+
import {KeyboardNavigation} from '@blockly/keyboard-navigation';
86+
import {CrossTabCopyPaste} from '@blockly/plugin-cross-tab-copy-paste';
87+
88+
// Inject Blockly.
89+
const workspace = Blockly.inject('blocklyDiv', {
90+
toolbox: toolboxCategories,
91+
});
92+
93+
// Initialize cross-tab-copy-paste
94+
// Must be done before keyboard-navigation
95+
const crossTabOptions = {
96+
// Don't use the context menu options from the ctcp plugin,
97+
// because the keyboard-navigation plugin provides its own.
98+
contextMenu: false,
99+
shortcut: true,
100+
};
101+
const plugin = new CrossTabCopyPaste();
102+
plugin.init(crossTabOptions, () => {
103+
console.log('Use this error callback to handle TypeError while pasting');
104+
});
105+
106+
// Initialize keyboard-navigation.
107+
// You must pass the `allowCrossWorkspacePaste` option in order for paste
108+
// to appear correctly enabled/disabled in the context menu.
109+
const keyboardNav = new KeyboardNavigation(workspace, {
110+
allowCrossWorkspacePaste: true,
111+
});
112+
```
113+
79114
## Contributing
80115

81116
To learn more about contributing to this project, see the [contributing page](https://github.com/google/blockly-keyboard-experimentation/blob/main/CONTRIBUTING.md).

0 commit comments

Comments
 (0)