Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
Signed-off-by: CTomlyn <[email protected]>
  • Loading branch information
tomlyn committed Nov 28, 2024
1 parent bceb37b commit 8a4dd8c
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 62 deletions.
29 changes: 13 additions & 16 deletions canvas_modules/common-canvas/src/common-canvas/keyboard-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,13 @@ export default class KeyboardUtils {
return !this.isMetaKey(d3Event) && d3Event.shiftKey && d3Event.code === DOWN_ARROW_KEY;
}

/* ----------------------------------------- */
/* Links */
/* ----------------------------------------- */
/* Link creation */

static createLink(d3Event) {
return this.isMetaKey(d3Event) && d3Event.shiftKey && d3Event.code === PERIOD_KEY;
}

/* ----------------------------------------- */
/* Comment Text Display */
/* ----------------------------------------- */
/* Comment display */

static scrollTextUp(d3Event) {
return !this.isMetaKey(d3Event) && !d3Event.shiftKey && d3Event.altKey && d3Event.code === DOWN_ARROW_KEY;
Expand All @@ -222,14 +218,6 @@ export default class KeyboardUtils {
return !this.isMetaKey(d3Event) && !d3Event.shiftKey && d3Event.altKey && d3Event.code === UP_ARROW_KEY;
}

/* ----------------------------------------- */
/* Text Toolbar */
/* ----------------------------------------- */

static returnToTextEditing(evt) {
return evt.code === TAB_KEY && !evt.shiftKey;
}

/* ----------------------------------------- */
/* Comment Text Entry */
/* ----------------------------------------- */
Expand All @@ -238,12 +226,22 @@ export default class KeyboardUtils {
return d3Event.code === ESC_KEY;
}

static completeTextEntry(d3Event) {
return d3Event.shiftKey && d3Event.code === RETURN_KEY;
}

static returnToTextEditing(evt) {
return !evt.shiftKey && evt.code === TAB_KEY;
}

// During text entry this might either complete the text entry OR
// add a new line.
static returnCommand(d3Event) {
return d3Event.code === RETURN_KEY;
}

/* Markdown text entry shortcuts */

static boldCommand(d3Event) {
return this.isMetaKey(d3Event) && d3Event.code === B_KEY;
}
Expand Down Expand Up @@ -281,7 +279,7 @@ export default class KeyboardUtils {
}

static decHashesCommand(d3Event) {
return this.isMetaKey(d3Event) && d3Event.code === LAB_KEY;
return this.isMetaKey(d3Event) && !d3Event.shiftKey && d3Event.code === LAB_KEY;
}

/* ----------------------------------------- */
Expand Down Expand Up @@ -320,7 +318,6 @@ export default class KeyboardUtils {
return evt.code === UP_ARROW_KEY;
}


/* ----------------------------------------- */
/* Color Picker */
/* ----------------------------------------- */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ export default class SvgCanvasTextArea {
.on("keydown", (d3Event) => {
// If user hits return/enter
if (KeyboardUtils.returnCommand(d3Event)) {
if (data.allowReturnKey === "save" || d3Event.shiftKey) {
if (data.allowReturnKey === "save" || KeyboardUtils.completeTextEntry(d3Event)) {
this.textContentSaved = true;
this.saveAndCloseTextArea(data, d3Event.target, d3Event);
return;
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/03.02-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _Allows customization of the toolbar including the addition of application speci
_Allows customization of the notification panel which is displayed by clicking the notification icon on the toolbar._

### [Context Menu Config](03.02.04-context-menu-config.md)
_Allows some minor customization of the what options the context menus/toolbars display._
_Allows some minor customization of the options the context menus/toolbars display._

### [Keyboard Config](03.02.05-keyboard-config.md)
_Allows customization of the shortcut keys supported by the flow editor._
5 changes: 4 additions & 1 deletion docs/pages/03.02.01-canvas-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ This can be either "None", "Locked" or "ReadOnly". The default is "None". When s

## Canvas Operation

#### **enableKeyboardNavigation**
This can be either true or false. The default is false. If set to true, the user can use the keyboard to move the keyboard focus around the Common Canvas interface and perform actions on the flow objects using [shortcut keys](03.05-keyboard-support.md).

#### **enableInteractionType**
This can be "Mouse", "Carbon" or "Trackpad". The default is "Mouse".
***"Trackpad" has been deprecated and will be removed in the future.***
Expand Down Expand Up @@ -362,7 +365,7 @@ This is a boolean. The default is `true`. It is recommended you leave this set t
This is a boolean. The default is false. If set to true the right flyout panel, when opened, will appear below the toolbar and will not cause the toolbar to compress. The default behavior is that the right flyout panel, when opened, will appear at the side of the toolbar and will compress the space available for the toolbar to be displayed. Warning: the notifications panel which is tied to the notifications icon in the toolbar will appear over the top of the right-side flyout with this option set to true.
#### **enableLeftFlyoutUnderToolbar**
This is a boolean. The default is false. If set to true the left flyout panel, when opened, will appear below the toolbar and will not cause the toolbar to compress. The default behavior is that the left flyout panel, when opened, will appear at the side of the toolbar and will compress the space available for the toolbar to be displayed.
This is a boolean. The default is false. If set to true the left flyout panel, when opened, will appear below the toolbar and will not cause the toolbar to compress. The default behavior is that the left flyout panel, when opened, will appear at the side of the toolbar and will compress the space available for the toolbar to be displayed.
#### **enableExternalPipelineFlows**
This is a boolean. The default is false. If true, the context menu will include a `Create External Supernode` option when a set of objects are selected from which a supernode can be created.
Expand Down
156 changes: 113 additions & 43 deletions docs/pages/03.05-keyboard-support.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,145 @@
# Keyboard support

Common Canvas supports a number of keyboard interactions as described below. Some keyboard shortcuts are only available if the config field `enableKeyboardNavigation` is set to `true`. Some others, shown with an asterisk below are always availble.
Common Canvas supports a number of keyboard interactions as described below. Some keyboard shortcuts are only available if the config field `enableKeyboardNavigation` is set to `true` as indictaed above each table.

When any of the shortcut keys are pressed, if the shortcut has an action (listed below), Common Canvas will follow the same procedure as if the action was initiated from a context menu or from the canvas toolbar or by direct manipulation on the canvas. That is, it will: call the [beforeEditActionHandler](03.03.02-before-edit-action-handler.md) and the [editActionHandler](03.03.03-edit-action-handler.md) callbacks, with the `data.editType` parameter set to the action name and the `data.editSource` parameter set to "keyboard"; it will then update the object model with the change and refresh the flow editor display.

## Flow Editoor
Note: In the tables below:
* "Meta" means either the Command key (⌘) on the Mac or, on Windows, the Windows key (⊞) or Control key (Ctrl).
* "Alt" means either the Option key (⌥) on the Mac or, on Windows, the Alternative key (Alt).

### When focus is in the flow editor background
## Flow Editor

### When focus is in the flow editor, either on the background or on a flow editor object

The shortcuts in this table are always available. The application can disable these actions by providing the [keyboard config object](03.02.05-keyboard-config.md) to the common-canvas React component.

|Keyboard Shortcut|Action|Description|
|---|---|---|
|Meta + a |selectAll| Selects alll objects|
|Meta + Shift + a |deselectAll| Deselects all objects|
|[delete key] |deleteSelectedObjects| Delete currently selected objects|
|[backspace key] |deleteSelectedObjects| Delete currently selected objects|
|Meta + x |cut| Cut selected objects to the clipboard|
|Meta + c |copy| Copy selected objects to the clipboard|
|Meta + v |paste| Paste objects from the clipboard. If the mouse cursor is over <br>the canvas, objects will be pasted at the cursor position or, <br>if not, at a default position|
|Meta + z |undo| Undo last command|
|Meta + Shift + z |redo| Redo last undone command|
|Meta + y |redo| Redo last undone command|

The shortcuts in this table are only available when the canvas config field [enableKeyboardNavigation](03.02.01-canvas-config.md#enablekeyboardnavigation) is set to `true`.

|Keyboard Shortcut|Action|Description|
|---|---|---|
|Meta + a|selectAll|Selects alll objects|
|Meta + Shift + a|deselectAll|Deselects all objects|
|delete|deleteSelectedObjects|Delete currently selected objects|
|Meta + x|cut|Cut selected objects to the clipboard|
|Meta + c|copy|Copy selected objects to the clipboard|
|Meta + v|paste|Paste objects from the clipboard. If the mouse cursor is over <br>the canvas, objects will be pasted at the cursor position or, <br>if not, at a default position|
|Meta + z|undo|Undo last command|
|Meta + Shift + z|redo|Redo last undone command|
|Meta + y|redo|Redo last undone command|
|[tab key] |-| Moves keyboard focus to the next group of objects in the flow editor|
|Shift + [tab key] |-| Moves keyboard focus to the previous group of objects in the flow editor|
|Meta + Shift + [plus key] |zoomIn| Zoom in the flow editor|
|Meta + Shift + [minus key] |zoomOut| Zoom out the flow editor|
|Meta + Shift + [zero key] |zoomToFit| Zooms to fit the flow obejcts within the flow editor viewport|
|Meta + Shift + [up arrow key] |-| Pans the flow obejcts within the flow editor viewport upwards|
|Meta + Shift + [down arrow key] |-| Pans the flow obejcts within the flow editor viewport downwards|
|Meta + Shift + [left arrow key] |-| Pans the flow obejcts within the flow editor viewport to the left|
|Meta + Shift + [right arrow key] |-| Pans the flow obejcts within the flow editor viewport to the right|
|Meta + [slash key] |-| Displays a content menu or context toolbar (depending on which is enabled) for the focused object|

Your application can disable any or all of these actions by providing the [keyboard config object](03.02.05-keyboard-config.md) to the CommonCanvas React component.
### When focus is on an object (node, comment or link) in the flow editor

When any of the shortcut keys are pressed the common-canvas object model will be updated and then the [editActionHandler](03.03-callbacks.md#editactionhandler) callback will be called with the `data.editType` parameter set to the action above and the `data.editSource` parameter set to "keyboard".
The shortcuts in this table are only available when the canvas config field [enableKeyboardNavigation](03.02.01-canvas-config.md#enablekeyboardnavigation) is set to `true`.

|Keyboard Shortcut|Action|Description|
|---|---|---|
|[right arrow key] |-| Moves focus to next object in the group|
|[left arrow key ] |-| Moves focus to previous object in the group|
|[return key] |-| Selects the focused object|
|Meta + [return key] |-| Selects the focused object and adds it to the current set of selected objects|
|Shift + [return key] |-| Selects a range of nodes through from from the currently selected object to the focused object|
|[up arrow key] |-| When the focused object is a link, moves focus to the previous sibling link|
|[down arrow key] |-| When the focused object is a link, moves focus to the next sibling link|
|Meta + [slash key] |-| Displays a content menu or context toolbar (depending on which is enabled) for the focused object|
|Meta + [up arrow key] |moveObjects| Moves the focused object, with any other selected objects, upwards|
|Meta + [down arrow key] |moveObjects| Moves the focused object, with any other selected objects, downwards|
|Meta + [left arrow key] |moveObjects| Moves the focused object, with any other selected objects, to the left|
|Meta + [right arrow key] |moveObjects| Moves the focused object, with any other selected objects, to the right|
|Shift + [up arrow key] |resizeObjects| Reduces the height of the focused comment or node (if `enableResizableNodes` is true)|
|Shift + [down arrow key] |resizeObjects| Increases the height of the focused comment or node (if `enableResizableNodes` is true)|
|Shift + [left arrow key] |resizeObjects| Reduces the width of the focused comment or node (if `enableResizableNodes` is true)|
|Shift + [right arrow key] |resizeObjects| Increases the width of the focused comment or node (if `enableResizableNodes` is true)|
|Meta + Shift + [right angle bracket key] |-| When the focused object is a node, creates a link to it from the currently selected node or comment|
|Alt + [up arrow key] |-| When the focused object is a comment and contains scrollable text, scrolls the text down|
|Alt + [down arrow key] |-| When the focused object is a comment and contains scrollable text, scrolls the text up|

### Text Entry

The shortcuts in this table are only available when the canvas config field [enableKeyboardNavigation](03.02.01-canvas-config.md#enablekeyboardnavigation) is set to `true`.

|Keyboard Shortcut|Action|Description|
|---|---|---|
|[esc key] |-| Cancels the text entry and discards any changes|
|Shift + [return key] |-| Completes the text entry and saves the changes made|
|[return key] |-| When allowReturnKey is set to "save", completes the text entry and saves the changes made. Otherwise, it enters a new line into the text|
|[tab key] |-| When focus is on the text entry area, moves focus to the text toolbar|
|[tab key] |-| When focus is on the text toolbar, moves focus to the text entry area|
|Markdown text | ||
|Meta + b |-| Insert 'bold' syntax around the selected text|
|Meta + i |-| Insert 'italics' syntax around the selected text|
|Meta + Shift + x |-| Insert 'strikethrough' syntax around the selected text|
|Meta + Shift + 7 |-| Insert 'numbered list' syntax around the selected text|
|Meta + Shift + 8 |-| Insert 'bulleted list' syntax around the selected text|
|Meta + e |-| Insert 'code' syntax around the selected text|
|Meta + k |-| Insert 'link' syntax around the selected text|
|Meta + Shift + [right angle bracket] |-| Insert 'quote' syntax around the selected text|
|Meta + [right angle bracket] |-| Increases number of hashes in front of the selected text|
|Meta + [left angle bracket] |-| Decreases number of hashes in front of the selected text|

## Toolbar

|Keyboard Shortcut|Action|Description|
|---|---|---|
|[right arrow key] |-| When focus is on a button in the toolbar, move focus to the button to the right of current focus position. When focus in on a menu item, opens any available sub-menu or sub-panel|
|[left arrow key] |-| When focus is on a button in the toolbar, move focus to the button to the left of current focus position. When focus is on a sub-menu or sub-panel, closes the area and moves focs to the parent menu. |
|[down arrow key] |-| When focus is on a button in the toolbar, opens sub-area (either a sub-menu or sub-panel) below button, if one is available. When focus is on a sub-menu, moves focus to the next menu entry. |
|[up arrow key] |-| When focus is on a sub-menu, moves focus to the previous menu entry. |
|[space bar] |-| Activate the button |
|[return key] |-| Activate the button |
|[esc key] |-| Close any open associated sub-area (either a sub-menu or sub-panel) |

## Palette

### When focus is on the Search area

|Keyboard Shortcut|Action|Description|
|---|---|---|
|Tab | | Moves focus to first category. |
|Shift + Tab | | Moves focus out of the palette. |
|[tab key] |-| Moves focus to first category. |
|Shift + [tab key] |-| Moves focus out of the palette. |

### When focus is on a category

|Keyboard Shortcut|Action|Description|
|---|---|---|
|Tab | | Moves focus to the next category. |
|Shift + Tab | | Moves focus to the previous category. |
|Down arrow | | When the category is open, moves focus to first node in the category.|
|[tab key] |-| Moves focus to the next category. |
|Shift + [tab key] |-| Moves focus to the previous category. |
|[down arrow key] |-| When the category is open, moves focus to first node in the category.|

### When focus is on node in a category

|Keyboard Shortcut|Action|Description|
|---|---|---|
|Tab | | Moves focus to the next category. |
|Shift + Tab | | Moves focus to the parent category. |
|Down arrow | | Moves the focus down to next node in the category.|
|Up arrow | | Moves focus up to previous node in the category.|
|space bar|createNodeAttachLinks | Adds the node to the canvas and links it to an available existing node on canvas. Same as double clicking the node. |
|Shift + space bar|createNodeAttachLinks (addLinks: false) | Adds the node to the canvas and does not create any links. Same as dragging a node onto the canvas. |
|Tab |-| Moves focus to the next category. |
|Shift + [tab key] |-| Moves focus to the parent category. |
|[down arrow] |-| Moves the focus down to next node in the category.|
|[up arrow] |-| Moves focus up to previous node in the category.|
|[space bar] |createNodeAttachLinks | Adds the node to the canvas and links it to an available existing node on canvas. Same as double clicking the node|
|Shift + [space bar]|createNodeAttachLinks (addLinks: false) | Adds the node to the canvas and does not create any links. Same as dragging a node onto the canvas. |


## Toolbar
## Context toolbar / menu

|Keyboard Shortcut|Description|
|---|---|
|right arrow|Move focus to the button to the right of current focus position |
|left arrow|Move focus to the button to the left of current focus position |
|down arrow|Open sub-area (either a sub-menu or sub-panel) below button, if one is available |
|space bar|Activate the button |
|esc | Close any open associated sub-area (either a sub-menu or sub-panel) |

## When focus is on the toolbar overflow menu or sub-area (either a sub-menu or sub-panel)

|Keyboard Shortcut|Description|
|---|---|
|down arrow|Move focus to next menu item below current focus position |
|up arrow|Move focus to next menu item above current focus position |
|right arrow|Opens cascade sub-area, if there is one, for the currenty focused item |
|space bar|Activate the current menu item |
|esc | Close the sub-area |
|Keyboard Shortcut|Action|Description|
|---|---|---|
|[down arrow key] |-| Move focus to next menu item below current focus position |
|[up arrow key] |-| Move focus to next menu item above current focus position |
|[right arrow key] |-| Opens cascade sub-area, if there is one, for the currenty focused item |
|[space bar key] |-| Activate the current menu item |
|[esc key] |-| Close the sub-area |


0 comments on commit 8a4dd8c

Please sign in to comment.