From 3a8434a1d42e1157c4cff2e46f9c6de451019b03 Mon Sep 17 00:00:00 2001 From: Torge Hamann <37174525+torge-hmn@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:47:21 +0100 Subject: [PATCH] fix(keyboard): correct `Keyboard#bind` and config signature Related to https://github.com/bpmn-io/diagram-js/pull/662 --- lib/features/keyboard/Keyboard.js | 9 ++++++++- lib/features/keyboard/Keyboard.spec.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 lib/features/keyboard/Keyboard.spec.ts diff --git a/lib/features/keyboard/Keyboard.js b/lib/features/keyboard/Keyboard.js index 3ae879d81..9255d073c 100644 --- a/lib/features/keyboard/Keyboard.js +++ b/lib/features/keyboard/Keyboard.js @@ -49,7 +49,7 @@ var compatMessage = 'Keyboard binding is now implicit; explicit binding to an el * `keyboard.bind=true|false` configuration option. * * @param {Object} config - * @param {EventTarget} [config.bindTo] + * @param {boolean} [config.bind] * @param {EventBus} eventBus */ export default function Keyboard(config, eventBus) { @@ -125,10 +125,17 @@ Keyboard.prototype._isEventIgnored = function(event) { /** * Bind keyboard events to the given DOM node. * + * @overlord + * @deprecated + * * @param {EventTarget} node */ +/** + * Bind keyboard events to the canvas node. + */ Keyboard.prototype.bind = function(node) { + // legacy argument provided if (node) { console.error('unsupported argument ', new Error(compatMessage)); } diff --git a/lib/features/keyboard/Keyboard.spec.ts b/lib/features/keyboard/Keyboard.spec.ts new file mode 100644 index 000000000..530f0cb4f --- /dev/null +++ b/lib/features/keyboard/Keyboard.spec.ts @@ -0,0 +1,12 @@ +import Diagram from '../../Diagram'; +import Keyboard from './Keyboard'; + +const diagram = new Diagram(); + +let keyboard = diagram.get('keyboard'); + +keyboard.bind(); + +keyboard.unbind(); + +keyboard.bind(document); \ No newline at end of file