mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
preprocessor for domline attributes
This commit is contained in:
parent
1fa2b32854
commit
c3d62c5fa4
1 changed files with 36 additions and 14 deletions
|
@ -101,33 +101,8 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
{
|
{
|
||||||
var listType = /(?:^| )list:(\S+)/.exec(cls);
|
var listType = /(?:^| )list:(\S+)/.exec(cls);
|
||||||
var start = /(?:^| )start:(\S+)/.exec(cls);
|
var start = /(?:^| )start:(\S+)/.exec(cls);
|
||||||
if (listType)
|
|
||||||
{
|
|
||||||
listType = listType[1];
|
|
||||||
if (listType)
|
|
||||||
{
|
|
||||||
if(listType.indexOf("number") < 0)
|
|
||||||
{
|
|
||||||
preHtml = '<ul class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
|
||||||
postHtml = '</li></ul>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(start){ // is it a start of a list with more than one item in?
|
|
||||||
if(start[1] == 1){ // if its the first one at this level?
|
|
||||||
lineClass = lineClass + " " + "list-start-" + listType; // Add start class to DIV node
|
|
||||||
}
|
|
||||||
preHtml = '<ol start='+start[1]+' class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
|
||||||
}else{
|
|
||||||
preHtml = '<ol class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>'; // Handles pasted contents into existing lists
|
|
||||||
}
|
|
||||||
postHtml = '</li></ol>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
processedMarker = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_.map(hooks.callAll("aceDomLineProcessLineAttributes", {
|
_.map(hooks.callAll("aceDomLinePreProcessLineAttributes", {
|
||||||
domline: domline,
|
domline: domline,
|
||||||
cls: cls
|
cls: cls
|
||||||
}), function(modifier)
|
}), function(modifier)
|
||||||
|
@ -137,12 +112,61 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
processedMarker |= modifier.processedMarker;
|
processedMarker |= modifier.processedMarker;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (listType)
|
||||||
|
{
|
||||||
|
listType = listType[1];
|
||||||
|
if (listType)
|
||||||
|
{
|
||||||
|
if(listType.indexOf("number") < 0)
|
||||||
|
{
|
||||||
|
if(!preHtml){
|
||||||
|
preHtml = '<ul class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
||||||
|
postHtml = '</li></ul>';
|
||||||
|
}else{
|
||||||
|
preHtml += '<ul class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
||||||
|
postHtml = '</li></ul>' + postHtml;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(start){ // is it a start of a list with more than one item in?
|
||||||
|
if(start[1] == 1){ // if its the first one at this level?
|
||||||
|
lineClass = lineClass + " " + "list-start-" + listType; // Add start class to DIV node
|
||||||
|
}
|
||||||
|
if(!preHtml){
|
||||||
|
preHtml = '<ol start='+start[1]+' class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
||||||
|
}else{
|
||||||
|
preHtml += '<ol start='+start[1]+' class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(!preHtml){
|
||||||
|
preHtml = '<ol class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>'; // Handles pasted contents into existing lists
|
||||||
|
}else{
|
||||||
|
preHtml += '<ol class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>'; // Handles pasted contents into existing lists
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!postHtml){
|
||||||
|
postHtml = '</li></ol>';
|
||||||
|
}else{
|
||||||
|
postHtml = '</li></ol>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
processedMarker = true;
|
||||||
|
}
|
||||||
|
_.map(hooks.callAll("aceDomLineProcessLineAttributes", {
|
||||||
|
domline: domline,
|
||||||
|
cls: cls
|
||||||
|
}), function(modifier)
|
||||||
|
{
|
||||||
|
preHtml += modifier.preHtml;
|
||||||
|
postHtml += modifier.postHtml;
|
||||||
|
processedMarker |= modifier.processedMarker;
|
||||||
|
});
|
||||||
if( processedMarker ){
|
if( processedMarker ){
|
||||||
result.lineMarker += txt.length;
|
result.lineMarker += txt.length;
|
||||||
return; // don't append any text
|
return; // don't append any text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
var href = null;
|
var href = null;
|
||||||
var simpleTags = null;
|
var simpleTags = null;
|
||||||
|
@ -234,7 +258,6 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
result.node.innerHTML = curHTML;
|
result.node.innerHTML = curHTML;
|
||||||
}
|
}
|
||||||
if (lineClass !== null) result.node.className = lineClass;
|
if (lineClass !== null) result.node.className = lineClass;
|
||||||
|
|
||||||
hooks.callAll("acePostWriteDomLineHTML", {
|
hooks.callAll("acePostWriteDomLineHTML", {
|
||||||
node: result.node
|
node: result.node
|
||||||
});
|
});
|
||||||
|
@ -245,7 +268,6 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
{
|
{
|
||||||
return curHTML || '';
|
return curHTML || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue