/** @type {string[]} */ export const CALLOUT_BACKGROUND_OPTIONS = ['gray', 'blue', 'green', 'yellow', 'red', 'purple'] /** @type {string[]} */ export const QUOTE_BACKGROUND_OPTIONS = ['gray', 'blue', 'green', 'yellow', 'red', 'purple'] /** @type {Record} */ export const QUOTE_BACKGROUND_LABELS = { gray: '회색', blue: '파랑', green: '초록', yellow: '노랑', red: '빨강', purple: '보라' } /** @type {Record} */ export const QUOTE_BACKGROUND_SWATCHES = { gray: 'color-mix(in srgb, #050505 10%, #ffffff)', blue: 'color-mix(in srgb, #0055ff 10%, #ffffff)', green: 'color-mix(in srgb, #16ae68 10%, #ffffff)', yellow: 'color-mix(in srgb, #ffff00 10%, #ffffff)', red: 'color-mix(in srgb, #ff0000 10%, #ffffff)', purple: 'color-mix(in srgb, #8800ff 10%, #ffffff)' } /** @type {Record} */ export const CALLOUT_BACKGROUND_SWATCHES = QUOTE_BACKGROUND_SWATCHES /** @type {string[]} */ export const CALLOUT_EMOJI_OPTIONS = ['💡', '⚠️', '❗', '✅', '📌', '🔥', '💬'] /** * 콜아웃 선언부 옵션을 파싱한다. * @param {string} line - 콜아웃 선언 라인 * @returns {{ calloutEmojiEnabled: boolean, calloutEmoji: string, calloutBackground: string }} */ export const parseCalloutOptions = (line) => { const options = { calloutEmojiEnabled: true, calloutEmoji: '💡', calloutBackground: 'blue' } const tokens = String(line ?? '').trim().split(/\s+/).slice(1) tokens.forEach((token) => { const [rawKey, ...rawValueParts] = token.split('=') if (!rawKey || !rawValueParts.length) { return } const key = rawKey.toLowerCase() const value = rawValueParts.join('=').trim() if (key === 'emoji') { if (!value || value === 'none') { options.calloutEmojiEnabled = false options.calloutEmoji = '💡' } else { options.calloutEmojiEnabled = true options.calloutEmoji = value } return } if (key === 'bg' && CALLOUT_BACKGROUND_OPTIONS.includes(value)) { options.calloutBackground = value } }) return options } /** * 콜아웃 선언 줄을 만든다. * @param {{ calloutEmojiEnabled?: boolean, calloutEmoji?: string, calloutBackground?: string }} options - 옵션 * @returns {string} 선언 줄 */ export const buildCalloutOpenerLine = (options = {}) => { const emojiEnabled = options.calloutEmojiEnabled !== false const emoji = emojiEnabled ? (options.calloutEmoji || '💡') : 'none' const background = CALLOUT_BACKGROUND_OPTIONS.includes(options.calloutBackground) ? options.calloutBackground : 'blue' return `:::callout emoji=${emoji} bg=${background}` }