General.Web/wwwroot/lib/codemirror-5.31.0/src/edit/key_events.js

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

import { signalLater } from "../util/operation_group"
import { restartBlink } from "../display/selection"
import { isModifierKey, keyName, lookupKey } from "../input/keymap"
import { eventInWidget } from "../measurement/widgets"
import { ie, ie_version, mac, presto } from "../util/browser"
import { activeElt, addClass, rmClass } from "../util/dom"
import { e_preventDefault, off, on, signalDOMEvent } from "../util/event"
import { hasCopyEvent } from "../util/feature_detection"
import { Delayed, Pass } from "../util/misc"

import { commands } from "./commands"

// Run a handler that was bound to a key.
function doHandleBinding(cm, bound, dropShift) {
  if (typeof bound == "string") {
    bound = commands[bound]
    if (!bound) return false
  }
  // Ensure previous input has been read, so that the handler sees a
  // consistent view of the document
  cm.display.input.ensurePolled()
  let prevShift = cm.display.shift, done = false
  try {
    if (cm.isReadOnly()) cm.state.suppressEdits = true
    if (dropShift) cm.display.shift = false
    done = bound(cm) != Pass
  } finally {
    cm.display.shift = prevShift
    cm.state.suppressEdits = false
  }
  return done
}

function lookupKeyForEditor(cm, name, handle) {
  for (let i = 0; i < cm.state.keyMaps.length; i++) {
    let result = lookupKey(name, cm.state.keyMaps[i], handle, cm)
    if (result) return result
  }
  return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
    || lookupKey(name, cm.options.keyMap, handle, cm)
}

// Note that, despite the name, this function is also used to check
// for bound mouse clicks.

let stopSeq = new Delayed
export function dispatchKey(cm, name, e, handle) {
  let seq = cm.state.keySeq
  if (seq) {
    if (isModifierKey(name)) return "handled"
    stopSeq.set(50, () => {
      if (cm.state.keySeq == seq) {
        cm.state.keySeq = null
        cm.display.input.reset()
      }
    })
    name = seq + " " + name
  }
  let result = lookupKeyForEditor(cm, name, handle)

后面还有 95 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。