From 09dae5eae8ed917641153c582e800fb21ac74d2a Mon Sep 17 00:00:00 2001 From: Andreas Gohr <gohr@cosmocode.de> Date: Thu, 27 Aug 2009 13:51:44 +0200 Subject: [PATCH] select sample in tb_formatln() Ignore-this: 85ca1838ed81f69512d07d8504f6673f Note: development is part of ICKE 2.0 project http://www.icke-projekt.de darcs-hash:20090827115144-6e07b-2cfd3c592de4a734cf92cbb2416a9a50f558cfdb.gz --- lib/scripts/toolbar.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 3ad370ff5..4f7aca12e 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -96,16 +96,26 @@ function tb_formatln(btn, props, edid) { } sample = fixtxt(sample); - var selection = getSelection($(edid)); - if(selection.getLength()) sample = selection.getText(); - props['open'] = fixtxt(props['open']); props['close'] = fixtxt(props['close']); + // is something selected? + var opts; + var selection = getSelection($(edid)); + if(selection.getLength()){ + sample = selection.getText(); + opts = {nosel: true}; + }else{ + opts = { + startofs: props['open'].length, + endofs: props['close'].length + }; + } + sample = sample.split("\n").join(props['close']+"\n"+props['open']); sample = props['open']+sample+props['close']; - pasteText(selection,sample,{nosel: true}); + pasteText(selection,sample,opts); pickerClose(); return false; -- GitLab