Merge pull request #2101 from ether/preProcessDomLine
preprocessor for domline attributespull/2108/head
commit
26869d29b3
|
@ -10,6 +10,22 @@ nothing
|
|||
|
||||
This hook proxies the functionality of jQuery's `$(document).ready` event.
|
||||
|
||||
## aceDomLinePreProcessLineAttributes
|
||||
Called from: src/static/js/domline.js
|
||||
|
||||
Things in context:
|
||||
|
||||
1. domline - The current DOM line being processed
|
||||
2. cls - The class of the current block element (useful for styling)
|
||||
|
||||
This hook is called for elements in the DOM that have the "lineMarkerAttribute" set. You can add elements into this category with the aceRegisterBlockElements hook above. This hook is run BEFORE the numbered and ordered lists logic is applied.
|
||||
|
||||
The return value of this hook should have the following structure:
|
||||
|
||||
`{ preHtml: String, postHtml: String, processedMarker: Boolean }`
|
||||
|
||||
The preHtml and postHtml values will be added to the HTML display of the element, and if processedMarker is true, the engine won't try to process it any more.
|
||||
|
||||
## aceDomLineProcessLineAttributes
|
||||
Called from: src/static/js/domline.js
|
||||
|
||||
|
@ -18,7 +34,7 @@ Things in context:
|
|||
1. domline - The current DOM line being processed
|
||||
2. cls - The class of the current block element (useful for styling)
|
||||
|
||||
This hook is called for elements in the DOM that have the "lineMarkerAttribute" set. You can add elements into this category with the aceRegisterBlockElements hook above.
|
||||
This hook is called for elements in the DOM that have the "lineMarkerAttribute" set. You can add elements into this category with the aceRegisterBlockElements hook above. This hook is run AFTER the ordered and numbered lists logic is applied.
|
||||
|
||||
The return value of this hook should have the following structure:
|
||||
|
||||
|
|
|
@ -101,6 +101,17 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
{
|
||||
var listType = /(?:^| )list:(\S+)/.exec(cls);
|
||||
var start = /(?:^| )start:(\S+)/.exec(cls);
|
||||
|
||||
_.map(hooks.callAll("aceDomLinePreProcessLineAttributes", {
|
||||
domline: domline,
|
||||
cls: cls
|
||||
}), function(modifier)
|
||||
{
|
||||
preHtml += modifier.preHtml;
|
||||
postHtml += modifier.postHtml;
|
||||
processedMarker |= modifier.processedMarker;
|
||||
});
|
||||
|
||||
if (listType)
|
||||
{
|
||||
listType = listType[1];
|
||||
|
@ -108,8 +119,8 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
{
|
||||
if(listType.indexOf("number") < 0)
|
||||
{
|
||||
preHtml = '<ul class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
||||
postHtml = '</li></ul>';
|
||||
preHtml += '<ul class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>';
|
||||
postHtml = '</li></ul>' + postHtml;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -117,16 +128,15 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
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>';
|
||||
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
|
||||
preHtml += '<ol class="list-' + Security.escapeHTMLAttribute(listType) + '"><li>'; // Handles pasted contents into existing lists
|
||||
}
|
||||
postHtml = '</li></ol>';
|
||||
postHtml += '</li></ol>';
|
||||
}
|
||||
}
|
||||
processedMarker = true;
|
||||
}
|
||||
|
||||
_.map(hooks.callAll("aceDomLineProcessLineAttributes", {
|
||||
domline: domline,
|
||||
cls: cls
|
||||
|
@ -136,13 +146,10 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
postHtml += modifier.postHtml;
|
||||
processedMarker |= modifier.processedMarker;
|
||||
});
|
||||
|
||||
if( processedMarker ){
|
||||
result.lineMarker += txt.length;
|
||||
return; // don't append any text
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
var href = null;
|
||||
var simpleTags = null;
|
||||
|
@ -245,7 +252,6 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
{
|
||||
return curHTML || '';
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue