overtype 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overtype",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay",
5
5
  "main": "dist/overtype.cjs",
6
6
  "module": "dist/overtype.esm.js",
package/src/overtype.d.ts CHANGED
@@ -3,6 +3,21 @@
3
3
  // Definitions generated from themes.js and styles.js
4
4
  // DO NOT EDIT MANUALLY - Run 'npm run generate:types' to regenerate
5
5
 
6
+ export interface PreviewColors {
7
+ bg?: string;
8
+ blockquote?: string;
9
+ code?: string;
10
+ codeBg?: string;
11
+ em?: string;
12
+ h1?: string;
13
+ h2?: string;
14
+ h3?: string;
15
+ hr?: string;
16
+ link?: string;
17
+ strong?: string;
18
+ text?: string;
19
+ }
20
+
6
21
  export interface Theme {
7
22
  name: string;
8
23
  colors: {
@@ -38,6 +53,7 @@ export interface Theme {
38
53
  toolbarHover?: string;
39
54
  toolbarIcon?: string;
40
55
  };
56
+ previewColors?: PreviewColors;
41
57
  }
42
58
 
43
59
  export interface Stats {
@@ -110,6 +126,7 @@ export interface Options {
110
126
  // Theme (deprecated in favor of global theme)
111
127
  theme?: string | Theme;
112
128
  colors?: Partial<Theme['colors']>;
129
+ previewColors?: PreviewColors;
113
130
 
114
131
  // File upload
115
132
  fileUpload?: {
package/src/overtype.js CHANGED
@@ -1223,7 +1223,7 @@ class OverType {
1223
1223
  }
1224
1224
 
1225
1225
  if (themeObj && themeObj.colors) {
1226
- const cssVars = themeToCSSVars(themeObj.colors);
1226
+ const cssVars = themeToCSSVars(themeObj.colors, themeObj.previewColors);
1227
1227
  this.container.style.cssText += cssVars;
1228
1228
  }
1229
1229
 
@@ -1239,7 +1239,7 @@ class OverType {
1239
1239
  this.container.setAttribute('data-theme', themeName);
1240
1240
 
1241
1241
  if (themeObj && themeObj.colors) {
1242
- this.container.style.cssText = themeToCSSVars(themeObj.colors);
1242
+ this.container.style.cssText = themeToCSSVars(themeObj.colors, themeObj.previewColors);
1243
1243
  }
1244
1244
 
1245
1245
  this.updatePreview();
package/src/styles.js CHANGED
@@ -37,7 +37,7 @@ export function generateStyles(options = {}) {
37
37
  ` : '';
38
38
 
39
39
  // Generate theme variables if provided
40
- const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors) : '';
40
+ const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors, theme.previewColors) : '';
41
41
 
42
42
  return `
43
43
  /* OverType Editor Styles */
@@ -710,27 +710,29 @@ export function generateStyles(options = {}) {
710
710
  }
711
711
 
712
712
  /* Headers - restore proper sizing in preview mode */
713
- .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
714
- .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
713
+ .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
714
+ .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
715
715
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
716
716
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
717
717
  font-weight: 600 !important;
718
718
  margin: 0 !important;
719
719
  display: block !important;
720
- color: inherit !important; /* Use parent text color */
721
- line-height: 1 !important; /* Tight line height for headings */
720
+ line-height: 1 !important;
722
721
  }
723
-
724
- .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
725
- font-size: 2em !important;
722
+
723
+ .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
724
+ font-size: 2em !important;
725
+ color: var(--preview-h1, var(--preview-h1-default)) !important;
726
726
  }
727
-
728
- .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
729
- font-size: 1.5em !important;
727
+
728
+ .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
729
+ font-size: 1.5em !important;
730
+ color: var(--preview-h2, var(--preview-h2-default)) !important;
730
731
  }
731
-
732
- .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
733
- font-size: 1.17em !important;
732
+
733
+ .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
734
+ font-size: 1.17em !important;
735
+ color: var(--preview-h3, var(--preview-h3-default)) !important;
734
736
  }
735
737
 
736
738
  /* Lists - restore list styling in preview mode */
@@ -780,14 +782,14 @@ export function generateStyles(options = {}) {
780
782
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a {
781
783
  pointer-events: auto !important;
782
784
  cursor: pointer !important;
783
- color: var(--link, #0066cc) !important;
785
+ color: var(--preview-link, var(--preview-link-default)) !important;
784
786
  text-decoration: underline !important;
785
787
  }
786
788
 
787
789
  /* Code blocks - proper pre/code styling in preview mode */
788
790
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
789
- background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
790
- color: var(--code, #0d3b66) !important;
791
+ background: var(--preview-code-bg, var(--preview-code-bg-default)) !important;
792
+ color: var(--preview-code, var(--preview-code-default)) !important;
791
793
  padding: 1.2em !important;
792
794
  border-radius: 3px !important;
793
795
  overflow-x: auto !important;
@@ -816,7 +818,8 @@ export function generateStyles(options = {}) {
816
818
  /* Blockquotes - enhanced styling in preview mode */
817
819
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote {
818
820
  display: block !important;
819
- border-left: 4px solid var(--blockquote, #ddd) !important;
821
+ border-left: 4px solid var(--preview-blockquote, var(--preview-blockquote-default)) !important;
822
+ color: var(--preview-blockquote, var(--preview-blockquote-default)) !important;
820
823
  padding-left: 1em !important;
821
824
  margin: 1em 0 !important;
822
825
  font-style: italic !important;
@@ -827,14 +830,16 @@ export function generateStyles(options = {}) {
827
830
  font-family: Georgia, 'Times New Roman', serif !important;
828
831
  font-size: 16px !important;
829
832
  line-height: 1.8 !important;
830
- color: var(--text, #333) !important; /* Consistent text color */
833
+ color: var(--preview-text, var(--preview-text-default)) !important;
834
+ background: var(--preview-bg, var(--preview-bg-default)) !important;
831
835
  }
832
836
 
833
837
  /* Inline code in preview mode - keep monospace */
834
838
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code {
835
839
  font-family: ${fontFamily} !important;
836
840
  font-size: 0.9em !important;
837
- background: rgba(135, 131, 120, 0.15) !important;
841
+ background: var(--preview-code-bg, var(--preview-code-bg-default)) !important;
842
+ color: var(--preview-code, var(--preview-code-default)) !important;
838
843
  padding: 0.2em 0.4em !important;
839
844
  border-radius: 3px !important;
840
845
  }
@@ -842,18 +847,18 @@ export function generateStyles(options = {}) {
842
847
  /* Strong and em elements in preview mode */
843
848
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong {
844
849
  font-weight: 700 !important;
845
- color: inherit !important; /* Use parent text color */
850
+ color: var(--preview-strong, var(--preview-strong-default)) !important;
846
851
  }
847
852
 
848
853
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em {
849
854
  font-style: italic !important;
850
- color: inherit !important; /* Use parent text color */
855
+ color: var(--preview-em, var(--preview-em-default)) !important;
851
856
  }
852
857
 
853
858
  /* HR in preview mode */
854
859
  .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker {
855
860
  display: block !important;
856
- border-top: 2px solid var(--hr, #ddd) !important;
861
+ border-top: 2px solid var(--preview-hr, var(--preview-hr-default)) !important;
857
862
  text-indent: -9999px !important;
858
863
  height: 2px !important;
859
864
  }
package/src/themes.js CHANGED
@@ -40,6 +40,20 @@ export const solar = {
40
40
  toolbarHover: '#f5f5f5', // Light gray - hover background
41
41
  toolbarActive: '#faf0ca', // Lemon Chiffon - active button background
42
42
  placeholder: '#999999', // Gray - placeholder text
43
+ },
44
+ previewColors: {
45
+ text: '#0d3b66',
46
+ h1: 'inherit',
47
+ h2: 'inherit',
48
+ h3: 'inherit',
49
+ strong: 'inherit',
50
+ em: 'inherit',
51
+ link: '#0d3b66',
52
+ code: '#0d3b66',
53
+ codeBg: 'rgba(244, 211, 94, 0.4)',
54
+ blockquote: '#5a7a9b',
55
+ hr: '#5a7a9b',
56
+ bg: 'transparent',
43
57
  }
44
58
  };
45
59
 
@@ -80,6 +94,20 @@ export const cave = {
80
94
  toolbarHover: '#243546', // Slightly lighter charcoal - hover background
81
95
  toolbarActive: '#2a3f52', // Even lighter - active button background
82
96
  placeholder: '#6a7a88', // Muted blue-gray - placeholder text
97
+ },
98
+ previewColors: {
99
+ text: '#c5dde8',
100
+ h1: 'inherit',
101
+ h2: 'inherit',
102
+ h3: 'inherit',
103
+ strong: 'inherit',
104
+ em: 'inherit',
105
+ link: '#9fcfec',
106
+ code: '#c5dde8',
107
+ codeBg: '#1a232b',
108
+ blockquote: '#9fcfec',
109
+ hr: '#c5dde8',
110
+ bg: 'transparent',
83
111
  }
84
112
  };
85
113
 
@@ -125,13 +153,18 @@ export function resolveAutoTheme(themeName) {
125
153
  * @param {Object} colors - Theme colors object
126
154
  * @returns {string} CSS custom properties string
127
155
  */
128
- export function themeToCSSVars(colors) {
156
+ export function themeToCSSVars(colors, previewColors) {
129
157
  const vars = [];
130
158
  for (const [key, value] of Object.entries(colors)) {
131
- // Convert camelCase to kebab-case
132
159
  const varName = key.replace(/([A-Z])/g, '-$1').toLowerCase();
133
160
  vars.push(`--${varName}: ${value};`);
134
161
  }
162
+ if (previewColors) {
163
+ for (const [key, value] of Object.entries(previewColors)) {
164
+ const varName = key.replace(/([A-Z])/g, '-$1').toLowerCase();
165
+ vars.push(`--preview-${varName}-default: ${value};`);
166
+ }
167
+ }
135
168
  return vars.join('\n');
136
169
  }
137
170
 
@@ -141,12 +174,16 @@ export function themeToCSSVars(colors) {
141
174
  * @param {Object} customColors - Custom color overrides
142
175
  * @returns {Object} Merged theme object
143
176
  */
144
- export function mergeTheme(baseTheme, customColors = {}) {
177
+ export function mergeTheme(baseTheme, customColors = {}, customPreviewColors = {}) {
145
178
  return {
146
179
  ...baseTheme,
147
180
  colors: {
148
181
  ...baseTheme.colors,
149
182
  ...customColors
183
+ },
184
+ previewColors: {
185
+ ...baseTheme.previewColors,
186
+ ...customPreviewColors
150
187
  }
151
188
  };
152
189
  }