मुख्य सामग्री पर जाएँ

थीम

Clepit थीम CSS वेरिएबल्स द्वारा संचालित होती हैं। theme: "auto" | "light" | "dark" सेट करें, या स्पष्ट themeOverrides पास करें।

theme

TypeScript
// EditorConfig / RendererConfig
theme?: 'auto' | 'light' | 'dark'

auto प्रीसेट prefers-color-scheme के माध्यम से ऑपरेटिंग सिस्टम के रंग योजना का पालन करता है और बदलने पर लाइव स्विच करता है।

TypeScript
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 वेरिएबल के रूप में इंजेक्ट करता है।

TypeScript
// 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-* वेरिएबल से मैप होता है। आप उन्हें अपनी स्टाइलशीट से पढ़ या विस्तारित कर सकते हैं।

CSS
/* 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
CSS
#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 क्लास जोड़ता है। दोनों को मिलाया जा सकता है।

TypeScript
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 को एडिटर थीम स्विच के साथ सिंक करने के लिए उपयोगी।

TypeScript
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();
प्रति mount themeOverrides प्रदान करने से एक ही ऐप एक ही पृष्ठ पर अलग-अलग थीम वाले कई एडिटर प्रदान कर सकता है।