refactor: remove individual alert enable options and simplify alert type configuration

pull/7766/head
Akibur Rahman 11 months ago
parent 406c103fa6
commit f8c5b7822f

@ -6,45 +6,10 @@ icon: mdi-alert-box-outline
enabledDefault: true
dependsOn: markdownCore
props:
enableNoteAlert:
type: Boolean
default: true
title: Enable NOTE alerts
hint: Support for > [!NOTE] syntax
order: 1
public: true
enableTipAlert:
type: Boolean
default: true
title: Enable TIP alerts
hint: Support for > [!TIP] syntax
order: 2
public: true
enableWarningAlert:
type: Boolean
default: true
title: Enable WARNING alerts
hint: Support for > [!WARNING] syntax
order: 3
public: true
enableImportantAlert:
type: Boolean
default: true
title: Enable IMPORTANT alerts
hint: Support for > [!IMPORTANT] syntax
order: 4
public: true
enableCautionAlert:
type: Boolean
default: true
title: Enable CAUTION alerts
hint: Support for > [!CAUTION] syntax
order: 5
public: true
customTitle:
type: Boolean
default: true
title: Support custom titles
hint: Allow custom titles like > [!NOTE] Custom Title
order: 6
order: 1
public: true

@ -11,12 +11,12 @@ module.exports = {
function githubAlertsPlugin(md, options = {}) {
const alertTypes = {
'note': { enabled: options.enableNoteAlert !== false, class: 'is-info' },
'info': { enabled: options.enableNoteAlert !== false, class: 'is-info' },
'tip': { enabled: options.enableTipAlert !== false, class: 'is-success' },
'warning': { enabled: options.enableWarningAlert !== false, class: 'is-warning' },
'important': { enabled: options.enableImportantAlert !== false, class: 'is-info' },
'caution': { enabled: options.enableCautionAlert !== false, class: 'is-danger' }
'note': { class: 'is-info' },
'info': { class: 'is-info' },
'tip': { class: 'is-success' },
'warning': { class: 'is-warning' },
'important': { class: 'is-info' },
'caution': { class: 'is-danger' }
}
// Add custom rule to transform GitHub alert syntax
@ -36,9 +36,9 @@ function githubAlertsPlugin(md, options = {}) {
const alertType = alertMatch[1].toLowerCase()
const customTitle = alertMatch[2] ? alertMatch[2].trim() : null
// Check if this alert type is enabled
// Check if this is a valid alert type
const alertConfig = alertTypes[alertType]
if (alertConfig && alertConfig.enabled) {
if (alertConfig) {
// Collect all blockquote lines for this alert
let blockquoteLines = []
let currentPos = pos + 1

Loading…
Cancel
Save