mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-12 19:46:47 +01:00
Line breaks and indents for DIV tag wrapping
If the user is wrapping the selected with a DIV tag, add line breaks were needed and indentation as appropriate.
This commit is contained in:
@@ -350,13 +350,26 @@ var ICEcoder = {
|
||||
|
||||
// Wrap our selected text/cursor with tags
|
||||
tagWrapper: function(tag) {
|
||||
var cM, tagStart, tagEnd;
|
||||
var cM, tagStart, tagEnd, startLine, endLine;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
tagStart = tag;
|
||||
tagEnd = tag;
|
||||
if (tag=='a') {tagStart='a href=""';}
|
||||
cM.replaceSelection("<"+tagStart+">"+cM.getSelection()+"</"+tagEnd+">");
|
||||
if (tag=='div') {
|
||||
startLine = cM.getCursor('start').line;
|
||||
endLine = cM.getCursor().line;
|
||||
cM.operation(function() {
|
||||
cM.replaceSelection("<div>\n"+cM.getSelection()+"\n</div>");
|
||||
for (var i=startLine+1; i<=endLine+1; i++) {
|
||||
cM.indentLine(i);
|
||||
}
|
||||
cM.indentLine(endLine+2,'prev');
|
||||
cM.indentLine(endLine+2,'subtract');
|
||||
});
|
||||
} else {
|
||||
if (tag=='a') {tagStart='a href=""';}
|
||||
cM.replaceSelection("<"+tagStart+">"+cM.getSelection()+"</"+tagEnd+">");
|
||||
}
|
||||
if (tag=='a') {cM.setCursor({line:cM.getCursor().line,ch:cM.getCursor('start').ch+9})}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user