TinyMCE Advanced - Version 4.1

Version Description

  • Updated for WordPress 4.0 and TinyMCE 4.1.
  • Add the 'textpattern' plugin that supports some of the markdown syntax while typing, (more info).
  • Add the updated 'table' plugin that supports background and border color.
Download this release

Release Info

Developer azaozz
Plugin Icon 128x128 TinyMCE Advanced
Version 4.1
Comparing to
See all releases

Code changes from version 4.0.2 to 4.1

css/tadv-styles.css CHANGED
@@ -182,6 +182,7 @@ ul.container,
182
 
183
  #unused {
184
  margin: 0;
 
185
  }
186
 
187
  #unused .tadvmodule .tadvitem {
182
 
183
  #unused {
184
  margin: 0;
185
+ min-height: 36px;
186
  }
187
 
188
  #unused .tadvmodule .tadvitem {
mce/advlist/plugin.js CHANGED
@@ -18,7 +18,9 @@ tinymce.PluginManager.add('advlist', function(editor) {
18
 
19
  tinymce.each(styleValues.split(/[ ,]/), function(styleValue) {
20
  items.push({
21
- text: styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function(chr) {return chr.toUpperCase();}),
 
 
22
  data: styleValue == 'default' ? '' : styleValue
23
  });
24
  });
@@ -49,7 +51,7 @@ tinymce.PluginManager.add('advlist', function(editor) {
49
  lastStyles[listName] = styleValue;
50
 
51
  list = dom.getParent(sel.getNode(), 'ol,ul');
52
- if (list) {
53
  dom.setStyle(list, 'listStyleType', styleValue);
54
  list.removeAttribute('data-mce-style');
55
  }
18
 
19
  tinymce.each(styleValues.split(/[ ,]/), function(styleValue) {
20
  items.push({
21
+ text: styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function(chr) {
22
+ return chr.toUpperCase();
23
+ }),
24
  data: styleValue == 'default' ? '' : styleValue
25
  });
26
  });
51
  lastStyles[listName] = styleValue;
52
 
53
  list = dom.getParent(sel.getNode(), 'ol,ul');
54
+ if (list && styleValue) {
55
  dom.setStyle(list, 'listStyleType', styleValue);
56
  list.removeAttribute('data-mce-style');
57
  }
mce/advlist/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("advlist",function(t){function e(t,e){var n=[];return tinymce.each(e.split(/[ ,]/),function(t){n.push({text:t.replace(/\-/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()}),data:"default"==t?"":t})}),n}function n(e,n){var o,l=t.dom,a=t.selection;o=l.getParent(a.getNode(),"ol,ul"),o&&o.nodeName==e&&n!==!1||t.execCommand("UL"==e?"InsertUnorderedList":"InsertOrderedList"),n=n===!1?i[e]:n,i[e]=n,o=l.getParent(a.getNode(),"ol,ul"),o&&(l.setStyle(o,"listStyleType",n),o.removeAttribute("data-mce-style")),t.focus()}function o(e){var n=t.dom.getStyle(t.dom.getParent(t.selection.getNode(),"ol,ul"),"listStyleType")||"";e.control.items().each(function(t){t.active(t.settings.data===n)})}var l,a,i={};l=e("OL",t.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman")),a=e("UL",t.getParam("advlist_bullet_styles","default,circle,disc,square")),t.addButton("numlist",{type:"splitbutton",tooltip:"Numbered list",menu:l,onshow:o,onselect:function(t){n("OL",t.control.settings.data)},onclick:function(){n("OL",!1)}}),t.addButton("bullist",{type:"splitbutton",tooltip:"Bullet list",menu:a,onshow:o,onselect:function(t){n("UL",t.control.settings.data)},onclick:function(){n("UL",!1)}})});
1
+ tinymce.PluginManager.add("advlist",function(t){function e(t,e){var n=[];return tinymce.each(e.split(/[ ,]/),function(t){n.push({text:t.replace(/\-/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()}),data:"default"==t?"":t})}),n}function n(e,n){var o,l=t.dom,a=t.selection;o=l.getParent(a.getNode(),"ol,ul"),o&&o.nodeName==e&&n!==!1||t.execCommand("UL"==e?"InsertUnorderedList":"InsertOrderedList"),n=n===!1?i[e]:n,i[e]=n,o=l.getParent(a.getNode(),"ol,ul"),o&&n&&(l.setStyle(o,"listStyleType",n),o.removeAttribute("data-mce-style")),t.focus()}function o(e){var n=t.dom.getStyle(t.dom.getParent(t.selection.getNode(),"ol,ul"),"listStyleType")||"";e.control.items().each(function(t){t.active(t.settings.data===n)})}var l,a,i={};l=e("OL",t.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman")),a=e("UL",t.getParam("advlist_bullet_styles","default,circle,disc,square")),t.addButton("numlist",{type:"splitbutton",tooltip:"Numbered list",menu:l,onshow:o,onselect:function(t){n("OL",t.control.settings.data)},onclick:function(){n("OL",!1)}}),t.addButton("bullist",{type:"splitbutton",tooltip:"Bullet list",menu:a,onshow:o,onselect:function(t){n("UL",t.control.settings.data)},onclick:function(){n("UL",!1)}})});
mce/anchor/plugin.js CHANGED
@@ -12,11 +12,15 @@
12
 
13
  tinymce.PluginManager.add('anchor', function(editor) {
14
  function showDialog() {
15
- var selectedNode = editor.selection.getNode();
 
 
 
 
16
 
17
  editor.windowManager.open({
18
  title: 'Anchor',
19
- body: {type: 'textbox', name: 'name', size: 40, label: 'Name', value: selectedNode.name || selectedNode.id},
20
  onsubmit: function(e) {
21
  editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', {
22
  id: e.data.name
12
 
13
  tinymce.PluginManager.add('anchor', function(editor) {
14
  function showDialog() {
15
+ var selectedNode = editor.selection.getNode(), name = '';
16
+
17
+ if (selectedNode.tagName == 'A') {
18
+ name = selectedNode.name || selectedNode.id || '';
19
+ }
20
 
21
  editor.windowManager.open({
22
  title: 'Anchor',
23
+ body: {type: 'textbox', name: 'name', size: 40, label: 'Name', value: name},
24
  onsubmit: function(e) {
25
  editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', {
26
  id: e.data.name
mce/anchor/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("anchor",function(n){function e(){var e=n.selection.getNode();n.windowManager.open({title:"Anchor",body:{type:"textbox",name:"name",size:40,label:"Name",value:e.name||e.id},onsubmit:function(e){n.execCommand("mceInsertContent",!1,n.dom.createHTML("a",{id:e.data.name}))}})}n.addButton("anchor",{icon:"anchor",tooltip:"Anchor",onclick:e,stateSelector:"a:not([href])"}),n.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",onclick:e})});
1
+ tinymce.PluginManager.add("anchor",function(n){function e(){var e=n.selection.getNode(),t="";"A"==e.tagName&&(t=e.name||e.id||""),n.windowManager.open({title:"Anchor",body:{type:"textbox",name:"name",size:40,label:"Name",value:t},onsubmit:function(e){n.execCommand("mceInsertContent",!1,n.dom.createHTML("a",{id:e.data.name}))}})}n.addButton("anchor",{icon:"anchor",tooltip:"Anchor",onclick:e,stateSelector:"a:not([href])"}),n.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",onclick:e})});
mce/code/plugin.js CHANGED
@@ -12,7 +12,7 @@
12
 
13
  tinymce.PluginManager.add('code', function(editor) {
14
  function showDialog() {
15
- editor.windowManager.open({
16
  title: "Source code",
17
  body: {
18
  type: 'textbox',
@@ -20,7 +20,6 @@ tinymce.PluginManager.add('code', function(editor) {
20
  multiline: true,
21
  minWidth: editor.getParam("code_dialog_width", 600),
22
  minHeight: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 500)),
23
- value: editor.getContent({source_view: true}),
24
  spellcheck: false,
25
  style: 'direction: ltr; text-align: left'
26
  },
@@ -38,6 +37,10 @@ tinymce.PluginManager.add('code', function(editor) {
38
  editor.nodeChanged();
39
  }
40
  });
 
 
 
 
41
  }
42
 
43
  editor.addCommand("mceCodeEditor", showDialog);
12
 
13
  tinymce.PluginManager.add('code', function(editor) {
14
  function showDialog() {
15
+ var win = editor.windowManager.open({
16
  title: "Source code",
17
  body: {
18
  type: 'textbox',
20
  multiline: true,
21
  minWidth: editor.getParam("code_dialog_width", 600),
22
  minHeight: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 500)),
 
23
  spellcheck: false,
24
  style: 'direction: ltr; text-align: left'
25
  },
37
  editor.nodeChanged();
38
  }
39
  });
40
+
41
+ // Gecko has a major performance issue with textarea
42
+ // contents so we need to set it when all reflows are done
43
+ win.find('#code').value(editor.getContent({source_view: true}));
44
  }
45
 
46
  editor.addCommand("mceCodeEditor", showDialog);
mce/code/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("code",function(e){function o(){e.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:e.getParam("code_dialog_width",600),minHeight:e.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),value:e.getContent({source_view:!0}),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(o){e.focus(),e.undoManager.transact(function(){e.setContent(o.data.code)}),e.selection.setCursorLocation(),e.nodeChanged()}})}e.addCommand("mceCodeEditor",o),e.addButton("code",{icon:"code",tooltip:"Source code",onclick:o}),e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:o})});
1
+ tinymce.PluginManager.add("code",function(e){function o(){var o=e.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:e.getParam("code_dialog_width",600),minHeight:e.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(o){e.focus(),e.undoManager.transact(function(){e.setContent(o.data.code)}),e.selection.setCursorLocation(),e.nodeChanged()}});o.find("#code").value(e.getContent({source_view:!0}))}e.addCommand("mceCodeEditor",o),e.addButton("code",{icon:"code",tooltip:"Source code",onclick:o}),e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:o})});
mce/contextmenu/plugin.js CHANGED
@@ -14,7 +14,7 @@ tinymce.PluginManager.add('contextmenu', function(editor) {
14
  var menu, contextmenuNeverUseNative = editor.settings.contextmenu_never_use_native;
15
 
16
  editor.on('contextmenu', function(e) {
17
- var contextmenu;
18
 
19
  // Block TinyMCE menu on ctrlKey
20
  if (e.ctrlKey && !contextmenuNeverUseNative) {
@@ -23,6 +23,16 @@ tinymce.PluginManager.add('contextmenu', function(editor) {
23
 
24
  e.preventDefault();
25
 
 
 
 
 
 
 
 
 
 
 
26
  contextmenu = editor.settings.contextmenu || 'link image inserttable | cell row column deletetable';
27
 
28
  // Render menu
14
  var menu, contextmenuNeverUseNative = editor.settings.contextmenu_never_use_native;
15
 
16
  editor.on('contextmenu', function(e) {
17
+ var contextmenu, doc = editor.getDoc();
18
 
19
  // Block TinyMCE menu on ctrlKey
20
  if (e.ctrlKey && !contextmenuNeverUseNative) {
23
 
24
  e.preventDefault();
25
 
26
+ /**
27
+ * WebKit/Blink on Mac has the odd behavior of selecting the target word or line this causes
28
+ * issues when for example inserting images see: #7022
29
+ */
30
+ if (tinymce.Env.mac && tinymce.Env.webkit) {
31
+ if (e.button == 2 && doc.caretRangeFromPoint) {
32
+ editor.selection.setRng(doc.caretRangeFromPoint(e.x, e.y));
33
+ }
34
+ }
35
+
36
  contextmenu = editor.settings.contextmenu || 'link image inserttable | cell row column deletetable';
37
 
38
  // Render menu
mce/contextmenu/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("contextmenu",function(e){var n,t=e.settings.contextmenu_never_use_native;e.on("contextmenu",function(i){var o;if(!i.ctrlKey||t){if(i.preventDefault(),o=e.settings.contextmenu||"link image inserttable | cell row column deletetable",n)n.show();else{var c=[];tinymce.each(o.split(/[ ,]/),function(n){var t=e.menuItems[n];"|"==n&&(t={text:n}),t&&(t.shortcut="",c.push(t))});for(var a=0;a<c.length;a++)"|"==c[a].text&&(0===a||a==c.length-1)&&c.splice(a,1);n=new tinymce.ui.Menu({items:c,context:"contextmenu"}).addClass("contextmenu").renderTo(),e.on("remove",function(){n.remove(),n=null})}var l={x:i.pageX,y:i.pageY};e.inline||(l=tinymce.DOM.getPos(e.getContentAreaContainer()),l.x+=i.clientX,l.y+=i.clientY),n.moveTo(l.x,l.y)}})});
1
+ tinymce.PluginManager.add("contextmenu",function(e){var t,n=e.settings.contextmenu_never_use_native;e.on("contextmenu",function(o){var i,c=e.getDoc();if(!o.ctrlKey||n){if(o.preventDefault(),tinymce.Env.mac&&tinymce.Env.webkit&&2==o.button&&c.caretRangeFromPoint&&e.selection.setRng(c.caretRangeFromPoint(o.x,o.y)),i=e.settings.contextmenu||"link image inserttable | cell row column deletetable",t)t.show();else{var a=[];tinymce.each(i.split(/[ ,]/),function(t){var n=e.menuItems[t];"|"==t&&(n={text:t}),n&&(n.shortcut="",a.push(n))});for(var r=0;r<a.length;r++)"|"==a[r].text&&(0===r||r==a.length-1)&&a.splice(r,1);t=new tinymce.ui.Menu({items:a,context:"contextmenu"}).addClass("contextmenu").renderTo(),e.on("remove",function(){t.remove(),t=null})}var m={x:o.pageX,y:o.pageY};e.inline||(m=tinymce.DOM.getPos(e.getContentAreaContainer()),m.x+=o.clientX,m.y+=o.clientY),t.moveTo(m.x,m.y)}})});
mce/importcss/plugin.js CHANGED
@@ -44,7 +44,7 @@ tinymce.PluginManager.add('importcss', function(editor) {
44
  try {
45
  rules = styleSheet.cssRules || styleSheet.rules;
46
  } catch (e) {
47
- // Firefox fails on rules to remote domain for example:
48
  // @import url(//fonts.googleapis.com/css?family=Pathway+Gothic+One);
49
  }
50
 
44
  try {
45
  rules = styleSheet.cssRules || styleSheet.rules;
46
  } catch (e) {
47
+ // Firefox fails on rules to remote domain for example:
48
  // @import url(//fonts.googleapis.com/css?family=Pathway+Gothic+One);
49
  }
50
 
mce/link/plugin.js CHANGED
@@ -22,72 +22,52 @@ tinymce.PluginManager.add('link', function(editor) {
22
  callback(tinymce.util.JSON.parse(text));
23
  }
24
  });
 
 
25
  } else {
26
  callback(linkList);
27
  }
28
  };
29
  }
30
 
31
- function showDialog(linkList) {
32
- var data = {}, selection = editor.selection, dom = editor.dom, selectedElm, anchorElm, initialText;
33
- var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl;
34
 
35
- function linkListChangeHandler(e) {
36
- var textCtrl = win.find('#text');
37
 
38
- if (!textCtrl.value() || (e.lastControl && textCtrl.value() == e.lastControl.text())) {
39
- textCtrl.value(e.control.text());
40
- }
41
-
42
- win.find('#href').value(e.control.value());
43
- }
44
-
45
- function buildLinkList() {
46
- var linkListItems = [{text: 'None', value: ''}];
47
-
48
- tinymce.each(linkList, function(link) {
49
- linkListItems.push({
50
- text: link.text || link.title,
51
- value: editor.convertURL(link.value || link.url, 'href'),
52
- menu: link.menu
53
- });
54
- });
55
 
56
- return linkListItems;
57
- }
 
 
58
 
59
- function applyPreview(items) {
60
- tinymce.each(items, function(item) {
61
- item.textStyle = function() {
62
- return editor.formatter.getCssText({inline: 'a', classes: [item.value]});
63
- };
64
  });
65
 
66
- return items;
67
  }
68
 
69
- function buildValues(listSettingName, dataItemName, defaultItems) {
70
- var selectedItem, items = [];
71
-
72
- tinymce.each(editor.settings[listSettingName] || defaultItems, function(target) {
73
- var item = {
74
- text: target.text || target.title,
75
- value: target.value
76
- };
77
 
78
- items.push(item);
 
 
79
 
80
- if (data[dataItemName] === target.value || (!selectedItem && target.selected)) {
81
- selectedItem = item;
82
- }
83
- });
84
 
85
- if (selectedItem && !data[dataItemName]) {
86
- data[dataItemName] = selectedItem.value;
87
- selectedItem.selected = true;
88
  }
89
 
90
- return items;
91
  }
92
 
93
  function buildAnchorListControl(url) {
@@ -118,13 +98,25 @@ tinymce.PluginManager.add('link', function(editor) {
118
  }
119
  }
120
 
121
- function urlChange() {
 
 
 
 
 
 
 
 
122
  if (linkListCtrl) {
123
  linkListCtrl.value(editor.convertURL(this.value(), 'href'));
124
  }
125
 
126
- if (!initialText && data.text.length === 0 && onlyText) {
127
- this.parent().parent().find('#text')[0].value(this.value());
 
 
 
 
128
  }
129
  }
130
 
@@ -159,10 +151,24 @@ tinymce.PluginManager.add('link', function(editor) {
159
 
160
  data.text = initialText = anchorElm ? (anchorElm.innerText || anchorElm.textContent) : selection.getContent({format: 'text'});
161
  data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : '';
162
- data.target = anchorElm ? dom.getAttrib(anchorElm, 'target') : (editor.settings.default_link_target || null);
163
- data.rel = anchorElm ? dom.getAttrib(anchorElm, 'rel') : null;
164
- data['class'] = anchorElm ? dom.getAttrib(anchorElm, 'class') : null;
165
- data.title = anchorElm ? dom.getAttrib(anchorElm, 'title') : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
  if (onlyText) {
168
  textListCtrl = {
@@ -180,7 +186,13 @@ tinymce.PluginManager.add('link', function(editor) {
180
  linkListCtrl = {
181
  type: 'listbox',
182
  label: 'Link list',
183
- values: buildLinkList(),
 
 
 
 
 
 
184
  onselect: linkListChangeHandler,
185
  value: editor.convertURL(data.href, 'href'),
186
  onPostRender: function() {
@@ -190,11 +202,18 @@ tinymce.PluginManager.add('link', function(editor) {
190
  }
191
 
192
  if (editor.settings.target_list !== false) {
 
 
 
 
 
 
 
193
  targetListCtrl = {
194
  name: 'target',
195
  type: 'listbox',
196
  label: 'Target',
197
- values: buildValues('target_list', 'target', [{text: 'None', value: ''}, {text: 'New window', value: '_blank'}])
198
  };
199
  }
200
 
@@ -203,7 +222,7 @@ tinymce.PluginManager.add('link', function(editor) {
203
  name: 'rel',
204
  type: 'listbox',
205
  label: 'Rel',
206
- values: buildValues('rel_list', 'rel', [{text: 'None', value: ''}])
207
  };
208
  }
209
 
@@ -212,7 +231,16 @@ tinymce.PluginManager.add('link', function(editor) {
212
  name: 'class',
213
  type: 'listbox',
214
  label: 'Class',
215
- values: applyPreview(buildValues('link_class_list', 'class'))
 
 
 
 
 
 
 
 
 
216
  };
217
  }
218
 
@@ -237,7 +265,7 @@ tinymce.PluginManager.add('link', function(editor) {
237
  autofocus: true,
238
  label: 'Url',
239
  onchange: urlChange,
240
- onkeyup: urlChange
241
  },
242
  textListCtrl,
243
  linkTitleCtrl,
@@ -356,6 +384,7 @@ tinymce.PluginManager.add('link', function(editor) {
356
  });
357
 
358
  editor.addShortcut('Ctrl+K', '', createLinkList(showDialog));
 
359
 
360
  this.showDialog = showDialog;
361
 
22
  callback(tinymce.util.JSON.parse(text));
23
  }
24
  });
25
+ } else if (typeof(linkList) == "function") {
26
+ linkList(callback);
27
  } else {
28
  callback(linkList);
29
  }
30
  };
31
  }
32
 
33
+ function buildListItems(inputList, itemCallback, startItems) {
34
+ function appendItems(values, output) {
35
+ output = output || [];
36
 
37
+ tinymce.each(values, function(item) {
38
+ var menuItem = {text: item.text || item.title};
39
 
40
+ if (item.menu) {
41
+ menuItem.menu = appendItems(item.menu);
42
+ } else {
43
+ menuItem.value = item.value;
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ if (itemCallback) {
46
+ itemCallback(menuItem);
47
+ }
48
+ }
49
 
50
+ output.push(menuItem);
 
 
 
 
51
  });
52
 
53
+ return output;
54
  }
55
 
56
+ return appendItems(inputList, startItems || []);
57
+ }
 
 
 
 
 
 
58
 
59
+ function showDialog(linkList) {
60
+ var data = {}, selection = editor.selection, dom = editor.dom, selectedElm, anchorElm, initialText;
61
+ var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value;
62
 
63
+ function linkListChangeHandler(e) {
64
+ var textCtrl = win.find('#text');
 
 
65
 
66
+ if (!textCtrl.value() || (e.lastControl && textCtrl.value() == e.lastControl.text())) {
67
+ textCtrl.value(e.control.text());
 
68
  }
69
 
70
+ win.find('#href').value(e.control.value());
71
  }
72
 
73
  function buildAnchorListControl(url) {
98
  }
99
  }
100
 
101
+ function updateText() {
102
+ if (!initialText && data.text.length === 0 && onlyText) {
103
+ this.parent().parent().find('#text')[0].value(this.value());
104
+ }
105
+ }
106
+
107
+ function urlChange(e) {
108
+ var meta = e.meta || {};
109
+
110
  if (linkListCtrl) {
111
  linkListCtrl.value(editor.convertURL(this.value(), 'href'));
112
  }
113
 
114
+ tinymce.each(e.meta, function(value, key) {
115
+ win.find('#' + key).value(value);
116
+ });
117
+
118
+ if (!meta.text) {
119
+ updateText.call(this);
120
  }
121
  }
122
 
151
 
152
  data.text = initialText = anchorElm ? (anchorElm.innerText || anchorElm.textContent) : selection.getContent({format: 'text'});
153
  data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : '';
154
+
155
+ if ((value = dom.getAttrib(anchorElm, 'target'))) {
156
+ data.target = value;
157
+ } else if (editor.settings.default_link_target) {
158
+ data.target = editor.settings.default_link_target;
159
+ }
160
+
161
+ if ((value = dom.getAttrib(anchorElm, 'rel'))) {
162
+ data.rel = value;
163
+ }
164
+
165
+ if ((value = dom.getAttrib(anchorElm, 'class'))) {
166
+ data['class'] = value;
167
+ }
168
+
169
+ if ((value = dom.getAttrib(anchorElm, 'title'))) {
170
+ data.title = value;
171
+ }
172
 
173
  if (onlyText) {
174
  textListCtrl = {
186
  linkListCtrl = {
187
  type: 'listbox',
188
  label: 'Link list',
189
+ values: buildListItems(
190
+ linkList,
191
+ function(item) {
192
+ item.value = editor.convertURL(item.value || item.url, 'href');
193
+ },
194
+ [{text: 'None', value: ''}]
195
+ ),
196
  onselect: linkListChangeHandler,
197
  value: editor.convertURL(data.href, 'href'),
198
  onPostRender: function() {
202
  }
203
 
204
  if (editor.settings.target_list !== false) {
205
+ if (!editor.settings.target_list) {
206
+ editor.settings.target_list = [
207
+ {text: 'None', value: ''},
208
+ {text: 'New window', value: '_blank'}
209
+ ];
210
+ }
211
+
212
  targetListCtrl = {
213
  name: 'target',
214
  type: 'listbox',
215
  label: 'Target',
216
+ values: buildListItems(editor.settings.target_list)
217
  };
218
  }
219
 
222
  name: 'rel',
223
  type: 'listbox',
224
  label: 'Rel',
225
+ values: buildListItems(editor.settings.rel_list)
226
  };
227
  }
228
 
231
  name: 'class',
232
  type: 'listbox',
233
  label: 'Class',
234
+ values: buildListItems(
235
+ editor.settings.link_class_list,
236
+ function(item) {
237
+ if (item.value) {
238
+ item.textStyle = function() {
239
+ return editor.formatter.getCssText({inline: 'a', classes: [item.value]});
240
+ };
241
+ }
242
+ }
243
+ )
244
  };
245
  }
246
 
265
  autofocus: true,
266
  label: 'Url',
267
  onchange: urlChange,
268
+ onkeyup: updateText
269
  },
270
  textListCtrl,
271
  linkTitleCtrl,
384
  });
385
 
386
  editor.addShortcut('Ctrl+K', '', createLinkList(showDialog));
387
+ editor.addCommand('mceLink', createLinkList(showDialog));
388
 
389
  this.showDialog = showDialog;
390
 
mce/link/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("link",function(t){function e(e){return function(){var n=t.settings.link_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(t){e(tinymce.util.JSON.parse(t))}}):e(n)}}function n(e){function n(t){var e=d.find("#text");(!e.value()||t.lastControl&&e.value()==t.lastControl.text())&&e.value(t.control.text()),d.find("#href").value(t.control.value())}function l(){var n=[{text:"None",value:""}];return tinymce.each(e,function(e){n.push({text:e.text||e.title,value:t.convertURL(e.value||e.url,"href"),menu:e.menu})}),n}function i(e){return tinymce.each(e,function(e){e.textStyle=function(){return t.formatter.getCssText({inline:"a",classes:[e.value]})}}),e}function a(e,n,l){var i,a=[];return tinymce.each(t.settings[e]||l,function(t){var e={text:t.text||t.title,value:t.value};a.push(e),(b[n]===t.value||!i&&t.selected)&&(i=e)}),i&&!b[n]&&(b[n]=i.value,i.selected=!0),a}function r(e){var l=[];return tinymce.each(t.dom.select("a:not([href])"),function(t){var n=t.name||t.id;n&&l.push({text:n,value:"#"+n,selected:-1!=e.indexOf("#"+n)})}),l.length?(l.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:l,onselect:n}):void 0}function o(){h&&h.value(t.convertURL(this.value(),"href")),!f&&0===b.text.length&&x&&this.parent().parent().find("#text")[0].value(this.value())}function s(t){var e=k.getContent();if(/</.test(e)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(e)||-1==e.indexOf("href=")))return!1;if(t){var n,l=t.childNodes;if(0===l.length)return!1;for(n=l.length-1;n>=0;n--)if(3!=l[n].nodeType)return!1}return!0}var u,c,f,d,x,v,h,g,m,p,y,b={},k=t.selection,w=t.dom;u=k.getNode(),c=w.getParent(u,"a[href]"),x=s(),b.text=f=c?c.innerText||c.textContent:k.getContent({format:"text"}),b.href=c?w.getAttrib(c,"href"):"",b.target=c?w.getAttrib(c,"target"):t.settings.default_link_target||null,b.rel=c?w.getAttrib(c,"rel"):null,b["class"]=c?w.getAttrib(c,"class"):null,b.title=c?w.getAttrib(c,"title"):"",x&&(v={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){b.text=this.value()}}),e&&(h={type:"listbox",label:"Link list",values:l(),onselect:n,value:t.convertURL(b.href,"href"),onPostRender:function(){h=this}}),t.settings.target_list!==!1&&(m={name:"target",type:"listbox",label:"Target",values:a("target_list","target",[{text:"None",value:""},{text:"New window",value:"_blank"}])}),t.settings.rel_list&&(g={name:"rel",type:"listbox",label:"Rel",values:a("rel_list","rel",[{text:"None",value:""}])}),t.settings.link_class_list&&(p={name:"class",type:"listbox",label:"Class",values:i(a("link_class_list","class"))}),t.settings.link_title!==!1&&(y={name:"title",type:"textbox",label:"Title",value:b.title}),d=t.windowManager.open({title:"Insert link",data:b,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:o,onkeyup:o},v,y,r(b.href),h,g,m,p],onSubmit:function(e){function n(e,n){var l=t.selection.getRng();window.setTimeout(function(){t.windowManager.confirm(e,function(e){t.selection.setRng(l),n(e)})},0)}function l(){var e={href:i,target:b.target?b.target:null,rel:b.rel?b.rel:null,"class":b["class"]?b["class"]:null,title:b.title?b.title:null};c?(t.focus(),x&&b.text!=f&&("innerText"in c?c.innerText=b.text:c.textContent=b.text),w.setAttribs(c,e),k.select(c),t.undoManager.add()):x?t.insertContent(w.createHTML("a",e,w.encode(b.text))):t.execCommand("mceInsertLink",!1,e)}var i;return b=tinymce.extend(b,e.data),(i=b.href)?i.indexOf("@")>0&&-1==i.indexOf("//")&&-1==i.indexOf("mailto:")?void n("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(t){t&&(i="mailto:"+i),l()}):/^\s*www\./i.test(i)?void n("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){t&&(i="http://"+i),l()}):void l():void t.execCommand("unlink")}})}t.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Ctrl+K",onclick:e(n),stateSelector:"a[href]"}),t.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),t.addShortcut("Ctrl+K","",e(n)),this.showDialog=n,t.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Ctrl+K",onclick:e(n),stateSelector:"a[href]",context:"insert",prependToContext:!0})});
1
+ tinymce.PluginManager.add("link",function(t){function e(e){return function(){var n=t.settings.link_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(t){e(tinymce.util.JSON.parse(t))}}):"function"==typeof n?n(e):e(n)}}function n(t,e,n){function i(t,n){return n=n||[],tinymce.each(t,function(t){var l={text:t.text||t.title};t.menu?l.menu=i(t.menu):(l.value=t.value,e&&e(l)),n.push(l)}),n}return i(t,n||[])}function i(e){function i(t){var e=f.find("#text");(!e.value()||t.lastControl&&e.value()==t.lastControl.text())&&e.value(t.control.text()),f.find("#href").value(t.control.value())}function l(e){var n=[];return tinymce.each(t.dom.select("a:not([href])"),function(t){var i=t.name||t.id;i&&n.push({text:i,value:"#"+i,selected:-1!=e.indexOf("#"+i)})}),n.length?(n.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:n,onselect:i}):void 0}function a(){!c&&0===y.text.length&&d&&this.parent().parent().find("#text")[0].value(this.value())}function o(e){var n=e.meta||{};x&&x.value(t.convertURL(this.value(),"href")),tinymce.each(e.meta,function(t,e){f.find("#"+e).value(t)}),n.text||a.call(this)}function r(t){var e=b.getContent();if(/</.test(e)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(e)||-1==e.indexOf("href=")))return!1;if(t){var n,i=t.childNodes;if(0===i.length)return!1;for(n=i.length-1;n>=0;n--)if(3!=i[n].nodeType)return!1}return!0}var s,u,c,f,d,g,x,v,h,m,p,k,y={},b=t.selection,_=t.dom;s=b.getNode(),u=_.getParent(s,"a[href]"),d=r(),y.text=c=u?u.innerText||u.textContent:b.getContent({format:"text"}),y.href=u?_.getAttrib(u,"href"):"",(k=_.getAttrib(u,"target"))?y.target=k:t.settings.default_link_target&&(y.target=t.settings.default_link_target),(k=_.getAttrib(u,"rel"))&&(y.rel=k),(k=_.getAttrib(u,"class"))&&(y["class"]=k),(k=_.getAttrib(u,"title"))&&(y.title=k),d&&(g={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){y.text=this.value()}}),e&&(x={type:"listbox",label:"Link list",values:n(e,function(e){e.value=t.convertURL(e.value||e.url,"href")},[{text:"None",value:""}]),onselect:i,value:t.convertURL(y.href,"href"),onPostRender:function(){x=this}}),t.settings.target_list!==!1&&(t.settings.target_list||(t.settings.target_list=[{text:"None",value:""},{text:"New window",value:"_blank"}]),h={name:"target",type:"listbox",label:"Target",values:n(t.settings.target_list)}),t.settings.rel_list&&(v={name:"rel",type:"listbox",label:"Rel",values:n(t.settings.rel_list)}),t.settings.link_class_list&&(m={name:"class",type:"listbox",label:"Class",values:n(t.settings.link_class_list,function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({inline:"a",classes:[e.value]})})})}),t.settings.link_title!==!1&&(p={name:"title",type:"textbox",label:"Title",value:y.title}),f=t.windowManager.open({title:"Insert link",data:y,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:o,onkeyup:a},g,p,l(y.href),x,v,h,m],onSubmit:function(e){function n(e,n){var i=t.selection.getRng();window.setTimeout(function(){t.windowManager.confirm(e,function(e){t.selection.setRng(i),n(e)})},0)}function i(){var e={href:l,target:y.target?y.target:null,rel:y.rel?y.rel:null,"class":y["class"]?y["class"]:null,title:y.title?y.title:null};u?(t.focus(),d&&y.text!=c&&("innerText"in u?u.innerText=y.text:u.textContent=y.text),_.setAttribs(u,e),b.select(u),t.undoManager.add()):d?t.insertContent(_.createHTML("a",e,_.encode(y.text))):t.execCommand("mceInsertLink",!1,e)}var l;return y=tinymce.extend(y,e.data),(l=y.href)?l.indexOf("@")>0&&-1==l.indexOf("//")&&-1==l.indexOf("mailto:")?void n("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(t){t&&(l="mailto:"+l),i()}):/^\s*www\./i.test(l)?void n("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){t&&(l="http://"+l),i()}):void i():void t.execCommand("unlink")}})}t.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Ctrl+K",onclick:e(i),stateSelector:"a[href]"}),t.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),t.addShortcut("Ctrl+K","",e(i)),t.addCommand("mceLink",e(i)),this.showDialog=i,t.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Ctrl+K",onclick:e(i),stateSelector:"a[href]",context:"insert",prependToContext:!0})});
mce/nonbreaking/plugin.js CHANGED
@@ -23,7 +23,7 @@ tinymce.PluginManager.add('nonbreaking', function(editor) {
23
  });
24
 
25
  editor.addButton('nonbreaking', {
26
- title: 'Insert nonbreaking space',
27
  cmd: 'mceNonBreaking'
28
  });
29
 
23
  });
