2016-11-11 184 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); 
    } 

,因爲它使文字褪色時,用戶不在線,至少對我來說的確如此。

就是這樣。 我希望這會幫助某人想要和我一樣的功能。