@principal-ade/industry-themed-mdx-editor 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Principal ADE Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # @principal-ade/industry-themed-mdx-editor
2
+
3
+ Industry-themed MDX editor wrapper with integrated theming support for `@mdxeditor/editor`.
4
+
5
+ ## Features
6
+
7
+ - Seamless integration with `@a24z/industry-theme`
8
+ - Automatic theme synchronization with MDXEditor
9
+ - Built-in save functionality with dirty state tracking
10
+ - Support for controlled and uncontrolled modes
11
+ - TypeScript support with full type definitions
12
+ - Custom CSS theming via CSS custom properties
13
+ - Optional status bar with save indicators
14
+ - File path tracking for context-aware operations
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @principal-ade/industry-themed-mdx-editor @mdxeditor/editor @a24z/industry-theme
20
+ ```
21
+
22
+ or with bun:
23
+
24
+ ```bash
25
+ bun add @principal-ade/industry-themed-mdx-editor @mdxeditor/editor @a24z/industry-theme
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Basic Usage with Theme Provider
31
+
32
+ ```tsx
33
+ import { ThemedMDXEditorWithProvider } from '@principal-ade/industry-themed-mdx-editor';
34
+ import '@mdxeditor/editor/style.css';
35
+ import '@principal-ade/industry-themed-mdx-editor/styles.css';
36
+
37
+ function App() {
38
+ return (
39
+ <ThemedMDXEditorWithProvider
40
+ markdown="# Hello World"
41
+ onChange={(value) => console.log(value)}
42
+ plugins={[
43
+ // Add your MDXEditor plugins here
44
+ ]}
45
+ />
46
+ );
47
+ }
48
+ ```
49
+
50
+ ### Usage with Explicit Theme
51
+
52
+ ```tsx
53
+ import { ThemedMDXEditor } from '@principal-ade/industry-themed-mdx-editor';
54
+ import { useTheme } from '@a24z/industry-theme';
55
+ import '@mdxeditor/editor/style.css';
56
+ import '@principal-ade/industry-themed-mdx-editor/styles.css';
57
+
58
+ function Editor() {
59
+ const { theme } = useTheme();
60
+
61
+ return (
62
+ <ThemedMDXEditor
63
+ theme={theme}
64
+ markdown="# Hello World"
65
+ onChange={(value) => console.log(value)}
66
+ plugins={[
67
+ // Add your MDXEditor plugins here
68
+ ]}
69
+ />
70
+ );
71
+ }
72
+ ```
73
+
74
+ ### With Save Functionality
75
+
76
+ ```tsx
77
+ import { ThemedMDXEditor } from '@principal-ade/industry-themed-mdx-editor';
78
+ import { useTheme } from '@a24z/industry-theme';
79
+ import {
80
+ headingsPlugin,
81
+ listsPlugin,
82
+ quotePlugin,
83
+ markdownShortcutPlugin,
84
+ } from '@mdxeditor/editor';
85
+
86
+ function Editor() {
87
+ const { theme } = useTheme();
88
+
89
+ const handleSave = async (content: string, context: { filePath?: string }) => {
90
+ console.log('Saving content:', content);
91
+ console.log('File path:', context.filePath);
92
+ // Perform save operation
93
+ await fetch('/api/save', {
94
+ method: 'POST',
95
+ body: JSON.stringify({ content, filePath: context.filePath }),
96
+ });
97
+ };
98
+
99
+ return (
100
+ <ThemedMDXEditor
101
+ theme={theme}
102
+ initialValue="# Hello World"
103
+ filePath="/docs/example.md"
104
+ onSave={handleSave}
105
+ enableSaveShortcut={true}
106
+ onDirtyChange={(isDirty) => console.log('Dirty:', isDirty)}
107
+ plugins={[
108
+ headingsPlugin(),
109
+ listsPlugin(),
110
+ quotePlugin(),
111
+ markdownShortcutPlugin(),
112
+ ]}
113
+ />
114
+ );
115
+ }
116
+ ```
117
+
118
+ ### Using the Hook
119
+
120
+ ```tsx
121
+ import { useThemedMDXEditor } from '@principal-ade/industry-themed-mdx-editor';
122
+
123
+ function CustomComponent() {
124
+ const { theme, getCSSVariables } = useThemedMDXEditor();
125
+
126
+ return (
127
+ <div style={getCSSVariables()}>
128
+ {/* Your custom MDX editor UI */}
129
+ </div>
130
+ );
131
+ }
132
+ ```
133
+
134
+ ## API
135
+
136
+ ### ThemedMDXEditor Props
137
+
138
+ Extends all `MDXEditorProps` from `@mdxeditor/editor` with additional props:
139
+
140
+ | Prop | Type | Default | Description |
141
+ |------|------|---------|-------------|
142
+ | `theme` | `Theme` | Required | Industry theme object |
143
+ | `loadingComponent` | `React.ReactNode` | - | Custom loading component |
144
+ | `initialValue` | `string` | - | Initial content for uncontrolled mode |
145
+ | `onSave` | `(value: string, context: { filePath?: string }) => void \| Promise<void>` | - | Save callback |
146
+ | `filePath` | `string` | - | File path for context |
147
+ | `enableSaveShortcut` | `boolean` | `true` | Enable Ctrl/Cmd+S shortcut |
148
+ | `onDirtyChange` | `(isDirty: boolean) => void` | - | Dirty state callback |
149
+ | `hideStatusBar` | `boolean` | `false` | Hide status bar |
150
+ | `containerClassName` | `string` | - | Additional CSS classes |
151
+ | `containerStyle` | `React.CSSProperties` | - | Additional styles |
152
+ | `showLoadingState` | `boolean` | `false` | Show initial loading state |
153
+
154
+ ### ThemedMDXEditorWithProvider Props
155
+
156
+ Same as `ThemedMDXEditor` but without the `theme` prop (uses theme from context).
157
+
158
+ Additional props:
159
+ - `themeName?: string` - Optional theme name to override current theme
160
+
161
+ ### useThemedMDXEditor Hook
162
+
163
+ Returns:
164
+ - `theme` - Processed theme object with editor-specific values
165
+ - `getCSSVariables()` - Function that returns CSS custom properties object
166
+
167
+ ## CSS Custom Properties
168
+
169
+ The package uses CSS custom properties for theming:
170
+
171
+ - `--mdx-editor-bg` - Background color
172
+ - `--mdx-editor-fg` - Foreground (text) color
173
+ - `--mdx-editor-border` - Border color
174
+ - `--mdx-editor-toolbar-bg` - Toolbar background
175
+ - `--mdx-editor-font-family` - Font family
176
+ - `--mdx-editor-font-size` - Font size
177
+ - `--mdx-editor-code-bg` - Code block background
178
+ - `--mdx-editor-selection-bg` - Selection background
179
+ - `--mdx-editor-link-color` - Link color
180
+ - `--mdx-editor-heading-color` - Heading color
181
+
182
+ ## License
183
+
184
+ MIT © Principal ADE Team
@@ -0,0 +1,9 @@
1
+ export { ThemedMDXEditor } from './src/components/ThemedMDXEditor';
2
+ export type { ThemedMDXEditorProps } from './src/components/ThemedMDXEditor';
3
+ export { ThemedMDXEditorWithProvider } from './src/components/ThemedMDXEditorWithProvider';
4
+ export type { ThemedMDXEditorWithProviderProps } from './src/components/ThemedMDXEditorWithProvider';
5
+ export { useThemedMDXEditor } from './src/hooks/useThemedMDXEditor';
6
+ export { createCodeMirrorTheme, createAutoCodeMirrorTheme } from './src/utils/codeMirrorTheme';
7
+ export type { Theme } from '@a24z/industry-theme';
8
+ export type { MDXEditorMethods, MDXEditorProps } from '@mdxeditor/editor';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,YAAY,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAGrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAG/F,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}