Created
September 19, 2021 14:37
-
-
Save emisjerry/8935d20c7bd3ee07440bcfd4e2b29387 to your computer and use it in GitHub Desktop.
QuickAdd macro file: demo_colors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aColors = [ "gray", "brown", "orange", | |
"yellow", "green", "blue", | |
"purple", "pink", "red" | |
]; | |
const aColorsChinese = [ "灰色", "褐色", "橘色", | |
"黃色", "綠色", "藍色", | |
"紫色", "粉紅色", "紅色" | |
]; | |
const backQuotes = String.fromCharCode(96)+String.fromCharCode(96)+String.fromCharCode(96); | |
async function demo_colors(params) { | |
const aTexts = [ "1. 區域文字前景顏色", "2. 區域文字背景顏色", "3. 程式碼區塊背景", | |
"4. 程式碼區塊前景", "5. 重點高亮" ]; | |
const aValues = [ text_fg, text_bg, code_bg, code_fg, mark ]; | |
let sResult = ""; | |
const choice = await params.quickAddApi.suggester(aTexts, aValues); | |
sResult = choice(); | |
return sResult; | |
} | |
function text_fg() { | |
let sResult = "<ol>"; | |
for (var i=0; i < aColors.length; i++) { | |
sColor = aColors[i]; | |
sColorChinese = aColorsChinese[i]; | |
sResult += `<li>這段文字變成<span class='note-${sColor}'>${sColor} ${sColorChinese}</span>,檢視看看😄<br>\n`; | |
} | |
sResult += "</ol>"; | |
return sResult; | |
} | |
function text_bg() { | |
let sResult = "<ol>"; | |
for (var i=0; i < aColors.length; i++) { | |
sColor = aColors[i]; | |
sColorChinese = aColorsChinese[i]; | |
sResult += `<li>這段文字變成<span class='${sColor}-bg'>${sColor} ${sColorChinese}</span>,檢視看看👼<br>\n`; | |
} | |
sResult += "</ol>"; | |
return sResult; | |
} | |
function code_bg() { | |
let sResult = ""; | |
for (var i=0; i < aColors.length; i++) { | |
sColor = aColors[i]; | |
sColorChinese = aColorsChinese[i]; | |
sLines = `${sColor} ${sColorChinese}\n${sColor} ${sColorChinese}\n${sColor} ${sColorChinese}` | |
sResult += `${backQuotes}note-${sColor}-bg\n${sLines}\n${backQuotes}\n`; | |
} | |
return sResult; | |
} | |
function code_fg() { | |
let sResult = ""; | |
for (var i=0; i < aColors.length; i++) { | |
sColor = aColors[i]; | |
sColorChinese = aColorsChinese[i]; | |
sLines = `${sColor} ${sColorChinese}\n${sColor} ${sColorChinese}\n${sColor} ${sColorChinese}` | |
sResult += `${backQuotes}note-${sColor}\n${sLines}\n${backQuotes}\n`; | |
} | |
return sResult; | |
} | |
function mark() { | |
let sResult = ""; | |
for (var i=0; i < aColors.length; i++) { | |
sColor = aColors[i]; | |
sColorChinese = aColorsChinese[i]; | |
sResult += `這是 <mark class='${sColor}'>重點</mark> 要特別注意。<br>\n`; | |
} | |
return sResult; | |
} | |
module.exports = demo_colors; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment