summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/table/editor_plugin_src.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-12-15 08:48:45 +0000
committeralecpl <alec@alec.pl>2009-12-15 08:48:45 +0000
commit58fb6502e3550e59afa8799d36dfce61a18f8b1b (patch)
tree821b5ac61675cada8977d956262ffb5e9b90a2fb /program/js/tiny_mce/plugins/table/editor_plugin_src.js
parent463a03112260ecf39818eac09905f41d8e84ced7 (diff)
- Updated TinyMCE to 3.2.7
Diffstat (limited to 'program/js/tiny_mce/plugins/table/editor_plugin_src.js')
-rw-r--r--program/js/tiny_mce/plugins/table/editor_plugin_src.js68
1 files changed, 67 insertions, 1 deletions
diff --git a/program/js/tiny_mce/plugins/table/editor_plugin_src.js b/program/js/tiny_mce/plugins/table/editor_plugin_src.js
index 80cf748a3..87b10556f 100644
--- a/program/js/tiny_mce/plugins/table/editor_plugin_src.js
+++ b/program/js/tiny_mce/plugins/table/editor_plugin_src.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 953 2008-11-04 10:16:50Z spocke $
+ * $Id: editor_plugin_src.js 1209 2009-08-20 12:35:10Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
@@ -8,6 +8,20 @@
(function() {
var each = tinymce.each;
+ // Checks if the selection/caret is at the start of the specified block element
+ function isAtStart(rng, par) {
+ var doc = par.ownerDocument, rng2 = doc.createRange(), elm;
+
+ rng2.setStartBefore(par);
+ rng2.setEnd(rng.endContainer, rng.endOffset);
+
+ elm = doc.createElement('body');
+ elm.appendChild(rng2.cloneContents());
+
+ // Check for text characters of other elements that should be treated as content
+ return elm.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi, '-').replace(/<[^>]+>/g, '').length == 0;
+ };
+
tinymce.create('tinymce.plugins.TablePlugin', {
init : function(ed, url) {
var t = this;
@@ -55,6 +69,58 @@
}
ed.onInit.add(function() {
+ // Fixes an issue on Gecko where it's impossible to place the caret behind a table
+ // This fix will force a paragraph element after the table but only when the forced_root_block setting is enabled
+ if (!tinymce.isIE && ed.getParam('forced_root_block')) {
+ function fixTableCaretPos() {
+ var last = ed.getBody().lastChild;
+
+ if (last && last.nodeName == 'TABLE')
+ ed.dom.add(ed.getBody(), 'p', null, '<br mce_bogus="1" />');
+ };
+
+ // Fixes an bug where it's impossible to place the caret before a table in Gecko
+ // this fix solves it by detecting when the caret is at the beginning of such a table
+ // and then manually moves the caret infront of the table
+ if (tinymce.isGecko) {
+ ed.onKeyDown.add(function(ed, e) {
+ var rng, table, dom = ed.dom;
+
+ // On gecko it's not possible to place the caret before a table
+ if (e.keyCode == 37 || e.keyCode == 38) {
+ rng = ed.selection.getRng();
+ table = dom.getParent(rng.startContainer, 'table');
+
+ if (table && ed.getBody().firstChild == table) {
+ if (isAtStart(rng, table)) {
+ rng = dom.createRng();
+
+ rng.setStartBefore(table);
+ rng.setEndBefore(table);
+
+ ed.selection.setRng(rng);
+
+ e.preventDefault();
+ }
+ }
+ }
+ });
+ }
+
+ ed.onKeyUp.add(fixTableCaretPos);
+ ed.onSetContent.add(fixTableCaretPos);
+ ed.onVisualAid.add(fixTableCaretPos);
+
+ ed.onPreProcess.add(function(ed, o) {
+ var last = o.node.lastChild;
+
+ if (last && last.childNodes.length == 1 && last.firstChild.nodeName == 'BR')
+ ed.dom.remove(last);
+ });
+
+ fixTableCaretPos();
+ }
+
if (ed && ed.plugins.contextmenu) {
ed.plugins.contextmenu.onContextMenu.add(function(th, m, e) {
var sm, se = ed.selection, el = se.getNode() || ed.getBody();