@elixpo/lixeditor 2.1.6
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/README.md +139 -0
- package/dist/index.cjs +2364 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +2337 -0
- package/dist/index.js.map +7 -0
- package/dist/styles/blocks.css +1154 -0
- package/dist/styles/blog-image.css +468 -0
- package/dist/styles/editor.css +499 -0
- package/dist/styles/index.css +11 -0
- package/dist/styles/menus.css +518 -0
- package/dist/styles/preview.css +620 -0
- package/dist/styles/variables.css +75 -0
- package/package.json +53 -0
- package/src/blocks/BlockEquation.jsx +122 -0
- package/src/blocks/ButtonBlock.jsx +90 -0
- package/src/blocks/DateInline.jsx +170 -0
- package/src/blocks/ImageBlock.jsx +274 -0
- package/src/blocks/InlineEquation.jsx +108 -0
- package/src/blocks/MermaidBlock.jsx +430 -0
- package/src/blocks/PDFEmbedBlock.jsx +200 -0
- package/src/blocks/SubpageBlock.jsx +180 -0
- package/src/blocks/TableOfContents.jsx +44 -0
- package/src/blocks/index.js +8 -0
- package/src/editor/KeyboardShortcutsModal.jsx +126 -0
- package/src/editor/LinkPreviewTooltip.jsx +165 -0
- package/src/editor/LixEditor.jsx +342 -0
- package/src/hooks/useLixTheme.js +55 -0
- package/src/index.js +41 -0
- package/src/preview/LixPreview.jsx +191 -0
- package/src/preview/renderBlocks.js +163 -0
- package/src/styles/blocks.css +1154 -0
- package/src/styles/blog-image.css +468 -0
- package/src/styles/editor.css +499 -0
- package/src/styles/index.css +11 -0
- package/src/styles/menus.css +518 -0
- package/src/styles/preview.css +620 -0
- package/src/styles/variables.css +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @elixpo/lixeditor
|
|
2
|
+
|
|
3
|
+
A rich WYSIWYG block editor and renderer built on [BlockNote](https://blocknotejs.org) — with LaTeX equations, Mermaid diagrams, syntax-highlighted code blocks, and more.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @elixpo/lixeditor @blocknote/core @blocknote/react @blocknote/mantine
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { LixEditor, LixPreview, LixThemeProvider } from '@elixpo/lixeditor';
|
|
15
|
+
import '@blocknote/core/fonts/inter.css';
|
|
16
|
+
import '@blocknote/mantine/style.css';
|
|
17
|
+
import '@elixpo/lixeditor/styles';
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
const [blocks, setBlocks] = useState(null);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<LixThemeProvider defaultTheme="dark">
|
|
24
|
+
{/* Editor */}
|
|
25
|
+
<LixEditor
|
|
26
|
+
initialContent={blocks}
|
|
27
|
+
onChange={(editor) => setBlocks(editor.getBlocks())}
|
|
28
|
+
features={{
|
|
29
|
+
equations: true,
|
|
30
|
+
mermaid: true,
|
|
31
|
+
codeHighlighting: true,
|
|
32
|
+
tableOfContents: true,
|
|
33
|
+
linkPreview: true,
|
|
34
|
+
}}
|
|
35
|
+
placeholder="Start writing..."
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
{/* Preview / Reader */}
|
|
39
|
+
<LixPreview blocks={blocks} />
|
|
40
|
+
</LixThemeProvider>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
| Feature | Default | Description |
|
|
48
|
+
|---------|---------|-------------|
|
|
49
|
+
| `equations` | `true` | Block & inline LaTeX via KaTeX |
|
|
50
|
+
| `mermaid` | `true` | Mermaid diagram blocks (flowchart, sequence, etc.) |
|
|
51
|
+
| `codeHighlighting` | `true` | Shiki syntax highlighting with 30+ languages |
|
|
52
|
+
| `tableOfContents` | `true` | Auto-generated TOC block |
|
|
53
|
+
| `images` | `true` | Image blocks with upload, embed, captions |
|
|
54
|
+
| `buttons` | `true` | Interactive button blocks |
|
|
55
|
+
| `pdf` | `true` | PDF embed blocks |
|
|
56
|
+
| `dates` | `true` | Inline date picker chips |
|
|
57
|
+
| `linkPreview` | `true` | OG metadata tooltip on link hover |
|
|
58
|
+
| `markdownLinks` | `true` | Auto-convert `[text](url)` to links |
|
|
59
|
+
|
|
60
|
+
## Extending
|
|
61
|
+
|
|
62
|
+
### Custom Block Specs
|
|
63
|
+
|
|
64
|
+
```jsx
|
|
65
|
+
<LixEditor
|
|
66
|
+
extraBlockSpecs={[
|
|
67
|
+
{ type: 'myBlock', spec: MyCustomBlockSpec({}) }
|
|
68
|
+
]}
|
|
69
|
+
extraInlineSpecs={[
|
|
70
|
+
{ type: 'myInline', spec: MyInlineSpec }
|
|
71
|
+
]}
|
|
72
|
+
slashMenuItems={[
|
|
73
|
+
{ title: 'My Block', group: 'Custom', onItemClick: (editor) => { ... } }
|
|
74
|
+
]}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Theming
|
|
79
|
+
|
|
80
|
+
Override CSS variables to customize colors:
|
|
81
|
+
|
|
82
|
+
```css
|
|
83
|
+
:root {
|
|
84
|
+
--lix-accent: #e040fb;
|
|
85
|
+
--lix-bg-app: #fafafa;
|
|
86
|
+
--lix-font-body: 'Inter', sans-serif;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Using Individual Blocks
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
import { BlockEquation, MermaidBlock, InlineEquation } from '@elixpo/lixeditor';
|
|
94
|
+
import { BlockNoteSchema, defaultBlockSpecs } from '@blocknote/core';
|
|
95
|
+
|
|
96
|
+
const schema = BlockNoteSchema.create({
|
|
97
|
+
blockSpecs: {
|
|
98
|
+
...defaultBlockSpecs,
|
|
99
|
+
blockEquation: BlockEquation({}),
|
|
100
|
+
mermaidBlock: MermaidBlock({}),
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## API Reference
|
|
106
|
+
|
|
107
|
+
### `<LixEditor />`
|
|
108
|
+
|
|
109
|
+
| Prop | Type | Description |
|
|
110
|
+
|------|------|-------------|
|
|
111
|
+
| `initialContent` | `Block[]` | Initial BlockNote document |
|
|
112
|
+
| `onChange` | `(editor) => void` | Called on content change |
|
|
113
|
+
| `features` | `object` | Enable/disable features |
|
|
114
|
+
| `codeLanguages` | `object` | Custom language map for code blocks |
|
|
115
|
+
| `extraBlockSpecs` | `array` | Additional block specs |
|
|
116
|
+
| `extraInlineSpecs` | `array` | Additional inline content specs |
|
|
117
|
+
| `slashMenuItems` | `array` | Extra slash menu items |
|
|
118
|
+
| `placeholder` | `string` | Editor placeholder text |
|
|
119
|
+
| `collaboration` | `object` | Yjs collaboration config |
|
|
120
|
+
| `ref` | `ref` | Access editor methods: `getBlocks()`, `getHTML()`, `getMarkdown()` |
|
|
121
|
+
|
|
122
|
+
### `<LixPreview />`
|
|
123
|
+
|
|
124
|
+
| Prop | Type | Description |
|
|
125
|
+
|------|------|-------------|
|
|
126
|
+
| `blocks` | `Block[]` | BlockNote document to render |
|
|
127
|
+
| `html` | `string` | Fallback raw HTML |
|
|
128
|
+
| `features` | `object` | Enable/disable post-processing features |
|
|
129
|
+
|
|
130
|
+
### `<LixThemeProvider />`
|
|
131
|
+
|
|
132
|
+
| Prop | Type | Description |
|
|
133
|
+
|------|------|-------------|
|
|
134
|
+
| `defaultTheme` | `'light' \| 'dark'` | Initial theme |
|
|
135
|
+
| `storageKey` | `string` | localStorage key for persistence |
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|