axiom-editor 1.0.1 → 1.0.3
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 +21 -0
- package/README.md +261 -0
- package/dist/axiom-editor.cjs +9 -216
- package/dist/axiom-editor.es.js +1183 -38469
- package/dist/index.d.ts +6 -0
- package/dist/style.css +1 -1
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aditya
|
|
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,261 @@
|
|
|
1
|
+
# AxiomEditor
|
|
2
|
+
|
|
3
|
+
A premium, modular narrative architecture block editor built on **React**, **Tiptap**, and **Tailwind CSS**.
|
|
4
|
+
|
|
5
|
+
AxiomEditor is designed for modern developers who need a gorgeous, distraction-free editing interface out of the box, but require the flexibility to tear it down and build custom compositions. By default, it ships with a dark-mode obsidian aesthetic, custom multi-color highlights, drag-and-drop media embeds, and clean AST rendering support.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
* ✨ **Monolithic & Modular APIs:** Use the all-in-one `<AxiomEditor />` component for instant setup, or compose custom layouts using `<AxiomEditorProvider />`, `<AxiomToolbar />`, and `<AxiomContent />`.
|
|
12
|
+
* 🚀 **Advanced Slash Commands:** Press `/` on a blank line to trigger a fluid slash command dropdown with smooth transitions and keyboard navigation support.
|
|
13
|
+
* 🎨 **Full Design Token Control:** Every color, border, and background is mapped to standard CSS custom properties. Customize the editor to light mode, amber mode, or your corporate brand with single CSS overrides.
|
|
14
|
+
* 🌈 **Simultaneous Multi-Color Highlighting:** Support for concurrently underlining or striking-through text in multiple custom colors (Bone, Amber, Charcoal, Obsidian, and Accent Primary).
|
|
15
|
+
* 🖼️ **Advanced Media System:** Drop-in embeds for **YouTube** videos, **X (Twitter)** posts, **Instagram** reels, and inline image uploads with resizing handles and captions.
|
|
16
|
+
* 📊 **Sync & Word Count Indicator:** Minimalist bottom status bar showing word counts and a Pulsing Sync indicator representing save-states.
|
|
17
|
+
* 💾 **Serialized JSON AST Parser:** Direct access to Tiptap JSON abstract syntax trees (AST) and a fast renderer component (`<AxiomJSONRenderer />`) to display them on user pages.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install the package and its required peer dependencies in your React project:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install axiom-editor lucide-react react react-dom
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Import Styles
|
|
30
|
+
Make sure to import the editor stylesheet in your main entry file (e.g., `main.tsx` or `_app.tsx`):
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import 'axiom-editor/style.css';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Implementation Guide
|
|
39
|
+
|
|
40
|
+
### 1. Quick Start (Monolithic Layout)
|
|
41
|
+
|
|
42
|
+
For standard setups, use the monolithic wrapper which includes a top sticky toolbar, a fixed-height editor canvas, and automated media modal routing.
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import React, { useState } from 'react';
|
|
46
|
+
import { AxiomEditor } from 'axiom-editor';
|
|
47
|
+
import type { JSONContent } from '@tiptap/core';
|
|
48
|
+
import 'axiom-editor/style.css';
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
const [content, setContent] = useState<JSONContent | string>('<p>Write your narrative here...</p>');
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="min-h-screen bg-neutral-900 p-8 flex items-center justify-center">
|
|
55
|
+
<div className="w-full max-w-4xl bg-neutral-950 p-6 rounded-2xl border border-neutral-800">
|
|
56
|
+
<AxiomEditor
|
|
57
|
+
initialContent={content}
|
|
58
|
+
onChange={(json, html) => {
|
|
59
|
+
console.log('JSON AST:', json);
|
|
60
|
+
console.log('HTML String:', html);
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default App;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### 2. Advanced Modular UI Composition
|
|
74
|
+
|
|
75
|
+
If you want a custom layout—such as placing the toolbar at the bottom, embedding the editor canvas in a floating card, or building custom sidebar controls—you can compose the subcomponents directly.
|
|
76
|
+
|
|
77
|
+
All child components inside `<AxiomEditorProvider />` share the editor context automatically via the `useAxiomEditor` hook.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import React from 'react';
|
|
81
|
+
import {
|
|
82
|
+
AxiomEditorProvider,
|
|
83
|
+
AxiomToolbar,
|
|
84
|
+
AxiomContent,
|
|
85
|
+
MediaMenu,
|
|
86
|
+
useAxiomEditor
|
|
87
|
+
} from 'axiom-editor';
|
|
88
|
+
|
|
89
|
+
function CustomSyncIndicator() {
|
|
90
|
+
const { editor } = useAxiomEditor();
|
|
91
|
+
if (!editor) return null;
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className="text-xs text-neutral-500 font-mono">
|
|
95
|
+
Words: {editor.storage.characterCount.words()}
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function CustomLayoutEditor() {
|
|
101
|
+
return (
|
|
102
|
+
<AxiomEditorProvider initialContent="Composition is key.">
|
|
103
|
+
<div className="flex flex-col gap-6 p-4 border rounded-3xl bg-black">
|
|
104
|
+
|
|
105
|
+
{/* Render Canvas First */}
|
|
106
|
+
<div className="p-4 bg-zinc-900/50 rounded-2xl">
|
|
107
|
+
<AxiomContent />
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
{/* Render Toolbar Below the Canvas */}
|
|
111
|
+
<div className="p-2 border-t border-zinc-800 flex items-center justify-between">
|
|
112
|
+
<AxiomToolbar />
|
|
113
|
+
<CustomSyncIndicator />
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
{/* The Media Insertion Modals */}
|
|
117
|
+
<MediaMenu />
|
|
118
|
+
</div>
|
|
119
|
+
</AxiomEditorProvider>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### 3. Native Image Upload Handler
|
|
127
|
+
|
|
128
|
+
Configure the `uploadImage` hook to handle local file selection and return a secure uploaded image URL. Below is a production-ready example integrating with **Cloudinary**:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
const handleImageUpload = async (file: File): Promise<string> => {
|
|
132
|
+
const formData = new FormData();
|
|
133
|
+
formData.append('file', file);
|
|
134
|
+
formData.append('upload_preset', 'your_unsigned_preset'); // Replace with your preset
|
|
135
|
+
formData.append('cloud_name', 'your_cloudinary_cloud_name'); // Replace with your cloud name
|
|
136
|
+
|
|
137
|
+
const response = await fetch(
|
|
138
|
+
`https://api.cloudinary.com/v1_1/your_cloudinary_cloud_name/image/upload`,
|
|
139
|
+
{
|
|
140
|
+
method: 'POST',
|
|
141
|
+
body: formData,
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
throw new Error('Image upload failed');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const result = await response.json();
|
|
150
|
+
return result.secure_url; // Returns the public hosting URL for Tiptap
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Usage:
|
|
154
|
+
// <AxiomEditor uploadImage={handleImageUpload} ... />
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Custom Theming
|
|
160
|
+
|
|
161
|
+
AxiomEditor namespaced classes are bound to CSS variables, preventing compilation purges in host projects and ensuring complete customizability. By default, it features a rich dark-mode theme.
|
|
162
|
+
|
|
163
|
+
To override colors, target the `.axiom-editor-wrapper` wrapper in your CSS:
|
|
164
|
+
|
|
165
|
+
```css
|
|
166
|
+
/* Custom Light Mode Theme */
|
|
167
|
+
.axiom-editor-wrapper {
|
|
168
|
+
--axiom-bg: #ffffff;
|
|
169
|
+
--axiom-bg-card: #f4f4f5;
|
|
170
|
+
--axiom-text: #09090b;
|
|
171
|
+
--axiom-text-muted: #71717a;
|
|
172
|
+
--axiom-border: #e4e4e7;
|
|
173
|
+
--axiom-border-separator: #d4d4d8;
|
|
174
|
+
--axiom-primary: #f59e0b; /* Amber accent highlight */
|
|
175
|
+
--axiom-primary-text: #09090b;
|
|
176
|
+
--axiom-primary-text-muted: #d97706;
|
|
177
|
+
--axiom-button-active: #f3f4f6;
|
|
178
|
+
--axiom-button-active-text: #0f172a;
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Full Token References
|
|
183
|
+
|
|
184
|
+
| CSS Variable | Description | Default Dark Theme Value |
|
|
185
|
+
| :--- | :--- | :--- |
|
|
186
|
+
| `--axiom-bg` | Main editor viewport background | `#0f0f10` (Obsidian black) |
|
|
187
|
+
| `--axiom-bg-card` | Menus, popups, and modal background | `#18181b` (Charcoal zinc) |
|
|
188
|
+
| `--axiom-text` | Body and header text | `#fafafa` (Bone white) |
|
|
189
|
+
| `--axiom-text-muted` | Secondary indicators, placeholders | `#71717a` (Steel gray) |
|
|
190
|
+
| `--axiom-border` | Component borders and wrappers | `rgba(250, 250, 250, 0.1)` |
|
|
191
|
+
| `--axiom-border-separator` | Internal toolbar separator vertical rules | `rgba(250, 250, 250, 0.06)` |
|
|
192
|
+
| `--axiom-primary` | Accent highlight color | `#ffbf00` (Amber gold) |
|
|
193
|
+
| `--axiom-primary-text` | Text color on active primary buttons | `#0f0f10` |
|
|
194
|
+
| `--axiom-primary-text-muted`| Colored highlights, word count save states | `#ffbf00` |
|
|
195
|
+
| `--axiom-button-active` | Active formatting state buttons background | `rgba(250, 250, 250, 0.08)` |
|
|
196
|
+
| `--axiom-button-active-text`| Active state icon/font color | `#ffbf00` |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Rendering Content Outside the Editor
|
|
201
|
+
|
|
202
|
+
When saving content from the editor, you should store the **JSON AST** output. To render this JSON back on your website or article page with correct narrative styling, use `<AxiomJSONRenderer />`:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
import React from 'react';
|
|
206
|
+
import { AxiomJSONRenderer } from 'axiom-editor';
|
|
207
|
+
|
|
208
|
+
const savedArticleJson = {
|
|
209
|
+
type: "doc",
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
type: "heading",
|
|
213
|
+
attrs: { level: 1 },
|
|
214
|
+
content: [{ type: "text", text: "Stunning Block Architectures" }]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: "paragraph",
|
|
218
|
+
content: [{ type: "text", text: "This content was rendered directly from JSON AST." }]
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
function ArticlePage() {
|
|
224
|
+
return (
|
|
225
|
+
<article className="max-w-3xl mx-auto p-6 bg-zinc-950 text-white">
|
|
226
|
+
{/* Renders Tiptap nodes natively using React elements */}
|
|
227
|
+
<AxiomJSONRenderer content={savedArticleJson} />
|
|
228
|
+
</article>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## API Reference
|
|
236
|
+
|
|
237
|
+
### Props: `<AxiomEditor />` & `<AxiomEditorProvider />`
|
|
238
|
+
|
|
239
|
+
| Prop | Type | Description |
|
|
240
|
+
| :--- | :--- | :--- |
|
|
241
|
+
| `initialContent` | `string \| JSONContent` | Initial markdown, HTML string, or parsed JSON AST document content. |
|
|
242
|
+
| `onChange` | `(json: JSONContent, html: string) => void` | Event fires on text/formatting changes, returning the AST and HTML string. |
|
|
243
|
+
| `uploadImage` | `(file: File) => Promise<string>` | Async file uploading function returning a public url path. |
|
|
244
|
+
| `minHeightClass` | `string` | Optional CSS height class for canvas height configuration. |
|
|
245
|
+
| `maxHeightClass` | `string` | Optional CSS height class for max constraints configuration. |
|
|
246
|
+
|
|
247
|
+
### Component Exports
|
|
248
|
+
|
|
249
|
+
* **`<AxiomEditor />`**: Easy-to-use monolithic component with built-in toolbar, canvas, and insertion routing.
|
|
250
|
+
* **`<AxiomEditorProvider />`**: Context wrapper mapping editor instances. Required for composing custom layouts.
|
|
251
|
+
* **`<AxiomContent />`**: Editor editor content layer with scroll constraints and styling namespaces.
|
|
252
|
+
* **`<AxiomToolbar />`**: Text layout modifiers, formatting utilities, headers, and video hooks.
|
|
253
|
+
* **`<MediaMenu />`**: Absolute-overlay modal triggers handling links, tweets, YouTube, and image attachments.
|
|
254
|
+
* **`<AxiomJSONRenderer />`**: High performance rendering agent mapping saved JSON schemas back to React nodes.
|
|
255
|
+
* **`useAxiomEditor()`**: Custom hook retrieving current `{ editor }` instance variables and status.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
This project is licensed under the [MIT License](file:///C:/Users/adity/.gemini/antigravity/scratch/axiom-editor-package/LICENSE).
|