mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Merge pull request #1811 from clkao/author-style-hook
Document author style hook and provide outer_ace dynamic css manager
This commit is contained in:
commit
ae78c6731d
4 changed files with 125 additions and 89 deletions
|
@ -261,3 +261,18 @@ This hook is provided to allow whether a given line should be deliniated with mu
|
|||
Multiple authors in one line cause the creation of magic span lines. This might not suit you and
|
||||
now you can disable it and handle your own deliniation.
|
||||
The return value should be either true(disable) or false.
|
||||
|
||||
## aceSetAuthorStyle
|
||||
Called from: src/static/js/ace2_inner.js
|
||||
|
||||
Things in context:
|
||||
|
||||
1. dynamicCSS - css manger for inner ace
|
||||
2. outerDynamicCSS - css manager for outer ace
|
||||
3. parentDynamicCSS - css manager for parent document
|
||||
4. info - author style info
|
||||
5. author - author info
|
||||
6. authorSelector - css selector for author span in inner ace
|
||||
|
||||
This hook is provided to allow author highlight style to be modified.
|
||||
Registered hooks should return 1 if the plugin handles highlighting. If no plugin returns 1, the core will use the default background-based highlighting.
|
||||
|
|
|
@ -313,7 +313,7 @@ window.onload = function () {\n\
|
|||
|
||||
// bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly
|
||||
// (throbs busy while typing)
|
||||
outerHTML.push('<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
|
||||
outerHTML.push('<style type="text/css" title="dynamicsyntax"></style>', '<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
|
||||
|
||||
var outerFrame = document.createElement("IFRAME");
|
||||
outerFrame.name = "ace_outer";
|
||||
|
|
|
@ -167,12 +167,14 @@ function Ace2Inner(){
|
|||
}
|
||||
|
||||
var dynamicCSS = null;
|
||||
var outerDynamicCSS = null;
|
||||
var parentDynamicCSS = null;
|
||||
|
||||
function initDynamicCSS()
|
||||
{
|
||||
dynamicCSS = makeCSSManager("dynamicsyntax");
|
||||
parentDynamicCSS = makeCSSManager("dynamicsyntax", true);
|
||||
outerDynamicCSS = makeCSSManager("dynamicsyntax", "outer");
|
||||
parentDynamicCSS = makeCSSManager("dynamicsyntax", "parent");
|
||||
}
|
||||
|
||||
var changesetTracker = makeChangesetTracker(scheduler, rep.apool, {
|
||||
|
@ -218,6 +220,7 @@ function Ace2Inner(){
|
|||
var authorStyleSet = hooks.callAll('aceSetAuthorStyle', {
|
||||
dynamicCSS: dynamicCSS,
|
||||
parentDynamicCSS: parentDynamicCSS,
|
||||
outerDynamicCSS: outerDynamicCSS,
|
||||
info: info,
|
||||
author: author,
|
||||
authorSelector: authorSelector,
|
||||
|
|
|
@ -20,13 +20,31 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function makeCSSManager(emptyStylesheetTitle, parentCss)
|
||||
function makeCSSManager(emptyStylesheetTitle, doc)
|
||||
{
|
||||
if (doc === true)
|
||||
{
|
||||
doc = 'parent';
|
||||
} else if (!doc) {
|
||||
doc = 'inner';
|
||||
}
|
||||
|
||||
function getSheetByTitle(title)
|
||||
{
|
||||
if (parentCss) var allSheets = window.parent.parent.document.styleSheets;
|
||||
else var allSheets = document.styleSheets;
|
||||
if (doc === 'parent')
|
||||
{
|
||||
win = window.parent.parent;
|
||||
}
|
||||
else if (doc === 'inner') {
|
||||
win = window;
|
||||
}
|
||||
else if (doc === 'outer') {
|
||||
win = window.parent;
|
||||
}
|
||||
else {
|
||||
throw "Unknown dynamic style container";
|
||||
}
|
||||
var allSheets = win.document.styleSheets;
|
||||
|
||||
for (var i = 0; i < allSheets.length; i++)
|
||||
{
|
||||
|
@ -39,7 +57,7 @@ function makeCSSManager(emptyStylesheetTitle, parentCss)
|
|||
return null;
|
||||
}
|
||||
|
||||
var browserSheet = getSheetByTitle(emptyStylesheetTitle, parentCss);
|
||||
var browserSheet = getSheetByTitle(emptyStylesheetTitle);
|
||||
|
||||
function browserRules()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue