PHP Classes

File: public/js/tinymce/src/plugins/textpattern/src/main/js/core/KeyHandler.js

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra   GoLavaCMS   public/js/tinymce/src/plugins/textpattern/src/main/js/core/KeyHandler.js   Download  
File: public/js/tinymce/src/plugins/textpattern/src/main/js/core/KeyHandler.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: GoLavaCMS
Publish content on Web pages with SEO support
Author: By
Last change:
Date: 6 years ago
Size: 2,387 bytes
 

Contents

Class file image Download
/** * KeyHandler.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ define( 'tinymce.plugins.textpattern.core.KeyHandler', [ 'tinymce.core.util.VK', 'tinymce.plugins.textpattern.core.Formatter' ], function (VK, Formatter) { function handleEnter(editor, patterns) { var wrappedTextNode, rng; wrappedTextNode = Formatter.applyInlineFormatEnter(editor, patterns); if (wrappedTextNode) { rng = editor.dom.createRng(); rng.setStart(wrappedTextNode, wrappedTextNode.data.length); rng.setEnd(wrappedTextNode, wrappedTextNode.data.length); editor.selection.setRng(rng); } Formatter.applyBlockFormat(editor, patterns); } function handleInlineKey(editor, patterns) { var wrappedTextNode, lastChar, lastCharNode, rng, dom; wrappedTextNode = Formatter.applyInlineFormatSpace(editor, patterns); if (wrappedTextNode) { dom = editor.dom; lastChar = wrappedTextNode.data.slice(-1); // Move space after the newly formatted node if (/[\u00a0 ]/.test(lastChar)) { wrappedTextNode.deleteData(wrappedTextNode.data.length - 1, 1); lastCharNode = dom.doc.createTextNode(lastChar); dom.insertAfter(lastCharNode, wrappedTextNode.parentNode); rng = dom.createRng(); rng.setStart(lastCharNode, 1); rng.setEnd(lastCharNode, 1); editor.selection.setRng(rng); } } } var checkKeyEvent = function (codes, event, predicate) { for (var i = 0; i < codes.length; i++) { if (predicate(codes[i], event)) { return true; } } }; var checkKeyCode = function (codes, event) { return checkKeyEvent(codes, event, function (code, event) { return code === event.keyCode && VK.modifierPressed(event) === false; }); }; var checkCharCode = function (chars, event) { return checkKeyEvent(chars, event, function (chr, event) { return chr.charCodeAt(0) === event.charCode; }); }; return { handleEnter: handleEnter, handleInlineKey: handleInlineKey, checkCharCode: checkCharCode, checkKeyCode: checkKeyCode }; } );