godmin-redactor 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdfeae6aa3856d2e782d7df23e7de45d312c99a4
|
4
|
+
data.tar.gz: 274f2a198d6d8926200ef5c5bf2b1f0d10fa626d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a4c25694b0ba36b5a3db43013e214e2622b1fc1e92f5f47809bff4ac99f05a452bfe31bad711740be53cceb9ed9a152c525ea8e83cdd2a9814a2c62f79fb7c
|
7
|
+
data.tar.gz: ee9b7e9d546f21cfa04feb8adf68f59c61a3d41d3777a0bcc00ee513fedbc8a42565e984c97e928a6ecc17613d229f21dab8e8ba334d2c1760006544a2895d47
|
data/CHANGELOG.md
CHANGED
@@ -27,13 +27,12 @@ Godmin.Redactor = (function() {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
function initializeRedactor($el) {
|
30
|
-
$el.
|
31
|
-
$(this).redactor($(this).data("options"));
|
32
|
-
});
|
30
|
+
$el.redactor($el.data("options"));
|
33
31
|
}
|
34
32
|
|
35
33
|
return {
|
36
|
-
initialize: initialize
|
34
|
+
initialize: initialize,
|
35
|
+
initializeRedactor: initializeRedactor
|
37
36
|
};
|
38
37
|
})();
|
39
38
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
|
-
Redactor v10.
|
3
|
-
Updated:
|
2
|
+
Redactor v10.1.1
|
3
|
+
Updated: April 28, 2015
|
4
4
|
|
5
5
|
http://imperavi.com/redactor/
|
6
6
|
|
@@ -28,9 +28,6 @@
|
|
28
28
|
|
29
29
|
var uuid = 0;
|
30
30
|
|
31
|
-
var reUrlYoutube = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
|
32
|
-
var reUrlVimeo = /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
|
33
|
-
|
34
31
|
// Plugin
|
35
32
|
$.fn.redactor = function(options)
|
36
33
|
{
|
@@ -94,13 +91,13 @@
|
|
94
91
|
|
95
92
|
// Functionality
|
96
93
|
$.Redactor = Redactor;
|
97
|
-
$.Redactor.VERSION = '10.
|
94
|
+
$.Redactor.VERSION = '10.1.1';
|
98
95
|
$.Redactor.modules = ['alignment', 'autosave', 'block', 'buffer', 'build', 'button',
|
99
96
|
'caret', 'clean', 'code', 'core', 'dropdown', 'file', 'focus',
|
100
97
|
'image', 'indent', 'inline', 'insert', 'keydown', 'keyup',
|
101
98
|
'lang', 'line', 'link', 'list', 'modal', 'observe', 'paragraphize',
|
102
99
|
'paste', 'placeholder', 'progress', 'selection', 'shortcuts',
|
103
|
-
'tabifier', 'tidy', 'toolbar', 'upload', 'utils'];
|
100
|
+
'tabifier', 'tidy', 'toolbar', 'upload', 'utils', 'linkify'];
|
104
101
|
|
105
102
|
$.Redactor.opts = {
|
106
103
|
|
@@ -195,6 +192,10 @@
|
|
195
192
|
deniedTags: ['script', 'style'],
|
196
193
|
allowedTags: false, // or array
|
197
194
|
|
195
|
+
paragraphizeBlocks: ['table', 'div', 'pre', 'form', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'dl', 'blockquote', 'figcaption',
|
196
|
+
'address', 'section', 'header', 'footer', 'aside', 'article', 'object', 'style', 'script', 'iframe', 'select', 'input', 'textarea',
|
197
|
+
'button', 'option', 'map', 'area', 'math', 'hr', 'fieldset', 'legend', 'hgroup', 'nav', 'figure', 'details', 'menu', 'summary', 'p'],
|
198
|
+
|
198
199
|
removeComments: false,
|
199
200
|
replaceTags: [
|
200
201
|
['strike', 'del']
|
@@ -328,7 +329,18 @@
|
|
328
329
|
upload_label: 'Drop file here or '
|
329
330
|
|
330
331
|
}
|
331
|
-
}
|
332
|
+
},
|
333
|
+
|
334
|
+
linkify: {
|
335
|
+
regexps: {
|
336
|
+
youtube: /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig,
|
337
|
+
vimeo: /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,
|
338
|
+
image: /((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/ig,
|
339
|
+
url: /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/ig,
|
340
|
+
}
|
341
|
+
},
|
342
|
+
|
343
|
+
codemirror: false
|
332
344
|
};
|
333
345
|
|
334
346
|
// Functionality
|
@@ -529,11 +541,11 @@
|
|
529
541
|
autosave: function()
|
530
542
|
{
|
531
543
|
return {
|
544
|
+
html: false,
|
532
545
|
enable: function()
|
533
546
|
{
|
534
547
|
if (!this.opts.autosave) return;
|
535
548
|
|
536
|
-
this.autosave.html = false;
|
537
549
|
this.autosave.name = (this.opts.autosaveName) ? this.opts.autosaveName : this.$textarea.attr('name');
|
538
550
|
|
539
551
|
if (this.opts.autosaveOnChange) return;
|
@@ -549,7 +561,7 @@
|
|
549
561
|
this.autosave.source = this.code.get();
|
550
562
|
|
551
563
|
if (this.autosave.html === this.autosave.source) return;
|
552
|
-
if (this.utils.isEmpty(this.autosave.source)) return;
|
564
|
+
//if (this.utils.isEmpty(this.autosave.source)) return;
|
553
565
|
|
554
566
|
// data
|
555
567
|
var data = {};
|
@@ -940,7 +952,7 @@
|
|
940
952
|
},
|
941
953
|
formatListToBlockquote: function()
|
942
954
|
{
|
943
|
-
var block = $(this.block.blocks[0]).closest('ul, ol');
|
955
|
+
var block = $(this.block.blocks[0]).closest('ul, ol', this.$editor[0]);
|
944
956
|
|
945
957
|
$(block).find('ul, ol').contents().unwrap();
|
946
958
|
$(block).find('li').append($('<br>')).contents().unwrap();
|
@@ -1033,10 +1045,10 @@
|
|
1033
1045
|
},
|
1034
1046
|
formatTableWrapping: function($formatted)
|
1035
1047
|
{
|
1036
|
-
if ($formatted.closest('table').length === 0) return;
|
1048
|
+
if ($formatted.closest('table', this.$editor[0]).length === 0) return;
|
1037
1049
|
|
1038
|
-
if ($formatted.closest('tr').length === 0) $formatted.wrap('<tr>');
|
1039
|
-
if ($formatted.closest('td').length === 0 && $formatted.closest('th').length === 0)
|
1050
|
+
if ($formatted.closest('tr', this.$editor[0]).length === 0) $formatted.wrap('<tr>');
|
1051
|
+
if ($formatted.closest('td', this.$editor[0]).length === 0 && $formatted.closest('th').length === 0)
|
1040
1052
|
{
|
1041
1053
|
$formatted.wrap('<td>');
|
1042
1054
|
}
|
@@ -1349,6 +1361,9 @@
|
|
1349
1361
|
// paste
|
1350
1362
|
this.$editor.on('paste.redactor', $.proxy(this.paste.init, this));
|
1351
1363
|
|
1364
|
+
// cut
|
1365
|
+
this.$editor.on('cut.redactor', $.proxy(this.code.sync, this));
|
1366
|
+
|
1352
1367
|
// keydown
|
1353
1368
|
this.$editor.on('keydown.redactor', $.proxy(this.keydown.init, this));
|
1354
1369
|
|
@@ -1395,8 +1410,11 @@
|
|
1395
1410
|
},
|
1396
1411
|
setHelpers: function()
|
1397
1412
|
{
|
1398
|
-
//
|
1399
|
-
this.
|
1413
|
+
// linkify
|
1414
|
+
if (this.linkify.isEnabled())
|
1415
|
+
{
|
1416
|
+
this.linkify.format();
|
1417
|
+
}
|
1400
1418
|
|
1401
1419
|
// placeholder
|
1402
1420
|
this.placeholder.enable();
|
@@ -1974,13 +1992,13 @@
|
|
1974
1992
|
html = html.replace(new RegExp('<br\\s?/?></li>', 'gi'), '</li>');
|
1975
1993
|
html = html.replace(new RegExp('</li><br\\s?/?>', 'gi'), '</li>');
|
1976
1994
|
// remove verified
|
1977
|
-
html = html.replace(
|
1978
|
-
html = html.replace(
|
1979
|
-
html = html.replace(
|
1980
|
-
html = html.replace(
|
1981
|
-
html = html.replace(
|
1982
|
-
html = html.replace(
|
1983
|
-
html = html.replace(
|
1995
|
+
html = html.replace(/<div(.*?[^>]) data-tagblock="redactor"(.*?[^>])>/gi, '<div$1$2>');
|
1996
|
+
html = html.replace(/<(.*?) data-verified="redactor"(.*?[^>])>/gi, '<$1$2>');
|
1997
|
+
html = html.replace(/<span(.*?[^>])\srel="(.*?[^>])"(.*?[^>])>/gi, '<span$1$3>');
|
1998
|
+
html = html.replace(/<img(.*?[^>])\srel="(.*?[^>])"(.*?[^>])>/gi, '<img$1$3>');
|
1999
|
+
html = html.replace(/<img(.*?[^>])\sstyle="" (.*?[^>])>'/gi, '<img$1 $2>');
|
2000
|
+
html = html.replace(/<img(.*?[^>])\sstyle (.*?[^>])>'/gi, '<img$1 $2>');
|
2001
|
+
html = html.replace(/<span class="redactor-invisible-space">(.*?)<\/span>/gi, '$1');
|
1984
2002
|
html = html.replace(/ data-save-url="(.*?[^>])"/gi, '');
|
1985
2003
|
|
1986
2004
|
// remove image resize
|
@@ -2250,29 +2268,16 @@
|
|
2250
2268
|
}
|
2251
2269
|
|
2252
2270
|
var options = {
|
2253
|
-
deniedTags: false,
|
2254
|
-
allowedTags: tags,
|
2271
|
+
deniedTags: (this.opts.deniedTags) ? this.opts.deniedTags : false,
|
2272
|
+
allowedTags: (this.opts.allowedTags) ? this.opts.allowedTags : tags,
|
2255
2273
|
removeComments: true,
|
2256
2274
|
removePhp: true,
|
2257
|
-
removeAttr: false,
|
2258
|
-
allowedAttr: attrAllowed,
|
2275
|
+
removeAttr: (this.opts.removeAttr) ? this.opts.removeAttr : false,
|
2276
|
+
allowedAttr: (this.opts.allowedAttr) ? this.opts.allowedAttr : attrAllowed,
|
2259
2277
|
removeEmpty: tagsEmpty
|
2260
2278
|
};
|
2261
2279
|
|
2262
|
-
// denied tags
|
2263
|
-
if (this.opts.deniedTags)
|
2264
|
-
{
|
2265
|
-
options.deniedTags = this.opts.deniedTags;
|
2266
|
-
}
|
2267
|
-
|
2268
|
-
// allowed tags
|
2269
|
-
if (this.opts.allowedTags)
|
2270
|
-
{
|
2271
|
-
options.allowedTags = this.opts.allowedTags;
|
2272
|
-
}
|
2273
|
-
|
2274
2280
|
return this.tidy.load(html, options);
|
2275
|
-
|
2276
2281
|
},
|
2277
2282
|
onPasteRemoveEmpty: function(html)
|
2278
2283
|
{
|
@@ -2498,6 +2503,15 @@
|
|
2498
2503
|
});
|
2499
2504
|
|
2500
2505
|
},
|
2506
|
+
cleanEmptyParagraph: function()
|
2507
|
+
{
|
2508
|
+
var p = this.$editor.find("p").first();
|
2509
|
+
|
2510
|
+
if (this.utils.isEmpty(p.html()))
|
2511
|
+
{
|
2512
|
+
p.remove();
|
2513
|
+
}
|
2514
|
+
},
|
2501
2515
|
setVerified: function(html)
|
2502
2516
|
{
|
2503
2517
|
if (this.utils.browser('msie')) return html;
|
@@ -2684,8 +2698,22 @@
|
|
2684
2698
|
|
2685
2699
|
this.start = false;
|
2686
2700
|
|
2687
|
-
|
2701
|
+
if (this.autosave.html == false)
|
2702
|
+
{
|
2703
|
+
this.autosave.html = this.code.get();
|
2704
|
+
}
|
2705
|
+
|
2706
|
+
if (this.opts.codemirror)
|
2707
|
+
{
|
2708
|
+
this.$textarea.next('.CodeMirror').each(function(i, el)
|
2709
|
+
{
|
2710
|
+
el.CodeMirror.setValue(html);
|
2711
|
+
});
|
2712
|
+
}
|
2713
|
+
|
2714
|
+
//autosave
|
2688
2715
|
this.autosave.onChange();
|
2716
|
+
this.autosave.enable();
|
2689
2717
|
},
|
2690
2718
|
toggle: function()
|
2691
2719
|
{
|
@@ -2703,7 +2731,8 @@
|
|
2703
2731
|
this.code.offset = this.caret.getOffset();
|
2704
2732
|
var scroll = $(window).scrollTop();
|
2705
2733
|
|
2706
|
-
var
|
2734
|
+
var width = this.$editor.innerWidth(),
|
2735
|
+
height = this.$editor.innerHeight();
|
2707
2736
|
|
2708
2737
|
this.$editor.hide();
|
2709
2738
|
|
@@ -2713,17 +2742,33 @@
|
|
2713
2742
|
// indent code
|
2714
2743
|
html = this.tabifier.get(html);
|
2715
2744
|
|
2716
|
-
this.$textarea.val(html)
|
2717
|
-
this.$textarea.on('keydown.redactor-textarea-indenting', this.code.textareaIndenting);
|
2718
|
-
|
2719
|
-
$(window).scrollTop(scroll);
|
2745
|
+
this.$textarea.val(html);
|
2720
2746
|
|
2721
|
-
if (this
|
2747
|
+
if (this.opts.codemirror)
|
2722
2748
|
{
|
2723
|
-
this.$textarea
|
2749
|
+
this.$textarea.next('.CodeMirror').each(function(i, el)
|
2750
|
+
{
|
2751
|
+
$(el).show();
|
2752
|
+
el.CodeMirror.setValue(html);
|
2753
|
+
el.CodeMirror.setSize(width, height);
|
2754
|
+
el.CodeMirror.refresh();
|
2755
|
+
el.CodeMirror.focus();
|
2756
|
+
});
|
2724
2757
|
}
|
2758
|
+
else
|
2759
|
+
{
|
2760
|
+
this.$textarea.height(height).show().focus();
|
2761
|
+
this.$textarea.on('keydown.redactor-textarea-indenting', this.code.textareaIndenting);
|
2725
2762
|
|
2726
|
-
|
2763
|
+
$(window).scrollTop(scroll);
|
2764
|
+
|
2765
|
+
if (this.$textarea[0].setSelectionRange)
|
2766
|
+
{
|
2767
|
+
this.$textarea[0].setSelectionRange(0, 0);
|
2768
|
+
}
|
2769
|
+
|
2770
|
+
this.$textarea[0].scrollTop = 0;
|
2771
|
+
}
|
2727
2772
|
|
2728
2773
|
this.opts.visual = false;
|
2729
2774
|
|
@@ -2733,15 +2778,32 @@
|
|
2733
2778
|
},
|
2734
2779
|
showVisual: function()
|
2735
2780
|
{
|
2781
|
+
var html;
|
2782
|
+
|
2736
2783
|
if (this.opts.visual) return;
|
2737
2784
|
|
2738
|
-
|
2785
|
+
if (this.opts.codemirror)
|
2786
|
+
{
|
2787
|
+
this.$textarea.next('.CodeMirror').each(function(i, el)
|
2788
|
+
{
|
2789
|
+
html = el.CodeMirror.getValue();
|
2790
|
+
});
|
2791
|
+
}
|
2792
|
+
else
|
2793
|
+
{
|
2794
|
+
html = this.$textarea.hide().val();
|
2795
|
+
}
|
2739
2796
|
|
2740
2797
|
if (this.modified !== this.clean.removeSpaces(html))
|
2741
2798
|
{
|
2742
2799
|
this.code.set(html);
|
2743
2800
|
}
|
2744
2801
|
|
2802
|
+
if (this.opts.codemirror)
|
2803
|
+
{
|
2804
|
+
this.$textarea.next('.CodeMirror').hide();
|
2805
|
+
}
|
2806
|
+
|
2745
2807
|
this.$editor.show();
|
2746
2808
|
|
2747
2809
|
if (!this.utils.isEmpty(html))
|
@@ -2890,14 +2952,24 @@
|
|
2890
2952
|
{
|
2891
2953
|
$.each(this.opts.formattingAdd, $.proxy(function(i,s)
|
2892
2954
|
{
|
2893
|
-
var name = s.tag
|
2955
|
+
var name = s.tag,
|
2956
|
+
func;
|
2957
|
+
|
2894
2958
|
if (typeof s['class'] != 'undefined')
|
2895
2959
|
{
|
2896
2960
|
name = name + '-' + s['class'];
|
2897
2961
|
}
|
2898
2962
|
|
2899
2963
|
s.type = (this.utils.isBlockTag(s.tag)) ? 'block' : 'inline';
|
2900
|
-
|
2964
|
+
|
2965
|
+
if (typeof s.func !== "undefined")
|
2966
|
+
{
|
2967
|
+
func = s.func;
|
2968
|
+
}
|
2969
|
+
else
|
2970
|
+
{
|
2971
|
+
func = (s.type == 'inline') ? 'inline.formatting' : 'block.formatting';
|
2972
|
+
}
|
2901
2973
|
|
2902
2974
|
if (this.opts.linebreaks && s.type == 'block' && s.tag == 'p') return;
|
2903
2975
|
|
@@ -3215,7 +3287,7 @@
|
|
3215
3287
|
},
|
3216
3288
|
showEdit: function($image)
|
3217
3289
|
{
|
3218
|
-
var $link = $image.closest('a');
|
3290
|
+
var $link = $image.closest('a', this.$editor[0]);
|
3219
3291
|
|
3220
3292
|
this.modal.load('imageEdit', this.lang.get('edit'), 705);
|
3221
3293
|
|
@@ -3292,7 +3364,7 @@
|
|
3292
3364
|
this.image.hideResize();
|
3293
3365
|
this.buffer.set();
|
3294
3366
|
|
3295
|
-
var $link = $image.closest('a');
|
3367
|
+
var $link = $image.closest('a', this.$editor[0]);
|
3296
3368
|
|
3297
3369
|
$image.attr('alt', $('#redactor-image-title').val());
|
3298
3370
|
|
@@ -3420,8 +3492,11 @@
|
|
3420
3492
|
|
3421
3493
|
if (height < 50 || width < 100) return;
|
3422
3494
|
|
3495
|
+
var height = Math.round(this.image.resizeHandle.el.width() / this.image.resizeHandle.ratio);
|
3496
|
+
|
3497
|
+
this.image.resizeHandle.el.attr({width: width, height: height});
|
3423
3498
|
this.image.resizeHandle.el.width(width);
|
3424
|
-
this.image.resizeHandle.el.height(
|
3499
|
+
this.image.resizeHandle.el.height(height);
|
3425
3500
|
|
3426
3501
|
this.code.sync();
|
3427
3502
|
},
|
@@ -3465,7 +3540,7 @@
|
|
3465
3540
|
},
|
3466
3541
|
hideResize: function(e)
|
3467
3542
|
{
|
3468
|
-
if (e && $(e.target).closest('#redactor-image-box').length !== 0) return;
|
3543
|
+
if (e && $(e.target).closest('#redactor-image-box', this.$editor[0]).length !== 0) return;
|
3469
3544
|
if (e && e.target.tagName == 'IMG')
|
3470
3545
|
{
|
3471
3546
|
var $image = $(e.target);
|
@@ -3577,8 +3652,8 @@
|
|
3577
3652
|
remove: function(image)
|
3578
3653
|
{
|
3579
3654
|
var $image = $(image);
|
3580
|
-
var $link = $image.closest('a');
|
3581
|
-
var $figure = $image.closest('figure');
|
3655
|
+
var $link = $image.closest('a', this.$editor[0]);
|
3656
|
+
var $figure = $image.closest('figure', this.$editor[0]);
|
3582
3657
|
var $parent = $image.parent();
|
3583
3658
|
if ($('#redactor-image-box').length !== 0)
|
3584
3659
|
{
|
@@ -3763,7 +3838,7 @@
|
|
3763
3838
|
|
3764
3839
|
var current = this.selection.getCurrent();
|
3765
3840
|
|
3766
|
-
var $item = $(current).closest('li');
|
3841
|
+
var $item = $(current).closest('li', this.$editor[0]);
|
3767
3842
|
var $parent = $item.parent();
|
3768
3843
|
if ($item.length !== 0 && $parent.length !== 0 && $parent[0].tagName == 'LI')
|
3769
3844
|
{
|
@@ -3847,6 +3922,15 @@
|
|
3847
3922
|
if (tag == tags[i]) tag = replaced[i];
|
3848
3923
|
}
|
3849
3924
|
|
3925
|
+
if (this.opts.allowedTags)
|
3926
|
+
{
|
3927
|
+
if ($.inArray(tag, this.opts.allowedTags) == -1) return;
|
3928
|
+
}
|
3929
|
+
else
|
3930
|
+
{
|
3931
|
+
if ($.inArray(tag, this.opts.deniedTags) !== -1) return;
|
3932
|
+
}
|
3933
|
+
|
3850
3934
|
this.inline.type = type || false;
|
3851
3935
|
this.inline.value = value || false;
|
3852
3936
|
|
@@ -3871,7 +3955,7 @@
|
|
3871
3955
|
formatCollapsed: function(tag)
|
3872
3956
|
{
|
3873
3957
|
var current = this.selection.getCurrent();
|
3874
|
-
var $parent = $(current).closest(tag + '[data-redactor-tag=' + tag + ']');
|
3958
|
+
var $parent = $(current).closest(tag + '[data-redactor-tag=' + tag + ']', this.$editor[0]);
|
3875
3959
|
|
3876
3960
|
// inline there is
|
3877
3961
|
if ($parent.length !== 0 && (this.inline.type != 'style' && $parent[0].tagName != 'SPAN'))
|
@@ -4527,7 +4611,7 @@
|
|
4527
4611
|
var $table = false;
|
4528
4612
|
if (this.keydown.block && this.keydown.block.tagName === 'TD')
|
4529
4613
|
{
|
4530
|
-
$table = $(this.keydown.block).closest('table');
|
4614
|
+
$table = $(this.keydown.block).closest('table', this.$editor[0]);
|
4531
4615
|
}
|
4532
4616
|
|
4533
4617
|
if ($table && $table.find('td').last()[0] === this.keydown.block)
|
@@ -4601,8 +4685,6 @@
|
|
4601
4685
|
current = this.selection.getCurrent();
|
4602
4686
|
$next = $(this.keydown.current).next();
|
4603
4687
|
|
4604
|
-
|
4605
|
-
|
4606
4688
|
if ($next.length !== 0 && $next[0].tagName == 'BR')
|
4607
4689
|
{
|
4608
4690
|
return this.keydown.insertBreakLine(e);
|
@@ -4642,11 +4724,13 @@
|
|
4642
4724
|
else
|
4643
4725
|
{
|
4644
4726
|
current = this.selection.getCurrent();
|
4645
|
-
var $parent = $(current).closest('li');
|
4646
|
-
var $list = $parent.closest('ul,ol');
|
4727
|
+
var $parent = $(current).closest('li', this.$editor[0]);
|
4728
|
+
var $list = $parent.closest('ul,ol', this.$editor[0]);
|
4647
4729
|
|
4648
|
-
if ($parent.length !== 0 && this.utils.isEmpty($parent.html()) && $list.next().length === 0)
|
4730
|
+
if ($parent.length !== 0 && this.utils.isEmpty($parent.html()) && $list.next().length === 0 && this.utils.isEmpty($list.find("li").last().html()))
|
4649
4731
|
{
|
4732
|
+
$list.find("li").last().remove();
|
4733
|
+
|
4650
4734
|
var node = $(this.opts.emptyHtml);
|
4651
4735
|
$list.after(node);
|
4652
4736
|
this.caret.setStart(node);
|
@@ -4993,6 +5077,7 @@
|
|
4993
5077
|
e.stopPropagation();
|
4994
5078
|
|
4995
5079
|
this.selection.get();
|
5080
|
+
|
4996
5081
|
var br1 = document.createElement('br');
|
4997
5082
|
|
4998
5083
|
if (this.utils.browser('msie'))
|
@@ -5007,9 +5092,19 @@
|
|
5007
5092
|
|
5008
5093
|
this.range.insertNode(br1);
|
5009
5094
|
|
5010
|
-
|
5095
|
+
// move br outside A tag
|
5096
|
+
var $parentA = $(br1).parent("a");
|
5097
|
+
|
5098
|
+
if ($parentA.length > 0)
|
5011
5099
|
{
|
5100
|
+
$parentA.find(br1)
|
5101
|
+
.remove();
|
5012
5102
|
|
5103
|
+
$parentA.after(br1);
|
5104
|
+
}
|
5105
|
+
|
5106
|
+
if (dbl === true)
|
5107
|
+
{
|
5013
5108
|
var $next = $(br1).next();
|
5014
5109
|
if ($next.length !== 0 && $next[0].tagName === 'BR' && this.utils.isEndOfEditor())
|
5015
5110
|
{
|
@@ -5019,6 +5114,7 @@
|
|
5019
5114
|
}
|
5020
5115
|
|
5021
5116
|
var br2 = document.createElement('br');
|
5117
|
+
|
5022
5118
|
this.range.insertNode(br2);
|
5023
5119
|
this.caret.setAfter(br2);
|
5024
5120
|
}
|
@@ -5053,9 +5149,9 @@
|
|
5053
5149
|
{
|
5054
5150
|
var $current = $(this.keydown.current);
|
5055
5151
|
var $parent = $(this.keydown.parent);
|
5056
|
-
var td = $current.closest('td');
|
5152
|
+
var td = $current.closest('td', this.$editor[0]);
|
5057
5153
|
|
5058
|
-
if (td.length !== 0 && $current.closest('li') && $parent.children('li').length === 1)
|
5154
|
+
if (td.length !== 0 && $current.closest('li', this.$editor[0]) && $parent.children('li').length === 1)
|
5059
5155
|
{
|
5060
5156
|
if (!this.utils.isEmpty($current.text())) return;
|
5061
5157
|
|
@@ -5110,13 +5206,8 @@
|
|
5110
5206
|
}
|
5111
5207
|
|
5112
5208
|
// linkify
|
5113
|
-
if (this.
|
5114
|
-
|
5115
|
-
this.formatLinkify(this.opts.linkProtocol, this.opts.convertLinks, this.opts.convertUrlLinks, this.opts.convertImageLinks, this.opts.convertVideoLinks, this.opts.linkSize);
|
5116
|
-
|
5117
|
-
this.observe.load();
|
5118
|
-
this.code.sync();
|
5119
|
-
}
|
5209
|
+
if (this.linkify.isEnabled() && this.linkify.isKey(key))
|
5210
|
+
this.linkify.format();
|
5120
5211
|
|
5121
5212
|
if (key === this.keyCode.DELETE || key === this.keyCode.BACKSPACE)
|
5122
5213
|
{
|
@@ -5137,7 +5228,10 @@
|
|
5137
5228
|
}
|
5138
5229
|
|
5139
5230
|
// remove empty paragraphs
|
5140
|
-
this.$editor.find('p').each($.proxy(
|
5231
|
+
this.$editor.find('p').each($.proxy(function(i, s)
|
5232
|
+
{
|
5233
|
+
this.utils.removeEmpty(i, $(s).html());
|
5234
|
+
}, this));
|
5141
5235
|
|
5142
5236
|
// remove invisible space
|
5143
5237
|
if (this.opts.linebreaks && this.keyup.current && this.keyup.current.tagName == 'DIV' && this.utils.isEmpty(this.keyup.current.innerHTML))
|
@@ -5151,10 +5245,6 @@
|
|
5151
5245
|
return this.keyup.formatEmpty(e);
|
5152
5246
|
}
|
5153
5247
|
},
|
5154
|
-
isLinkify: function(key)
|
5155
|
-
{
|
5156
|
-
return this.opts.convertLinks && (this.opts.convertUrlLinks || this.opts.convertImageLinks || this.opts.convertVideoLinks) && key === this.keyCode.ENTER && !this.utils.isCurrentOrParent('PRE');
|
5157
|
-
},
|
5158
5248
|
replaceToParagraph: function(clone)
|
5159
5249
|
{
|
5160
5250
|
var $current = $(this.keyup.current);
|
@@ -5335,23 +5425,26 @@
|
|
5335
5425
|
cleanUrl: function()
|
5336
5426
|
{
|
5337
5427
|
var thref = self.location.href.replace(/\/$/i, '');
|
5338
|
-
this.link.url = this.link.url.replace(thref, '');
|
5339
|
-
this.link.url = this.link.url.replace(/^\/#/, '#');
|
5340
|
-
this.link.url = this.link.url.replace('mailto:', '');
|
5341
5428
|
|
5342
|
-
|
5343
|
-
if (!this.opts.linkProtocol)
|
5429
|
+
if (typeof this.link.url !== "undefined")
|
5344
5430
|
{
|
5345
|
-
|
5346
|
-
this.link.url = this.link.url.replace(
|
5347
|
-
|
5431
|
+
this.link.url = this.link.url.replace(thref, '');
|
5432
|
+
this.link.url = this.link.url.replace(/^\/#/, '#');
|
5433
|
+
this.link.url = this.link.url.replace('mailto:', '');
|
5348
5434
|
|
5435
|
+
// remove host from href
|
5436
|
+
if (!this.opts.linkProtocol)
|
5437
|
+
{
|
5438
|
+
var re = new RegExp('^(http|ftp|https)://' + self.location.host, 'i');
|
5439
|
+
this.link.url = this.link.url.replace(re, '');
|
5440
|
+
}
|
5441
|
+
}
|
5349
5442
|
},
|
5350
5443
|
getData: function()
|
5351
5444
|
{
|
5352
5445
|
this.link.$node = false;
|
5353
5446
|
|
5354
|
-
var $el = $(this.selection.getCurrent()).closest('a');
|
5447
|
+
var $el = $(this.selection.getCurrent()).closest('a', this.$editor[0]);
|
5355
5448
|
if ($el.length !== 0 && $el[0].tagName === 'A')
|
5356
5449
|
{
|
5357
5450
|
this.link.$node = $el;
|
@@ -5370,6 +5463,8 @@
|
|
5370
5463
|
},
|
5371
5464
|
insert: function()
|
5372
5465
|
{
|
5466
|
+
this.placeholder.remove();
|
5467
|
+
|
5373
5468
|
var target = '';
|
5374
5469
|
var link = this.link.$inputUrl.val();
|
5375
5470
|
var text = this.link.$inputText.val();
|
@@ -5426,16 +5521,37 @@
|
|
5426
5521
|
{
|
5427
5522
|
this.buffer.set();
|
5428
5523
|
|
5429
|
-
this.link.$node
|
5524
|
+
var $link = this.link.$node,
|
5525
|
+
$el = $link.children();
|
5526
|
+
|
5527
|
+
if ($el.length > 0)
|
5528
|
+
{
|
5529
|
+
while ($el.length)
|
5530
|
+
{
|
5531
|
+
$el = $el.children();
|
5532
|
+
}
|
5533
|
+
|
5534
|
+
$el = $el.end();
|
5535
|
+
}
|
5536
|
+
else
|
5537
|
+
{
|
5538
|
+
$el = $link;
|
5539
|
+
}
|
5540
|
+
|
5541
|
+
$link.attr('href', link);
|
5542
|
+
$el.text(text);
|
5543
|
+
|
5430
5544
|
if (target !== '')
|
5431
5545
|
{
|
5432
|
-
|
5546
|
+
$link.attr('target', target);
|
5433
5547
|
}
|
5434
5548
|
else
|
5435
5549
|
{
|
5436
|
-
|
5550
|
+
$link.removeAttr('target');
|
5437
5551
|
}
|
5438
5552
|
|
5553
|
+
this.selection.selectElement($link);
|
5554
|
+
|
5439
5555
|
this.code.sync();
|
5440
5556
|
}
|
5441
5557
|
else
|
@@ -5457,13 +5573,19 @@
|
|
5457
5573
|
if (target !== '') $a.attr('target', target);
|
5458
5574
|
|
5459
5575
|
$a = $(this.insert.node($a));
|
5576
|
+
|
5577
|
+
if (this.selection.getText().match(/\s$/))
|
5578
|
+
{
|
5579
|
+
$a.after(" ");
|
5580
|
+
}
|
5581
|
+
|
5460
5582
|
this.selection.selectElement($a);
|
5461
5583
|
}
|
5462
5584
|
else
|
5463
5585
|
{
|
5464
5586
|
document.execCommand('createLink', false, link);
|
5465
5587
|
|
5466
|
-
$a = $(this.selection.getCurrent()).closest('a');
|
5588
|
+
$a = $(this.selection.getCurrent()).closest('a', this.$editor[0]);
|
5467
5589
|
if (this.utils.browser('mozilla'))
|
5468
5590
|
{
|
5469
5591
|
$a = $('a[_moz_dirty=""]');
|
@@ -5472,10 +5594,15 @@
|
|
5472
5594
|
if (target !== '') $a.attr('target', target);
|
5473
5595
|
$a.removeAttr('style').removeAttr('_moz_dirty');
|
5474
5596
|
|
5475
|
-
if (this.
|
5597
|
+
if (this.selection.getText().match(/\s$/))
|
5476
5598
|
{
|
5599
|
+
$a.after(" ");
|
5600
|
+
}
|
5477
5601
|
|
5602
|
+
if (this.link.text !== '' || this.link.text != text)
|
5603
|
+
{
|
5478
5604
|
$a.text(text);
|
5605
|
+
|
5479
5606
|
this.selection.selectElement($a);
|
5480
5607
|
}
|
5481
5608
|
}
|
@@ -5508,7 +5635,7 @@
|
|
5508
5635
|
var len = nodes.length;
|
5509
5636
|
for (var i = 0; i < len; i++)
|
5510
5637
|
{
|
5511
|
-
var $node = $(nodes[i]).closest('a');
|
5638
|
+
var $node = $(nodes[i]).closest('a', this.$editor[0]);
|
5512
5639
|
$node.replaceWith($node.contents());
|
5513
5640
|
}
|
5514
5641
|
|
@@ -5554,7 +5681,7 @@
|
|
5554
5681
|
this.selection.save();
|
5555
5682
|
|
5556
5683
|
var parent = this.selection.getParent();
|
5557
|
-
var $list = $(parent).closest('ol, ul');
|
5684
|
+
var $list = $(parent).closest('ol, ul', this.$editor[0]);
|
5558
5685
|
|
5559
5686
|
if (!this.utils.isRedactorParent($list) && $list.length !== 0)
|
5560
5687
|
{
|
@@ -5592,7 +5719,6 @@
|
|
5592
5719
|
}
|
5593
5720
|
}
|
5594
5721
|
|
5595
|
-
|
5596
5722
|
this.selection.restore();
|
5597
5723
|
this.code.sync();
|
5598
5724
|
},
|
@@ -5600,7 +5726,7 @@
|
|
5600
5726
|
{
|
5601
5727
|
var parent = this.selection.getParent();
|
5602
5728
|
var current = this.selection.getCurrent();
|
5603
|
-
var $td = $(current).closest('td, th');
|
5729
|
+
var $td = $(current).closest('td, th', this.$editor[0]);
|
5604
5730
|
|
5605
5731
|
if (this.utils.browser('msie') && this.opts.linebreaks)
|
5606
5732
|
{
|
@@ -5611,7 +5737,7 @@
|
|
5611
5737
|
document.execCommand('insert' + cmd);
|
5612
5738
|
}
|
5613
5739
|
|
5614
|
-
var $list = $(this.selection.getParent()).closest('ol, ul');
|
5740
|
+
var $list = $(this.selection.getParent()).closest('ol, ul', this.$editor[0]);
|
5615
5741
|
|
5616
5742
|
if ($td.length !== 0)
|
5617
5743
|
{
|
@@ -5698,13 +5824,13 @@
|
|
5698
5824
|
|
5699
5825
|
this.indent.fixEmptyIndent();
|
5700
5826
|
|
5701
|
-
if (!this.opts.linebreaks && $current.closest('li, th, td').length === 0)
|
5827
|
+
if (!this.opts.linebreaks && $current.closest('li, th, td', this.$editor[0]).length === 0)
|
5702
5828
|
{
|
5703
5829
|
document.execCommand('formatblock', false, 'p');
|
5704
5830
|
this.$editor.find('ul, ol, blockquote').each($.proxy(this.utils.removeEmpty, this));
|
5705
5831
|
}
|
5706
5832
|
|
5707
|
-
var $table = $(this.selection.getCurrent()).closest('table');
|
5833
|
+
var $table = $(this.selection.getCurrent()).closest('table', this.$editor[0]);
|
5708
5834
|
var $prev = $table.prev();
|
5709
5835
|
if (!this.opts.linebreaks && $table.length !== 0 && $prev.length !== 0 && $prev[0].tagName == 'BR')
|
5710
5836
|
{
|
@@ -6085,19 +6211,19 @@
|
|
6085
6211
|
|
6086
6212
|
$.each(this.opts.activeButtonsStates, $.proxy(function(key, value)
|
6087
6213
|
{
|
6088
|
-
var parentEl = $(parent).closest(key);
|
6089
|
-
var currentEl = $(current).closest(key);
|
6214
|
+
var parentEl = $(parent).closest(key, this.$editor[0]);
|
6215
|
+
var currentEl = $(current).closest(key, this.$editor[0]);
|
6090
6216
|
|
6091
6217
|
if (parentEl.length !== 0 && !this.utils.isRedactorParent(parentEl)) return;
|
6092
6218
|
if (!this.utils.isRedactorParent(currentEl)) return;
|
6093
|
-
if (parentEl.length !== 0 || currentEl.closest(key).length !== 0)
|
6219
|
+
if (parentEl.length !== 0 || currentEl.closest(key, this.$editor[0]).length !== 0)
|
6094
6220
|
{
|
6095
6221
|
this.button.setActive(value);
|
6096
6222
|
}
|
6097
6223
|
|
6098
6224
|
}, this));
|
6099
6225
|
|
6100
|
-
var $parent = $(parent).closest(this.opts.alignmentTags.toString().toLowerCase());
|
6226
|
+
var $parent = $(parent).closest(this.opts.alignmentTags.toString().toLowerCase(), this.$editor[0]);
|
6101
6227
|
if (this.utils.isRedactorParent(parent) && $parent.length)
|
6102
6228
|
{
|
6103
6229
|
var align = ($parent.css('text-align') === '') ? 'left' : $parent.css('text-align');
|
@@ -6116,7 +6242,7 @@
|
|
6116
6242
|
var $img = $(img);
|
6117
6243
|
|
6118
6244
|
// IE fix (when we clicked on an image and then press backspace IE does goes to image's url)
|
6119
|
-
$img.closest('a').on('click', function(e) { e.preventDefault(); });
|
6245
|
+
$img.closest('a', this.$editor[0]).on('click', function(e) { e.preventDefault(); });
|
6120
6246
|
|
6121
6247
|
if (this.utils.browser('msie')) $img.attr('unselectable', 'on');
|
6122
6248
|
|
@@ -6149,20 +6275,18 @@
|
|
6149
6275
|
},
|
6150
6276
|
showTooltip: function(e)
|
6151
6277
|
{
|
6152
|
-
var $
|
6153
|
-
var $parent = $link.closest('a');
|
6154
|
-
var tag = ($link.length !== 0) ? $link[0].tagName : false;
|
6278
|
+
var $el = $(e.target);
|
6155
6279
|
|
6156
|
-
if ($
|
6157
|
-
|
6158
|
-
if (tag === 'IMG') return;
|
6159
|
-
else if (tag !== 'A') $link = $parent;
|
6160
|
-
}
|
6280
|
+
if ($el[0].tagName == 'IMG')
|
6281
|
+
return;
|
6161
6282
|
|
6162
|
-
if (
|
6163
|
-
|
6283
|
+
if ($el[0].tagName !== 'A')
|
6284
|
+
$el = $el.closest('a', this.$editor[0]);
|
6285
|
+
|
6286
|
+
if ($el[0].tagName !== 'A')
|
6164
6287
|
return;
|
6165
|
-
|
6288
|
+
|
6289
|
+
var $link = $el;
|
6166
6290
|
|
6167
6291
|
var pos = this.observe.getTooltipPosition($link);
|
6168
6292
|
var tooltip = $('<span class="redactor-link-tooltip"></span>');
|
@@ -6193,7 +6317,7 @@
|
|
6193
6317
|
e = e.originalEvent || e;
|
6194
6318
|
|
6195
6319
|
var target = e.target;
|
6196
|
-
var $parent = $(target).closest('a');
|
6320
|
+
var $parent = $(target).closest('a', this.$editor[0]);
|
6197
6321
|
if ($parent.length !== 0 && $parent[0].tagName === 'A' && target.tagName !== 'A')
|
6198
6322
|
{
|
6199
6323
|
return;
|
@@ -6216,10 +6340,6 @@
|
|
6216
6340
|
if (this.opts.linebreaks) return html;
|
6217
6341
|
if (html === '' || html === '<p></p>') return this.opts.emptyHtml;
|
6218
6342
|
|
6219
|
-
this.paragraphize.blocks = ['table', 'div', 'pre', 'form', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'dl', 'blockquote', 'figcaption',
|
6220
|
-
'address', 'section', 'header', 'footer', 'aside', 'article', 'object', 'style', 'script', 'iframe', 'select', 'input', 'textarea',
|
6221
|
-
'button', 'option', 'map', 'area', 'math', 'hr', 'fieldset', 'legend', 'hgroup', 'nav', 'figure', 'details', 'menu', 'summary', 'p'];
|
6222
|
-
|
6223
6343
|
html = html + "\n";
|
6224
6344
|
|
6225
6345
|
this.paragraphize.safes = [];
|
@@ -6234,7 +6354,7 @@
|
|
6234
6354
|
html = this.paragraphize.clear(html);
|
6235
6355
|
html = this.paragraphize.restoreSafes(html);
|
6236
6356
|
|
6237
|
-
html = html.replace(new RegExp('<br\\s?/?>\n?<(' + this.
|
6357
|
+
html = html.replace(new RegExp('<br\\s?/?>\n?<(' + this.opts.paragraphizeBlocks.join('|') + ')(.*?[^>])>', 'gi'), '<p><br /></p>\n<$1$2>');
|
6238
6358
|
|
6239
6359
|
return $.trim(html);
|
6240
6360
|
},
|
@@ -6250,7 +6370,7 @@
|
|
6250
6370
|
|
6251
6371
|
html = $div.html();
|
6252
6372
|
|
6253
|
-
$div.find(this.
|
6373
|
+
$div.find(this.opts.paragraphizeBlocks.join(', ')).each($.proxy(function(i,s)
|
6254
6374
|
{
|
6255
6375
|
this.paragraphize.z++;
|
6256
6376
|
this.paragraphize.safes[this.paragraphize.z] = s.outerHTML;
|
@@ -6382,8 +6502,10 @@
|
|
6382
6502
|
|
6383
6503
|
$(window).off('scroll.redactor-freeze');
|
6384
6504
|
|
6385
|
-
|
6505
|
+
if (this.linkify.isEnabled())
|
6506
|
+
this.linkify.format();
|
6386
6507
|
|
6508
|
+
}, this), 1);
|
6387
6509
|
},
|
6388
6510
|
createPasteBox: function()
|
6389
6511
|
{
|
@@ -7283,24 +7405,13 @@
|
|
7283
7405
|
replacement.push(this.tidy.settings.replaceTags[i][0]);
|
7284
7406
|
}
|
7285
7407
|
|
7286
|
-
|
7408
|
+
$.each(replacement, $.proxy(function(key, value)
|
7287
7409
|
{
|
7288
|
-
|
7289
|
-
$(s).replaceWith(function()
|
7410
|
+
this.tidy.$div.find(value).replaceWith(function()
|
7290
7411
|
{
|
7291
|
-
|
7292
|
-
|
7293
|
-
for (var i = 0; i < this.attributes.length; i++)
|
7294
|
-
{
|
7295
|
-
replaced.attr(this.attributes[i].name, this.attributes[i].value);
|
7296
|
-
}
|
7297
|
-
|
7298
|
-
return replaced;
|
7412
|
+
return $("<" + rTags[key] + " />", {html: $(this).html()});
|
7299
7413
|
});
|
7300
|
-
|
7301
7414
|
}, this));
|
7302
|
-
|
7303
|
-
return html;
|
7304
7415
|
},
|
7305
7416
|
replaceStyles: function()
|
7306
7417
|
{
|
@@ -7805,6 +7916,9 @@
|
|
7805
7916
|
left: left
|
7806
7917
|
});
|
7807
7918
|
|
7919
|
+
if (scrollTop > end)
|
7920
|
+
$('.redactor-dropdown-' + this.uuid + ':visible').hide();
|
7921
|
+
|
7808
7922
|
this.toolbar.setDropdownsFixed();
|
7809
7923
|
this.$toolbar.css('visibility', (scrollTop < end) ? 'visible' : 'hidden');
|
7810
7924
|
},
|
@@ -7820,8 +7934,6 @@
|
|
7820
7934
|
|
7821
7935
|
this.toolbar.unsetDropdownsFixed();
|
7822
7936
|
this.$toolbar.removeClass('toolbar-fixed-box');
|
7823
|
-
|
7824
|
-
|
7825
7937
|
},
|
7826
7938
|
setDropdownsFixed: function()
|
7827
7939
|
{
|
@@ -7971,6 +8083,7 @@
|
|
7971
8083
|
|
7972
8084
|
var xhr = new XMLHttpRequest();
|
7973
8085
|
xhr.open('POST', this.upload.url);
|
8086
|
+
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
7974
8087
|
|
7975
8088
|
// complete
|
7976
8089
|
xhr.onreadystatechange = $.proxy(function()
|
@@ -8273,12 +8386,13 @@
|
|
8273
8386
|
},
|
8274
8387
|
removeEmpty: function(i, s)
|
8275
8388
|
{
|
8276
|
-
var $s = $(s);
|
8389
|
+
var $s = $($.parseHTML(s));
|
8277
8390
|
|
8278
8391
|
$s.find('.redactor-invisible-space').removeAttr('style').removeAttr('class');
|
8279
8392
|
|
8280
8393
|
if ($s.find('hr, br, img, iframe, source').length !== 0) return;
|
8281
8394
|
var text = $.trim($s.text());
|
8395
|
+
|
8282
8396
|
if (this.utils.isEmpty(text, false))
|
8283
8397
|
{
|
8284
8398
|
$s.remove();
|
@@ -8406,7 +8520,7 @@
|
|
8406
8520
|
// tag detection
|
8407
8521
|
isTag: function(current, tag)
|
8408
8522
|
{
|
8409
|
-
var element = $(current).closest(tag);
|
8523
|
+
var element = $(current).closest(tag, this.$editor[0]);
|
8410
8524
|
if (element.length == 1)
|
8411
8525
|
{
|
8412
8526
|
return element[0];
|
@@ -8514,116 +8628,141 @@
|
|
8514
8628
|
return browser == match[1];
|
8515
8629
|
}
|
8516
8630
|
};
|
8517
|
-
}
|
8518
|
-
|
8519
|
-
|
8520
|
-
|
8521
|
-
|
8522
|
-
|
8523
|
-
|
8524
|
-
|
8525
|
-
|
8526
|
-
|
8631
|
+
},
|
8632
|
+
linkify: function()
|
8633
|
+
{
|
8634
|
+
return {
|
8635
|
+
isKey: function(key)
|
8636
|
+
{
|
8637
|
+
return key == this.keyCode.ENTER || key == this.keyCode.SPACE;
|
8638
|
+
},
|
8639
|
+
isEnabled: function()
|
8640
|
+
{
|
8641
|
+
return this.opts.convertLinks && (this.opts.convertUrlLinks || this.opts.convertImageLinks || this.opts.convertVideoLinks) && !this.utils.isCurrentOrParent('PRE');
|
8642
|
+
},
|
8643
|
+
format: function()
|
8644
|
+
{
|
8645
|
+
var linkify = this.linkify,
|
8646
|
+
opts = this.opts;
|
8527
8647
|
|
8528
|
-
|
8529
|
-
|
8530
|
-
|
8531
|
-
|
8532
|
-
|
8533
|
-
|
8534
|
-
|
8648
|
+
this.$editor
|
8649
|
+
.find(":not(iframe,img,a,pre)")
|
8650
|
+
.addBack()
|
8651
|
+
.contents()
|
8652
|
+
.filter(function()
|
8653
|
+
{
|
8654
|
+
return this.nodeType === 3 && $.trim(this.nodeValue) != "" && !$(this).parent().is("pre") && (this.nodeValue.match(opts.linkify.regexps.youtube) || this.nodeValue.match(opts.linkify.regexps.vimeo) || this.nodeValue.match(opts.linkify.regexps.image) || this.nodeValue.match(opts.linkify.regexps.url));
|
8655
|
+
})
|
8656
|
+
.each(function()
|
8657
|
+
{
|
8658
|
+
var text = $(this).text(),
|
8659
|
+
html = text;
|
8535
8660
|
|
8536
|
-
|
8537
|
-
|
8538
|
-
|
8539
|
-
|
8661
|
+
if (opts.convertVideoLinks && (html.match(opts.linkify.regexps.youtube) || html.match(opts.linkify.regexps.vimeo)) )
|
8662
|
+
{
|
8663
|
+
html = linkify.convertVideoLinks(html);
|
8664
|
+
}
|
8665
|
+
else if (opts.convertImageLinks && html.match(opts.linkify.regexps.image))
|
8666
|
+
{
|
8667
|
+
html = linkify.convertImages(html);
|
8668
|
+
}
|
8669
|
+
else if (opts.convertUrlLinks)
|
8670
|
+
{
|
8671
|
+
html = linkify.convertLinks(html);
|
8672
|
+
}
|
8540
8673
|
|
8541
|
-
|
8542
|
-
|
8543
|
-
|
8674
|
+
$(this).before(text.replace(text, html))
|
8675
|
+
.remove();
|
8676
|
+
});
|
8544
8677
|
|
8545
|
-
|
8546
|
-
|
8678
|
+
this.linkify.after();
|
8679
|
+
},
|
8680
|
+
convertVideoLinks: function(html)
|
8547
8681
|
{
|
8548
8682
|
var iframeStart = '<iframe width="500" height="281" src="',
|
8549
8683
|
iframeEnd = '" frameborder="0" allowfullscreen></iframe>';
|
8550
8684
|
|
8551
|
-
if (html.match(
|
8685
|
+
if (html.match(this.opts.linkify.regexps.youtube))
|
8552
8686
|
{
|
8553
|
-
html = html.replace(
|
8554
|
-
$(n).after(html).remove();
|
8687
|
+
html = html.replace(this.opts.linkify.regexps.youtube, iframeStart + '//www.youtube.com/embed/$1' + iframeEnd);
|
8555
8688
|
}
|
8556
|
-
|
8689
|
+
|
8690
|
+
if (html.match(this.opts.linkify.regexps.vimeo))
|
8557
8691
|
{
|
8558
|
-
html = html.replace(
|
8559
|
-
$(n).after(html).remove();
|
8692
|
+
html = html.replace(this.opts.linkify.regexps.vimeo, iframeStart + '//player.vimeo.com/video/$2' + iframeEnd);
|
8560
8693
|
}
|
8561
|
-
}
|
8562
8694
|
|
8563
|
-
|
8564
|
-
|
8695
|
+
return html;
|
8696
|
+
},
|
8697
|
+
convertImages: function(html)
|
8565
8698
|
{
|
8566
|
-
var matches = html.match(
|
8567
|
-
html = html.replace(urlImage, '<img src="' + matches + '" />');
|
8699
|
+
var matches = html.match(this.opts.linkify.regexps.image);
|
8568
8700
|
|
8569
|
-
|
8570
|
-
|
8571
|
-
|
8572
|
-
|
8573
|
-
// link
|
8574
|
-
if (html.search(/\$/g) != -1) html = html.replace(/\$/g, '$');
|
8701
|
+
if (matches)
|
8702
|
+
{
|
8703
|
+
html = html.replace(html, '<img src="' + matches + '" />');
|
8704
|
+
}
|
8575
8705
|
|
8576
|
-
|
8577
|
-
|
8706
|
+
return html;
|
8707
|
+
},
|
8708
|
+
convertLinks: function(html)
|
8578
8709
|
{
|
8579
|
-
var
|
8580
|
-
|
8710
|
+
var matches = html.match(this.opts.linkify.regexps.url);
|
8711
|
+
|
8712
|
+
if (matches)
|
8581
8713
|
{
|
8582
|
-
|
8583
|
-
if (matches[z].match(/\.$/) !== null) matches[z] = matches[z].replace(/\.$/, '');
|
8714
|
+
matches = $.grep(matches, function(v, k) { return $.inArray(v, matches) === k; });
|
8584
8715
|
|
8585
|
-
var
|
8586
|
-
var text = href;
|
8716
|
+
var length = matches.length;
|
8587
8717
|
|
8588
|
-
var
|
8589
|
-
|
8718
|
+
for (var i = 0; i < length; i++)
|
8719
|
+
{
|
8720
|
+
var href = matches[i],
|
8721
|
+
text = href,
|
8722
|
+
linkProtocol = this.opts.linkProtocol + '://';
|
8590
8723
|
|
8591
|
-
|
8592
|
-
|
8724
|
+
if (href.match(/(https?|ftp):\/\//i) !== null)
|
8725
|
+
{
|
8726
|
+
linkProtocol = "";
|
8727
|
+
}
|
8593
8728
|
|
8594
|
-
|
8595
|
-
|
8729
|
+
if (text.length > this.opts.linkSize)
|
8730
|
+
{
|
8731
|
+
text = text.substring(0, this.opts.linkSize) + '...';
|
8732
|
+
}
|
8596
8733
|
|
8597
|
-
|
8598
|
-
|
8599
|
-
|
8600
|
-
|
8601
|
-
|
8602
|
-
var len = links.length;
|
8603
|
-
for (i = 0; i < len; i++)
|
8734
|
+
text = decodeURIComponent(text);
|
8735
|
+
|
8736
|
+
var regexB = "\\b";
|
8737
|
+
|
8738
|
+
if ($.inArray(href.slice(-1), ["/", "&", "="]) != -1)
|
8604
8739
|
{
|
8605
|
-
|
8606
|
-
html = html.replace(links[i], '{abuffer' + i + '}');
|
8740
|
+
regexB = "";
|
8607
8741
|
}
|
8608
|
-
}
|
8609
8742
|
|
8610
|
-
|
8743
|
+
// escaping url
|
8744
|
+
var regexp = new RegExp('(' + href.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + regexB + ')', 'g');
|
8611
8745
|
|
8612
|
-
|
8613
|
-
|
8614
|
-
{
|
8615
|
-
html = html.replace('{abuffer' + i + '}', s);
|
8616
|
-
});
|
8746
|
+
html = html.replace(regexp, '<a href="' + linkProtocol + $.trim(href) + '">' + $.trim(text) + '</a>');
|
8747
|
+
}
|
8617
8748
|
}
|
8618
8749
|
|
8619
|
-
|
8750
|
+
return html;
|
8751
|
+
},
|
8752
|
+
after: function()
|
8753
|
+
{
|
8754
|
+
this.observe.load();
|
8755
|
+
this.code.sync();
|
8620
8756
|
}
|
8621
8757
|
}
|
8622
|
-
else if (n.nodeType === 1 && !/^(pre|a|button|textarea)$/i.test(n.tagName))
|
8623
|
-
{
|
8624
|
-
$.Redactor.fn.formatLinkify.call(n, protocol, convertLinks, convertUrlLinks, convertImageLinks, convertVideoLinks, linkSize);
|
8625
|
-
}
|
8626
8758
|
}
|
8627
8759
|
};
|
8628
8760
|
|
8761
|
+
$(window).on('load.tools.redactor', function()
|
8762
|
+
{
|
8763
|
+
$('[data-tools="redactor"]').redactor();
|
8764
|
+
});
|
8765
|
+
|
8766
|
+
// constructor
|
8767
|
+
Redactor.prototype.init.prototype = Redactor.prototype;
|
8629
8768
|
})(jQuery);
|
@@ -227,6 +227,12 @@ body .redactor-box-fullscreen {
|
|
227
227
|
background-color: transparent !important;
|
228
228
|
cursor: default;
|
229
229
|
}
|
230
|
+
/*
|
231
|
+
CodeMirror
|
232
|
+
*/
|
233
|
+
.redactor-box .CodeMirror {
|
234
|
+
display: none;
|
235
|
+
}
|
230
236
|
/*
|
231
237
|
Icons
|
232
238
|
*/
|
@@ -845,6 +851,12 @@ body .redactor-box-fullscreen {
|
|
845
851
|
padding-left: 2em;
|
846
852
|
border: none;
|
847
853
|
}
|
854
|
+
.redactor-editor ol ol li {
|
855
|
+
list-style-type: lower-alpha;
|
856
|
+
}
|
857
|
+
.redactor-editor ol ol ol li {
|
858
|
+
list-style-type: lower-roman;
|
859
|
+
}
|
848
860
|
.redactor-editor dl dt {
|
849
861
|
font-weight: bold;
|
850
862
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: godmin-redactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Varvet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: godmin
|