diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-08-04 11:57:07 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-08-04 11:57:07 +0200 |
commit | 201ea5f3891ddc2bd1841288c6c03916fe3c68dc (patch) | |
tree | 410514a6d885750178c10f993f0eaa1bdef1b863 /lib/scripts/toolbar.js | |
parent | ad4aaef7a487c01e8448c3371005826b4b51d9fc (diff) | |
download | rpg-201ea5f3891ddc2bd1841288c6c03916fe3c68dc.tar.gz rpg-201ea5f3891ddc2bd1841288c6c03916fe3c68dc.tar.bz2 |
improved list handling
Ignore-this: 2e4f3fbfb28917ee66cf3e1925c806d3
This patch adds multiple enhancements to handling lists and indented
code blocks in the editor.
1. Pressing enter when in a list item or code block will keep the indention
and adds a new list point
2. Pressing space at the start of a list item will indent the item to the
next level
3. Pressing bckspace at the start of a list item will outdent the item
to the previous level or delete the list bullet when you are at the
1st level already
4. A new type of formatting button called formatln is added. It applies
formatting to several lines. It's used for the list buttons currently
and makes it possible to convert mutiple lines to a list
This enhncement are currently only tested in Firefox are most likely to
break IE compatibility. A compatibility patch will be submitted later
note: development was part of the ICKE 2.0 project see
http://www.icke-projekt.de for info
darcs-hash:20090804095707-7ad00-e565c66087c7121188ad7ece8265d9f64f7e6947.gz
Diffstat (limited to 'lib/scripts/toolbar.js')
-rw-r--r-- | lib/scripts/toolbar.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 1a152b1a7..48a4a4a7e 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -78,6 +78,40 @@ function tb_format(btn, props, edid) { } /** + * Button action for format buttons + * + * This works exactly as tb_format() except that, if multiple lines + * are selected, each line will be formatted seperately + * + * @param DOMElement btn Button element to add the action to + * @param array props Associative array of button properties + * @param string edid ID of the editor textarea + * @author Gabriel Birke <birke@d-scribe.de> + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tb_formatln(btn, props, edid) { + var sample = props['title']; + if(props['sample']){ + sample = props['sample']; + } + sample = fixtxt(sample); + + var selection = getSelection($(edid)); + if(selection.getLength()) sample = selection.getText(); + + props['open'] = fixtxt(props['open']); + props['close'] = fixtxt(props['close']); + + sample = sample.split("\n").join(props['close']+"\n"+props['open']); + sample = props['open']+sample+props['close']; + + pasteText(selection,sample,{nosel: true}); + + pickerClose(); + return false; +} + +/** * Button action for insert buttons * * @param DOMElement btn Button element to add the action to |