थीम
Clepit थीम CSS वेरिएबल्स द्वारा संचालित होती हैं। theme: "auto" | "light" | "dark" सेट करें, या स्पष्ट themeOverrides पास करें।
theme
// EditorConfig / RendererConfig
theme?: 'auto' | 'light' | 'dark'auto प्रीसेट prefers-color-scheme के माध्यम से ऑपरेटिंग सिस्टम के रंग योजना का पालन करता है और बदलने पर लाइव स्विच करता है।
import { Editor } from '@clepit/core';
Editor.create({ containerId: 'editor', theme: 'auto' });ThemeTokens
सभी 22 टोकन वैकल्पिक हैं। आप जो कुछ भी छोड़ देते हैं वह चयनित प्रीसेट पर वापस चला जाता है।
| टोकन | नियंत्रित करता है |
|---|---|
| bg | एडिटर/रेंडरर की मुख्य पृष्ठभूमि |
| surface | सेकेंडरी सर्फेस: कमांड पैनल, मोड-बार हेडर |
| surface2 | तृतीयक सर्फेस: होवर-मेनू पृष्ठभूमि |
| text | प्राथमिक टेक्स्ट रंग |
| textMuted | सेकेंडरी टेक्स्ट: लेबल, फ़ॉलबैक पैराग्राफ |
| textSubtle | सूक्ष्म टेक्स्ट: हल्के तत्व, तिथि मार्कर |
| border | प्राथमिक बॉर्डर रंग |
| borderSubtle | सूक्ष्म बॉर्डर: गैर-जोर वाले विभाजक |
| primary | प्राथमिक ब्रांड रंग: बटन, एंकर लिंक |
| primaryHover | प्राथमिक होवर रंग: बटन hover/focus स्थिति |
| primaryBg | टिंटेड प्राथमिक पृष्ठभूमि: फ़ोकस रिंग |
| marker | टेक्स्ट हाइलाइट रंग: मार्कर इनलाइन टूल |
| selectionBg | टेक्स्ट सिलेक्शन पृष्ठभूमि |
| blockHighlightBg | सक्रिय ब्लॉक पृष्ठभूमि |
| success | सफलता स्थिति टेक्स्ट/आइकन रंग |
| successBg | टिंटेड सफलता पृष्ठभूमि: नोटिफिकेशन बॉक्स |
| warning | चेतावनी स्थिति टेक्स्ट/आइकन रंग |
| warningBg | टिंटेड चेतावनी पृष्ठभूमि |
| error | त्रुटि स्थिति टेक्स्ट/आइकन रंग |
| errorBg | टिंटेड त्रुटि पृष्ठभूमि |
| info | जानकारी स्थिति टेक्स्ट/आइकन रंग |
| infoBg | टिंटेड जानकारी पृष्ठभूमि |
themeOverrides
टोकन के किसी भी उपसमुच्चय को ओवरराइड करें। एडिटर उन्हें अपने कंटेनर तक सीमित CSS वेरिएबल के रूप में इंजेक्ट करता है।
// themeOverrides accepts separate light and dark token sets.
// Both keys are optional — omit one to use the preset for that mode.
Editor.create({
containerId: 'editor',
theme: 'auto',
themeOverrides: {
light: {
primary: '#5b5bff',
primaryHover: '#4747e6',
bg: '#ffffff',
text: '#0a0a0a',
},
dark: {
primary: '#7c7cff',
primaryHover: '#9494ff',
bg: '#161b22',
text: 'rgba(240, 246, 252, 0.92)',
},
},
});CSS कस्टम प्रॉपर्टी
प्रत्येक टोकन एडिटर कंटेनर तक सीमित एक --clepit-* वेरिएबल से मैप होता है। आप उन्हें अपनी स्टाइलशीट से पढ़ या विस्तारित कर सकते हैं।
/* Every ThemeToken maps to a --clepit-* CSS variable.
Variables are scoped to .clepit-editor, .clepit-renderer-content, and body[data-clepit-theme]. */
--clepit-bg
--clepit-surface
--clepit-surface-2
--clepit-text
--clepit-text-muted
--clepit-text-subtle
--clepit-border
--clepit-border-subtle
--clepit-primary
--clepit-primary-hover
--clepit-primary-bg
--clepit-marker
--clepit-selection-bg
--clepit-block-highlight-bg
--clepit-success
--clepit-success-bg
--clepit-warning
--clepit-warning-bg
--clepit-error
--clepit-error-bg
--clepit-info
--clepit-info-bg#editor {
color: var(--clepit-text);
background: var(--clepit-bg);
--my-surface: var(--clepit-surface-2);
border: 1px solid var(--clepit-border);
}प्रति-ब्लॉक styles और classNames
RendererConfig.styles फ्रेमवर्क-मुक्त CSS प्रॉपर्टी सीधे कम्पोनेंट रूट एलिमेंट में पाइप करता है। RendererConfig.classNames बिल्ट-इन स्टाइल को छुए बिना अतिरिक्त CSS क्लास जोड़ता है। दोनों को मिलाया जा सकता है।
import { Renderer } from '@clepit/core';
import type { BlockStyles, BlockClassNames } from '@clepit/core';
const styles: BlockStyles = {
// alert block — keyed by variant
alert: {
error: { borderRadius: '8px', padding: '12px 16px' },
info: { borderRadius: '8px', padding: '12px 16px' },
},
// header block — keyed by level
header: {
h1: { fontFamily: 'Georgia, serif' },
h2: { fontFamily: 'Georgia, serif' },
},
// paragraph block — flat CSSProperties
paragraph: { lineHeight: '1.75' },
// table block — sub-element keys
table: { cell: { padding: '8px 12px' } },
// code block — sub-element keys
code: { container: { borderRadius: '6px' } },
};
const classNames: BlockClassNames = {
paragraph: 'prose-paragraph',
header: { h1: 'prose-h1', h2: 'prose-h2' },
alert: { info: 'alert-info', error: 'alert-error' },
};
Renderer.create({ containerId: 'output', data, styles, classNames });StyleManager.subscribe
रनटाइम टोकन परिवर्तनों की सदस्यता लें। आसपास के UI को एडिटर थीम स्विच के साथ सिंक करने के लिए उपयोगी।
import { StyleManager } from '@clepit/core';
const unsubscribe = StyleManager.subscribe(theme => {
// theme is 'light' | 'dark' — sync surrounding UI
document.documentElement.setAttribute('data-theme', theme);
});
// later — clean up when the component unmounts
unsubscribe();