Skip to content

Commit

Permalink
Item2516: override default indent / exdent behaviour for : paras
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@13395 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Dec 12, 2011
1 parent ce8409a commit 7610b10
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TinyMCEPlugin/data/System/TinyMCEPlugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Below is the default configuration. If it is to be modified, it should be copied
"theme_advanced_buttons1" : "%IF{
"defined 'TINYMCEPLUGIN_BUTTONS1'"
then="%TINYMCEPLUGIN_BUTTONS1%"
else="%STARTSECTION{"BUTTONS1"}%foswikiformat, separator, bold, italic, tt, colour, removeformat, separator, bullist, numlist, outdent, indent, blockquote, separator, link, unlink, anchor, separator, undo, redo, separator, search, replace%ENDSECTION{"BUTTONS1"}%"
else="%STARTSECTION{"BUTTONS1"}%foswikiformat, separator, bold, italic, tt, colour, removeformat, separator, bullist, numlist, fwexdent, fwindent, blockquote, separator, link, unlink, anchor, separator, undo, redo, separator, search, replace%ENDSECTION{"BUTTONS1"}%"
}%%IF{
"defined 'TINYMCEPLUGIN_ADDITIONAL_BUTTONS1'"
then=", %TINYMCEPLUGIN_ADDITIONAL_BUTTONS1%"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
this._setupTTButton(ed, url);
this._setupColourButton(ed, url);
this._setupAttachButton(ed, url);
this._setupIndentButton(ed, url);
this._setupExdentButton(ed, url);
this._setupHideButton(ed, url);
this._setupFormatCommand(ed, this.formats);

Expand Down Expand Up @@ -226,6 +228,75 @@
return;
},

_setupIndentButton: function (ed, url) {
ed.addCommand('fwindent', function () {
if (this.queryCommandState('InsertUnorderedList') ||
this.queryCommandState('InsertOrderedList'))
// list type node - use the default behaviour
this.execCommand("Indent");
else {
// drive up to the nearest block node
var dom = ed.dom, selection = ed.selection;
var node = dom.getParent(selection.getStart(), dom.isBlock) ||
dom.getParent(selection.getEnd(), dom.isBlock);
if (node) {
// SMELL: what about indentation inside tables? Needs to be disabled.
// insert div below the nearest block node
var div = dom.create('div', { class : 'foswikiIndent'});
while (node.firstChild) {
dom.add(div, dom.remove(node.firstChild));
}
dom.add(node, div);
ed.selection.select(div);
ed.selection.collapse();
}
}
});

ed.addButton('fwindent', {
title: 'foswikibuttons.indent_desc',
cmd: 'fwindent',
image: url + '/img/indent.gif'
});

return;
},

_setupExdentButton: function (ed, url) {
ed.addCommand('fwexdent', function () {
var dom = ed.dom, selection = ed.selection;
var node = dom.getParent(selection.getStart(), dom.isBlock);
if (node && dom.hasClass(node, 'foswikiIndent')) {
var p = node.parentNode;
while (node.firstChild) {
p.insertBefore(dom.remove(node.firstChild), node);
}
dom.remove(node);
ed.selection.select(p.firstChild);
ed.selection.collapse();
} else
this.execCommand("Outdent");
});

ed.onNodeChange.add(function(ed, cm, n, co, ob) {
var dom = ed.dom, selection = ed.selection;
var node = dom.getParent(selection.getStart(), dom.isBlock);

var state = (node && dom.hasClass(node, 'foswikiIndent')) ||
ed.queryCommandState('Outdent');

cm.setDisabled('fwexdent', !state);
});

ed.addButton('fwexdent', {
title: 'foswikibuttons.exdent_desc',
cmd: 'fwexdent',
image: url + '/img/exdent.gif'
});

return;
},

_setupHideButton: function (ed, url) {
ed.addCommand('foswikibuttonsHide', function () {
if (FoswikiTiny.saveEnabled) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ tinyMCE.addI18n('en.foswikibuttons', {
tt_desc: "Typewriter text",
colour_desc: "Font colour",
attach_desc: "Manage Attachments",
indent_desc: "Indent more",
exdent_desc: "Indent less",
hide_desc: "Edit Foswiki markup"
});

0 comments on commit 7610b10

Please sign in to comment.