
preventdelete.js
About this file
We attempted to read from templates/app_static_js_plugins_tinymce_preventdelete.js_hw.txt but failed.
Code Check Report
1:1 error Move the invocation into the parens that contain the function wrap-iife 2:2 error Array prototype is read only, properties should not be added no-extend-native 14:3 warning Function 'hasText' has a complexity of 7 complexity 27:3 warning Function 'hasStopText' has a complexity of 12 complexity 74:24 warning Function has a complexity of 8 complexity 93:20 error Expected '===' and instead saw '==' eqeqeq 136:21 warning Function has a complexity of 33 complexity 145:28 error Expected '===' and instead saw '==' eqeqeq 146:27 error Expected '===' and instead saw '==' eqeqeq 214:2 error Do not use 'new' for side effects no-new ✖ 10 problems (6 errors, 4 warnings) 1 error and 0 warnings potentially fixable with the `--fix` option.
Documentation drawn from source code
(function() {
Array.prototype.contains = function (e) {
function PreventDelete() {
function r(val, min, max) {
function hasText(str, pos, left) {
function hasStopText(str, pos, left) {
this.nextElement = function(elem) {
this.prevElement = function(elem) {
this.keyWillDelete = function(evt) {
/*
In trying to figure out how to detect if a key was relevant, I appended all the keycodes for keys on my keyboard that would "delete" selected text, and sorted. Generated the range blow:
Deleting
8, 9, 13, 46, 48-57, 65-90, 96-111, 186-192, 219-222
I did the same thign with keys that wouldn't and got these below
Not harmful
16-19, 27, 33-40, 45, 91-93, 112-123, 144
You should note, since it's onkeydown it doesn't change the code if you have alt or ctrl or something pressed. It makes it fewer keycombos actually.
I'm pretty sure in these "deleting" keys will still "delete" if shift is held
*/
this.cancelKey = function(evt) {
this.check = function(node) {
this.checkChildren = function(node) {
this.logElem = function(elem) {
function(key) {
tinymce.PluginManager.add('preventdelete', function(ed, link) {
ed.on('keydown', function(evt) {