Merge branch 'master' into next
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / 3rdParty / redactor2 / plugins / WoltLabBlock.js
1 $.Redactor.prototype.WoltLabBlock = function() {
2 "use strict";
3
4 return {
5 init: function() {
6 this.block.tags = ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'figure'];
7
8 this.block.format = (function(tag, attr, value, type) {
9 tag = (tag === 'quote') ? 'blockquote' : tag;
10
11 // WoltLab modification: move list of allowed elements
12 // outside this method to allow extending it
13 //
14 //this.block.tags = ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'figure'];
15 if ($.inArray(tag, this.block.tags) === -1)
16 {
17 return;
18 }
19
20 if (tag === 'p' && typeof attr === 'undefined')
21 {
22 // remove all
23 attr = 'class';
24 }
25
26 this.placeholder.hide();
27 this.buffer.set();
28
29 return (this.utils.isCollapsed()) ? this.block.formatCollapsed(tag, attr, value, type) : this.block.formatUncollapsed(tag, attr, value, type);
30 }).bind(this);
31 },
32
33 register: function(tag) {
34 if (this.block.tags.indexOf(tag) !== -1) {
35 return;
36 }
37
38 this.block.tags.push(tag);
39
40 if (this.opts.blockTags.indexOf(tag) === -1) {
41 this.opts.blockTags.push(tag);
42
43 this.reIsBlock = new RegExp('^(' + this.opts.blockTags.join('|').toUpperCase() + ')$', 'i');
44 }
45 }
46 }
47 };