mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
Improved regex on CSS values
Looks for hex, rgb/hsl-a or colour name values in their correct format Need match ? match[0] : '' to handle no match scenarios
This commit is contained in:
@@ -1308,8 +1308,7 @@ var ICEcoder = {
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
string = cM.getLine(cM.getCursor().line);
|
||||
rx = /[a-z0-9#(),.]+/gi;
|
||||
|
||||
rx = /(#[\da-f]{3,6}\b|(?:rgb|hsl)a?\([^)]*\)|[a-z]+\b)/gi;
|
||||
|
||||
while((match = rx.exec(string)) && cM.getCursor().ch > match.index + match[0].length);
|
||||
|
||||
@@ -1321,7 +1320,7 @@ var ICEcoder = {
|
||||
newBlock.style.position = "absolute";
|
||||
newBlock.style.display = "block";
|
||||
newBlock.style.width = newBlock.style.height = "20px";
|
||||
newBlock.style.background = match;
|
||||
newBlock.style.background = match ? match[0] : '';
|
||||
if (newBlock.style.backgroundColor=="") {newBlock.style.display = "none"};
|
||||
top.document.getElementById('header').appendChild(newBlock);
|
||||
cM.addWidget(cM.getCursor(), top.document.getElementById('cssColor'), true);
|
||||
|
||||
Reference in New Issue
Block a user