24
 
25
  editor.addButton('nonbreaking', {
26
+ title: 'Nonbreaking space',
27
  cmd: 'mceNonBreaking'
28
  });
29
 
mce/nonbreaking/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("nonbreaking",function(n){var e=n.getParam("nonbreaking_force_tab");if(n.addCommand("mceNonBreaking",function(){n.insertContent(n.plugins.visualchars&&n.plugins.visualchars.state?'<span class="mce-nbsp">&nbsp;</span>':"&nbsp;"),n.dom.setAttrib(n.dom.select("span.mce-nbsp"),"data-mce-bogus","1")}),n.addButton("nonbreaking",{title:"Insert nonbreaking space",cmd:"mceNonBreaking"}),n.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"}),e){var a=+e>1?+e:3;n.on("keydown",function(e){if(9==e.keyCode){if(e.shiftKey)return;e.preventDefault();for(var t=0;a>t;t++)n.execCommand("mceNonBreaking")}})}});
1
+ tinymce.PluginManager.add("nonbreaking",function(n){var e=n.getParam("nonbreaking_force_tab");if(n.addCommand("mceNonBreaking",function(){n.insertContent(n.plugins.visualchars&&n.plugins.visualchars.state?'<span class="mce-nbsp">&nbsp;</span>':"&nbsp;"),n.dom.setAttrib(n.dom.select("span.mce-nbsp"),"data-mce-bogus","1")}),n.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),n.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"}),e){var a=+e>1?+e:3;n.on("keydown",function(e){if(9==e.keyCode){if(e.shiftKey)return;e.preventDefault();for(var t=0;a>t;t++)n.execCommand("mceNonBreaking")}})}});
mce/searchreplace/plugin.js CHANGED
@@ -378,9 +378,8 @@
378
  shortcut: 'Ctrl+F',
379
  onclick: showDialog
380
  });
381
-
382
- ed.addCommand("SearchReplace", showDialog);
383
 
 
384
  ed.shortcuts.add('Ctrl+F', '', showDialog);
385
  };
386
 
378
  shortcut: 'Ctrl+F',
379
  onclick: showDialog
380
  });
 
 
381
 
382
+ ed.addCommand("SearchReplace", showDialog);
383
  ed.shortcuts.add('Ctrl+F', '', showDialog);
384
  };
385
 
mce/table/plugin.js CHANGED
@@ -111,12 +111,13 @@ define("tinymce/tableplugin/TableGrid", [
111
  }
112
 
113
  return function(editor, table) {
114
- var grid, startPos, endPos, selectedCell, selection = editor.selection, dom = selection.dom;
115
 
116
  function buildGrid() {
117
  var startY = 0;
118
 
119
  grid = [];
 
120
 
121
  each(['thead', 'tbody', 'tfoot'], function(part) {
122
  var rows = dom.select('> ' + part + ' tr', table);
@@ -154,6 +155,8 @@ define("tinymce/tableplugin/TableGrid", [
154
  };
155
  }
156
  }
 
 
157
  });
158
  });
159
 
