【问题标题】:Cannot paste text in CodeMirror in Google Chrome无法在 Google Chrome 的 CodeMirror 中粘贴文本
【发布时间】:2010-10-11 11:59:43
【问题描述】:

几个月前没有问题,但突然“粘贴”在 Google Chrome 的 CodeMirror 中停止工作。 “Ctrl+V”、“Shift+Insert”和右键单击->“粘贴”均无任何作用。

这不是我的代码中的错误,因为即使在演示页面
http://codemirror.net/jstest.html
它不起作用。

【问题讨论】:

  • 它适用于我的 Chrome(版本 6.0.472.63)
  • 我有 Google Chrome 8.0.552.0 开发版

标签: javascript google-chrome clipboard codemirror


【解决方案1】:

当使用任何 webkit 变体(Chrome 就是其中之一)时,此问题在 Linux 上仍然存在。它在 CodeMirror 2.25 中仍未处理。

这里是bug

您可以在 var name=... 之后在 CodeMirror 中为 handleKeyBinding(e) 打一个非常部分的补丁 这不是一个完美的修复,但它会帮助您识别 DeleteCtrl +插入Shift+插入

if( name == null && (webkit || chrome) && e.keyCode == 0 && e.charCode == 0 && e.keyLocation == 3 ) {
    // Now we know something on the keypad has been pressed and not translated properly by webkit.
    if( e.ctrlKey == false && e.shiftKey == false ) {
      // We're probably hitting the Delete key to delete a character.
      name = 'Delete';    
    }
    if( e.ctrlKey == true || e.shiftKey == true ) {
      // We're probably using Ctrl-Ins to copy, or Shift-Ins to paste.
      name = 'Insert';    
    }
  }    

现在 Delete 已处理。但是由于您无法从 Javascript 访问剪贴板,因此您会被 Ctrl+Insert (复制)和 Shift+插入(粘贴)直到 webkit 错误被修复。

【讨论】:

    【解决方案2】:

    我有同样的问题 - 但是,我发现它的这个实例确实接受来自 chrome 的复制粘贴。

    http://kml-samples.googlecode.com/svn/trunk/interactive/index.html

    我尝试在我的网站上使用他们的 chromemirror 源代码副本 - 但还没有成功

    【讨论】:

      【解决方案3】:

      更新谷歌浏览器。 在新版本中一切正常 - Google Chrome 8.0.552.0 dev

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-08
        • 1970-01-01
        • 2023-03-27
        • 2017-04-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多