2016-11-11 187 views
0

我试图在etherpad中找到“作者颜色”的解决方案。从来没有使用过etherpad的人,请忽略这个问题,因为他们不明白。在etherpad中更改颜色代替文本的背景颜色

所以通常“作者颜色”是作为文本的背景颜色提供的颜色,它可以在初始化平板时作为参数给出。它有助于识别谁写了什么。

我希望所有文字都有白色背景,并根据用户更改文字颜色而不是背景颜色。因此,如果在初始化打击垫时我提供了红色,我想要在打击垫上写红色,而不是红色背景和垫上的白色书写(如往常一样)。

请不要把这个问题搁置,因为我没有任何具体的代码提供有关这个问题。反过来说,我会清除任何不可理解的东西。

感谢,

回答

0

首先,感谢大家没有阻挡或使上张贴了这个问题,因为没有一段代码提供了依据。

当我决定再次尝试自己时,我正要为这个问题付出恩典,我经历了很多事情后才解决了这个问题。虽然,它帮助我更好地了解etherpad。

我想列出有关EtherPad的两个重要环节:

  1. https://github.com/ether/etherpad-lite/wiki
  2. 关于SRC - https://github.com/ether/etherpad-lite/wiki/Introduction-to-the-source

,如果你想了解EtherPad的或想他们是非常重要的自己做一些修改。

因此,这里是你怎么做:

src/static/js/ace2_inner.js,去setAuthorStyle和替换功能:

 // author color 
     authorStyle.backgroundColor = bgcolor; 
     parentAuthorStyle.backgroundColor = bgcolor; 

     // text contrast 
     if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5) 
     { 
      authorStyle.color = '#ffffff'; 
      parentAuthorStyle.color = '#ffffff'; 
     }else{ 
      authorStyle.color = null; 
      parentAuthorStyle.color = null; 
     } 

     // anchor text contrast 
     if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.55) 
     { 
      anchorStyle.color = colorutils.triple2css(colorutils.complementary(colorutils.css2triple(bgcolor))); 
     }else{ 
      anchorStyle.color = null; 
     } 

有了:

authorStyle.backgroundColor = '#ffffff'; 
parentAuthorStyle.backgroundColor = '#ffffff'; 

authorStyle.color = bgcolor; 
parentAuthorStyle.color = bgcolor; 

,并注释:

if ((typeof info.fade) == "number") 
{ 
    bgcolor = fadeColor(bgcolor, info.fade); 
} 

Ofcource不要忘记重新启动过程bin/run.sh以进行更改。

有兴趣了解其工作原理的人可以继续阅读。

因此,etherpad接收的参数已经在src/static/js/pad.js中初始化了etherpad,所以如果你已经定义了:'userColor',当你初始化了pad时,它会在globalUserColor的提到的文件中。

然后这个变量globalUserColor在同一个文件中填入pad.myUserInfo.colorId

collab_client.js

现在,这colorId被存储在cssColor在功能tellAceAuthorInfoeditor.setAuthorInfo正在给参数bgcolor: cssColor调用。

现在这个函数setAuthorInfo存在于src/static/js/ace2_inner.js中,该函数调用其他本地函数(相同文件)setAuthorStyle我们已经进行了更改。

我做什么,而不是改变背景颜色与提供可变bgcolor其实际持有userColor

authorStyle.backgroundColor = bgcolor; 
parentAuthorStyle.backgroundColor = bgcolor; 

我改变backgroundColor为白色(#FFFFFF)和文本的颜色bgcolor

authorStyle.backgroundColor = '#ffffff'; 
parentAuthorStyle.backgroundColor = '#ffffff'; 

authorStyle.color = bgcolor; 
parentAuthorStyle.color = bgcolor; 

我也删除了:

  // text contrast 
     if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5) 
     { 
      authorStyle.color = '#ffffff'; 
      parentAuthorStyle.color = '#ffffff'; 
     }else{ 
      authorStyle.color = null; 
      parentAuthorStyle.color = null; 
     } 

     // anchor text contrast 
     if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.55) 
     { 
      anchorStyle.color = colorutils.triple2css(colorutils.complementary(colorutils.css2triple(bgcolor))); 
     }else{ 
      anchorStyle.color = null; 
     } 

因为这些线根据背景选择的颜色设置文本颜色的对比度。但我已将背景设为白色并将文本颜色设置为userColor,因此我不再需要对比度功能。

最终我也评论说:

if ((typeof info.fade) == "number") 
    { 
     bgcolor = fadeColor(bgcolor, info.fade); 
    } 

,因为它使文字褪色时,用户不在线,至少对我来说的确如此。

就是这样。 我希望这会帮助某人想要和我一样的功能。