@@ -266,7 +269,7 @@ define("tinymce/tableplugin/TableGrid", [
266
  if (formatNode) {
267
  cell.appendChild(formatNode);
268
  } else {
269
- if (!Env.ie) {
270
  cell.innerHTML = '<br data-mce-bogus="1" />';
271
  }
272
  }
@@ -615,9 +618,7 @@ define("tinymce/tableplugin/TableGrid", [
615
  var rows;
616
 
617
  function deleteRow(tr) {
618
- var nextTr, pos, lastCell;
619
-
620
- nextTr = dom.getNext(tr, 'tr');
621
 
622
  // Move down row spanned cells
623
  each(tr.cells, function(cell) {
@@ -887,6 +888,34 @@ define("tinymce/tableplugin/TableGrid", [
887
  }
888
  }
889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
890
  table = table || dom.getParent(selection.getStart(), 'table');
891
 
892
  buildGrid();
@@ -911,7 +940,9 @@ define("tinymce/tableplugin/TableGrid", [
911
  pasteRows: pasteRows,
912
  getPos: getPos,
913
  setStartCell: setStartCell,
914
- setEndCell: setEndCell
 
 
915
  });
916
  };
917
  });
@@ -1157,7 +1188,7 @@ define("tinymce/tableplugin/Quirks", [
1157
  if (last.nodeValue.length > 0) {
1158
  break;
1159
  }
1160
- } else if (last.nodeType == 1 && !last.getAttribute('data-mce-bogus')) {
1161
  break;
1162
  }
1163
  }
@@ -1232,8 +1263,10 @@ define("tinymce/tableplugin/Quirks", [
1232
  }
1233
 
1234
  // Select the entire table cell. Nothing outside of the table cell should be selected.
1235
- rng.setEnd(end, end.nodeValue.length);
1236
- editor.selection.setRng(rng);
 
 
1237
  }
1238
 
1239
  editor.on('KeyDown', function() {
@@ -1314,13 +1347,13 @@ define("tinymce/tableplugin/CellSelection", [
1314
  "tinymce/util/Tools"
1315
  ], function(TableGrid, TreeWalker, Tools) {
1316
  return function(editor) {
1317
- var dom = editor.dom, tableGrid, startCell, startTable, hasCellSelection = true;
1318
 
1319
- function clear() {
1320
  // Restore selection possibilities
1321
  editor.getBody().style.webkitUserSelect = '';
1322
 
1323
- if (hasCellSelection) {
1324
  editor.dom.removeClass(
1325
  editor.dom.select('td.mce-item-selected,th.mce-item-selected'),
1326
  'mce-item-selected'
@@ -1333,6 +1366,10 @@ define("tinymce/tableplugin/CellSelection", [
1333
  function cellSelectionHandler(e) {
1334
  var sel, table, target = e.target;
1335
 
 
 
 
 
1336
  if (startCell && (tableGrid || target != startCell) && (target.nodeName == 'TD' || target.nodeName == 'TH')) {
1337
  table = dom.getParent(target, 'table');
1338
  if (table == startTable) {
@@ -1366,7 +1403,7 @@ define("tinymce/tableplugin/CellSelection", [
1366
 
1367
  // Add cell selection logic
1368
  editor.on('MouseDown', function(e) {
1369
- if (e.button != 2) {
1370
  clear();
1371
 
1372
  startCell = dom.getParent(e.target, 'td,th');
@@ -1381,7 +1418,7 @@ define("tinymce/tableplugin/CellSelection", [
1381
  });
1382
 
1383
  editor.on('MouseUp', function() {
1384
- var rng, sel = editor.selection, selectedCells, walker, node, lastNode, endNode;
1385
 
1386
  function setPoint(node, start) {
1387
  var walker = new TreeWalker(node, node);
@@ -1422,7 +1459,6 @@ define("tinymce/tableplugin/CellSelection", [
1422
  if (selectedCells.length > 0) {
1423
  rng = dom.createRng();
1424
  node = selectedCells[0];
1425
- endNode = selectedCells[selectedCells.length - 1];
1426
  rng.setStartBefore(node);
1427
  rng.setEndAfter(node);
1428
 
@@ -1449,9 +1485,14 @@ define("tinymce/tableplugin/CellSelection", [
1449
  }
1450
  });
1451
 
1452
- editor.on('KeyUp Drop', function() {
1453
- clear();
1454
  startCell = tableGrid = startTable = null;
 
 
 
 
 
1455
  });
1456
 
1457
  return {
@@ -1460,10 +1501,10 @@ define("tinymce/tableplugin/CellSelection", [
1460
  };
1461
  });
1462
 
1463
- // Included from: js/tinymce/plugins/table/classes/Plugin.js
1464
 
1465
  /**
1466
- * Plugin.js
1467
  *
1468
  * Copyright, Moxiecode Systems AB
1469
  * Released under LGPL License.
@@ -1473,24 +1514,83 @@ define("tinymce/tableplugin/CellSelection", [
1473
  */
1474
 
1475
  /**
1476
- * This class contains all core logic for the table plugin.
1477
  *
1478
- * @class tinymce.tableplugin.Plugin
1479
  * @private
1480
  */
1481
- define("tinymce/tableplugin/Plugin", [
1482
- "tinymce/tableplugin/TableGrid",
1483
- "tinymce/tableplugin/Quirks",
1484
- "tinymce/tableplugin/CellSelection",
1485
  "tinymce/util/Tools",
1486
- "tinymce/dom/TreeWalker",
1487
- "tinymce/Env",
1488
- "tinymce/PluginManager"
1489
- ], function(TableGrid, Quirks, CellSelection, Tools, TreeWalker, Env, PluginManager) {
1490
  var each = Tools.each;
1491
 
1492
- function Plugin(editor) {
1493
- var winMan, clipboardRows, self = this; // Might be selected cells on reload
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1494
 
1495
  function removePxSuffix(size) {
1496
  return size ? size.replace(/px$/, '') : "";
@@ -1509,129 +1609,260 @@ define("tinymce/tableplugin/Plugin", [
1509
  editor.formatter.remove('align' + name, {}, elm);
1510
  });
1511
  }
1512
-
1513
  function unApplyVAlign(elm) {
1514
-
1515
- console.log( elm );
1516
- return;
1517
-
1518
  each('top middle bottom'.split(' '), function(name) {
1519
  editor.formatter.remove('valign' + name, {}, elm);
1520
  });
1521
- }
1522
 
1523
- function tableDialog() {
1524
- var dom = editor.dom, tableElm, colsCtrl, rowsCtrl, data;
 
1525
 
1526
- tableElm = dom.getParent(editor.selection.getStart(), 'table');
 
1527
 
1528
- data = {
1529
- width: removePxSuffix(dom.getStyle(tableElm, 'width') || dom.getAttrib(tableElm, 'width')),
1530
- height: removePxSuffix(dom.getStyle(tableElm, 'height') || dom.getAttrib(tableElm, 'height')),
1531
- cellspacing: tableElm ? dom.getAttrib(tableElm, 'cellspacing') : '',
1532
- cellpadding: tableElm ? dom.getAttrib(tableElm, 'cellpadding') : '',
1533
- border: tableElm ? dom.getAttrib(tableElm, 'border') : '',
1534
- caption: !!dom.select('caption', tableElm)[0]
1535
- };
1536
 
1537
- each('left center right'.split(' '), function(name) {
1538
- if (editor.formatter.matchNode(tableElm, 'align' + name)) {
1539
- data.align = name;
1540
- }
1541
- });
1542
 
1543
- if (!tableElm) {
1544
- colsCtrl = {label: 'Cols', name: 'cols'};
1545
- rowsCtrl = {label: 'Rows', name: 'rows'};
 
1546
  }
1547
 
1548
- editor.windowManager.open({
1549
- title: "Table properties",
1550
- items: {
1551
- type: 'form',
1552
- layout: 'grid',
1553
- columns: 2,
1554
- data: data,
1555
- defaults: {
1556
- type: 'textbox',
1557
- maxWidth: 50
1558
- },
1559
- items: [
1560
- colsCtrl,
1561
- rowsCtrl,
1562
- {label: 'Width', name: 'width'},
1563
- {label: 'Height', name: 'height'},
1564
- {label: 'Cell spacing', name: 'cellspacing'},
1565
- {label: 'Cell padding', name: 'cellpadding'},
1566
- {label: 'Border', name: 'border'},
1567
- {label: 'Caption', name: 'caption', type: 'checkbox'},
1568
- {
1569
- label: 'Alignment',
1570
- minWidth: 90,
1571
- name: 'align',
1572
- type: 'listbox',
1573
- text: 'None',
1574
- maxWidth: null,
1575
- values: [
1576
- {text: 'None', value: ''},
1577
- {text: 'Left', value: 'left'},
1578
- {text: 'Center', value: 'center'},
1579
- {text: 'Right', value: 'right'}
1580
- ]
1581
- }
1582
- ]
1583
- },
1584
 
1585
- onsubmit: function() {
1586
- var data = this.toJSON(), captionElm;
 
1587
 
1588
- editor.undoManager.transact(function() {
1589
- if (!tableElm) {
1590
- tableElm = insertTable(data.cols || 1, data.rows || 1);
1591
- }
 
 
 
1592
 
1593
- editor.dom.setAttribs(tableElm, {
1594
- cellspacing: data.cellspacing,
1595
- cellpadding: data.cellpadding,
1596
- border: data.border
1597
- });
1598
 
1599
- editor.dom.setStyles(tableElm, {
1600
- width: addSizeSuffix(data.width),
1601
- height: addSizeSuffix(data.height)
1602
- });
1603
 
1604
- // Toggle caption on/off
1605
- captionElm = dom.select('caption', tableElm)[0];
 
1606
 
1607
- if (captionElm && !data.caption) {
1608
- dom.remove(captionElm);
1609
- }
1610
 
1611
- if (!captionElm && data.caption) {
1612
- captionElm = dom.create('caption');
1613
- captionElm.innerHTML = !Env.ie ? '<br data-mce-bogus="1"/>' : '\u00a0';
1614
- tableElm.insertBefore(captionElm, tableElm.firstChild);
1615
- }
1616
 
1617
- unApplyAlign(tableElm);
1618
- if (data.align) {
1619
- editor.formatter.apply('align' + data.align, {}, tableElm);
1620
- }
1621
 
1622
- editor.focus();
1623
- editor.addVisual();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1624
  });
1625
  }
1626
- });
1627
- }
 
 
1628
 
1629
- function mergeDialog(grid, cell) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1630
  editor.windowManager.open({
1631
  title: "Merge cells",
1632
  body: [
1633
- {label: 'Cols', name: 'cols', type: 'textbox', size: 10},
1634
- {label: 'Rows', name: 'rows', type: 'textbox', size: 10}
1635
  ],
1636
  onsubmit: function() {
1637
  var data = this.toJSON();
@@ -1641,10 +1872,49 @@ define("tinymce/tableplugin/Plugin", [
1641
  });
1642
  }
1643
  });
1644
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1645
 
1646
- function cellDialog() {
1647
- var dom = editor.dom, cellElm, data, cells = [];
 
 
 
 
 
 
 
 
1648
 
1649
  // Get selected cells or the current cell
1650
  cells = editor.dom.select('td.mce-item-selected,th.mce-item-selected');
@@ -1663,7 +1933,8 @@ define("tinymce/tableplugin/Plugin", [
1663
  data = {
1664
  width: removePxSuffix(dom.getStyle(cellElm, 'width') || dom.getAttrib(cellElm, 'width')),
1665
  height: removePxSuffix(dom.getStyle(cellElm, 'height') || dom.getAttrib(cellElm, 'height')),
1666
- scope: dom.getAttrib(cellElm, 'scope')
 
1667
  };
1668
 
1669
  data.type = cellElm.nodeName.toLowerCase();
@@ -1680,120 +1951,189 @@ define("tinymce/tableplugin/Plugin", [
1680
  }
1681
  });
1682
 
1683
- editor.windowManager.open({
1684
- title: "Cell properties",
1685
- items: {
1686
- type: 'form',
1687
- data: data,
1688
- layout: 'grid',
1689
- columns: 2,
1690
- defaults: {
1691
- type: 'textbox',
1692
- maxWidth: 50
1693
- },
1694
- items: [
1695
- {label: 'Width', name: 'width'},
1696
- {label: 'Height', name: 'height'},
1697
- {
1698
- label: 'Cell type',
1699
- name: 'type',
1700
- type: 'listbox',
1701
- text: 'None',
1702
- minWidth: 90,
1703
- maxWidth: null,
1704
- values: [
1705
- {text: 'Cell', value: 'td'},
1706
- {text: 'Header cell', value: 'th'}
1707
- ]
1708
- },
1709
- {
1710
- label: 'Scope',
1711
- name: 'scope',
1712
- type: 'listbox',
1713
- text: 'None',
1714
- minWidth: 90,
1715
- maxWidth: null,
1716
- values: [
1717
- {text: 'None', value: ''},
1718
- {text: 'Row', value: 'row'},
1719
- {text: 'Column', value: 'col'},
1720
- {text: 'Row group', value: 'rowgroup'},
1721
- {text: 'Column group', value: 'colgroup'}
1722
- ]
1723
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1724
  {
1725
- label: 'H Align',
1726
- name: 'align',
1727
- type: 'listbox',
1728
- text: 'None',
1729
- minWidth: 90,
1730
- maxWidth: null,
1731
- values: [
1732
- {text: 'None', value: ''},
1733
- {text: 'Left', value: 'left'},
1734
- {text: 'Center', value: 'center'},
1735
- {text: 'Right', value: 'right'}
1736
- ]
1737
  },
1738
- {
1739
- label: 'V Align',
1740
- name: 'valign',
1741
- type: 'listbox',
1742
- text: 'None',
1743
- minWidth: 90,
1744
- maxWidth: null,
1745
- values: [
1746
- {text: 'None', value: ''},
1747
- {text: 'Top', value: 'top'},
1748
- {text: 'Middle', value: 'middle'},
1749
- {text: 'Bottom', value: 'bottom'}
1750
- ]
1751
- }
1752
- ]
1753
- },
1754
 
1755
- onsubmit: function() {
1756
- var data = this.toJSON();
1757
 
1758
- editor.undoManager.transact(function() {
1759
- each(cells, function(cellElm) {
1760
- editor.dom.setAttrib(cellElm, 'scope', data.scope);
 
 
 
 
 
 
 
 
1761
 
1762
- editor.dom.setStyles(cellElm, {
1763
- width: addSizeSuffix(data.width),
1764
- height: addSizeSuffix(data.height)
1765
- });
1766
 
1767
- // Switch cell type
1768
- if (data.type && cellElm.nodeName.toLowerCase() != data.type) {
1769
- cellElm = dom.rename(cellElm, data.type);
1770
- }
1771
 
1772
- // Apply/remove alignment
1773
- unApplyAlign(cellElm);
1774
- if (data.align) {
1775
- editor.formatter.apply('align' + data.align, {}, cellElm);
1776
- }
 
 
 
 
 
 
 
1777
 
1778
- // Apply/remove vertical alignment
1779
- unApplyVAlign(cellElm);
1780
- if (data.valign) {
1781
-
1782
- console.log( data.valign )
1783
-
1784
- editor.formatter.apply('valign' + data.valign, {}, cellElm);
1785
- }
1786
-
1787
  });
1788
 
1789
- editor.focus();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1790
  });
1791
- }
1792
- });
1793
- }
1794
 
1795
- function rowDialog() {
1796
- var dom = editor.dom, tableElm, cellElm, rowElm, data, rows = [];
 
1797
 
1798
  tableElm = editor.dom.getParent(editor.selection.getStart(), 'table');
1799
  cellElm = editor.dom.getParent(editor.selection.getStart(), 'td,th');
@@ -1815,7 +2155,8 @@ define("tinymce/tableplugin/Plugin", [
1815
 
1816
  data = {
1817
  height: removePxSuffix(dom.getStyle(rowElm, 'height') || dom.getAttrib(rowElm, 'height')),
1818
- scope: dom.getAttrib(rowElm, 'scope')
 
1819
  };
1820
 
1821
  data.type = rowElm.parentNode.nodeName.toLowerCase();
@@ -1826,91 +2167,124 @@ define("tinymce/tableplugin/Plugin", [
1826
  }
1827
  });
1828
 
1829
- editor.windowManager.open({
1830
- title: "Row properties",
1831
- items: {
1832
- type: 'form',
1833
- data: data,
1834
- columns: 2,
1835
- defaults: {
1836
- type: 'textbox'
1837
- },
1838
- items: [
1839
- {
1840
- type: 'listbox',
1841
- name: 'type',
1842
- label: 'Row type',
1843
- text: 'None',
1844
- maxWidth: null,
1845
- values: [
1846
- {text: 'Header', value: 'thead'},
1847
- {text: 'Body', value: 'tbody'},
1848
- {text: 'Footer', value: 'tfoot'}
1849
- ]
1850
- },
1851
- {
1852
- type: 'listbox',
1853
- name: 'align',
1854
- label: 'Alignment',
1855
- text: 'None',
1856
- maxWidth: null,
1857
- values: [
1858
- {text: 'None', value: ''},
1859
- {text: 'Left', value: 'left'},
1860
- {text: 'Center', value: 'center'},
1861
- {text: 'Right', value: 'right'}
1862
- ]
1863
- },
1864
- {label: 'Height', name: 'height'}
1865
- ]
1866
- },
1867
-
1868
- onsubmit: function() {
1869
- var data = this.toJSON(), tableElm, oldParentElm, parentElm;
1870
 
1871
- editor.undoManager.transact(function() {
1872
- var toType = data.type;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1873
 
1874
- each(rows, function(rowElm) {
1875
- editor.dom.setAttrib(rowElm, 'scope', data.scope);
1876
 
1877
- editor.dom.setStyles(rowElm, {
1878
- height: addSizeSuffix(data.height)
1879
- });
 
 
 
 
 
 
 
 
 
1880
 
1881
- if (toType != rowElm.parentNode.nodeName.toLowerCase()) {
1882
- tableElm = dom.getParent(rowElm, 'table');
1883
-
1884
- oldParentElm = rowElm.parentNode;
1885
- parentElm = dom.select(toType, tableElm)[0];
1886
- if (!parentElm) {
1887
- parentElm = dom.create(toType);
1888
- if (tableElm.firstChild) {
1889
- tableElm.insertBefore(parentElm, tableElm.firstChild);
1890
- } else {
1891
- tableElm.appendChild(parentElm);
1892
- }
1893
- }
1894
 
1895
- parentElm.appendChild(rowElm);
1896
 
1897
- if (!oldParentElm.hasChildNodes()) {
1898
- dom.remove(oldParentElm);
1899
- }
1900
- }
 
 
 
 
 
1901
 
1902
- // Apply/remove alignment
1903
- unApplyAlign(rowElm);
1904
- if (data.align) {
1905
- editor.formatter.apply('align' + data.align, {}, rowElm);
1906
- }
1907
- });
 
 
 
 
 
 
 
 
 
 
 
1908
 
1909
- editor.focus();
1910
- });
1911
- }
1912
- });
1913
- }
1914
 
1915
  function cmd(command) {
1916
  return function() {
@@ -1919,7 +2293,7 @@ define("tinymce/tableplugin/Plugin", [
1919
  }
1920
 
1921
  function insertTable(cols, rows) {
1922
- var y, x, html;
1923
 
1924
  html = '<table id="__mce"><tbody>';
1925
 
@@ -1935,10 +2309,15 @@ define("tinymce/tableplugin/Plugin", [
1935
 
1936
  html += '</tbody></table>';
1937
 
1938
- editor.insertContent(html);
 
1939
 
1940
- var tableElm = editor.dom.get('__mce');
1941
- editor.dom.setAttrib(tableElm, 'id', null);
 
 
 
 
1942
 
1943
  return tableElm;
1944
  }
@@ -2024,7 +2403,7 @@ define("tinymce/tableplugin/Plugin", [
2024
  text: 'Insert table',
2025
  icon: 'table',
2026
  context: 'table',
2027
- onclick: tableDialog
2028
  });
2029
  } else {
2030
  editor.addMenuItem('inserttable', {
@@ -2036,7 +2415,7 @@ define("tinymce/tableplugin/Plugin", [
2036
  if (e.aria) {
2037
  this.parent().hideAll();
2038
  e.stopImmediatePropagation();
2039
- tableDialog();
2040
  }
2041
  },
2042
  onshow: function() {
@@ -2076,60 +2455,19 @@ define("tinymce/tableplugin/Plugin", [
2076
  }
2077
  },
2078
 
2079
- onkeydown: function(e) {
2080
- var x = this.lastX, y = this.lastY, isHandled;
2081
-
2082
- switch (e.keyCode) {
2083
- case 37: // DOM_VK_LEFT
2084
- if (x > 0) {
2085
- x--;
2086
- isHandled = true;
2087
- }
2088
- break;
2089
-
2090
- case 39: // DOM_VK_RIGHT
2091
- isHandled = true;
2092
-
2093
- if (x < 9) {
2094
- x++;
2095
- }
2096
- break;
2097
-
2098
- case 38: // DOM_VK_UP
2099
- isHandled = true;
2100
-
2101
- if (y > 0) {
2102
- y--;
2103
- }
2104
- break;
2105
-
2106
- case 40: // DOM_VK_DOWN
2107
- isHandled = true;
2108
-
2109
- if (y < 9) {
2110
- y++;
2111
- }
2112
- break;
2113
- }
2114
-
2115
- if (isHandled) {
2116
- e.preventDefault();
2117
- e.stopPropagation();
2118
-
2119
- selectGrid(x, y, e.control).focus();
2120
-
2121
- this.lastX = x;
2122
- this.lastY = y;
2123
- }
2124
- },
2125
-
2126
  onclick: function(e) {
 
 
2127
  if (e.target.tagName.toUpperCase() == 'A') {
2128
  e.preventDefault();
2129
  e.stopPropagation();
2130
- this.parent().cancel();
 
 
 
 
2131
 
2132
- insertTable(this.lastX + 1, this.lastY + 1);
2133
  }
2134
  }
2135
  }
@@ -2141,7 +2479,7 @@ define("tinymce/tableplugin/Plugin", [
2141
  text: 'Table properties',
2142
  context: 'table',
2143
  onPostRender: postRender,
2144
- onclick: tableDialog
2145
  });
2146
 
2147
  editor.addMenuItem('deletetable', {
@@ -2218,7 +2556,6 @@ define("tinymce/tableplugin/Plugin", [
2218
  self.quirks = new Quirks(editor);
2219
 
2220
  editor.on('Init', function() {
2221
- winMan = editor.windowManager;
2222
  self.cellSelection = new CellSelection(editor);
2223
  });
2224
 
@@ -2229,16 +2566,12 @@ define("tinymce/tableplugin/Plugin", [
2229
  },
2230
 
2231
  mceTableMergeCells: function(grid) {
2232
- var rowSpan, colSpan, cell;
2233
 
2234
  cell = editor.dom.getParent(editor.selection.getStart(), 'th,td');
2235
- if (cell) {
2236
- rowSpan = cell.rowSpan;
2237
- colSpan = cell.colSpan;
2238
- }
2239
 
2240
  if (!editor.dom.select('td.mce-item-selected,th.mce-item-selected').length) {
2241
- mergeDialog(grid, cell);
2242
  } else {
2243
  grid.merge();
2244
  }
@@ -2301,21 +2634,47 @@ define("tinymce/tableplugin/Plugin", [
2301
 
2302
  // Register dialog commands
2303
  each({
2304
- mceInsertTable: function() {
2305
- tableDialog();
 
2306
  },
2307
-
2308
- mceTableRowProps: rowDialog,
2309
- mceTableCellProps: cellDialog
2310
  }, function(func, name) {
2311
  editor.addCommand(name, function(ui, val) {
2312
  func(val);
2313
  });
2314
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2315
  }
2316
 
2317
  PluginManager.add('table', Plugin);
2318
  });
2319
-
2320
- expose(["tinymce/tableplugin/TableGrid","tinymce/tableplugin/Quirks","tinymce/tableplugin/CellSelection","tinymce/tableplugin/Plugin"]);
2321
- })(this);
111
  }
112
 
113
  return function(editor, table) {
114
+ var grid, gridWidth, startPos, endPos, selectedCell, selection = editor.selection, dom = selection.dom;
115
 
116
  function buildGrid() {
117
  var startY = 0;
118
 
119
  grid = [];
120
+ gridWidth = 0;
121
 
122
  each(['thead', 'tbody', 'tfoot'], function(part) {
123
  var rows = dom.select('> ' + part + ' tr', table);
155
  };
156
  }
157
  }
158
+
159
+ gridWidth = Math.max(gridWidth, x + 1);
160
  });
161
  });
162
 
269
  if (formatNode) {
270
  cell.appendChild(formatNode);
271
  } else {
272
+ if (!Env.ie || Env.ie > 10) {
273
  cell.innerHTML = '<br data-mce-bogus="1" />';
274
  }
275
  }
618
  var rows;
619
 
620
  function deleteRow(tr) {
621
+ var pos, lastCell;
 
 
622
 
623
  // Move down row spanned cells
624
  each(tr.cells, function(cell) {
888
  }
889
  }
890
 
891
+ function moveRelIdx(cellElm, delta) {
892
+ var pos, index, cell;
893
+
894
+ pos = getPos(cellElm);
895
+ index = pos.y * gridWidth + pos.x;
896
+
897
+ do {
898
+ index += delta;
899
+ cell = getCell(index % gridWidth, Math.floor(index / gridWidth));
900
+
901
+ if (!cell) {
902
+ break;
903
+ }
904
+
905
+ if (cell.elm != cellElm) {
906
+ selection.select(cell.elm, true);
907
+
908
+ if (dom.isEmpty(cell.elm)) {
909
+ selection.collapse(true);
910
+ }
911
+
912
+ return true;
913
+ }
914
+ } while (cell.elm == cellElm);
915
+
916
+ return false;
917
+ }
918
+
919
  table = table || dom.getParent(selection.getStart(), 'table');
920
 
921
  buildGrid();
940
  pasteRows: pasteRows,
941
  getPos: getPos,
942
  setStartCell: setStartCell,
943
+ setEndCell: setEndCell,
944
+ moveRelIdx: moveRelIdx,
945
+ refresh: buildGrid
946
  });
947
  };
948
  });
1188
  if (last.nodeValue.length > 0) {
1189
  break;
1190
  }
1191
+ } else if (last.nodeType == 1 && (last.tagName == 'BR' || !last.getAttribute('data-mce-bogus'))) {
1192
  break;
1193
  }
1194
  }
1263
  }
1264
 
1265
  // Select the entire table cell. Nothing outside of the table cell should be selected.
1266
+ if (end.nodeType == 3) {
1267
+ rng.setEnd(end, end.data.length);
1268
+ editor.selection.setRng(rng);
1269
+ }
1270
  }
1271
 
1272
  editor.on('KeyDown', function() {
1347
  "tinymce/util/Tools"
1348
  ], function(TableGrid, TreeWalker, Tools) {
1349
  return function(editor) {
1350
+ var dom = editor.dom, tableGrid, startCell, startTable, hasCellSelection = true, resizing;
1351
 
1352
+ function clear(force) {
1353
  // Restore selection possibilities
1354
  editor.getBody().style.webkitUserSelect = '';
1355
 
1356
+ if (force || hasCellSelection) {
1357
  editor.dom.removeClass(
1358
  editor.dom.select('td.mce-item-selected,th.mce-item-selected'),
1359
  'mce-item-selected'
1366
  function cellSelectionHandler(e) {
1367
  var sel, table, target = e.target;
1368
 
1369
+ if (resizing) {
1370
+ return;
1371
+ }
1372
+
1373
  if (startCell && (tableGrid || target != startCell) && (target.nodeName == 'TD' || target.nodeName == 'TH')) {
1374
  table = dom.getParent(target, 'table');
1375
  if (table == startTable) {
1403
 
1404
  // Add cell selection logic
1405
  editor.on('MouseDown', function(e) {
1406
+ if (e.button != 2 && !resizing) {
1407
  clear();
1408
 
1409
  startCell = dom.getParent(e.target, 'td,th');
1418
  });
1419
 
1420
  editor.on('MouseUp', function() {
1421
+ var rng, sel = editor.selection, selectedCells, walker, node, lastNode;
1422
 
1423
  function setPoint(node, start) {
1424
  var walker = new TreeWalker(node, node);
1459
  if (selectedCells.length > 0) {
1460
  rng = dom.createRng();
1461
  node = selectedCells[0];
 
1462
  rng.setStartBefore(node);
1463
  rng.setEndAfter(node);
1464
 
1485
  }
1486
  });
1487
 
1488
+ editor.on('KeyUp Drop SetContent', function(e) {
1489
+ clear(e.type == 'setcontent');
1490
  startCell = tableGrid = startTable = null;
1491
+ resizing = false;
1492
+ });
1493
+
1494
+ editor.on('ObjectResizeStart ObjectResized', function(e) {
1495
+ resizing = e.type != 'objectresized';
1496
  });
1497
 
1498
  return {
1501
  };
1502
  });
1503
 
1504
+ // Included from: js/tinymce/plugins/table/classes/Dialogs.js
1505
 
1506
  /**
1507
+ * Dialogs.js
1508
  *
1509
  * Copyright, Moxiecode Systems AB
1510
  * Released under LGPL License.
1514
  */
1515
 
1516
  /**
1517
+ * ...
1518
  *
1519
+ * @class tinymce.tableplugin.Dialogs
1520
  * @private
1521
  */
1522
+ define("tinymce/tableplugin/Dialogs", [
 
 
 
1523
  "tinymce/util/Tools",
1524
+ "tinymce/Env"
1525
+ ], function(Tools, Env) {
 
 
1526
  var each = Tools.each;
1527
 
1528
+ return function(editor) {
1529
+ var self = this;
1530
+
1531
+ function createColorPickAction() {
1532
+ var colorPickerCallback = editor.settings.color_picker_callback;
1533
+
1534
+ if (colorPickerCallback) {
1535
+ return function() {
1536
+ var self = this;
1537
+
1538
+ colorPickerCallback.call(
1539
+ editor,
1540
+ function(value) {
1541
+ self.value(value).fire('change');
1542
+ },
1543
+ self.value()
1544
+ );
1545
+ };
1546
+ }
1547
+ }
1548
+
1549
+ function createStyleForm(dom) {
1550
+ return {
1551
+ title: 'Advanced',
1552
+ type: 'form',
1553
+ defaults: {
1554
+ onchange: function() {
1555
+ updateStyle(dom, this.parents().reverse()[0], this.name() == "style");
1556
+ }
1557
+ },
1558
+ items: [
1559
+ {
1560
+ label: 'Style',
1561
+ name: 'style',
1562
+ type: 'textbox'
1563
+ },
1564
+
1565
+ {
1566
+ type: 'form',
1567
+ padding: 0,
1568
+ formItemDefaults: {
1569
+ layout: 'grid',
1570
+ alignH: ['start', 'right']
1571
+ },
1572
+ defaults: {
1573
+ size: 7
1574
+ },
1575
+ items: [
1576
+ {
1577
+ label: 'Border color',
1578
+ type: 'colorbox',
1579
+ name: 'borderColor',
1580
+ onaction: createColorPickAction()
1581
+ },
1582
+
1583
+ {
1584
+ label: 'Background color',
1585
+ type: 'colorbox',
1586
+ name: 'backgroundColor',
1587
+ onaction: createColorPickAction()
1588
+ }
1589
+ ]
1590
+ }
1591
+ ]
1592
+ };
1593
+ }
1594
 
1595
  function removePxSuffix(size) {
1596
  return size ? size.replace(/px$/, '') : "";
1609
  editor.formatter.remove('align' + name, {}, elm);
1610
  });
1611
  }
1612
+
1613
  function unApplyVAlign(elm) {
 
 
 
 
1614
  each('top middle bottom'.split(' '), function(name) {
1615
  editor.formatter.remove('valign' + name, {}, elm);
1616
  });
1617
+ }
1618
 
1619
+ function buildListItems(inputList, itemCallback, startItems) {
1620
+ function appendItems(values, output) {
1621
+ output = output || [];
1622
 
1623
+ Tools.each(values, function(item) {
1624
+ var menuItem = {text: item.text || item.title};
1625
 
1626
+ if (item.menu) {
1627
+ menuItem.menu = appendItems(item.menu);
1628
+ } else {
1629
+ menuItem.value = item.value;
 
 
 
 
1630
 
1631
+ if (itemCallback) {
1632
+ itemCallback(menuItem);
1633
+ }
1634
+ }
 
1635
 
1636
+ output.push(menuItem);
1637
+ });
1638
+
1639
+ return output;
1640
  }
1641
 
1642
+ return appendItems(inputList, startItems || []);
1643
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1644
 
1645
+ function updateStyle(dom, win, isStyleCtrl) {
1646
+ var data = win.toJSON();
1647
+ var css = dom.parseStyle(data.style);
1648
 
1649
+ if (isStyleCtrl) {
1650
+ win.find('#borderColor').value(css["border-color"] || '')[0].fire('change');
1651
+ win.find('#backgroundColor').value(css["background-color"] || '')[0].fire('change');
1652
+ } else {
1653
+ css["border-color"] = data.borderColor;
1654
+ css["background-color"] = data.backgroundColor;
1655
+ }
1656
 
1657
+ win.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css))));
1658
+ }
 
 
 
1659
 
1660
+ function appendStylesToData(dom, data, elm) {
1661
+ var css = dom.parseStyle(dom.getAttrib(elm, 'style'));
 
 
1662
 
1663
+ if (css["border-color"]) {
1664
+ data.borderColor = css["border-color"];
1665
+ }
1666
 
1667
+ if (css["background-color"]) {
1668
+ data.backgroundColor = css["background-color"];
1669
+ }
1670
 
1671
+ data.style = dom.serializeStyle(css);
1672
+ }
 
 
 
1673
 
1674
+ self.tableProps = function() {
1675
+ self.table(true);
1676
+ };
 
1677
 
1678
+ self.table = function(isProps) {
1679
+ var dom = editor.dom, tableElm, colsCtrl, rowsCtrl, classListCtrl, data = {}, generalTableForm;
1680
+
1681
+ function onSubmitTableForm() {
1682
+ var captionElm;
1683
+
1684
+ updateStyle(dom, this);
1685
+ data = Tools.extend(data, this.toJSON());
1686
+
1687
+ Tools.each('backgroundColor borderColor'.split(' '), function(name) {
1688
+ delete data[name];
1689
+ });
1690
+
1691
+ if (data["class"] === false) {
1692
+ delete data["class"];
1693
+ }
1694
+
1695
+ editor.undoManager.transact(function() {
1696
+ if (!tableElm) {
1697
+ tableElm = editor.plugins.table.insertTable(data.cols || 1, data.rows || 1);
1698
+ }
1699
+
1700
+ editor.dom.setAttribs(tableElm, {
1701
+ cellspacing: data.cellspacing,
1702
+ cellpadding: data.cellpadding,
1703
+ border: data.border,
1704
+ style: data.style,
1705
+ 'class': data['class']
1706
+ });
1707
+
1708
+ if (dom.getAttrib(tableElm, 'width')) {
1709
+ dom.setAttrib(tableElm, 'width', removePxSuffix(data.width));
1710
+ } else {
1711
+ dom.setStyle(tableElm, 'width', addSizeSuffix(data.width));
1712
+ }
1713
+
1714
+ dom.setStyle(tableElm, 'height', addSizeSuffix(data.height));
1715
+
1716
+ // Toggle caption on/off
1717
+ captionElm = dom.select('caption', tableElm)[0];
1718
+
1719
+ if (captionElm && !data.caption) {
1720
+ dom.remove(captionElm);
1721
+ }
1722
+
1723
+ if (!captionElm && data.caption) {
1724
+ captionElm = dom.create('caption');
1725
+ captionElm.innerHTML = !Env.ie ? '<br data-mce-bogus="1"/>' : '\u00a0';
1726
+ tableElm.insertBefore(captionElm, tableElm.firstChild);
1727
+ }
1728
+
1729
+ unApplyAlign(tableElm);
1730
+ if (data.align) {
1731
+ editor.formatter.apply('align' + data.align, {}, tableElm);
1732
+ }
1733
+
1734
+ editor.focus();
1735
+ editor.addVisual();
1736
+ });
1737
+ }
1738
+
1739
+ if (isProps === true) {
1740
+ tableElm = dom.getParent(editor.selection.getStart(), 'table');
1741
+
1742
+ if (tableElm) {
1743
+ data = {
1744
+ width: removePxSuffix(dom.getStyle(tableElm, 'width') || dom.getAttrib(tableElm, 'width')),
1745
+ height: removePxSuffix(dom.getStyle(tableElm, 'height') || dom.getAttrib(tableElm, 'height')),
1746
+ cellspacing: tableElm ? dom.getAttrib(tableElm, 'cellspacing') : '',
1747
+ cellpadding: tableElm ? dom.getAttrib(tableElm, 'cellpadding') : '',
1748
+ border: tableElm ? dom.getAttrib(tableElm, 'border') : '',
1749
+ caption: !!dom.select('caption', tableElm)[0],
1750
+ 'class': dom.getAttrib(tableElm, 'class')
1751
+ };
1752
+
1753
+ each('left center right'.split(' '), function(name) {
1754
+ if (editor.formatter.matchNode(tableElm, 'align' + name)) {
1755
+ data.align = name;
1756
+ }
1757
  });
1758
  }
1759
+ } else {
1760
+ colsCtrl = {label: 'Cols', name: 'cols'};
1761
+ rowsCtrl = {label: 'Rows', name: 'rows'};
1762
+ }
1763
 
1764
+ if (editor.settings.table_class_list) {
1765
+ if (data["class"]) {
1766
+ data["class"] = data["class"].replace(/\s*mce\-item\-table\s*/g, '');
1767
+ }
1768
+
1769
+ classListCtrl = {
1770
+ name: 'class',
1771
+ type: 'listbox',
1772
+ label: 'Class',
1773
+ values: buildListItems(
1774
+ editor.settings.table_class_list,
1775
+ function(item) {
1776
+ if (item.value) {
1777
+ item.textStyle = function() {
1778
+ return editor.formatter.getCssText({block: 'table', classes: [item.value]});
1779
+ };
1780
+ }
1781
+ }
1782
+ )
1783
+ };
1784
+ }
1785
+
1786
+ generalTableForm = {
1787
+ type: 'form',
1788
+ layout: 'flex',
1789
+ direction: 'column',
1790
+ labelGapCalc: 'children',
1791
+ padding: 0,
1792
+ items: [
1793
+ {
1794
+ type: 'form',
1795
+ labelGapCalc: false,
1796
+ padding: 0,
1797
+ layout: 'grid',
1798
+ columns: 2,
1799
+ defaults: {
1800
+ type: 'textbox',
1801
+ maxWidth: 50
1802
+ },
1803
+ items: [
1804
+ colsCtrl,
1805
+ rowsCtrl,
1806
+ {label: 'Width', name: 'width'},
1807
+ {label: 'Height', name: 'height'},
1808
+ {label: 'Cell spacing', name: 'cellspacing'},
1809
+ {label: 'Cell padding', name: 'cellpadding'},
1810
+ {label: 'Border', name: 'border'},
1811
+ {label: 'Caption', name: 'caption', type: 'checkbox'}
1812
+ ]
1813
+ },
1814
+
1815
+ {
1816
+ label: 'Alignment',
1817
+ name: 'align',
1818
+ type: 'listbox',
1819
+ text: 'None',
1820
+ values: [
1821
+ {text: 'None', value: ''},
1822
+ {text: 'Left', value: 'left'},
1823
+ {text: 'Center', value: 'center'},
1824
+ {text: 'Right', value: 'right'}
1825
+ ]
1826
+ },
1827
+
1828
+ classListCtrl
1829
+ ]
1830
+ };
1831
+
1832
+ if (editor.settings.table_advtab !== false) {
1833
+ appendStylesToData(dom, data, tableElm);
1834
+
1835
+ editor.windowManager.open({
1836
+ title: "Table properties",
1837
+ data: data,
1838
+ bodyType: 'tabpanel',
1839
+ body: [
1840
+ {
1841
+ title: 'General',
1842
+ type: 'form',
1843
+ items: generalTableForm
1844
+ },
1845
+ createStyleForm(dom)
1846
+ ],
1847
+
1848
+ onsubmit: onSubmitTableForm
1849
+ });
1850
+ } else {
1851
+ editor.windowManager.open({
1852
+ title: "Table properties",
1853
+ data: data,
1854
+ body: generalTableForm,
1855
+ onsubmit: onSubmitTableForm
1856
+ });
1857
+ }
1858
+ };
1859
+
1860
+ self.merge = function(grid, cell) {
1861
  editor.windowManager.open({
1862
  title: "Merge cells",
1863
  body: [
1864
+ {label: 'Cols', name: 'cols', type: 'textbox', value: '1', size: 10},
1865
+ {label: 'Rows', name: 'rows', type: 'textbox', value: '1', size: 10}
1866
  ],
1867
  onsubmit: function() {
1868
  var data = this.toJSON();
1872
  });
1873
  }
1874
  });
1875
+ };
1876
+
1877
+ self.cell = function() {
1878
+ var dom = editor.dom, cellElm, data, classListCtrl, cells = [];
1879
+
1880
+ function onSubmitCellForm() {
1881
+ updateStyle(dom, this);
1882
+ data = Tools.extend(data, this.toJSON());
1883
+
1884
+ editor.undoManager.transact(function() {
1885
+ each(cells, function(cellElm) {
1886
+ editor.dom.setAttribs(cellElm, {
1887
+ scope: data.scope,
1888
+ style: data.style,
1889
+ 'class': data['class']
1890
+ });
1891
+
1892
+ editor.dom.setStyles(cellElm, {
1893
+ width: addSizeSuffix(data.width),
1894
+ height: addSizeSuffix(data.height)
1895
+ });
1896
+
1897
+ // Switch cell type
1898
+ if (data.type && cellElm.nodeName.toLowerCase() != data.type) {
1899
+ cellElm = dom.rename(cellElm, data.type);
1900
+ }
1901
+
1902
+ // Apply/remove alignment
1903
+ unApplyAlign(cellElm);
1904
+ if (data.align) {
1905
+ editor.formatter.apply('align' + data.align, {}, cellElm);
1906
+ }
1907
 
1908
+ // Apply/remove vertical alignment
1909
+ unApplyVAlign(cellElm);
1910
+ if (data.valign) {
1911
+ editor.formatter.apply('valign' + data.valign, {}, cellElm);
1912
+ }
1913
+ });
1914
+
1915
+ editor.focus();
1916
+ });
1917
+ }
1918
 
1919
  // Get selected cells or the current cell
1920
  cells = editor.dom.select('td.mce-item-selected,th.mce-item-selected');
1933
  data = {
1934
  width: removePxSuffix(dom.getStyle(cellElm, 'width') || dom.getAttrib(cellElm, 'width')),
1935
  height: removePxSuffix(dom.getStyle(cellElm, 'height') || dom.getAttrib(cellElm, 'height')),
1936
+ scope: dom.getAttrib(cellElm, 'scope'),
1937
+ 'class': dom.getAttrib(cellElm, 'class')
1938
  };
1939
 
1940
  data.type = cellElm.nodeName.toLowerCase();
1951
  }
1952
  });
1953
 
1954
+ if (editor.settings.table_cell_class_list) {
1955
+ classListCtrl = {
1956
+ name: 'class',
1957
+ type: 'listbox',
1958
+ label: 'Class',
1959
+ values: buildListItems(
1960
+ editor.settings.table_cell_class_list,
1961
+ function(item) {
1962
+ if (item.value) {
1963
+ item.textStyle = function() {
1964
+ return editor.formatter.getCssText({block: 'td', classes: [item.value]});
1965
+ };
1966
+ }
1967
+ }
1968
+ )
1969
+ };
1970
+ }
1971
+
1972
+ var generalCellForm = {
1973
+ type: 'form',
1974
+ layout: 'flex',
1975
+ direction: 'column',
1976
+ labelGapCalc: 'children',
1977
+ padding: 0,
1978
+ items: [
1979
+ {
1980
+ type: 'form',
1981
+ layout: 'grid',
1982
+ columns: 2,
1983
+ labelGapCalc: false,
1984
+ padding: 0,
1985
+ defaults: {
1986
+ type: 'textbox',
1987
+ maxWidth: 50
 
 
 
 
 
 
1988
  },
1989
+ items: [
1990
+ {label: 'Width', name: 'width'},
1991
+ {label: 'Height', name: 'height'},
1992
+ {
1993
+ label: 'Cell type',
1994
+ name: 'type',
1995
+ type: 'listbox',
1996
+ text: 'None',
1997
+ minWidth: 90,
1998
+ maxWidth: null,
1999
+ values: [
2000
+ {text: 'Cell', value: 'td'},
2001
+ {text: 'Header cell', value: 'th'}
2002
+ ]
2003
+ },
2004
+ {
2005
+ label: 'Scope',
2006
+ name: 'scope',
2007
+ type: 'listbox',
2008
+ text: 'None',
2009
+ minWidth: 90,
2010
+ maxWidth: null,
2011
+ values: [
2012
+ {text: 'None', value: ''},
2013
+ {text: 'Row', value: 'row'},
2014
+ {text: 'Column', value: 'col'},
2015
+ {text: 'Row group', value: 'rowgroup'},
2016
+ {text: 'Column group', value: 'colgroup'}
2017
+ ]
2018
+ },
2019
+ {
2020
+ label: 'H Align',
2021
+ name: 'align',
2022
+ type: 'listbox',
2023
+ text: 'None',
2024
+ minWidth: 90,
2025
+ maxWidth: null,
2026
+ values: [
2027
+ {text: 'None', value: ''},
2028
+ {text: 'Left', value: 'left'},
2029
+ {text: 'Center', value: 'center'},
2030
+ {text: 'Right', value: 'right'}
2031
+ ]
2032
+ },
2033
+ {
2034
+ label: 'V Align',
2035
+ name: 'valign',
2036
+ type: 'listbox',
2037
+ text: 'None',
2038
+ minWidth: 90,
2039
+ maxWidth: null,
2040
+ values: [
2041
+ {text: 'None', value: ''},
2042
+ {text: 'Top', value: 'top'},
2043
+ {text: 'Middle', value: 'middle'},
2044
+ {text: 'Bottom', value: 'bottom'}
2045
+ ]
2046
+ }
2047
+ ]
2048
+ },
2049
+
2050
+ classListCtrl
2051
+ ]
2052
+ };
2053
+
2054
+ if (editor.settings.table_cell_advtab !== false) {
2055
+ appendStylesToData(dom, data, cellElm);
2056
+
2057
+ editor.windowManager.open({
2058
+ title: "Cell properties",
2059
+ bodyType: 'tabpanel',
2060
+ data: data,
2061
+ body: [
2062
  {
2063
+ title: 'General',
2064
+ type: 'form',
2065
+ items: generalCellForm
 
 
 
 
 
 
 
 
 
2066
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2067
 
2068
+ createStyleForm(dom)
2069
+ ],
2070
 
2071
+ onsubmit: onSubmitCellForm
2072
+ });
2073
+ } else {
2074
+ editor.windowManager.open({
2075
+ title: "Cell properties",
2076
+ data: data,
2077
+ body: generalCellForm,
2078
+ onsubmit: onSubmitCellForm
2079
+ });
2080
+ }
2081
+ };
2082
 
2083
+ self.row = function() {
2084
+ var dom = editor.dom, tableElm, cellElm, rowElm, classListCtrl, data, rows = [], generalRowForm;
 
 
2085
 
2086
+ function onSubmitRowForm() {
2087
+ var tableElm, oldParentElm, parentElm;
 
 
2088
 
2089
+ updateStyle(dom, this);
2090
+ data = Tools.extend(data, this.toJSON());
2091
+
2092
+ editor.undoManager.transact(function() {
2093
+ var toType = data.type;
2094
+
2095
+ each(rows, function(rowElm) {
2096
+ editor.dom.setAttribs(rowElm, {
2097
+ scope: data.scope,
2098
+ style: data.style,
2099
+ 'class': data['class']
2100
+ });
2101
 
2102
+ editor.dom.setStyles(rowElm, {
2103
+ height: addSizeSuffix(data.height)
 
 
 
 
 
 
 
2104
  });
2105
 
2106
+ if (toType != rowElm.parentNode.nodeName.toLowerCase()) {
2107
+ tableElm = dom.getParent(rowElm, 'table');
2108
+
2109
+ oldParentElm = rowElm.parentNode;
2110
+ parentElm = dom.select(toType, tableElm)[0];
2111
+ if (!parentElm) {
2112
+ parentElm = dom.create(toType);
2113
+ if (tableElm.firstChild) {
2114
+ tableElm.insertBefore(parentElm, tableElm.firstChild);
2115
+ } else {
2116
+ tableElm.appendChild(parentElm);
2117
+ }
2118
+ }
2119
+
2120
+ parentElm.appendChild(rowElm);
2121
+
2122
+ if (!oldParentElm.hasChildNodes()) {
2123
+ dom.remove(oldParentElm);
2124
+ }
2125
+ }
2126
+
2127
+ // Apply/remove alignment
2128
+ unApplyAlign(rowElm);
2129
+ if (data.align) {
2130
+ editor.formatter.apply('align' + data.align, {}, rowElm);
2131
+ }
2132
  });
 
 
 
2133
 
2134
+ editor.focus();
2135
+ });
2136
+ }
2137
 
2138
  tableElm = editor.dom.getParent(editor.selection.getStart(), 'table');
2139
  cellElm = editor.dom.getParent(editor.selection.getStart(), 'td,th');
2155
 
2156
  data = {
2157
  height: removePxSuffix(dom.getStyle(rowElm, 'height') || dom.getAttrib(rowElm, 'height')),
2158
+ scope: dom.getAttrib(rowElm, 'scope'),
2159
+ 'class': dom.getAttrib(rowElm, 'class')
2160
  };
2161
 
2162
  data.type = rowElm.parentNode.nodeName.toLowerCase();
2167
  }
2168
  });
2169
 
2170
+ if (editor.settings.table_row_class_list) {
2171
+ classListCtrl = {
2172
+ name: 'class',
2173
+ type: 'listbox',
2174
+ label: 'Class',
2175
+ values: buildListItems(
2176
+ editor.settings.table_row_class_list,
2177
+ function(item) {
2178
+ if (item.value) {
2179
+ item.textStyle = function() {
2180
+ return editor.formatter.getCssText({block: 'tr', classes: [item.value]});
2181
+ };
2182
+ }
2183
+ }
2184
+ )
2185
+ };
2186
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2187
 
2188
+ generalRowForm = {
2189
+ type: 'form',
2190
+ columns: 2,
2191
+ padding: 0,
2192
+ defaults: {
2193
+ type: 'textbox'
2194
+ },
2195
+ items: [
2196
+ {
2197
+ type: 'listbox',
2198
+ name: 'type',
2199
+ label: 'Row type',
2200
+ text: 'None',
2201
+ maxWidth: null,
2202
+ values: [
2203
+ {text: 'Header', value: 'thead'},
2204
+ {text: 'Body', value: 'tbody'},
2205
+ {text: 'Footer', value: 'tfoot'}
2206
+ ]
2207
+ },
2208
+ {
2209
+ type: 'listbox',
2210
+ name: 'align',
2211
+ label: 'Alignment',
2212
+ text: 'None',
2213
+ maxWidth: null,
2214
+ values: [
2215
+ {text: 'None', value: ''},
2216
+ {text: 'Left', value: 'left'},
2217
+ {text: 'Center', value: 'center'},
2218
+ {text: 'Right', value: 'right'}
2219
+ ]
2220
+ },
2221
+ {label: 'Height', name: 'height'},
2222
+ classListCtrl
2223
+ ]
2224
+ };
2225
 
2226
+ if (editor.settings.table_row_advtab !== false) {
2227
+ appendStylesToData(dom, data, rowElm);
2228
 
2229
+ editor.windowManager.open({
2230
+ title: "Row properties",
2231
+ data: data,
2232
+ bodyType: 'tabpanel',
2233
+ body: [
2234
+ {
2235
+ title: 'General',
2236
+ type: 'form',
2237
+ items: generalRowForm
2238
+ },
2239
+ createStyleForm(dom)
2240
+ ],
2241
 
2242
+ onsubmit: onSubmitRowForm
2243
+ });
2244
+ } else {
2245
+ editor.windowManager.open({
2246
+ title: "Row properties",
2247
+ data: data,
2248
+ body: generalRowForm,
2249
+ onsubmit: onSubmitRowForm
2250
+ });
2251
+ }
2252
+ };
2253
+ };
2254
+ });
2255
 
2256
+ // Included from: js/tinymce/plugins/table/classes/Plugin.js
2257
 
2258
+ /**
2259
+ * Plugin.js
2260
+ *
2261
+ * Copyright, Moxiecode Systems AB
2262
+ * Released under LGPL License.
2263
+ *
2264
+ * License: http://www.tinymce.com/license
2265
+ * Contributing: http://www.tinymce.com/contributing
2266
+ */
2267
 
2268
+ /**
2269
+ * This class contains all core logic for the table plugin.
2270
+ *
2271
+ * @class tinymce.tableplugin.Plugin
2272
+ * @private
2273
+ */
2274
+ define("tinymce/tableplugin/Plugin", [
2275
+ "tinymce/tableplugin/TableGrid",
2276
+ "tinymce/tableplugin/Quirks",
2277
+ "tinymce/tableplugin/CellSelection",
2278
+ "tinymce/tableplugin/Dialogs",
2279
+ "tinymce/util/Tools",
2280
+ "tinymce/dom/TreeWalker",
2281
+ "tinymce/Env",
2282
+ "tinymce/PluginManager"
2283
+ ], function(TableGrid, Quirks, CellSelection, Dialogs, Tools, TreeWalker, Env, PluginManager) {
2284
+ var each = Tools.each;
2285
 
2286
+ function Plugin(editor) {
2287
+ var clipboardRows, self = this, dialogs = new Dialogs(editor);
 
 
 
2288
 
2289
  function cmd(command) {
2290
  return function() {
2293
  }
2294
 
2295
  function insertTable(cols, rows) {
2296
+ var y, x, html, tableElm;
2297
 
2298
  html = '<table id="__mce"><tbody>';
2299
 
2309
 
2310
  html += '</tbody></table>';
2311
 
2312
+ editor.undoManager.transact(function() {
2313
+ editor.insertContent(html);
2314
 
2315
+ tableElm = editor.dom.get('__mce');
2316
+ editor.dom.setAttrib(tableElm, 'id', null);
2317
+
2318
+ editor.dom.setAttribs(tableElm, editor.settings.table_default_attributes || {});
2319
+ editor.dom.setStyles(tableElm, editor.settings.table_default_styles || {});
2320
+ });
2321
 
2322
  return tableElm;
2323
  }
2403
  text: 'Insert table',
2404
  icon: 'table',
2405
  context: 'table',
2406
+ onclick: dialogs.table
2407
  });
2408
  } else {
2409
  editor.addMenuItem('inserttable', {
2415
  if (e.aria) {
2416
  this.parent().hideAll();
2417
  e.stopImmediatePropagation();
2418
+ dialogs.table();
2419
  }
2420
  },
2421
  onshow: function() {
2455
  }
2456
  },
2457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2458
  onclick: function(e) {
2459
+ var self = this;
2460
+
2461
  if (e.target.tagName.toUpperCase() == 'A') {
2462
  e.preventDefault();
2463
  e.stopPropagation();
2464
+ self.parent().cancel();
2465
+
2466
+ editor.undoManager.transact(function() {
2467
+ insertTable(self.lastX + 1, self.lastY + 1);
2468
+ });
2469
 
2470
+ editor.addVisual();
2471
  }
2472
  }
2473
  }
2479
  text: 'Table properties',
2480
  context: 'table',
2481
  onPostRender: postRender,
2482
+ onclick: dialogs.tableProps
2483
  });
2484
 
2485
  editor.addMenuItem('deletetable', {
2556
  self.quirks = new Quirks(editor);
2557
 
2558
  editor.on('Init', function() {
 
2559
  self.cellSelection = new CellSelection(editor);
2560
  });
2561
 
2566
  },
2567
 
2568
  mceTableMergeCells: function(grid) {
2569
+ var cell;
2570
 
2571
  cell = editor.dom.getParent(editor.selection.getStart(), 'th,td');
 
 
 
 
2572
 
2573
  if (!editor.dom.select('td.mce-item-selected,th.mce-item-selected').length) {
2574
+ dialogs.merge(grid, cell);
2575
  } else {
2576
  grid.merge();
2577
  }
2634
 
2635
  // Register dialog commands
2636
  each({
2637
+ mceInsertTable: dialogs.table,
2638
+ mceTableProps: function() {
2639
+ dialogs.table(true);
2640
  },
2641
+ mceTableRowProps: dialogs.row,
2642
+ mceTableCellProps: dialogs.cell
 
2643
  }, function(func, name) {
2644
  editor.addCommand(name, function(ui, val) {
2645
  func(val);
2646
  });
2647
  });
2648
+
2649
+ // Enable tab key cell navigation
2650
+ if (editor.settings.table_tab_navigation !== false) {
2651
+ editor.on('keydown', function(e) {
2652
+ var cellElm, grid, delta;
2653
+
2654
+ if (e.keyCode == 9) {
2655
+ cellElm = editor.dom.getParent(editor.selection.getStart(), 'th,td');
2656
+
2657
+ if (cellElm) {
2658
+ e.preventDefault();
2659
+
2660
+ grid = new TableGrid(editor);
2661
+ delta = e.shiftKey ? -1 : 1;
2662
+
2663
+ editor.undoManager.transact(function() {
2664
+ if (!grid.moveRelIdx(cellElm, delta) && delta > 0) {
2665
+ grid.insertRow();
2666
+ grid.refresh();
2667
+ grid.moveRelIdx(cellElm, delta);
2668
+ }
2669
+ });
2670
+ }
2671
+ }
2672
+ });
2673
+ }
2674
+
2675
+ self.insertTable = insertTable;
2676
  }
2677
 
2678
  PluginManager.add('table', Plugin);
2679
  });
2680
+ })(this);
 
 
mce/table/plugin.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"use strict";function n(e,t){for(var n,r=[],i=0;i<e.length;++i){if(n=s[e[i]]||o(e[i]),!n)throw"module definition dependecy not found: "+e[i];r.push(n)}t.apply(null,r)}function r(e,r,i){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(r===t)throw"invalid module definition, dependencies must be specified";if(i===t)throw"invalid module definition, definition function must be specified";n(r,function(){s[e]=i.apply(null,arguments)})}function i(e){return!!s[e]}function o(t){for(var n=e,r=t.split(/[.\/]/),i=0;i<r.length;++i){if(!n[r[i]])return;n=n[r[i]]}return n}function a(n){for(var r=0;r<n.length;r++){for(var i=e,o=n[r],a=o.split(/[.\/]/),l=0;l<a.length-1;++l)i[a[l]]===t&&(i[a[l]]={}),i=i[a[l]];i[a[a.length-1]]=s[o]}}var s={},l="tinymce/tableplugin/TableGrid",c="tinymce/util/Tools",d="tinymce/Env",u="tinymce/tableplugin/Quirks",f="tinymce/util/VK",m="tinymce/tableplugin/CellSelection",p="tinymce/dom/TreeWalker",h="tinymce/tableplugin/Plugin",g="tinymce/PluginManager";r(l,[c,d],function(e,n){function r(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=e.each;return function(o,a){function s(){var e=0;A=[],i(["thead","tbody","tfoot"],function(t){var n=M.select("> "+t+" tr",a);i(n,function(n,o){o+=e,i(M.select("> td, > th",n),function(e,n){var i,a,s,l;if(A[o])for(;A[o][n];)n++;for(s=r(e,"rowspan"),l=r(e,"colspan"),a=o;o+s>a;a++)for(A[a]||(A[a]=[]),i=n;n+l>i;i++)A[a][i]={part:t,real:a==o&&i==n,elm:e,rowspan:s,colspan:l}})}),e+=n.length})}function l(e,t){return e=e.cloneNode(t),e.removeAttribute("id"),e}function c(e,t){var n;return n=A[t],n?n[e]:void 0}function d(e,t,n){e&&(n=parseInt(n,10),1===n?e.removeAttribute(t,1):e.setAttribute(t,n,1))}function u(e){return e&&(M.hasClass(e.elm,"mce-item-selected")||e==D)}function f(){var e=[];return i(a.rows,function(t){i(t.cells,function(n){return M.hasClass(n,"mce-item-selected")||D&&n==D.elm?(e.push(t),!1):void 0})}),e}function m(){var e=M.createRng();e.setStartAfter(a),e.setEndAfter(a),L.setRng(e),M.remove(a)}function p(t){var r,a={};return o.settings.table_clone_elements!==!1&&(a=e.makeMap((o.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),e.walk(t,function(e){var o;return 3==e.nodeType?(i(M.getParents(e.parentNode,null,t).reverse(),function(e){a[e.nodeName]&&(e=l(e,!1),r?o&&o.appendChild(e):r=o=e,o=e)}),o&&(o.innerHTML=n.ie?"&nbsp;":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),t=l(t,!1),d(t,"rowSpan",1),d(t,"colSpan",1),r?t.appendChild(r):n.ie||(t.innerHTML='<br data-mce-bogus="1" />'),t}function h(){var e=M.createRng(),t;return i(M.select("tr",a),function(e){0===e.cells.length&&M.remove(e)}),0===M.select("tr",a).length?(e.setStartBefore(a),e.setEndBefore(a),L.setRng(e),void M.remove(a)):(i(M.select("thead,tbody,tfoot",a),function(e){0===e.rows.length&&M.remove(e)}),s(),void(B&&(t=A[Math.min(A.length-1,B.y)],t&&(L.select(t[Math.min(t.length-1,B.x)].elm,!0),L.collapse(!0)))))}function g(e,t,n,r){var i,o,a,s,l;for(i=A[t][e].elm.parentNode,a=1;n>=a;a++)if(i=M.getNext(i,"tr")){for(o=e;o>=0;o--)if(l=A[t+a][o].elm,l.parentNode==i){for(s=1;r>=s;s++)M.insertAfter(p(l),l);break}if(-1==o)for(s=1;r>=s;s++)i.insertBefore(p(i.cells[0]),i.cells[0])}}function v(){i(A,function(e,t){i(e,function(e,n){var i,o,a;if(u(e)&&(e=e.elm,i=r(e,"colspan"),o=r(e,"rowspan"),i>1||o>1)){for(d(e,"rowSpan",1),d(e,"colSpan",1),a=0;i-1>a;a++)M.insertAfter(p(e),e);g(n,t,o-1,i)}})})}function y(t,n,r){var o,a,l,f,m,p,g,y,b,C,x;if(t?(o=S(t),a=o.x,l=o.y,f=a+(n-1),m=l+(r-1)):(B=P=null,i(A,function(e,t){i(e,function(e,n){u(e)&&(B||(B={x:n,y:t}),P={x:n,y:t})})}),B&&(a=B.x,l=B.y,f=P.x,m=P.y)),y=c(a,l),b=c(f,m),y&&b&&y.part==b.part){for(v(),s(),y=c(a,l).elm,d(y,"colSpan",f-a+1),d(y,"rowSpan",m-l+1),g=l;m>=g;g++)for(p=a;f>=p;p++)A[g]&&A[g][p]&&(t=A[g][p].elm,t!=y&&(C=e.grep(t.childNodes),i(C,function(e){y.appendChild(e)}),C.length&&(C=e.grep(y.childNodes),x=0,i(C,function(e){"BR"==e.nodeName&&M.getAttrib(e,"data-mce-bogus")&&x++<C.length-1&&y.removeChild(e)})),M.remove(t)));h()}}function b(e){var n,o,a,s,c,f,m,h,g;if(i(A,function(t,r){return i(t,function(t){return u(t)&&(t=t.elm,c=t.parentNode,f=l(c,!1),n=r,e)?!1:void 0}),e?!n:void 0}),n!==t){for(s=0;s<A[0].length;s++)if(A[n][s]&&(o=A[n][s].elm,o!=a)){if(e){if(n>0&&A[n-1][s]&&(h=A[n-1][s].elm,g=r(h,"rowSpan"),g>1)){d(h,"rowSpan",g+1);continue}}else if(g=r(o,"rowspan"),g>1){d(o,"rowSpan",g+1);continue}m=p(o),d(m,"colSpan",o.colSpan),f.appendChild(m),a=o}f.hasChildNodes()&&(e?c.parentNode.insertBefore(f,c):M.insertAfter(f,c))}}function C(e){var t,n;i(A,function(n){return i(n,function(n,r){return u(n)&&(t=r,e)?!1:void 0}),e?!t:void 0}),i(A,function(i,o){var a,s,l;i[t]&&(a=i[t].elm,a!=n&&(l=r(a,"colspan"),s=r(a,"rowspan"),1==l?e?(a.parentNode.insertBefore(p(a),a),g(t,o,s-1,l)):(M.insertAfter(p(a),a),g(t,o,s-1,l)):d(a,"colSpan",a.colSpan+1),n=a))})}function x(){var t=[];i(A,function(n){i(n,function(n,o){u(n)&&-1===e.inArray(t,o)&&(i(A,function(e){var t=e[o].elm,n;n=r(t,"colSpan"),n>1?d(t,"colSpan",n-1):M.remove(t)}),t.push(o))})}),h()}function w(){function e(e){var t,n,o;t=M.getNext(e,"tr"),i(e.cells,function(e){var t=r(e,"rowSpan");t>1&&(d(e,"rowSpan",t-1),n=S(e),g(n.x,n.y,1,1))}),n=S(e.cells[0]),i(A[n.y],function(e){var t;e=e.elm,e!=o&&(t=r(e,"rowSpan"),1>=t?M.remove(e):d(e,"rowSpan",t-1),o=e)})}var t;t=f(),i(t.reverse(),function(t){e(t)}),h()}function _(){var e=f();return M.remove(e),h(),e}function N(){var e=f();return i(e,function(t,n){e[n]=l(t,!0)}),e}function E(e,t){var n=f(),r=n[t?0:n.length-1],o=r.cells.length;e&&(i(A,function(e){var t;return o=0,i(e,function(e){e.real&&(o+=e.colspan),e.elm.parentNode==r&&(t=1)}),t?!1:void 0}),t||e.reverse(),i(e,function(e){var n,i=e.cells.length,a;for(n=0;i>n;n++)a=e.cells[n],d(a,"colSpan",1),d(a,"rowSpan",1);for(n=i;o>n;n++)e.appendChild(p(e.cells[i-1]));for(n=o;i>n;n++)M.remove(e.cells[n]);t?r.parentNode.insertBefore(e,r):M.insertAfter(e,r)}),M.removeClass(M.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function S(e){var t;return i(A,function(n,r){return i(n,function(n,i){return n.elm==e?(t={x:i,y:r},!1):void 0}),!t}),t}function k(e){B=S(e)}function T(){var e,t;return e=t=0,i(A,function(n,r){i(n,function(n,i){var o,a;u(n)&&(n=A[r][i],i>e&&(e=i),r>t&&(t=r),n.real&&(o=n.colspan-1,a=n.rowspan-1,o&&i+o>e&&(e=i+o),a&&r+a>t&&(t=r+a)))})}),{x:e,y:t}}function R(e){var t,n,r,i,o,a,s,l,c,d;if(P=S(e),B&&P){for(t=Math.min(B.x,P.x),n=Math.min(B.y,P.y),r=Math.max(B.x,P.x),i=Math.max(B.y,P.y),o=r,a=i,d=n;a>=d;d++)e=A[d][t],e.real||t-(e.colspan-1)<t&&(t-=e.colspan-1);for(c=t;o>=c;c++)e=A[n][c],e.real||n-(e.rowspan-1)<n&&(n-=e.rowspan-1);for(d=n;i>=d;d++)for(c=t;r>=c;c++)e=A[d][c],e.real&&(s=e.colspan-1,l=e.rowspan-1,s&&c+s>o&&(o=c+s),l&&d+l>a&&(a=d+l));for(M.removeClass(M.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=n;a>=d;d++)for(c=t;o>=c;c++)A[d][c]&&M.addClass(A[d][c].elm,"mce-item-selected")}}var A,B,P,D,L=o.selection,M=L.dom;a=a||M.getParent(L.getStart(),"table"),s(),D=M.getParent(L.getStart(),"th,td"),D&&(B=S(D),P=T(),D=c(B.x,B.y)),e.extend(this,{deleteTable:m,split:v,merge:y,insertRow:b,insertCol:C,deleteCols:x,deleteRows:w,cutRows:_,copyRows:N,pasteRows:E,getPos:S,setStartCell:k,setEndCell:R})}}),r(u,[f,d,c],function(e,t,n){function r(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=n.each;return function(n){function o(){function t(t){function o(e,r){var i=e?"previousSibling":"nextSibling",o=n.dom.getParent(r,"tr"),s=o[i];if(s)return g(n,r,s,e),t.preventDefault(),!0;var d=n.dom.getParent(o,"table"),u=o.parentNode,f=u.nodeName.toLowerCase();if("tbody"===f||f===(e?"tfoot":"thead")){var m=a(e,d,u,"tbody");if(null!==m)return l(e,m,r)}return c(e,o,i,d)}function a(e,t,r,i){var o=n.dom.select(">"+i,t),a=o.indexOf(r);if(e&&0===a||!e&&a===o.length-1)return s(e,t);if(-1===a){var l="thead"===r.tagName.toLowerCase()?0:o.length-1;return o[l]}return o[a+(e?-1:1)]}function s(e,t){var r=e?"thead":"tfoot",i=n.dom.select(">"+r,t);return 0!==i.length?i[0]:null}function l(e,r,i){var o=d(r,e);return o&&g(n,i,o,e),t.preventDefault(),!0}function c(e,r,i,a){var s=a[i];if(s)return u(s),!0;var l=n.dom.getParent(a,"td,th");if(l)return o(e,l,t);var c=d(r,!e);return u(c),t.preventDefault(),!1}function d(e,t){var r=e&&e[t?"lastChild":"firstChild"];return r&&"BR"===r.nodeName?n.dom.getParent(r,"td,th"):r}function u(e){n.selection.setCursorLocation(e,0)}function f(){return b==e.UP||b==e.DOWN}function m(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"tr");return null!==n}function p(e){for(var t=0,n=e;n.previousSibling;)n=n.previousSibling,t+=r(n,"colspan");return t}function h(e,t){var n=0,o=0;return i(e.children,function(e,i){return n+=r(e,"colspan"),o=i,n>t?!1:void 0}),o}function g(e,t,r,i){var o=p(n.dom.getParent(t,"td,th")),a=h(r,o),s=r.childNodes[a],l=d(s,i);u(l||s)}function v(e){var t=n.selection.getNode(),r=n.dom.getParent(t,"td,th"),i=n.dom.getParent(e,"td,th");return r&&r!==i&&y(r,i)}function y(e,t){return n.dom.getParent(e,"TABLE")===n.dom.getParent(t,"TABLE")}var b=t.keyCode;if(f()&&m(n)){var C=n.selection.getNode();setTimeout(function(){v(C)&&o(!t.shiftKey&&b===e.UP,C,t)},0)}}n.on("KeyDown",function(e){t(e)})}function a(){function e(e,t){var n=t.ownerDocument,r=n.createRange(),i;return r.setStartBefore(t),r.setEnd(e.endContainer,e.endOffset),i=n.createElement("body"),i.appendChild(r.cloneContents()),0===i.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}n.on("KeyDown",function(t){var r,i,o=n.dom;(37==t.keyCode||38==t.keyCode)&&(r=n.selection.getRng(),i=o.getParent(r.startContainer,"table"),i&&n.getBody().firstChild==i&&e(r,i)&&(r=o.createRng(),r.setStartBefore(i),r.setEndBefore(i),n.selection.setRng(r),t.preventDefault()))})}function s(){n.on("KeyDown SetContent VisualAid",function(){var e;for(e=n.getBody().lastChild;e;e=e.previousSibling)if(3==e.nodeType){if(e.nodeValue.length>0)break}else if(1==e.nodeType&&!e.getAttribute("data-mce-bogus"))break;e&&"TABLE"==e.nodeName&&(n.settings.forced_root_block?n.dom.add(n.getBody(),n.settings.forced_root_block,n.settings.forced_root_block_attrs,t.ie&&t.ie<11?"&nbsp;":'<br data-mce-bogus="1" />'):n.dom.add(n.getBody(),"br",{"data-mce-bogus":"1"}))}),n.on("PreProcess",function(e){var t=e.node.lastChild;t&&("BR"==t.nodeName||1==t.childNodes.length&&("BR"==t.firstChild.nodeName||"\xa0"==t.firstChild.nodeValue))&&t.previousSibling&&"TABLE"==t.previousSibling.nodeName&&n.dom.remove(t)})}function l(){function e(e,t,n,r){var i=3,o=e.dom.getParent(t.startContainer,"TABLE"),a,s,l;return o&&(a=o.parentNode),s=t.startContainer.nodeType==i&&0===t.startOffset&&0===t.endOffset&&r&&("TR"==n.nodeName||n==a),l=("TD"==n.nodeName||"TH"==n.nodeName)&&!r,s||l}function t(){var t=n.selection.getRng(),r=n.selection.getNode(),i=n.dom.getParent(t.startContainer,"TD,TH");if(e(n,t,r,i)){i||(i=r);for(var o=i.lastChild;o.lastChild;)o=o.lastChild;t.setEnd(o,o.nodeValue.length),n.selection.setRng(t)}}n.on("KeyDown",function(){t()}),n.on("MouseDown",function(e){2!=e.button&&t()})}function c(){n.on("keydown",function(t){if((t.keyCode==e.DELETE||t.keyCode==e.BACKSPACE)&&!t.isDefaultPrevented()){var r=n.dom.getParent(n.selection.getStart(),"table");if(r){for(var i=n.dom.select("td,th",r),o=i.length;o--;)if(!n.dom.hasClass(i[o],"mce-item-selected"))return;t.preventDefault(),n.execCommand("mceTableDelete")}}})}c(),t.webkit&&(o(),l()),t.gecko&&(a(),s()),t.ie>10&&(a(),s())}}),r(m,[l,p,c],function(e,t,n){return function(r){function i(){r.getBody().style.webkitUserSelect="",d&&(r.dom.removeClass(r.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=!1)}function o(t){var n,i,o=t.target;if(l&&(s||o!=l)&&("TD"==o.nodeName||"TH"==o.nodeName)){i=a.getParent(o,"table"),i==c&&(s||(s=new e(r,i),s.setStartCell(l),r.getBody().style.webkitUserSelect="none"),s.setEndCell(o),d=!0),n=r.selection.getSel();try{n.removeAllRanges?n.removeAllRanges():n.empty()}catch(u){}t.preventDefault()}}var a=r.dom,s,l,c,d=!0;return r.on("MouseDown",function(e){2!=e.button&&(i(),l=a.getParent(e.target,"td,th"),c=a.getParent(l,"table"))}),r.on("mouseover",o),r.on("remove",function(){a.unbind(r.getDoc(),"mouseover",o)}),r.on("MouseUp",function(){function e(e,r){var o=new t(e,e);do{if(3==e.nodeType&&0!==n.trim(e.nodeValue).length)return void(r?i.setStart(e,0):i.setEnd(e,e.nodeValue.length));if("BR"==e.nodeName)return void(r?i.setStartBefore(e):i.setEndBefore(e))}while(e=r?o.next():o.prev())}var i,o=r.selection,d,u,f,m,p;if(l){if(s&&(r.getBody().style.webkitUserSelect=""),d=a.select("td.mce-item-selected,th.mce-item-selected"),d.length>0){i=a.createRng(),f=d[0],p=d[d.length-1],i.setStartBefore(f),i.setEndAfter(f),e(f,1),u=new t(f,a.getParent(d[0],"table"));do if("TD"==f.nodeName||"TH"==f.nodeName){if(!a.hasClass(f,"mce-item-selected"))break;m=f}while(f=u.next());e(m),o.setRng(i)}r.nodeChanged(),l=s=c=null}}),r.on("KeyUp Drop",function(){i(),l=s=c=null}),{clear:i}}}),r(h,[l,u,m,c,p,d,g],function(e,t,n,r,i,o,a){function s(r){function i(e){return e?e.replace(/px$/,""):""}function a(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function s(e){l("left center right".split(" "),function(t){r.formatter.remove("align"+t,{},e)})}function c(e){l("top middle bottom".split(" "),function(t){r.formatter.remove("valign"+t,{},e)})}function d(){var e=r.dom,t,n,c,d;t=e.getParent(r.selection.getStart(),"table"),d={width:i(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:i(e.getStyle(t,"height")||e.getAttrib(t,"height")),cellspacing:t?e.getAttrib(t,"cellspacing"):"",cellpadding:t?e.getAttrib(t,"cellpadding"):"",border:t?e.getAttrib(t,"border"):"",caption:!!e.select("caption",t)[0]},l("left center right".split(" "),function(e){r.formatter.matchNode(t,"align"+e)&&(d.align=e)}),t||(n={label:"Cols",name:"cols"},c={label:"Rows",name:"rows"}),r.windowManager.open({title:"Table properties",items:{type:"form",layout:"grid",columns:2,data:d,defaults:{type:"textbox",maxWidth:50},items:[n,c,{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"},{label:"Alignment",minWidth:90,name:"align",type:"listbox",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var n=this.toJSON(),i;r.undoManager.transact(function(){t||(t=h(n.cols||1,n.rows||1)),r.dom.setAttribs(t,{cellspacing:n.cellspacing,cellpadding:n.cellpadding,border:n.border}),r.dom.setStyles(t,{width:a(n.width),height:a(n.height)}),i=e.select("caption",t)[0],i&&!n.caption&&e.remove(i),!i&&n.caption&&(i=e.create("caption"),i.innerHTML=o.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(i,t.firstChild)),s(t),n.align&&r.formatter.apply("align"+n.align,{},t),r.focus(),r.addVisual()})}})}function u(e,t){r.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",size:10},{label:"Rows",name:"rows",type:"textbox",size:10}],onsubmit:function(){var n=this.toJSON();r.undoManager.transact(function(){e.merge(t,n.cols,n.rows)})}})}function f(){var e=r.dom,t,n,o=[];o=r.dom.select("td.mce-item-selected,th.mce-item-selected"),t=r.dom.getParent(r.selection.getStart(),"td,th"),!o.length&&t&&o.push(t),t=t||o[0],t&&(n={width:i(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:i(e.getStyle(t,"height")||e.getAttrib(t,"height")),scope:e.getAttrib(t,"scope")},n.type=t.nodeName.toLowerCase(),l("left center right".split(" "),function(e){r.formatter.matchNode(t,"align"+e)&&(n.align=e)}),l("top middle bottom".split(" "),function(e){r.formatter.matchNode(t,"valign"+e)&&(n.valign=e)}),r.windowManager.open({title:"Cell properties",items:{type:"form",data:n,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},onsubmit:function(){var t=this.toJSON();r.undoManager.transact(function(){l(o,function(n){r.dom.setAttrib(n,"scope",t.scope),r.dom.setStyles(n,{width:a(t.width),height:a(t.height)}),t.type&&n.nodeName.toLowerCase()!=t.type&&(n=e.rename(n,t.type)),s(n),t.align&&r.formatter.apply("align"+t.align,{},n),c(n),t.valign&&r.formatter.apply("valign"+t.valign,{},n)}),r.focus()})}}))}function m(){var e=r.dom,t,n,o,c,d=[];t=r.dom.getParent(r.selection.getStart(),"table"),n=r.dom.getParent(r.selection.getStart(),"td,th"),l(t.rows,function(t){l(t.cells,function(r){return e.hasClass(r,"mce-item-selected")||r==n?(d.push(t),!1):void 0})}),o=d[0],o&&(c={height:i(e.getStyle(o,"height")||e.getAttrib(o,"height")),scope:e.getAttrib(o,"scope")},c.type=o.parentNode.nodeName.toLowerCase(),l("left center right".split(" "),function(e){r.formatter.matchNode(o,"align"+e)&&(c.align=e)}),r.windowManager.open({title:"Row properties",items:{type:"form",data:c,columns:2,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"}]},onsubmit:function(){var t=this.toJSON(),n,i,o;r.undoManager.transact(function(){var c=t.type;l(d,function(l){r.dom.setAttrib(l,"scope",t.scope),r.dom.setStyles(l,{height:a(t.height)}),c!=l.parentNode.nodeName.toLowerCase()&&(n=e.getParent(l,"table"),i=l.parentNode,o=e.select(c,n)[0],o||(o=e.create(c),n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o)),o.appendChild(l),i.hasChildNodes()||e.remove(i)),s(l),t.align&&r.formatter.apply("align"+t.align,{},l)}),r.focus()})}}))}function p(e){return function(){r.execCommand(e)}}function h(e,t){var n,i,a;for(a='<table id="__mce"><tbody>',n=0;t>n;n++){for(a+="<tr>",i=0;e>i;i++)a+="<td>"+(o.ie?" ":"<br>")+"</td>";a+="</tr>"}a+="</tbody></table>",r.insertContent(a);var s=r.dom.get("__mce");return r.dom.setAttrib(s,"id",null),s}function g(e,t){function n(){e.disabled(!r.dom.getParent(r.selection.getStart(),t)),r.selection.selectorChanged(t,function(t){e.disabled(!t)})}r.initialized?n():r.on("init",n)}function v(){g(this,"table")}function y(){g(this,"td,th")}function b(){var e="";e='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';for(var t=0;10>t;t++){e+="<tr>";for(var n=0;10>n;n++)e+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+n)+'" href="#" data-mce-x="'+n+'" data-mce-y="'+t+'"></a></td>';e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}function C(e,t,n){var i=n.getEl().getElementsByTagName("table")[0],o,a,s,l,c,d=n.isRtl()||"tl-tr"==n.parent().rel;for(i.nextSibling.innerHTML=e+1+" x "+(t+1),d&&(e=9-e),a=0;10>a;a++)for(o=0;10>o;o++)l=i.rows[a].childNodes[o].firstChild,c=(d?o>=e:e>=o)&&t>=a,r.dom.toggleClass(l,"mce-active",c),c&&(s=l);return s.parentNode}var x,w,_=this;r.settings.table_grid===!1?r.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onclick:d}):r.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(e){e.aria&&(this.parent().hideAll(),e.stopImmediatePropagation(),d())},onshow:function(){C(0,0,this.menu.items()[0])},onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");r.dom.removeClass(e,"mce-active"),r.dom.addClass(e[0],"mce-active")},menu:[{type:"container",html:b(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t=e.target,n,r;"A"==t.tagName.toUpperCase()&&(n=parseInt(t.getAttribute("data-mce-x"),10),r=parseInt(t.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(n=9-n),(n!==this.lastX||r!==this.lastY)&&(C(n,r,e.control),this.lastX=n,this.lastY=r))},onkeydown:function(e){var t=this.lastX,n=this.lastY,r;switch(e.keyCode){case 37:t>0&&(t--,r=!0);break;case 39:r=!0,9>t&&t++;break;case 38:r=!0,n>0&&n--;break;case 40:r=!0,9>n&&n++}r&&(e.preventDefault(),e.stopPropagation(),C(t,n,e.control).focus(),this.lastX=t,this.lastY=n)},onclick:function(e){"A"==e.target.tagName.toUpperCase()&&(e.preventDefault(),e.stopPropagation(),this.parent().cancel(),h(this.lastX+1,this.lastY+1))}}]}),r.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:v,onclick:d}),r.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:v,cmd:"mceTableDelete"}),r.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:p("mceTableCellProps"),onPostRender:y},{text:"Merge cells",onclick:p("mceTableMergeCells"),onPostRender:y},{text:"Split cell",onclick:p("mceTableSplitCells"),onPostRender:y}]}),r.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:p("mceTableInsertRowBefore"),onPostRender:y},{text:"Insert row after",onclick:p("mceTableInsertRowAfter"),onPostRender:y},{text:"Delete row",onclick:p("mceTableDeleteRow"),onPostRender:y},{text:"Row properties",onclick:p("mceTableRowProps"),onPostRender:y},{text:"-"},{text:"Cut row",onclick:p("mceTableCutRow"),onPostRender:y},{text:"Copy row",onclick:p("mceTableCopyRow"),onPostRender:y},{text:"Paste row before",onclick:p("mceTablePasteRowBefore"),onPostRender:y},{text:"Paste row after",onclick:p("mceTablePasteRowAfter"),onPostRender:y}]}),r.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:p("mceTableInsertColBefore"),onPostRender:y},{text:"Insert column after",onclick:p("mceTableInsertColAfter"),onPostRender:y},{text:"Delete column",onclick:p("mceTableDeleteCol"),onPostRender:y}]});var N=[];l("inserttable tableprops deletetable | cell row column".split(" "),function(e){N.push("|"==e?{text:"-"}:r.menuItems[e])}),r.addButton("table",{type:"menubutton",title:"Table",menu:N}),o.isIE||r.on("click",function(e){e=e.target,"TABLE"===e.nodeName&&(r.selection.select(e),r.nodeChanged())}),_.quirks=new t(r),r.on("Init",function(){x=r.windowManager,_.cellSelection=new n(r)}),l({mceTableSplitCells:function(e){e.split()},mceTableMergeCells:function(e){var t,n,i;i=r.dom.getParent(r.selection.getStart(),"th,td"),i&&(t=i.rowSpan,n=i.colSpan),r.dom.select("td.mce-item-selected,th.mce-item-selected").length?e.merge():u(e,i)},mceTableInsertRowBefore:function(e){e.insertRow(!0)},mceTableInsertRowAfter:function(e){e.insertRow()},mceTableInsertColBefore:function(e){e.insertCol(!0)},mceTableInsertColAfter:function(e){e.insertCol()},mceTableDeleteCol:function(e){e.deleteCols()},mceTableDeleteRow:function(e){e.deleteRows()},mceTableCutRow:function(e){w=e.cutRows()},mceTableCopyRow:function(e){w=e.copyRows()},mceTablePasteRowBefore:function(e){e.pasteRows(w,!0)},mceTablePasteRowAfter:function(e){e.pasteRows(w)},mceTableDelete:function(e){e.deleteTable()}},function(t,n){r.addCommand(n,function(){var n=new e(r);n&&(t(n),r.execCommand("mceRepaint"),_.cellSelection.clear())})}),l({mceInsertTable:function(){d()},mceTableRowProps:m,mceTableCellProps:f},function(e,t){r.addCommand(t,function(t,n){e(n)})})}var l=r.each;a.add("table",s)}),a([l,u,m,h])}(this);
1
+ !function(e,t){"use strict";function n(e,t){for(var n,r=[],i=0;i<e.length;++i){if(n=s[e[i]]||o(e[i]),!n)throw"module definition dependecy not found: "+e[i];r.push(n)}t.apply(null,r)}function r(e,r,i){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(r===t)throw"invalid module definition, dependencies must be specified";if(i===t)throw"invalid module definition, definition function must be specified";n(r,function(){s[e]=i.apply(null,arguments)})}function i(e){return!!s[e]}function o(t){for(var n=e,r=t.split(/[.\/]/),i=0;i<r.length;++i){if(!n[r[i]])return;n=n[r[i]]}return n}function a(n){for(var r=0;r<n.length;r++){for(var i=e,o=n[r],a=o.split(/[.\/]/),l=0;l<a.length-1;++l)i[a[l]]===t&&(i[a[l]]={}),i=i[a[l]];i[a[a.length-1]]=s[o]}}var s={},l="tinymce/tableplugin/TableGrid",c="tinymce/util/Tools",u="tinymce/Env",d="tinymce/tableplugin/Quirks",f="tinymce/util/VK",p="tinymce/tableplugin/CellSelection",m="tinymce/dom/TreeWalker",h="tinymce/tableplugin/Dialogs",g="tinymce/tableplugin/Plugin",v="tinymce/PluginManager";r(l,[c,u],function(e,n){function r(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=e.each;return function(o,a){function s(){var e=0;B=[],D=0,i(["thead","tbody","tfoot"],function(t){var n=O.select("> "+t+" tr",a);i(n,function(n,o){o+=e,i(O.select("> td, > th",n),function(e,n){var i,a,s,l;if(B[o])for(;B[o][n];)n++;for(s=r(e,"rowspan"),l=r(e,"colspan"),a=o;o+s>a;a++)for(B[a]||(B[a]=[]),i=n;n+l>i;i++)B[a][i]={part:t,real:a==o&&i==n,elm:e,rowspan:s,colspan:l};D=Math.max(D,n+1)})}),e+=n.length})}function l(e,t){return e=e.cloneNode(t),e.removeAttribute("id"),e}function c(e,t){var n;return n=B[t],n?n[e]:void 0}function u(e,t,n){e&&(n=parseInt(n,10),1===n?e.removeAttribute(t,1):e.setAttribute(t,n,1))}function d(e){return e&&(O.hasClass(e.elm,"mce-item-selected")||e==H)}function f(){var e=[];return i(a.rows,function(t){i(t.cells,function(n){return O.hasClass(n,"mce-item-selected")||H&&n==H.elm?(e.push(t),!1):void 0})}),e}function p(){var e=O.createRng();e.setStartAfter(a),e.setEndAfter(a),L.setRng(e),O.remove(a)}function m(t){var r,a={};return o.settings.table_clone_elements!==!1&&(a=e.makeMap((o.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),e.walk(t,function(e){var o;return 3==e.nodeType?(i(O.getParents(e.parentNode,null,t).reverse(),function(e){a[e.nodeName]&&(e=l(e,!1),r?o&&o.appendChild(e):r=o=e,o=e)}),o&&(o.innerHTML=n.ie?"&nbsp;":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),t=l(t,!1),u(t,"rowSpan",1),u(t,"colSpan",1),r?t.appendChild(r):(!n.ie||n.ie>10)&&(t.innerHTML='<br data-mce-bogus="1" />'),t}function h(){var e=O.createRng(),t;return i(O.select("tr",a),function(e){0===e.cells.length&&O.remove(e)}),0===O.select("tr",a).length?(e.setStartBefore(a),e.setEndBefore(a),L.setRng(e),void O.remove(a)):(i(O.select("thead,tbody,tfoot",a),function(e){0===e.rows.length&&O.remove(e)}),s(),void(P&&(t=B[Math.min(B.length-1,P.y)],t&&(L.select(t[Math.min(t.length-1,P.x)].elm,!0),L.collapse(!0)))))}function g(e,t,n,r){var i,o,a,s,l;for(i=B[t][e].elm.parentNode,a=1;n>=a;a++)if(i=O.getNext(i,"tr")){for(o=e;o>=0;o--)if(l=B[t+a][o].elm,l.parentNode==i){for(s=1;r>=s;s++)O.insertAfter(m(l),l);break}if(-1==o)for(s=1;r>=s;s++)i.insertBefore(m(i.cells[0]),i.cells[0])}}function v(){i(B,function(e,t){i(e,function(e,n){var i,o,a;if(d(e)&&(e=e.elm,i=r(e,"colspan"),o=r(e,"rowspan"),i>1||o>1)){for(u(e,"rowSpan",1),u(e,"colSpan",1),a=0;i-1>a;a++)O.insertAfter(m(e),e);g(n,t,o-1,i)}})})}function y(t,n,r){var o,a,l,f,p,m,g,y,b,C,x;if(t?(o=k(t),a=o.x,l=o.y,f=a+(n-1),p=l+(r-1)):(P=M=null,i(B,function(e,t){i(e,function(e,n){d(e)&&(P||(P={x:n,y:t}),M={x:n,y:t})})}),P&&(a=P.x,l=P.y,f=M.x,p=M.y)),y=c(a,l),b=c(f,p),y&&b&&y.part==b.part){for(v(),s(),y=c(a,l).elm,u(y,"colSpan",f-a+1),u(y,"rowSpan",p-l+1),g=l;p>=g;g++)for(m=a;f>=m;m++)B[g]&&B[g][m]&&(t=B[g][m].elm,t!=y&&(C=e.grep(t.childNodes),i(C,function(e){y.appendChild(e)}),C.length&&(C=e.grep(y.childNodes),x=0,i(C,function(e){"BR"==e.nodeName&&O.getAttrib(e,"data-mce-bogus")&&x++<C.length-1&&y.removeChild(e)})),O.remove(t)));h()}}function b(e){var n,o,a,s,c,f,p,h,g;if(i(B,function(t,r){return i(t,function(t){return d(t)&&(t=t.elm,c=t.parentNode,f=l(c,!1),n=r,e)?!1:void 0}),e?!n:void 0}),n!==t){for(s=0;s<B[0].length;s++)if(B[n][s]&&(o=B[n][s].elm,o!=a)){if(e){if(n>0&&B[n-1][s]&&(h=B[n-1][s].elm,g=r(h,"rowSpan"),g>1)){u(h,"rowSpan",g+1);continue}}else if(g=r(o,"rowspan"),g>1){u(o,"rowSpan",g+1);continue}p=m(o),u(p,"colSpan",o.colSpan),f.appendChild(p),a=o}f.hasChildNodes()&&(e?c.parentNode.insertBefore(f,c):O.insertAfter(f,c))}}function C(e){var t,n;i(B,function(n){return i(n,function(n,r){return d(n)&&(t=r,e)?!1:void 0}),e?!t:void 0}),i(B,function(i,o){var a,s,l;i[t]&&(a=i[t].elm,a!=n&&(l=r(a,"colspan"),s=r(a,"rowspan"),1==l?e?(a.parentNode.insertBefore(m(a),a),g(t,o,s-1,l)):(O.insertAfter(m(a),a),g(t,o,s-1,l)):u(a,"colSpan",a.colSpan+1),n=a))})}function x(){var t=[];i(B,function(n){i(n,function(n,o){d(n)&&-1===e.inArray(t,o)&&(i(B,function(e){var t=e[o].elm,n;n=r(t,"colSpan"),n>1?u(t,"colSpan",n-1):O.remove(t)}),t.push(o))})}),h()}function w(){function e(e){var t,n;i(e.cells,function(e){var n=r(e,"rowSpan");n>1&&(u(e,"rowSpan",n-1),t=k(e),g(t.x,t.y,1,1))}),t=k(e.cells[0]),i(B[t.y],function(e){var t;e=e.elm,e!=n&&(t=r(e,"rowSpan"),1>=t?O.remove(e):u(e,"rowSpan",t-1),n=e)})}var t;t=f(),i(t.reverse(),function(t){e(t)}),h()}function _(){var e=f();return O.remove(e),h(),e}function E(){var e=f();return i(e,function(t,n){e[n]=l(t,!0)}),e}function N(e,t){var n=f(),r=n[t?0:n.length-1],o=r.cells.length;e&&(i(B,function(e){var t;return o=0,i(e,function(e){e.real&&(o+=e.colspan),e.elm.parentNode==r&&(t=1)}),t?!1:void 0}),t||e.reverse(),i(e,function(e){var n,i=e.cells.length,a;for(n=0;i>n;n++)a=e.cells[n],u(a,"colSpan",1),u(a,"rowSpan",1);for(n=i;o>n;n++)e.appendChild(m(e.cells[i-1]));for(n=o;i>n;n++)O.remove(e.cells[n]);t?r.parentNode.insertBefore(e,r):O.insertAfter(e,r)}),O.removeClass(O.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function k(e){var t;return i(B,function(n,r){return i(n,function(n,i){return n.elm==e?(t={x:i,y:r},!1):void 0}),!t}),t}function S(e){P=k(e)}function T(){var e,t;return e=t=0,i(B,function(n,r){i(n,function(n,i){var o,a;d(n)&&(n=B[r][i],i>e&&(e=i),r>t&&(t=r),n.real&&(o=n.colspan-1,a=n.rowspan-1,o&&i+o>e&&(e=i+o),a&&r+a>t&&(t=r+a)))})}),{x:e,y:t}}function R(e){var t,n,r,i,o,a,s,l,c,u;if(M=k(e),P&&M){for(t=Math.min(P.x,M.x),n=Math.min(P.y,M.y),r=Math.max(P.x,M.x),i=Math.max(P.y,M.y),o=r,a=i,u=n;a>=u;u++)e=B[u][t],e.real||t-(e.colspan-1)<t&&(t-=e.colspan-1);for(c=t;o>=c;c++)e=B[n][c],e.real||n-(e.rowspan-1)<n&&(n-=e.rowspan-1);for(u=n;i>=u;u++)for(c=t;r>=c;c++)e=B[u][c],e.real&&(s=e.colspan-1,l=e.rowspan-1,s&&c+s>o&&(o=c+s),l&&u+l>a&&(a=u+l));for(O.removeClass(O.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),u=n;a>=u;u++)for(c=t;o>=c;c++)B[u][c]&&O.addClass(B[u][c].elm,"mce-item-selected")}}function A(e,t){var n,r,i;n=k(e),r=n.y*D+n.x;do{if(r+=t,i=c(r%D,Math.floor(r/D)),!i)break;if(i.elm!=e)return L.select(i.elm,!0),O.isEmpty(i.elm)&&L.collapse(!0),!0}while(i.elm==e);return!1}var B,D,P,M,H,L=o.selection,O=L.dom;a=a||O.getParent(L.getStart(),"table"),s(),H=O.getParent(L.getStart(),"th,td"),H&&(P=k(H),M=T(),H=c(P.x,P.y)),e.extend(this,{deleteTable:p,split:v,merge:y,insertRow:b,insertCol:C,deleteCols:x,deleteRows:w,cutRows:_,copyRows:E,pasteRows:N,getPos:k,setStartCell:S,setEndCell:R,moveRelIdx:A,refresh:s})}}),r(d,[f,u,c],function(e,t,n){function r(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=n.each;return function(n){function o(){function t(t){function o(e,r){var i=e?"previousSibling":"nextSibling",o=n.dom.getParent(r,"tr"),s=o[i];if(s)return g(n,r,s,e),t.preventDefault(),!0;var u=n.dom.getParent(o,"table"),d=o.parentNode,f=d.nodeName.toLowerCase();if("tbody"===f||f===(e?"tfoot":"thead")){var p=a(e,u,d,"tbody");if(null!==p)return l(e,p,r)}return c(e,o,i,u)}function a(e,t,r,i){var o=n.dom.select(">"+i,t),a=o.indexOf(r);if(e&&0===a||!e&&a===o.length-1)return s(e,t);if(-1===a){var l="thead"===r.tagName.toLowerCase()?0:o.length-1;return o[l]}return o[a+(e?-1:1)]}function s(e,t){var r=e?"thead":"tfoot",i=n.dom.select(">"+r,t);return 0!==i.length?i[0]:null}function l(e,r,i){var o=u(r,e);return o&&g(n,i,o,e),t.preventDefault(),!0}function c(e,r,i,a){var s=a[i];if(s)return d(s),!0;var l=n.dom.getParent(a,"td,th");if(l)return o(e,l,t);var c=u(r,!e);return d(c),t.preventDefault(),!1}function u(e,t){var r=e&&e[t?"lastChild":"firstChild"];return r&&"BR"===r.nodeName?n.dom.getParent(r,"td,th"):r}function d(e){n.selection.setCursorLocation(e,0)}function f(){return b==e.UP||b==e.DOWN}function p(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"tr");return null!==n}function m(e){for(var t=0,n=e;n.previousSibling;)n=n.previousSibling,t+=r(n,"colspan");return t}function h(e,t){var n=0,o=0;return i(e.children,function(e,i){return n+=r(e,"colspan"),o=i,n>t?!1:void 0}),o}function g(e,t,r,i){var o=m(n.dom.getParent(t,"td,th")),a=h(r,o),s=r.childNodes[a],l=u(s,i);d(l||s)}function v(e){var t=n.selection.getNode(),r=n.dom.getParent(t,"td,th"),i=n.dom.getParent(e,"td,th");return r&&r!==i&&y(r,i)}function y(e,t){return n.dom.getParent(e,"TABLE")===n.dom.getParent(t,"TABLE")}var b=t.keyCode;if(f()&&p(n)){var C=n.selection.getNode();setTimeout(function(){v(C)&&o(!t.shiftKey&&b===e.UP,C,t)},0)}}n.on("KeyDown",function(e){t(e)})}function a(){function e(e,t){var n=t.ownerDocument,r=n.createRange(),i;return r.setStartBefore(t),r.setEnd(e.endContainer,e.endOffset),i=n.createElement("body"),i.appendChild(r.cloneContents()),0===i.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}n.on("KeyDown",function(t){var r,i,o=n.dom;(37==t.keyCode||38==t.keyCode)&&(r=n.selection.getRng(),i=o.getParent(r.startContainer,"table"),i&&n.getBody().firstChild==i&&e(r,i)&&(r=o.createRng(),r.setStartBefore(i),r.setEndBefore(i),n.selection.setRng(r),t.preventDefault()))})}function s(){n.on("KeyDown SetContent VisualAid",function(){var e;for(e=n.getBody().lastChild;e;e=e.previousSibling)if(3==e.nodeType){if(e.nodeValue.length>0)break}else if(1==e.nodeType&&("BR"==e.tagName||!e.getAttribute("data-mce-bogus")))break;e&&"TABLE"==e.nodeName&&(n.settings.forced_root_block?n.dom.add(n.getBody(),n.settings.forced_root_block,n.settings.forced_root_block_attrs,t.ie&&t.ie<11?"&nbsp;":'<br data-mce-bogus="1" />'):n.dom.add(n.getBody(),"br",{"data-mce-bogus":"1"}))}),n.on("PreProcess",function(e){var t=e.node.lastChild;t&&("BR"==t.nodeName||1==t.childNodes.length&&("BR"==t.firstChild.nodeName||"\xa0"==t.firstChild.nodeValue))&&t.previousSibling&&"TABLE"==t.previousSibling.nodeName&&n.dom.remove(t)})}function l(){function e(e,t,n,r){var i=3,o=e.dom.getParent(t.startContainer,"TABLE"),a,s,l;return o&&(a=o.parentNode),s=t.startContainer.nodeType==i&&0===t.startOffset&&0===t.endOffset&&r&&("TR"==n.nodeName||n==a),l=("TD"==n.nodeName||"TH"==n.nodeName)&&!r,s||l}function t(){var t=n.selection.getRng(),r=n.selection.getNode(),i=n.dom.getParent(t.startContainer,"TD,TH");if(e(n,t,r,i)){i||(i=r);for(var o=i.lastChild;o.lastChild;)o=o.lastChild;3==o.nodeType&&(t.setEnd(o,o.data.length),n.selection.setRng(t))}}n.on("KeyDown",function(){t()}),n.on("MouseDown",function(e){2!=e.button&&t()})}function c(){n.on("keydown",function(t){if((t.keyCode==e.DELETE||t.keyCode==e.BACKSPACE)&&!t.isDefaultPrevented()){var r=n.dom.getParent(n.selection.getStart(),"table");if(r){for(var i=n.dom.select("td,th",r),o=i.length;o--;)if(!n.dom.hasClass(i[o],"mce-item-selected"))return;t.preventDefault(),n.execCommand("mceTableDelete")}}})}c(),t.webkit&&(o(),l()),t.gecko&&(a(),s()),t.ie>10&&(a(),s())}}),r(p,[l,m,c],function(e,t,n){return function(r){function i(e){r.getBody().style.webkitUserSelect="",(e||u)&&(r.dom.removeClass(r.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),u=!1)}function o(t){var n,i,o=t.target;if(!d&&l&&(s||o!=l)&&("TD"==o.nodeName||"TH"==o.nodeName)){i=a.getParent(o,"table"),i==c&&(s||(s=new e(r,i),s.setStartCell(l),r.getBody().style.webkitUserSelect="none"),s.setEndCell(o),u=!0),n=r.selection.getSel();try{n.removeAllRanges?n.removeAllRanges():n.empty()}catch(f){}t.preventDefault()}}var a=r.dom,s,l,c,u=!0,d;return r.on("MouseDown",function(e){2==e.button||d||(i(),l=a.getParent(e.target,"td,th"),c=a.getParent(l,"table"))}),r.on("mouseover",o),r.on("remove",function(){a.unbind(r.getDoc(),"mouseover",o)}),r.on("MouseUp",function(){function e(e,r){var o=new t(e,e);do{if(3==e.nodeType&&0!==n.trim(e.nodeValue).length)return void(r?i.setStart(e,0):i.setEnd(e,e.nodeValue.length));if("BR"==e.nodeName)return void(r?i.setStartBefore(e):i.setEndBefore(e))}while(e=r?o.next():o.prev())}var i,o=r.selection,u,d,f,p;if(l){if(s&&(r.getBody().style.webkitUserSelect=""),u=a.select("td.mce-item-selected,th.mce-item-selected"),u.length>0){i=a.createRng(),f=u[0],i.setStartBefore(f),i.setEndAfter(f),e(f,1),d=new t(f,a.getParent(u[0],"table"));do if("TD"==f.nodeName||"TH"==f.nodeName){if(!a.hasClass(f,"mce-item-selected"))break;p=f}while(f=d.next());e(p),o.setRng(i)}r.nodeChanged(),l=s=c=null}}),r.on("KeyUp Drop SetContent",function(e){i("setcontent"==e.type),l=s=c=null,d=!1}),r.on("ObjectResizeStart ObjectResized",function(e){d="objectresized"!=e.type}),{clear:i}}}),r(h,[c,u],function(e,t){var n=e.each;return function(r){function i(){var e=r.settings.color_picker_callback;return e?function(){var t=this;e.call(r,function(e){t.value(e).fire("change")},t.value())}:void 0}function o(e){return{title:"Advanced",type:"form",defaults:{onchange:function(){d(e,this.parents().reverse()[0],"style"==this.name())}},items:[{label:"Style",name:"style",type:"textbox"},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border color",type:"colorbox",name:"borderColor",onaction:i()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:i()}]}]}}function a(e){return e?e.replace(/px$/,""):""}function s(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function l(e){n("left center right".split(" "),function(t){r.formatter.remove("align"+t,{},e)})}function c(e){n("top middle bottom".split(" "),function(t){r.formatter.remove("valign"+t,{},e)})}function u(t,n,r){function i(t,r){return r=r||[],e.each(t,function(e){var t={text:e.text||e.title};e.menu?t.menu=i(e.menu):(t.value=e.value,n&&n(t)),r.push(t)}),r}return i(t,r||[])}function d(e,t,n){var r=t.toJSON(),i=e.parseStyle(r.style);n?(t.find("#borderColor").value(i["border-color"]||"")[0].fire("change"),t.find("#backgroundColor").value(i["background-color"]||"")[0].fire("change")):(i["border-color"]=r.borderColor,i["background-color"]=r.backgroundColor),t.find("#style").value(e.serializeStyle(e.parseStyle(e.serializeStyle(i))))}function f(e,t,n){var r=e.parseStyle(e.getAttrib(n,"style"));r["border-color"]&&(t.borderColor=r["border-color"]),r["background-color"]&&(t.backgroundColor=r["background-color"]),t.style=e.serializeStyle(r)}var p=this;p.tableProps=function(){p.table(!0)},p.table=function(i){function c(){var n;d(p,this),y=e.extend(y,this.toJSON()),e.each("backgroundColor borderColor".split(" "),function(e){delete y[e]}),y["class"]===!1&&delete y["class"],r.undoManager.transact(function(){m||(m=r.plugins.table.insertTable(y.cols||1,y.rows||1)),r.dom.setAttribs(m,{cellspacing:y.cellspacing,cellpadding:y.cellpadding,border:y.border,style:y.style,"class":y["class"]}),p.getAttrib(m,"width")?p.setAttrib(m,"width",a(y.width)):p.setStyle(m,"width",s(y.width)),p.setStyle(m,"height",s(y.height)),n=p.select("caption",m)[0],n&&!y.caption&&p.remove(n),!n&&y.caption&&(n=p.create("caption"),n.innerHTML=t.ie?"\xa0":'<br data-mce-bogus="1"/>',m.insertBefore(n,m.firstChild)),l(m),y.align&&r.formatter.apply("align"+y.align,{},m),r.focus(),r.addVisual()})}var p=r.dom,m,h,g,v,y={},b;i===!0?(m=p.getParent(r.selection.getStart(),"table"),m&&(y={width:a(p.getStyle(m,"width")||p.getAttrib(m,"width")),height:a(p.getStyle(m,"height")||p.getAttrib(m,"height")),cellspacing:m?p.getAttrib(m,"cellspacing"):"",cellpadding:m?p.getAttrib(m,"cellpadding"):"",border:m?p.getAttrib(m,"border"):"",caption:!!p.select("caption",m)[0],"class":p.getAttrib(m,"class")},n("left center right".split(" "),function(e){r.formatter.matchNode(m,"align"+e)&&(y.align=e)}))):(h={label:"Cols",name:"cols"},g={label:"Rows",name:"rows"}),r.settings.table_class_list&&(y["class"]&&(y["class"]=y["class"].replace(/\s*mce\-item\-table\s*/g,"")),v={name:"class",type:"listbox",label:"Class",values:u(r.settings.table_class_list,function(e){e.value&&(e.textStyle=function(){return r.formatter.getCssText({block:"table",classes:[e.value]})})})}),b={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",labelGapCalc:!1,padding:0,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:[h,g,{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"}]},{label:"Alignment",name:"align",type:"listbox",text:"None",values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},v]},r.settings.table_advtab!==!1?(f(p,y,m),r.windowManager.open({title:"Table properties",data:y,bodyType:"tabpanel",body:[{title:"General",type:"form",items:b},o(p)],onsubmit:c})):r.windowManager.open({title:"Table properties",data:y,body:b,onsubmit:c})},p.merge=function(e,t){r.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",value:"1",size:10},{label:"Rows",name:"rows",type:"textbox",value:"1",size:10}],onsubmit:function(){var n=this.toJSON();r.undoManager.transact(function(){e.merge(t,n.cols,n.rows)})}})},p.cell=function(){function t(){d(i,this),m=e.extend(m,this.toJSON()),r.undoManager.transact(function(){n(g,function(e){r.dom.setAttribs(e,{scope:m.scope,style:m.style,"class":m["class"]}),r.dom.setStyles(e,{width:s(m.width),height:s(m.height)}),m.type&&e.nodeName.toLowerCase()!=m.type&&(e=i.rename(e,m.type)),l(e),m.align&&r.formatter.apply("align"+m.align,{},e),c(e),m.valign&&r.formatter.apply("valign"+m.valign,{},e)}),r.focus()})}var i=r.dom,p,m,h,g=[];if(g=r.dom.select("td.mce-item-selected,th.mce-item-selected"),p=r.dom.getParent(r.selection.getStart(),"td,th"),!g.length&&p&&g.push(p),p=p||g[0]){m={width:a(i.getStyle(p,"width")||i.getAttrib(p,"width")),height:a(i.getStyle(p,"height")||i.getAttrib(p,"height")),scope:i.getAttrib(p,"scope"),"class":i.getAttrib(p,"class")},m.type=p.nodeName.toLowerCase(),n("left center right".split(" "),function(e){r.formatter.matchNode(p,"align"+e)&&(m.align=e)}),n("top middle bottom".split(" "),function(e){r.formatter.matchNode(p,"valign"+e)&&(m.valign=e)}),r.settings.table_cell_class_list&&(h={name:"class",type:"listbox",label:"Class",values:u(r.settings.table_cell_class_list,function(e){e.value&&(e.textStyle=function(){return r.formatter.getCssText({block:"td",classes:[e.value]})})})});var v={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",layout:"grid",columns:2,labelGapCalc:!1,padding:0,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},h]};r.settings.table_cell_advtab!==!1?(f(i,m,p),r.windowManager.open({title:"Cell properties",bodyType:"tabpanel",data:m,body:[{title:"General",type:"form",items:v},o(i)],onsubmit:t})):r.windowManager.open({title:"Cell properties",data:m,body:v,onsubmit:t})}},p.row=function(){function t(){var t,o,a;d(i,this),g=e.extend(g,this.toJSON()),r.undoManager.transact(function(){var e=g.type;n(v,function(n){r.dom.setAttribs(n,{scope:g.scope,style:g.style,"class":g["class"]}),r.dom.setStyles(n,{height:s(g.height)}),e!=n.parentNode.nodeName.toLowerCase()&&(t=i.getParent(n,"table"),o=n.parentNode,a=i.select(e,t)[0],a||(a=i.create(e),t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a)),a.appendChild(n),o.hasChildNodes()||i.remove(o)),l(n),g.align&&r.formatter.apply("align"+g.align,{},n)}),r.focus()})}var i=r.dom,c,p,m,h,g,v=[],y;c=r.dom.getParent(r.selection.getStart(),"table"),p=r.dom.getParent(r.selection.getStart(),"td,th"),n(c.rows,function(e){n(e.cells,function(t){return i.hasClass(t,"mce-item-selected")||t==p?(v.push(e),!1):void 0})}),m=v[0],m&&(g={height:a(i.getStyle(m,"height")||i.getAttrib(m,"height")),scope:i.getAttrib(m,"scope"),"class":i.getAttrib(m,"class")},g.type=m.parentNode.nodeName.toLowerCase(),n("left center right".split(" "),function(e){r.formatter.matchNode(m,"align"+e)&&(g.align=e)}),r.settings.table_row_class_list&&(h={name:"class",type:"listbox",label:"Class",values:u(r.settings.table_row_class_list,function(e){e.value&&(e.textStyle=function(){return r.formatter.getCssText({block:"tr",classes:[e.value]})})})}),y={type:"form",columns:2,padding:0,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"},h]},r.settings.table_row_advtab!==!1?(f(i,g,m),r.windowManager.open({title:"Row properties",data:g,bodyType:"tabpanel",body:[{title:"General",type:"form",items:y},o(i)],onsubmit:t})):r.windowManager.open({title:"Row properties",data:g,body:y,onsubmit:t}))}}}),r(g,[l,d,p,h,c,m,u,v],function(e,t,n,r,i,o,a,s){function l(i){function o(e){return function(){i.execCommand(e)}}function s(e,t){var n,r,o,s;for(o='<table id="__mce"><tbody>',n=0;t>n;n++){for(o+="<tr>",r=0;e>r;r++)o+="<td>"+(a.ie?" ":"<br>")+"</td>";o+="</tr>"}return o+="</tbody></table>",i.undoManager.transact(function(){i.insertContent(o),s=i.dom.get("__mce"),i.dom.setAttrib(s,"id",null),i.dom.setAttribs(s,i.settings.table_default_attributes||{}),i.dom.setStyles(s,i.settings.table_default_styles||{})}),s}function l(e,t){function n(){e.disabled(!i.dom.getParent(i.selection.getStart(),t)),i.selection.selectorChanged(t,function(t){e.disabled(!t)})}i.initialized?n():i.on("init",n)}function u(){l(this,"table")}function d(){l(this,"td,th")}function f(){var e="";e='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';for(var t=0;10>t;t++){e+="<tr>";for(var n=0;10>n;n++)e+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+n)+'" href="#" data-mce-x="'+n+'" data-mce-y="'+t+'"></a></td>';e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}function p(e,t,n){var r=n.getEl().getElementsByTagName("table")[0],o,a,s,l,c,u=n.isRtl()||"tl-tr"==n.parent().rel;for(r.nextSibling.innerHTML=e+1+" x "+(t+1),u&&(e=9-e),a=0;10>a;a++)for(o=0;10>o;o++)l=r.rows[a].childNodes[o].firstChild,c=(u?o>=e:e>=o)&&t>=a,i.dom.toggleClass(l,"mce-active",c),c&&(s=l);return s.parentNode}var m,h=this,g=new r(i);i.settings.table_grid===!1?i.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onclick:g.table}):i.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(e){e.aria&&(this.parent().hideAll(),e.stopImmediatePropagation(),g.table())},onshow:function(){p(0,0,this.menu.items()[0])},onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");i.dom.removeClass(e,"mce-active"),i.dom.addClass(e[0],"mce-active")},menu:[{type:"container",html:f(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t=e.target,n,r;"A"==t.tagName.toUpperCase()&&(n=parseInt(t.getAttribute("data-mce-x"),10),r=parseInt(t.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(n=9-n),(n!==this.lastX||r!==this.lastY)&&(p(n,r,e.control),this.lastX=n,this.lastY=r))},onclick:function(e){var t=this;"A"==e.target.tagName.toUpperCase()&&(e.preventDefault(),e.stopPropagation(),t.parent().cancel(),i.undoManager.transact(function(){s(t.lastX+1,t.lastY+1)}),i.addVisual())}}]}),i.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:u,onclick:g.tableProps}),i.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:u,cmd:"mceTableDelete"}),i.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:o("mceTableCellProps"),onPostRender:d},{text:"Merge cells",onclick:o("mceTableMergeCells"),onPostRender:d},{text:"Split cell",onclick:o("mceTableSplitCells"),onPostRender:d}]}),i.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:o("mceTableInsertRowBefore"),onPostRender:d},{text:"Insert row after",onclick:o("mceTableInsertRowAfter"),onPostRender:d},{text:"Delete row",onclick:o("mceTableDeleteRow"),onPostRender:d},{text:"Row properties",onclick:o("mceTableRowProps"),onPostRender:d},{text:"-"},{text:"Cut row",onclick:o("mceTableCutRow"),onPostRender:d},{text:"Copy row",onclick:o("mceTableCopyRow"),onPostRender:d},{text:"Paste row before",onclick:o("mceTablePasteRowBefore"),onPostRender:d},{text:"Paste row after",onclick:o("mceTablePasteRowAfter"),onPostRender:d}]}),i.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:o("mceTableInsertColBefore"),onPostRender:d},{text:"Insert column after",onclick:o("mceTableInsertColAfter"),onPostRender:d},{text:"Delete column",onclick:o("mceTableDeleteCol"),onPostRender:d}]});var v=[];c("inserttable tableprops deletetable | cell row column".split(" "),function(e){v.push("|"==e?{text:"-"}:i.menuItems[e])}),i.addButton("table",{type:"menubutton",title:"Table",menu:v}),a.isIE||i.on("click",function(e){e=e.target,"TABLE"===e.nodeName&&(i.selection.select(e),i.nodeChanged())}),h.quirks=new t(i),i.on("Init",function(){h.cellSelection=new n(i)}),c({mceTableSplitCells:function(e){e.split()},mceTableMergeCells:function(e){var t;t=i.dom.getParent(i.selection.getStart(),"th,td"),i.dom.select("td.mce-item-selected,th.mce-item-selected").length?e.merge():g.merge(e,t)},mceTableInsertRowBefore:function(e){e.insertRow(!0)},mceTableInsertRowAfter:function(e){e.insertRow()},mceTableInsertColBefore:function(e){e.insertCol(!0)},mceTableInsertColAfter:function(e){e.insertCol()},mceTableDeleteCol:function(e){e.deleteCols()},mceTableDeleteRow:function(e){e.deleteRows()},mceTableCutRow:function(e){m=e.cutRows()},mceTableCopyRow:function(e){m=e.copyRows()},mceTablePasteRowBefore:function(e){e.pasteRows(m,!0)},mceTablePasteRowAfter:function(e){e.pasteRows(m)},mceTableDelete:function(e){e.deleteTable()}},function(t,n){i.addCommand(n,function(){var n=new e(i);n&&(t(n),i.execCommand("mceRepaint"),h.cellSelection.clear())})}),c({mceInsertTable:g.table,mceTableProps:function(){g.table(!0)},mceTableRowProps:g.row,mceTableCellProps:g.cell},function(e,t){i.addCommand(t,function(t,n){e(n)})}),i.settings.table_tab_navigation!==!1&&i.on("keydown",function(t){var n,r,o;9==t.keyCode&&(n=i.dom.getParent(i.selection.getStart(),"th,td"),n&&(t.preventDefault(),r=new e(i),o=t.shiftKey?-1:1,i.undoManager.transact(function(){!r.moveRelIdx(n,o)&&o>0&&(r.insertRow(),r.refresh(),r.moveRelIdx(n,o))})))}),h.insertTable=s}var c=i.each;s.add("table",l)}),a([])}(this);
mce/textpattern/plugin.js ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * plugin.js
3
+ *
4
+ * Copyright, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://www.tinymce.com/license
8
+ * Contributing: http://www.tinymce.com/contributing
9
+ */
10
+
11
+ /*global tinymce:true */
12
+
13
+ tinymce.PluginManager.add('textpattern', function(editor) {
14
+ var isPatternsDirty = true, patterns;
15
+
16
+ patterns = editor.settings.textpattern_patterns || [
17
+ {start: '*', end: '*', format: 'italic'},
18
+ {start: '**', end: '**', format: 'bold'},
19
+ {start: '#', format: 'h1'},
20
+ {start: '##', format: 'h2'},
21
+ {start: '###', format: 'h3'},
22
+ {start: '####', format: 'h4'},
23
+ {start: '#####', format: 'h5'},
24
+ {start: '######', format: 'h6'},
25
+ {start: '1. ', cmd: 'InsertOrderedList'},
26
+ {start: '* ', cmd: 'InsertUnorderedList'},
27
+ {start: '- ', cmd: 'InsertUnorderedList'}
28
+ ];
29
+
30
+ // Returns a sorted patterns list, ordered descending by start length
31
+ function getPatterns() {
32
+ if (isPatternsDirty) {
33
+ patterns.sort(function(a, b) {
34
+ if (a.start.length > b.start.length) {
35
+ return -1;
36
+ }
37
+
38
+ if (a.start.length < b.start.length) {
39
+ return 1;
40
+ }
41
+
42
+ return 0;
43
+ });
44
+
45
+ isPatternsDirty = false;
46
+ }
47
+
48
+ return patterns;
49
+ }
50
+
51
+ // Finds a matching pattern to the specified text
52
+ function findPattern(text) {
53
+ var patterns = getPatterns();
54
+
55
+ for (var i = 0; i < patterns.length; i++) {
56
+ if (text.indexOf(patterns[i].start) !== 0) {
57
+ continue;
58
+ }
59
+
60
+ if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
61
+ continue;
62
+ }
63
+
64
+ return patterns[i];
65
+ }
66
+ }
67
+
68
+ // Finds the best matching end pattern
69
+ function findEndPattern(text, offset, delta) {
70
+ var patterns, pattern, i;
71
+
72
+ // Find best matching end
73
+ patterns = getPatterns();
74
+ for (i = 0; i < patterns.length; i++) {
75
+ pattern = patterns[i];
76
+ if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end.length) == pattern.end) {
77
+ return pattern;
78
+ }
79
+ }
80
+ }
81
+
82
+ // Handles inline formats like *abc* and **abc**
83
+ function applyInlineFormat(space) {
84
+ var selection, dom, rng, container, offset, startOffset, text, patternRng, pattern, delta, format;
85
+
86
+ function splitContainer() {
87
+ // Split text node and remove start/end from text node
88
+ container = container.splitText(startOffset);
89
+ container.splitText(offset - startOffset - delta);
90
+ container.deleteData(0, pattern.start.length);
91
+ container.deleteData(container.data.length - pattern.end.length, pattern.end.length);
92
+ }
93
+
94
+ selection = editor.selection;
95
+ dom = editor.dom;
96
+
97
+ if (!selection.isCollapsed()) {
98
+ return;
99
+ }
100
+
101
+ rng = selection.getRng(true);
102
+ container = rng.startContainer;
103
+ offset = rng.startOffset;
104
+ text = container.data;
105
+ delta = space ? 1 : 0;
106
+
107
+ if (container.nodeType != 3) {
108
+ return;
109
+ }
110
+
111
+ // Find best matching end
112
+ pattern = findEndPattern(text, offset, delta);
113
+ if (!pattern) {
114
+ return;
115
+ }
116
+
117
+ // Find start of matched pattern
118
+ // TODO: Might need to improve this if there is nested formats
119
+ startOffset = Math.max(0, offset - delta);
120
+ startOffset = text.lastIndexOf(pattern.start, startOffset - pattern.end.length - 1);
121
+
122
+ if (startOffset === -1) {
123
+ return;
124
+ }
125
+
126
+ // Setup a range for the matching word
127
+ patternRng = dom.createRng();
128
+ patternRng.setStart(container, startOffset);
129
+ patternRng.setEnd(container, offset - delta);
130
+ pattern = findPattern(patternRng.toString());
131
+
132
+ if (!pattern || !pattern.end) {
133
+ return;
134
+ }
135
+
136
+ // If container match doesn't have anything between start/end then do nothing
137
+ if (container.data.length <= pattern.start.length + pattern.end.length) {
138
+ return;
139
+ }
140
+
141
+ format = editor.formatter.get(pattern.format);
142
+ if (format && format[0].inline) {
143
+ splitContainer();
144
+ editor.formatter.apply(pattern.format, {}, container);
145
+ return container;
146
+ }
147
+ }
148
+
149
+ // Handles block formats like ##abc or 1. abc
150
+ function applyBlockFormat() {
151
+ var selection, dom, container, firstTextNode, node, format, textBlockElm, pattern, walker, rng, offset;
152
+
153
+ selection = editor.selection;
154
+ dom = editor.dom;
155
+
156
+ if (!selection.isCollapsed()) {
157
+ return;
158
+ }
159
+
160
+ textBlockElm = dom.getParent(selection.getStart(), 'p');
161
+ if (textBlockElm) {
162
+ walker = new tinymce.dom.TreeWalker(textBlockElm, textBlockElm);
163
+ while ((node = walker.next())) {
164
+ if (node.nodeType == 3) {
165
+ firstTextNode = node;
166
+ break;
167
+ }
168
+ }
169
+
170
+ if (firstTextNode) {
171
+ pattern = findPattern(firstTextNode.data);
172
+ if (!pattern) {
173
+ return;
174
+ }
175
+
176
+ rng = selection.getRng(true);
177
+ container = rng.startContainer;
178
+ offset = rng.startOffset;
179
+
180
+ if (firstTextNode == container) {
181
+ offset = Math.max(0, offset - pattern.start.length);
182
+ }
183
+
184
+ if (tinymce.trim(firstTextNode.data).length == pattern.start.length) {
185
+ return;
186
+ }
187
+
188
+ if (pattern.format) {
189
+ format = editor.formatter.get(pattern.format);
190
+ if (format && format[0].block) {
191
+ firstTextNode.deleteData(0, pattern.start.length);
192
+ editor.formatter.apply(pattern.format, {}, firstTextNode);
193
+
194
+ rng.setStart(container, offset);
195
+ rng.collapse(true);
196
+ selection.setRng(rng);
197
+ }
198
+ }
199
+
200
+ if (pattern.cmd) {
201
+ editor.undoManager.transact(function() {
202
+ firstTextNode.deleteData(0, pattern.start.length);
203
+ editor.execCommand(pattern.cmd);
204
+ });
205
+ }
206
+ }
207
+ }
208
+ }
209
+
210
+ function handleEnter() {
211
+ var rng, wrappedTextNode;
212
+
213
+ wrappedTextNode = applyInlineFormat();
214
+ if (wrappedTextNode) {
215
+ rng = editor.dom.createRng();
216
+ rng.setStart(wrappedTextNode, wrappedTextNode.data.length);
217
+ rng.setEnd(wrappedTextNode, wrappedTextNode.data.length);
218
+ editor.selection.setRng(rng);
219
+ }
220
+
221
+ applyBlockFormat();
222
+ }
223
+
224
+ function handleSpace() {
225
+ var wrappedTextNode, lastChar, lastCharNode, rng, dom;
226
+
227
+ wrappedTextNode = applyInlineFormat(true);
228
+ if (wrappedTextNode) {
229
+ dom = editor.dom;
230
+ lastChar = wrappedTextNode.data.slice(-1);
231
+
232
+ // Move space after the newly formatted node
233
+ if (/[\u00a0 ]/.test(lastChar)) {
234
+ wrappedTextNode.deleteData(wrappedTextNode.data.length - 1, 1);
235
+ lastCharNode = dom.doc.createTextNode(lastChar);
236
+
237
+ if (wrappedTextNode.nextSibling) {
238
+ dom.insertAfter(lastCharNode, wrappedTextNode.nextSibling);
239
+ } else {
240
+ wrappedTextNode.parentNode.appendChild(lastCharNode);
241
+ }
242
+
243
+ rng = dom.createRng();
244
+ rng.setStart(lastCharNode, 1);
245
+ rng.setEnd(lastCharNode, 1);
246
+ editor.selection.setRng(rng);
247
+ }
248
+ }
249
+ }
250
+
251
+ editor.on('keydown', function(e) {
252
+ if (e.keyCode == 13 && !tinymce.util.VK.modifierPressed(e)) {
253
+ handleEnter();
254
+ }
255
+ }, true);
256
+
257
+ editor.on('keyup', function(e) {
258
+ if (e.keyCode == 32 && !tinymce.util.VK.modifierPressed(e)) {
259
+ handleSpace();
260
+ }
261
+ });
262
+
263
+ this.getPatterns = getPatterns;
264
+ this.setPatterns = function(newPatterns) {
265
+ patterns = newPatterns;
266
+ isPatternsDirty = true;
267
+ };
268
+ });
mce/textpattern/plugin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ tinymce.PluginManager.add("textpattern",function(t){function e(){return l&&(i.sort(function(t,e){return t.start.length>e.start.length?-1:t.start.length<e.start.length?1:0}),l=!1),i}function n(t){for(var n=e(),a=0;a<n.length;a++)if(0===t.indexOf(n[a].start)&&(!n[a].end||t.lastIndexOf(n[a].end)==t.length-n[a].end.length))return n[a]}function a(t,n,a){var r,s,d;for(r=e(),d=0;d<r.length;d++)if(s=r[d],s.end&&t.substr(n-s.end.length-a,s.end.length)==s.end)return s}function r(e){function r(){i=i.splitText(f),i.splitText(l-f-h),i.deleteData(0,m.start.length),i.deleteData(i.data.length-m.end.length,m.end.length)}var s,d,o,i,l,f,g,c,m,h,u;return s=t.selection,d=t.dom,s.isCollapsed()&&(o=s.getRng(!0),i=o.startContainer,l=o.startOffset,g=i.data,h=e?1:0,3==i.nodeType&&(m=a(g,l,h),m&&(f=Math.max(0,l-h),f=g.lastIndexOf(m.start,f-m.end.length-1),-1!==f&&(c=d.createRng(),c.setStart(i,f),c.setEnd(i,l-h),m=n(c.toString()),m&&m.end&&!(i.data.length<=m.start.length+m.end.length)))))?(u=t.formatter.get(m.format),u&&u[0].inline?(r(),t.formatter.apply(m.format,{},i),i):void 0):void 0}function s(){var e,a,r,s,d,o,i,l,f,g,c;if(e=t.selection,a=t.dom,e.isCollapsed()&&(i=a.getParent(e.getStart(),"p"))){for(f=new tinymce.dom.TreeWalker(i,i);d=f.next();)if(3==d.nodeType){s=d;break}if(s){if(l=n(s.data),!l)return;if(g=e.getRng(!0),r=g.startContainer,c=g.startOffset,s==r&&(c=Math.max(0,c-l.start.length)),tinymce.trim(s.data).length==l.start.length)return;l.format&&(o=t.formatter.get(l.format),o&&o[0].block&&(s.deleteData(0,l.start.length),t.formatter.apply(l.format,{},s),g.setStart(r,c),g.collapse(!0),e.setRng(g))),l.cmd&&t.undoManager.transact(function(){s.deleteData(0,l.start.length),t.execCommand(l.cmd)})}}}function d(){var e,n;n=r(),n&&(e=t.dom.createRng(),e.setStart(n,n.data.length),e.setEnd(n,n.data.length),t.selection.setRng(e)),s()}function o(){var e,n,a,s,d;e=r(!0),e&&(d=t.dom,n=e.data.slice(-1),/[\u00a0 ]/.test(n)&&(e.deleteData(e.data.length-1,1),a=d.doc.createTextNode(n),e.nextSibling?d.insertAfter(a,e.nextSibling):e.parentNode.appendChild(a),s=d.createRng(),s.setStart(a,1),s.setEnd(a,1),t.selection.setRng(s)))}var i,l=!0;i=t.settings.textpattern_patterns||[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],t.on("keydown",function(t){13!=t.keyCode||tinymce.util.VK.modifierPressed(t)||d()},!0),t.on("keyup",function(t){32!=t.keyCode||tinymce.util.VK.modifierPressed(t)||o()}),this.getPatterns=e,this.setPatterns=function(t){i=t,l=!0}});
mce/visualblocks/css/visualblocks.css CHANGED
@@ -126,3 +126,10 @@
126
  margin: 0 0 1em 3px;
127
  background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybH6HHt0qourxC6CvzXieHyeWQAAOw==);
128
  }
 
 
 
 
 
 
 
126
  margin: 0 0 1em 3px;
127
  background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybH6HHt0qourxC6CvzXieHyeWQAAOw==);
128
  }
129
+
130
+ .mce-visualblocks dl {
131
+ padding-top: 10px;
132
+ border: 1px dashed #BBB;
133
+ margin: 0 0 1em 3px;
134
+ background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybEOnmOvUoWznTqeuEjNSCqeGRUAOw==);
135
+ }
mce/visualblocks/img/dl.gif ADDED
Binary file
mce/wptadv/plugin.js CHANGED
@@ -1,14 +1,7 @@
1
  /*global tinymce:true */
2
 
3
  tinymce.PluginManager.add('wptadv', function( editor ) {
4
-
5
  editor.on( 'init', function() {
6
- editor.formatter.register({
7
- valigntop: [{selector: 'td,th', styles: {'verticalAlign': 'top'}}],
8
- valignmiddle: [{selector: 'td,th', styles: {'verticalAlign': 'middle'}}],
9
- valignbottom: [{selector: 'td,th', styles: {'verticalAlign': 'bottom'}}]
10
- });
11
-
12
  if ( ! editor.settings.wpautop && editor.settings.tadv_noautop ) {
13
  editor.on( 'SaveContent', function( event ) {
14
  var regex = [
1
  /*global tinymce:true */
2
 
3
  tinymce.PluginManager.add('wptadv', function( editor ) {
 
4
  editor.on( 'init', function() {
 
 
 
 
 
 
5
  if ( ! editor.settings.wpautop && editor.settings.tadv_noautop ) {
6
  editor.on( 'SaveContent', function( event ) {
7
  var regex = [
mce/wptadv/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("wptadv",function(a){a.on("init",function(){a.formatter.register({valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}]}),!a.settings.wpautop&&a.settings.tadv_noautop&&a.on("SaveContent",function(a){var b=[new RegExp("https?://(www.)?youtube.com/watch.*","i"),new RegExp("http://youtu.be/*"),new RegExp("http://blip.tv/*"),new RegExp("https?://(www.)?vimeo.com/.*","i"),new RegExp("https?://(www.)?dailymotion.com/.*","i"),new RegExp("http://dai.ly/*"),new RegExp("https?://(www.)?flickr.com/.*","i"),new RegExp("http://flic.kr/*"),new RegExp("https?://(.+.)?smugmug.com/.*","i"),new RegExp("https?://(www.)?hulu.com/watch/.*","i"),new RegExp("https?://(www.)?viddler.com/.*","i"),new RegExp("http://qik.com/*"),new RegExp("http://revision3.com/*"),new RegExp("http://i*.photobucket.com/albums/*"),new RegExp("http://gi*.photobucket.com/groups/*"),new RegExp("https?://(www.)?scribd.com/.*","i"),new RegExp("http://wordpress.tv/*"),new RegExp("https?://(.+.)?polldaddy.com/.*","i"),new RegExp("https?://(www.)?funnyordie.com/videos/.*","i"),new RegExp("https?://(www.)?twitter.com/.+?/status(es)?/.*","i"),new RegExp("https?://(www.)?soundcloud.com/.*","i"),new RegExp("https?://(www.)?slideshare.net/*","i"),new RegExp("http://instagr(.am|am.com)/p/.*","i"),new RegExp("https?://(www.)?rdio.com/.*","i"),new RegExp("https?://rd.io/x/.*","i"),new RegExp("https?://(open|play).spotify.com/.*","i")];a.content=a.content.replace(/<p>(https?:\/\/[^<> "]+?)<\/p>/gi,function(a,c){for(var d in b)if(b[d].test(c))return"\n"+c+"\n";return a}).replace(/caption\]\[caption/g,"caption] [caption").replace(/<(object|audio|video)[\s\S]+?<\/\1>/g,function(a){return a.replace(/[\r\n]+/g," ")}).replace(/<pre[^>]*>[\s\S]+?<\/pre>/g,function(a){return a=a.replace(/<br ?\/?>(\r\n|\n)?/g,"\n"),a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"\n")})})})});
1
+ tinymce.PluginManager.add("wptadv",function(a){a.on("init",function(){!a.settings.wpautop&&a.settings.tadv_noautop&&a.on("SaveContent",function(a){var b=[new RegExp("https?://(www.)?youtube.com/watch.*","i"),new RegExp("http://youtu.be/*"),new RegExp("http://blip.tv/*"),new RegExp("https?://(www.)?vimeo.com/.*","i"),new RegExp("https?://(www.)?dailymotion.com/.*","i"),new RegExp("http://dai.ly/*"),new RegExp("https?://(www.)?flickr.com/.*","i"),new RegExp("http://flic.kr/*"),new RegExp("https?://(.+.)?smugmug.com/.*","i"),new RegExp("https?://(www.)?hulu.com/watch/.*","i"),new RegExp("https?://(www.)?viddler.com/.*","i"),new RegExp("http://qik.com/*"),new RegExp("http://revision3.com/*"),new RegExp("http://i*.photobucket.com/albums/*"),new RegExp("http://gi*.photobucket.com/groups/*"),new RegExp("https?://(www.)?scribd.com/.*","i"),new RegExp("http://wordpress.tv/*"),new RegExp("https?://(.+.)?polldaddy.com/.*","i"),new RegExp("https?://(www.)?funnyordie.com/videos/.*","i"),new RegExp("https?://(www.)?twitter.com/.+?/status(es)?/.*","i"),new RegExp("https?://(www.)?soundcloud.com/.*","i"),new RegExp("https?://(www.)?slideshare.net/*","i"),new RegExp("http://instagr(.am|am.com)/p/.*","i"),new RegExp("https?://(www.)?rdio.com/.*","i"),new RegExp("https?://rd.io/x/.*","i"),new RegExp("https?://(open|play).spotify.com/.*","i")];a.content=a.content.replace(/<p>(https?:\/\/[^<> "]+?)<\/p>/gi,function(a,c){for(var d in b)if(b[d].test(c))return"\n"+c+"\n";return a}).replace(/caption\]\[caption/g,"caption] [caption").replace(/<(object|audio|video)[\s\S]+?<\/\1>/g,function(a){return a.replace(/[\r\n]+/g," ")}).replace(/<pre[^>]*>[\s\S]+?<\/pre>/g,function(a){return a=a.replace(/<br ?\/?>(\r\n|\n)?/g,"\n"),a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"\n")})})})});
readme.txt CHANGED
@@ -1,10 +1,11 @@
1
  === TinyMCE Advanced ===
2
  Contributors: azaozz
3
  Tags: wysiwyg, formatting, tinymce, write, editor
4
- License: GPL v2
5
- Requires at least: 3.9
6
- Tested up to: 3.9
7
- Stable tag: 4.0.1
 
8
 
9
  Enables the advanced features of TinyMCE, the WordPress WYSIWYG editor.
10
 
@@ -29,6 +30,11 @@ Best is to install directly from WordPress. If manual installation is required,
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
32
  = 4.0.2 =
33
  * Fix showing of the second, third and forth button rows when the Toolbar Toggle button is not used.
34
  * Fix adding the ''directionality'' plugin when RTL or LTR button is selected.
@@ -103,8 +109,8 @@ Includes an admin page for arranging the TinyMCE toolbar buttons, easy installat
103
 
104
  == Upgrade Notice ==
105
 
106
- = 4.0.2 =
107
- Fixes for showing of all toolbars, advanced options for superadmins, vertical align for table cells, and more.
108
 
109
  == Frequently Asked Questions ==
110
 
1
  === TinyMCE Advanced ===
2
  Contributors: azaozz
3
  Tags: wysiwyg, formatting, tinymce, write, editor
4
+ Requires at least: 4.0
5
+ Tested up to: 4.0
6
+ Stable tag: 4.1
7
+ License: GPLv2
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Enables the advanced features of TinyMCE, the WordPress WYSIWYG editor.
11
 
30
 
31
  == Changelog ==
32
 
33
+ = 4.1 =
34
+ * Updated for WordPress 4.0 and TinyMCE 4.1.
35
+ * Add the 'textpattern' plugin that supports some of the markdown syntax while typing, [(more info)](http://www.tinymce.com/wiki.php/Configuration:textpattern_patterns).
36
+ * Add the updated 'table' plugin that supports background and border color.
37
+
38
  = 4.0.2 =
39
  * Fix showing of the second, third and forth button rows when the Toolbar Toggle button is not used.
40
  * Fix adding the ''directionality'' plugin when RTL or LTR button is selected.
109
 
110
  == Upgrade Notice ==
111
 
112
+ = 4.1 =
113
+ Includes the 'textpattern' plugin that supports some of the markdown syntax while typing, and the updated 'table' plugin that supports background and border color for tables.
114
 
115
  == Frequently Asked Questions ==
116
 
tadv_admin.php CHANGED
@@ -3,7 +3,7 @@
3
  if ( ! defined( 'TADV_ADMIN_PAGE' ) ) {
4
  exit;
5
  }
6
-
7
  // TODO
8
  if ( ! current_user_can( 'manage_options' ) ) {
9
  wp_die('Access denied');
@@ -14,8 +14,15 @@ $message = '';
14
  // TODO admin || SA
15
  if ( ! $this->check_minimum_supported_version() ) {
16
  ?>
17
- <div class="error" style="margin-top:30px;">
18
- <p><?php _e( 'This plugin requires WordPress version 3.9 or newer. Please upgrade your WordPress installation or download an', 'tadv'); ?> <a href="http://wordpress.org/extend/plugins/tinymce-advanced/download/"><?php _e('older version of the plugin.', 'tadv'); ?></a></p>
 
 
 
 
 
 
 
19
  </div>
20
  <?php
21
 
@@ -60,7 +67,8 @@ if ( isset( $_POST['tadv-save'] ) ) {
60
 
61
  if ( ! empty( $_POST['menubar'] ) ) {
62
  $options_array[] = 'menubar';
63
- $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace', 'table', 'visualblocks', 'visualchars' );
 
64
  }
65
 
66
  // Admin settings, TODO
@@ -68,10 +76,22 @@ if ( isset( $_POST['tadv-save'] ) ) {
68
  $admin_settings_array[] = 'importcss';
69
  }
70
 
 
 
 
 
71
  if ( ! empty( $_POST['no_autop'] ) ) {
72
  $admin_settings_array[] = 'no_autop';
73
  }
74
 
 
 
 
 
 
 
 
 
75
  if ( ! empty( $_POST['editorstyle'] ) ) {
76
  $admin_settings_array[] = 'editorstyle';
77
  }
@@ -122,7 +142,7 @@ if ( isset( $_POST['tadv-save'] ) ) {
122
  $this->settings = $this->default_settings;
123
  update_option( 'tadv_settings', $this->default_settings );
124
 
125
- $message = '<div class="updated"><p>' . __('Default settings restored.', 'tadv') . '</p></div>';
126
  } elseif ( isset( $_POST['tadv-export-settings'] ) ) {
127
  $this->load_settings();
128
  $output = array( 'settings' => $this->settings );
@@ -131,24 +151,24 @@ if ( isset( $_POST['tadv-save'] ) ) {
131
 
132
  ?>
133
  <div class="wrap">
134
- <h2><?php _e('TinyMCE Advanced Settings Export', 'tadv'); ?></h2>
135
 
136
  <div class="tadv-import-export">
137
  <p>
138
  <?php
139
 
140
- _e( 'The settings are exported as a JSON encoded string. ', 'tadv' );
141
- _e( 'Please copy the content and save it in a <b>text</b> (.txt) file, using a plain text editor like Notepad. ', 'tadv' );
142
- _e( 'It is important that the export is not changed in any way, no spaces, line breaks, etc.', 'tadv' );
143
 
144
  ?>
145
  </p>
146
 
147
  <form action="">
148
  <p><textarea readonly="readonly" id="tadv-export"><?php echo json_encode( $output ); ?></textarea></p>
149
- <p><button type="button" class="button" id="tadv-export-select"><?php _e( 'Select All', 'tadv' ); ?></button></p>
150
  </form>
151
- <p><a href=""><?php _e('Back to Editor Settings', 'tadv'); ?></a></p>
152
  </div>
153
  </div>
154
  <?php
@@ -158,29 +178,29 @@ if ( isset( $_POST['tadv-save'] ) ) {
158
  // TODO ! admin && ! SA
159
  ?>
160
  <div class="wrap">
161
- <h2><?php _e('TinyMCE Advanced Settings Import', 'tadv'); ?></h2>
162
 
163
  <div class="tadv-import-export">
164
  <p><?php
165
-
166
- _e( 'The settings are imported from a JSON encoded string. Please paste the exported string in the textarea below.', 'tadv' );
167
-
168
  ?></p>
169
 
170
  <form action="" method="post">
171
  <p><textarea id="tadv-import" name="tadv-import"></textarea></p>
172
  <p>
173
- <button type="button" class="button" id="tadv-import-verify"><?php _e( 'Verify', 'tadv' ); ?></button>
174
- <input type="submit" class="button button-primary alignright" name="tadv-import-submit" value="<?php _e( 'Import', 'tadv' ); ?>" />
 
175
  </p>
176
  <?php wp_nonce_field('tadv-import'); ?>
177
  <p id="tadv-import-error"></p>
178
  </form>
179
- <p><a href=""><?php _e('Back to Editor Settings', 'tadv'); ?></a></p>
180
  </div>
181
  </div>
182
  <?php
183
-
184
  return;
185
  } elseif ( isset( $_POST['tadv-import-submit'] ) && ! empty( $_POST['tadv-import'] ) && is_string( $_POST['tadv-import'] ) ) {
186
  check_admin_referer( 'tadv-import' );
@@ -198,23 +218,23 @@ if ( isset( $_POST['tadv-save'] ) ) {
198
  }
199
 
200
  if ( empty( $settings ) ) {
201
- $message = '<div class="error"><p>' . __('Importing of settings failed.', 'tadv') . '</p></div>';
202
  } else {
203
  $this->admin_settings = $admin_settings;
204
  update_option( 'tadv_admin_settings', $admin_settings );
205
-
206
  // User options
207
  // TODO allow editors, authors and contributors some access
208
  $this->settings = $settings;
209
  $this->load_settings();
210
-
211
  // Merge the submitted plugins and from the buttons
212
  if ( ! empty( $settings['plugins'] ) ) {
213
  $settings['plugins'] = implode( ',', $this->get_plugins( explode( ',', $settings['plugins'] ) ) );
214
  }
215
 
216
  $this->plugins = $settings['plugins'];
217
-
218
  // Save the new settings
219
  update_option( 'tadv_settings', $settings );
220
  }
@@ -223,7 +243,9 @@ if ( isset( $_POST['tadv-save'] ) ) {
223
  $this->load_settings();
224
 
225
  if ( empty( $this->toolbar_1 ) && empty( $this->toolbar_2 ) && empty( $this->toolbar_3 ) && empty( $this->toolbar_4 ) ) {
226
- $message = '<div class="error"><p>' . __('ERROR: All toolbars are empty. Default settings loaded.', 'tadv') . '</p></div>';
 
 
227
 
228
  $this->admin_settings = $this->default_admin_settings;
229
  $this->settings = $this->default_settings;
@@ -235,24 +257,30 @@ $all_buttons = $this->get_all_buttons();
235
 
236
  ?>
237
  <div class="wrap" id="contain">
238
- <h2><?php _e('Editor Settings', 'tadv'); ?></h2>
239
  <?php
240
 
241
  if ( isset( $_POST['tadv-save'] ) && empty( $message ) ) {
242
- ?><div class="updated" id="message"><p><?php _e( 'Settings saved.', 'tadv' ); ?></p></div><?php
243
  } else {
244
  echo $message;
245
  }
246
 
247
  ?>
248
  <form id="tadvadmin" method="post" action="">
 
 
 
 
 
249
  <div id="tadvzones">
250
 
251
- <p><?php _e( 'New in TinyMCE 4.0/WordPress 3.9 is the editor menu. When it is enabled, most buttons are also available as menu items.', 'tadv' ); ?></p>
 
252
 
253
  <p><label>
254
  <input type="checkbox" name="menubar" id="menubar" <?php if ( $this->check_setting( 'menubar' ) ) { echo ' checked="checked"'; } ?>>
255
- <?php _e('Enable the editor menu.', 'tadv'); ?>
256
  </label></p>
257
 
258
  <p id="tadv-menu-img" <?php if ( $this->check_setting( 'menubar' ) ) { echo ' class="enabled"'; } ?>>&nbsp;</p>
@@ -261,12 +289,12 @@ if ( isset( $_POST['tadv-save'] ) && empty( $message ) ) {
261
 
262
  for ( $i = 1; $i < 5; $i++ ) {
263
  $toolbar = "toolbar_$i";
264
-
265
  ?>
266
  <div class="tadvdropzone">
267
  <ul id="tb<?php echo $i; ?>" class="container">
268
  <?php
269
-
270
  foreach( $this->$toolbar as $button ) {
271
  if ( strpos( $button, 'separator' ) !== false || in_array( $button, array( 'moveforward', 'movebackward', 'absolute' ) ) ) {
272
  continue;
@@ -279,7 +307,7 @@ for ( $i = 1; $i < 5; $i++ ) {
279
  // error?..
280
  continue;
281
  }
282
-
283
  if ( strpos( $name, '<!' ) === 0 )
284
  $name = '';
285
 
@@ -301,10 +329,11 @@ for ( $i = 1; $i < 5; $i++ ) {
301
  ?>
302
  </div>
303
 
304
- <p><?php _e('Drag buttons from the unused buttons below and drop them in the toolbars above, or drag the buttons in the toolbars to rearrange them.', 'tadv'); ?></p>
 
305
 
306
  <div id="unuseddiv">
307
- <h3><?php _e('Unused Buttons', 'tadv'); ?></h3>
308
  <ul id="unused" class="container">
309
  <?php
310
 
@@ -334,17 +363,18 @@ foreach( $all_buttons as $button => $name ) {
334
  <p class="tadv-more-plugins"><?php _e( 'Also enable:' ); ?>
335
  <label>
336
  <input type="checkbox" name="advlist" id="advlist" <?php if ( $this->check_setting('advlist') ) echo ' checked="checked"'; ?> />
337
- <?php _e('List Style Options', 'tadv'); ?>
338
  </label>
339
 
340
  <label>
341
- <input type="checkbox" name="contextmenu" id="contextmenu" <?php if ( $this->check_setting('contextmenu') ) echo ' checked="checked"'; ?> />
342
- <?php _e('Context Menu', 'tadv'); ?>
 
343
  </label>
344
 
345
  <label>
346
  <input type="checkbox" name="advlink" id="advlink" <?php if ( $this->check_setting('advlink') ) echo ' checked="checked"'; ?> />
347
- <?php _e('Link (replaces the Insert/Edit Link dialog)', 'tadv'); ?>
348
  </label>
349
  </p>
350
 
@@ -354,19 +384,20 @@ if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
354
 
355
  ?>
356
  <div class="advanced-options">
357
- <h3><?php _e('Advanced Options', 'tadv'); ?></h3>
358
  <?php
359
-
360
  if ( ! is_multisite() && ! current_theme_supports( 'editor-style' ) ) {
361
-
362
  ?>
363
  <div>
364
- <label><input type="checkbox" name="editorstyle" id="editorstyle" <?php if ( $this->check_admin_setting( 'editorstyle' ) ) echo ' checked="checked"'; ?> />
365
- <?php _e('Import editor-style.css.', 'tadv'); ?></label>
 
366
  <p><?php
367
- _e('It seems your theme doesn\'t support customised styles for the editor. ', 'tadv');
368
- _e('You can create a CSS file named <code>editor-style.css</code> and upload it to your theme\'s directory. ', 'tadv');
369
- _e('After that, enable this setting.', 'tadv');
370
  ?></p>
371
  </div>
372
  <?php
@@ -374,26 +405,73 @@ if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
374
 
375
  ?>
376
  <div>
377
- <label><input type="checkbox" name="importcss" id="importcss" <?php if ( $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; ?> />
378
- <?php _e('Load the CSS classes used in editor-style.css and replace the Formats button and sub-menu.', 'tadv'); ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  </div>
380
 
381
  <div>
382
- <label><input type="checkbox" name="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
383
- <?php _e('Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the Text editor', 'tadv'); ?></label>
 
384
  <p><?php
385
- _e('This will make it possible to use more advanced coding in the HTML editor without the back-end filtering affecting it much. ', 'tadv');
386
- _e('However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. ', 'tadv');
387
- _e('Line breaks in the HTML editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br /&gt; tags.', 'tadv');
 
 
 
388
  ?></p>
389
  </div>
390
  </div>
391
-
392
  <div class="advanced-options">
393
- <h3><?php _e('Administration', 'tadv'); ?></h3>
394
  <div>
395
- <input type="submit" class="button" name="tadv-export-settings" value="<?php _e( 'Export Settings', 'tadv' ); ?>" /> &nbsp;
396
- <input type="submit" class="button" name="tadv-import-settings" value="<?php _e( 'Import Settings', 'tadv' ); ?>" />
 
 
397
  </div>
398
  </div>
399
  <?php
@@ -403,12 +481,15 @@ if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
403
 
404
  <p class="tadv-submit">
405
  <?php wp_nonce_field( 'tadv-save-buttons-order' ); ?>
406
- <input class="button" type="submit" name="tadv-restore-defaults" value="<?php _e('Restore Default Settings', 'tadv'); ?>" />
407
- <input class="button-primary button-large" type="submit" name="tadv-save" value="<?php _e('Save Changes', 'tadv'); ?>" />
 
 
408
  </p>
409
  </form>
410
 
411
  <div id="wp-adv-error-message" class="tadv-error">
412
- <?php _e('The "Toolbar toggle" button shows/hides the second, third, and forth button rows. It will only work when it is in the first row and there are buttons in the second row.', 'tadv'); ?>
 
413
  </div>
414
  </div><!-- /wrap -->
3
  if ( ! defined( 'TADV_ADMIN_PAGE' ) ) {
4
  exit;
5
  }
6
+
7
  // TODO
8
  if ( ! current_user_can( 'manage_options' ) ) {
9
  wp_die('Access denied');
14
  // TODO admin || SA
15
  if ( ! $this->check_minimum_supported_version() ) {
16
  ?>
17
+ <div class="wrap">
18
+ <div class="error">
19
+ <p><?php printf(
20
+ __( 'This plugin requires WordPress version 4.0 or newer. Please upgrade your WordPress ' .
21
+ 'installation or download an %1$solder version of the plugin%2$s.', 'tinymce-advanced' ),
22
+ '<a href="//wordpress.org/extend/plugins/tinymce-advanced/download/">',
23
+ '</a>'
24
+ ); ?></p>
25
+ </div>
26
  </div>
27
  <?php
28
 
67
 
68
  if ( ! empty( $_POST['menubar'] ) ) {
69
  $options_array[] = 'menubar';
70
+ $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace',
71
+ 'table', 'visualblocks', 'visualchars' );
72
  }
73
 
74
  // Admin settings, TODO
76
  $admin_settings_array[] = 'importcss';
77
  }
78
 
79
+ if ( ! empty( $_POST['textpattern'] ) ) {
80
+ $admin_settings_array[] = 'textpattern';
81
+ }
82
+
83
  if ( ! empty( $_POST['no_autop'] ) ) {
84
  $admin_settings_array[] = 'no_autop';
85
  }
86
 
87
+ if ( ! empty( $_POST['paste_images'] ) ) {
88
+ $admin_settings_array[] = 'paste_images';
89
+ }
90
+
91
+ if ( ! empty( $_POST['fontsize_formats'] ) ) {
92
+ $admin_settings_array[] = 'fontsize_formats';
93
+ }
94
+
95
  if ( ! empty( $_POST['editorstyle'] ) ) {
96
  $admin_settings_array[] = 'editorstyle';
97
  }
142
  $this->settings = $this->default_settings;
143
  update_option( 'tadv_settings', $this->default_settings );
144
 
145
+ $message = '<div class="updated"><p>' . __('Default settings restored.', 'tinymce-advanced') . '</p></div>';
146
  } elseif ( isset( $_POST['tadv-export-settings'] ) ) {
147
  $this->load_settings();
148
  $output = array( 'settings' => $this->settings );
151
 
152
  ?>
153
  <div class="wrap">
154
+ <h2><?php _e('TinyMCE Advanced Settings Export', 'tinymce-advanced'); ?></h2>
155
 
156
  <div class="tadv-import-export">
157
  <p>
158
  <?php
159
 
160
+ _e( 'The settings are exported as a JSON encoded string. Please copy the content ' .
161
+ 'and save it in a <b>text</b> (.txt) file, using a plain text editor like Notepad. ' .
162
+ 'It is important that the export is not changed in any way, no spaces, line breaks, etc.', 'tinymce-advanced' );
163
 
164
  ?>
165
  </p>
166
 
167
  <form action="">
168
  <p><textarea readonly="readonly" id="tadv-export"><?php echo json_encode( $output ); ?></textarea></p>
169
+ <p><button type="button" class="button" id="tadv-export-select"><?php _e( 'Select All', 'tinymce-advanced' ); ?></button></p>
170
  </form>
171
+ <p><a href=""><?php _e('Back to Editor Settings', 'tinymce-advanced'); ?></a></p>
172
  </div>
173
  </div>
174
  <?php
178
  // TODO ! admin && ! SA
179
  ?>
180
  <div class="wrap">
181
+ <h2><?php _e('TinyMCE Advanced Settings Import', 'tinymce-advanced'); ?></h2>
182
 
183
  <div class="tadv-import-export">
184
  <p><?php
185
+ _e( 'The settings are imported from a JSON encoded string. Please paste ' .
186
+ 'the exported string in the textarea below.', 'tinymce-advanced' );
 
187
  ?></p>
188
 
189
  <form action="" method="post">
190
  <p><textarea id="tadv-import" name="tadv-import"></textarea></p>
191
  <p>
192
+ <button type="button" class="button" id="tadv-import-verify"><?php _e( 'Verify', 'tinymce-advanced' ); ?></button>
193
+ <input type="submit" class="button button-primary alignright" name="tadv-import-submit" value="<?php
194
+ _e( 'Import', 'tinymce-advanced' ); ?>" />
195
  </p>
196
  <?php wp_nonce_field('tadv-import'); ?>
197
  <p id="tadv-import-error"></p>
198
  </form>
199
+ <p><a href=""><?php _e('Back to Editor Settings', 'tinymce-advanced'); ?></a></p>
200
  </div>
201
  </div>
202
  <?php
203
+
204
  return;
205
  } elseif ( isset( $_POST['tadv-import-submit'] ) && ! empty( $_POST['tadv-import'] ) && is_string( $_POST['tadv-import'] ) ) {
206
  check_admin_referer( 'tadv-import' );
218
  }
219
 
220
  if ( empty( $settings ) ) {
221
+ $message = '<div class="error"><p>' . __('Importing of settings failed.', 'tinymce-advanced') . '</p></div>';
222
  } else {
223
  $this->admin_settings = $admin_settings;
224
  update_option( 'tadv_admin_settings', $admin_settings );
225
+
226
  // User options
227
  // TODO allow editors, authors and contributors some access
228
  $this->settings = $settings;
229
  $this->load_settings();
230
+
231
  // Merge the submitted plugins and from the buttons
232
  if ( ! empty( $settings['plugins'] ) ) {
233
  $settings['plugins'] = implode( ',', $this->get_plugins( explode( ',', $settings['plugins'] ) ) );
234
  }
235
 
236
  $this->plugins = $settings['plugins'];
237
+
238
  // Save the new settings
239
  update_option( 'tadv_settings', $settings );
240
  }
243
  $this->load_settings();
244
 
245
  if ( empty( $this->toolbar_1 ) && empty( $this->toolbar_2 ) && empty( $this->toolbar_3 ) && empty( $this->toolbar_4 ) ) {
246
+ $message = '<div class="error"><p>' .
247
+ __('ERROR: All toolbars are empty. Default settings loaded.', 'tinymce-advanced') .
248
+ '</p></div>';
249
 
250
  $this->admin_settings = $this->default_admin_settings;
251
  $this->settings = $this->default_settings;
257
 
258
  ?>
259
  <div class="wrap" id="contain">
260
+ <h2><?php _e('Editor Settings', 'tinymce-advanced'); ?></h2>
261
  <?php
262
 
263
  if ( isset( $_POST['tadv-save'] ) && empty( $message ) ) {
264
+ ?><div class="updated" id="message"><p><?php _e( 'Settings saved.', 'tinymce-advanced' ); ?></p></div><?php
265
  } else {
266
  echo $message;
267
  }
268
 
269
  ?>
270
  <form id="tadvadmin" method="post" action="">
271
+
272
+ <p class="tadv-submit">
273
+ <input class="button-primary button-large" type="submit" name="tadv-save" value="<?php _e('Save Changes', 'tinymce-advanced'); ?>" />
274
+ </p>
275
+
276
  <div id="tadvzones">
277
 
278
+ <p><?php _e( 'New in TinyMCE 4.0/WordPress 3.9 is the editor menu. When it is enabled, ' .
279
+ 'most buttons are also available as menu items.', 'tinymce-advanced' ); ?></p>
280
 
281
  <p><label>
282
  <input type="checkbox" name="menubar" id="menubar" <?php if ( $this->check_setting( 'menubar' ) ) { echo ' checked="checked"'; } ?>>
283
+ <?php _e('Enable the editor menu.', 'tinymce-advanced'); ?>
284
  </label></p>
285
 
286
  <p id="tadv-menu-img" <?php if ( $this->check_setting( 'menubar' ) ) { echo ' class="enabled"'; } ?>>&nbsp;</p>
289
 
290
  for ( $i = 1; $i < 5; $i++ ) {
291
  $toolbar = "toolbar_$i";
292
+
293
  ?>
294
  <div class="tadvdropzone">
295
  <ul id="tb<?php echo $i; ?>" class="container">
296
  <?php
297
+
298
  foreach( $this->$toolbar as $button ) {
299
  if ( strpos( $button, 'separator' ) !== false || in_array( $button, array( 'moveforward', 'movebackward', 'absolute' ) ) ) {
300
  continue;
307
  // error?..
308
  continue;
309
  }
310
+
311
  if ( strpos( $name, '<!' ) === 0 )
312
  $name = '';
313
 
329
  ?>
330
  </div>
331
 
332
+ <p><?php _e('Drag buttons from the unused buttons below and drop them in the toolbars above, ' .
333
+ 'or drag the buttons in the toolbars to rearrange them.', 'tinymce-advanced'); ?></p>
334
 
335
  <div id="unuseddiv">
336
+ <h3><?php _e('Unused Buttons', 'tinymce-advanced'); ?></h3>
337
  <ul id="unused" class="container">
338
  <?php
339
 
363
  <p class="tadv-more-plugins"><?php _e( 'Also enable:' ); ?>
364
  <label>
365
  <input type="checkbox" name="advlist" id="advlist" <?php if ( $this->check_setting('advlist') ) echo ' checked="checked"'; ?> />
366
+ <?php _e('List Style Options', 'tinymce-advanced'); ?>
367
  </label>
368
 
369
  <label>
370
+ <input type="checkbox" name="contextmenu" id="contextmenu" <?php
371
+ if ( $this->check_setting('contextmenu') ) echo ' checked="checked"'; ?> />
372
+ <?php _e('Context Menu', 'tinymce-advanced'); ?>
373
  </label>
374
 
375
  <label>
376
  <input type="checkbox" name="advlink" id="advlink" <?php if ( $this->check_setting('advlink') ) echo ' checked="checked"'; ?> />
377
+ <?php _e('Link (replaces the Insert/Edit Link dialog)', 'tinymce-advanced'); ?>
378
  </label>
379
  </p>
380
 
384
 
385
  ?>
386
  <div class="advanced-options">
387
+ <h3><?php _e('Advanced Options', 'tinymce-advanced'); ?></h3>
388
  <?php
389
+
390
  if ( ! is_multisite() && ! current_theme_supports( 'editor-style' ) ) {
391
+
392
  ?>
393
  <div>
394
+ <label><input type="checkbox" name="editorstyle" id="editorstyle" <?php
395
+ if ( $this->check_admin_setting( 'editorstyle' ) ) echo ' checked="checked"'; ?> />
396
+ <?php _e('Import editor-style.css.', 'tinymce-advanced'); ?></label>
397
  <p><?php
398
+ _e( 'It seems your theme does not support customised styles for the editor. ' .
399
+ 'You can create a CSS file named <code>editor-style.css</code> and upload it to your ' .
400
+ 'theme\'s directory. After that, enable this setting.', 'tinymce-advanced' );
401
  ?></p>
402
  </div>
403
  <?php
405
 
406
  ?>
407
  <div>
408
+ <label><input type="checkbox" name="importcss" id="importcss" <?php
409
+ if ( $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; ?> />
410
+ <?php _e('Load the CSS classes used in editor-style.css and replace the Formats button ' .
411
+ 'and sub-menu.', 'tinymce-advanced'); ?></label>
412
+ </div>
413
+
414
+ <div>
415
+ <label><input type="checkbox" name="textpattern" id="textpattern" <?php
416
+ if ( $this->check_admin_setting('textpattern') ) echo ' checked="checked"'; ?> />
417
+ <?php _e('Markdown typing support (text pattern plugin)', 'tinymce-advanced'); ?></label>
418
+ <p><?php
419
+ _e( 'This plugin matches special patterns while you type and applies formats ' .
420
+ 'or executed commands on these text patterns. The default patterns are the ' .
421
+ 'same as the markdown syntax so you can type <code># text</code> to create ' .
422
+ 'a header, <code>1. text</code> to create a list, <code>**text**</code> ' .
423
+ 'to make something bold, etc.', 'tinymce-advanced' );
424
+ ?> <a href="http://www.tinymce.com/wiki.php/Configuration:textpattern_patterns" target="_blank"><?php
425
+ _e('More information', 'tinymce-advanced'); ?></a>
426
+ </p>
427
+ </div>
428
+
429
+ <div>
430
+ <label><input type="checkbox" name="no_autop" id="no_autop" <?php
431
+ if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
432
+ <?php _e('Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them ' .
433
+ 'in the Text editor', 'tinymce-advanced'); ?></label>
434
+ <p><?php
435
+ _e( 'This will make it possible to use more advanced coding in the HTML editor ' .
436
+ 'without the back-end filtering affecting it much. However it may behave ' .
437
+ 'unexpectedly in rare cases, so test it thoroughly before enabling it ' .
438
+ 'permanently. Line breaks in the HTML editor would still affect the output, ' .
439
+ 'in particular do not use empty lines, line breaks inside HTML tags ' .
440
+ 'or multiple &lt;br /&gt; tags.', 'tinymce-advanced' );
441
+ ?></p>
442
+ </div>
443
+
444
+ <div>
445
+ <label><input type="checkbox" name="fontsize_formats" id="fontsize_formats" <?php
446
+ if ( $this->check_admin_setting( 'fontsize_formats' ) ) echo ' checked="checked"'; ?> />
447
+ <?php _e('Replace font size settings', 'tinymce-advanced'); ?></label>
448
+ <p><?php
449
+ _e( 'Replaces the size setting available for fonts with: 8px 10px 12px 14px 16px 20px 24px 28px 32px 36px.', 'tinymce-advanced' );
450
+ ?></p>
451
  </div>
452
 
453
  <div>
454
+ <label><input type="checkbox" name="paste_images" id="paste_images" <?php
455
+ if ( $this->check_admin_setting( 'paste_images' ) ) echo ' checked="checked"'; ?> />
456
+ <?php _e('Enable pasting of image source', 'tinymce-advanced'); ?></label>
457
  <p><?php
458
+ _e( 'Works only in Firefox and Safari. These browsers support pasting of ' .
459
+ 'images directly in the editor and convert them to base64 encoded text. ' .
460
+ 'This is not acceptable for larger images like photos or graphics, ' .
461
+ 'but may be useful in some cases for very small images like icons, ' .
462
+ 'not larger than 2-3KB. These images will not be available in ' .
463
+ 'the Media Library.', 'tinymce-advanced' );
464
  ?></p>
465
  </div>
466
  </div>
467
+
468
  <div class="advanced-options">
469
+ <h3><?php _e('Administration', 'tinymce-advanced'); ?></h3>
470
  <div>
471
+ <input type="submit" class="button" name="tadv-export-settings" value="<?php
472
+ _e( 'Export Settings', 'tinymce-advanced' ); ?>" /> &nbsp;
473
+ <input type="submit" class="button" name="tadv-import-settings" value="<?php
474
+ _e( 'Import Settings', 'tinymce-advanced' ); ?>" />
475
  </div>
476
  </div>
477
  <?php
481
 
482
  <p class="tadv-submit">
483
  <?php wp_nonce_field( 'tadv-save-buttons-order' ); ?>
484
+ <input class="button" type="submit" name="tadv-restore-defaults" value="<?php
485
+ _e('Restore Default Settings', 'tinymce-advanced'); ?>" />
486
+ <input class="button-primary button-large" type="submit" name="tadv-save" value="<?php
487
+ _e('Save Changes', 'tinymce-advanced'); ?>" />
488
  </p>
489
  </form>
490
 
491
  <div id="wp-adv-error-message" class="tadv-error">
492
+ <?php _e('The "Toolbar toggle" button shows/hides the second, third, and forth button rows. '.
493
+ 'It will only work when it is in the first row and there are buttons in the second row.', 'tinymce-advanced'); ?>
494
  </div>
495
  </div><!-- /wrap -->
tinymce-advanced.php CHANGED
@@ -3,9 +3,10 @@
3
  Plugin Name: TinyMCE Advanced
4
  Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5
  Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6
- Version: 4.0.2
7
  Author: Andrew Ozz
8
  Author URI: http://www.laptoptips.ca/
 
9
 
10
  Released under the GPL version 2.0, http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -32,7 +33,7 @@ class Tinymce_Advanced {
32
  private $used_buttons = array();
33
  private $all_buttons = array();
34
  private $buttons_filter = array();
35
- private $all_plugins = array( 'advlist','anchor','code','contextmenu','emoticons','importcss','insertdatetime','nonbreaking','print','searchreplace','table','visualblocks','visualchars','link' );
36
 
37
  private $default_settings = array(
38
  'options' => 'menubar,advlist',
@@ -46,6 +47,11 @@ class Tinymce_Advanced {
46
  private $default_admin_settings = array( 'options' => array() );
47
 
48
  function __construct() {
 
 
 
 
 
49
  add_action( 'plugins_loaded', array( &$this, 'set_paths' ), 50 );
50
 
51
  if ( is_admin() ) {
@@ -67,6 +73,7 @@ class Tinymce_Advanced {
67
  add_filter( 'htmledit_pre', array( &$this, 'htmledit' ), 999 );
68
  add_filter( 'mce_external_plugins', array( &$this, 'mce_external_plugins' ), 999 );
69
  add_filter( 'tiny_mce_plugins', array( &$this, 'tiny_mce_plugins' ), 999 );
 
70
  }
71
 
72
  // When using a plugin that changes the paths dinamically, set these earlier than 'plugins_loaded' 50.
@@ -136,7 +143,7 @@ class Tinymce_Advanced {
136
 
137
  // Min version 3.9-RC1
138
  private function check_minimum_supported_version() {
139
- return ( isset( $GLOBALS['wp_db_version'] ) && $GLOBALS['wp_db_version'] > 27000 );
140
  }
141
 
142
  private function check_plugin_version() {
@@ -224,14 +231,6 @@ class Tinymce_Advanced {
224
  'wp_page' => 'Page Break',
225
  );
226
 
227
- if ( function_exists('moxiecode_plugins_url') ) {
228
- if ( moxiecode_plugins_url('imagemanager') )
229
- $buttons['insertimage'] = 'MC Image Manager';
230
-
231
- if ( moxiecode_plugins_url('filemanager') )
232
- $buttons['insertfile'] = 'MC File Manager';
233
- }
234
-
235
  // add/remove allowed buttons
236
  $buttons = apply_filters( 'tadv_allowed_buttons', $buttons );
237
 
@@ -289,6 +288,9 @@ class Tinymce_Advanced {
289
  if ( $this->check_setting( 'contextmenu' ) )
290
  $plugins[] = 'contextmenu';
291
 
 
 
 
292
  // add/remove used plugins
293
  $plugins = apply_filters( 'tadv_used_plugins', $plugins, $this->used_buttons );
294
 
@@ -315,10 +317,6 @@ class Tinymce_Advanced {
315
 
316
  $buttons_1 = $this->toolbar_1;
317
 
318
- if ( 'content' === $editor_id && ! in_array( 'wp_adv', $buttons_1, true ) ) {
319
- add_action( 'wp_enqueue_editor', array( &$this, 'wp_enqueue_editor' ) );
320
- }
321
-
322
  if ( is_array( $original ) && ! empty( $original ) ) {
323
  $original = array_diff( $original, $this->buttons_filter );
324
  $buttons_1 = array_merge( $buttons_1, $original );
@@ -400,9 +398,27 @@ class Tinymce_Advanced {
400
  $init['importcss_file_filter'] = 'editor-style.css';
401
  }
402
 
 
 
 
 
 
 
 
 
 
 
403
  return $init;
404
  }
405
 
 
 
 
 
 
 
 
 
406
  function htmledit( $c ) {
407
  if ( $this->check_admin_setting( 'no_autop' ) ) {
408
  $c = str_replace( array('&amp;', '&lt;', '&gt;'), array('&', '<', '>'), $c );
@@ -453,14 +469,6 @@ class Tinymce_Advanced {
453
  return $plugins;
454
  }
455
 
456
- function wp_enqueue_editor( $array ) {
457
- if ( ! empty( $array['tinymce'] ) ) {
458
- ?>
459
- <script>if ( typeof setUserSetting !== 'undefined' ) setUserSetting( 'hidetb', '1' );</script>
460
- <?php
461
- }
462
- }
463
-
464
  private function parse_buttons( $toolbar_id = false, $buttons = false ) {
465
  if ( $toolbar_id && ! $buttons && ! empty( $_POST[$toolbar_id] ) )
466
  $buttons = $_POST[$toolbar_id];
3
  Plugin Name: TinyMCE Advanced
4
  Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5
  Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6
+ Version: 4.1
7
  Author: Andrew Ozz
8
  Author URI: http://www.laptoptips.ca/
9
+ Text Domain: tinymce-advanced
10
 
11
  Released under the GPL version 2.0, http://www.gnu.org/licenses/gpl-2.0.html
12
 
33
  private $used_buttons = array();
34
  private $all_buttons = array();
35
  private $buttons_filter = array();
36
+ private $all_plugins = array( 'advlist','anchor','code','contextmenu','emoticons','importcss','insertdatetime','nonbreaking','print','searchreplace','table','visualblocks','visualchars','link','textpattern' );
37
 
38
  private $default_settings = array(
39
  'options' => 'menubar,advlist',
47
  private $default_admin_settings = array( 'options' => array() );
48
 
49
  function __construct() {
50
+ // Don't run outside of WP
51
+ if ( ! defined('ABSPATH') ) {
52
+ return;
53
+ }
54
+
55
  add_action( 'plugins_loaded', array( &$this, 'set_paths' ), 50 );
56
 
57
  if ( is_admin() ) {
73
  add_filter( 'htmledit_pre', array( &$this, 'htmledit' ), 999 );
74
  add_filter( 'mce_external_plugins', array( &$this, 'mce_external_plugins' ), 999 );
75
  add_filter( 'tiny_mce_plugins', array( &$this, 'tiny_mce_plugins' ), 999 );
76
+ add_action( 'after_wp_tiny_mce', array( &$this, 'after_wp_tiny_mce' ) );
77
  }
78
 
79
  // When using a plugin that changes the paths dinamically, set these earlier than 'plugins_loaded' 50.
143
 
144
  // Min version 3.9-RC1
145
  private function check_minimum_supported_version() {
146
+ return ( isset( $GLOBALS['wp_db_version'] ) && $GLOBALS['wp_db_version'] >= 29630 );
147
  }
148
 
149
  private function check_plugin_version() {
231
  'wp_page' => 'Page Break',
232
  );
233
 
 
 
 
 
 
 
 
 
234
  // add/remove allowed buttons
235
  $buttons = apply_filters( 'tadv_allowed_buttons', $buttons );
236
 
288
  if ( $this->check_setting( 'contextmenu' ) )
289
  $plugins[] = 'contextmenu';
290
 
291
+ if ( $this->check_admin_setting( 'textpattern' ) )
292
+ $plugins[] = 'textpattern';
293
+
294
  // add/remove used plugins
295
  $plugins = apply_filters( 'tadv_used_plugins', $plugins, $this->used_buttons );
296
 
317
 
318
  $buttons_1 = $this->toolbar_1;
319
 
 
 
 
 
320
  if ( is_array( $original ) && ! empty( $original ) ) {
321
  $original = array_diff( $original, $this->buttons_filter );
322
  $buttons_1 = array_merge( $buttons_1, $original );
398
  $init['importcss_file_filter'] = 'editor-style.css';
399
  }
400
 
401
+ if ( $this->check_admin_setting( 'fontsize_formats' ) ) {
402
+ $init['fontsize_formats'] = '8px 10px 12px 14px 16px 20px 24px 28px 32px 36px';
403
+ }
404
+
405
+ if ( $this->check_setting( 'paste_images' ) ) {
406
+ $init['paste_data_images'] = true;
407
+ $init['paste_word_valid_elements'] = '-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],' .
408
+ '-table[width],-tr,-td[colspan|rowspan|width],-th,-thead,-tfoot,-tbody,sub,sup,strike,br,del,ins,img[src|alt|title|height|width]';
409
+ }
410
+
411
  return $init;
412
  }
413
 
414
+ function after_wp_tiny_mce() {
415
+ if ( $this->check_setting('menubar') ) {
416
+ ?>
417
+ <style type="text/css">.wp-fullscreen-wrap .mce-menubar { position: static !important; width: auto !important; }</style>
418
+ <?php
419
+ }
420
+ }
421
+
422
  function htmledit( $c ) {
423
  if ( $this->check_admin_setting( 'no_autop' ) ) {
424
  $c = str_replace( array('&amp;', '&lt;', '&gt;'), array('&', '<', '>'), $c );
469
  return $plugins;
470
  }
471
 
 
 
 
 
 
 
 
 
472
  private function parse_buttons( $toolbar_id = false, $buttons = false ) {
473
  if ( $toolbar_id && ! $buttons && ! empty( $_POST[$toolbar_id] ) )
474
  $buttons = $_POST[$toolbar_id];