UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

32 lines (29 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleKeyDown = void 0; var _commands = require("./commands"); var _pmPlugin = require("./pm-plugin"); var handleKeyDown = exports.handleKeyDown = function handleKeyDown(view, event) { // Check if this is a keyboard shortcut (Ctrl/Cmd + key) var isShortcut = event.ctrlKey || event.metaKey || event.altKey; if (isShortcut) { return false; } // Only consider actual typing keys (not shortcuts) // We need to check if it's a single character key or a deletion key // and ensure it's not part of a shortcut var isTypingKey = // Single character keys (letters, numbers, symbols) event.key.length === 1 || event.key === 'Backspace' || event.key === 'Delete' || event.key === ' ' || event.key === 'Enter'; if (!isTypingKey) { return false; } var state = (0, _pmPlugin.getInteractionTrackingState)(view.state); // if user hasnt started typing yet, start timer if (!(state !== null && state !== void 0 && state.isEditing)) { (0, _commands.startEditing)(view); } return false; };