Path: blob/trunk/third_party/closure/goog/editor/plugins/linkshortcutplugin.js
2868 views
// Copyright 2011 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Adds a keyboard shortcut for the link command.16*17*/1819goog.provide('goog.editor.plugins.LinkShortcutPlugin');2021goog.require('goog.editor.Command');22goog.require('goog.editor.Plugin');23242526/**27* Plugin to add a keyboard shortcut for the link command28* @constructor29* @extends {goog.editor.Plugin}30* @final31*/32goog.editor.plugins.LinkShortcutPlugin = function() {33goog.editor.plugins.LinkShortcutPlugin.base(this, 'constructor');34};35goog.inherits(goog.editor.plugins.LinkShortcutPlugin, goog.editor.Plugin);363738/** @override */39goog.editor.plugins.LinkShortcutPlugin.prototype.getTrogClassId = function() {40return 'LinkShortcutPlugin';41};424344/**45* @override46*/47goog.editor.plugins.LinkShortcutPlugin.prototype.handleKeyboardShortcut =48function(e, key, isModifierPressed) {49if (isModifierPressed && key == 'k' && !e.shiftKey) {50var link = /** @type {goog.editor.Link?} */ (51this.getFieldObject().execCommand(goog.editor.Command.LINK));52if (link) {53link.finishLinkCreation(this.getFieldObject());54}55return true;56}5758return false;59};606162