@docen/extensions 0.0.10 → 0.0.11
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 +315 -315
- package/dist/_chunks/tiptap-x0R9GhXd.d.mts +31 -0
- package/dist/index.d.mts +23 -14
- package/dist/index.mjs +47831 -8
- package/dist/tiptap.d.mts +2 -3
- package/dist/tiptap.mjs +31 -1
- package/dist/types.d.mts +133 -333
- package/dist/types.mjs +1 -1
- package/package.json +43 -46
- package/dist/index.cjs +0 -8
- package/dist/index.d.cts +0 -72
- package/dist/index.d.ts +0 -72
- package/dist/shared/extensions.BOBBi1Z_.d.cts +0 -6606
- package/dist/shared/extensions.BOBBi1Z_.d.mts +0 -6606
- package/dist/shared/extensions.BOBBi1Z_.d.ts +0 -6606
- package/dist/shared/extensions.CAUtiZQg.cjs +0 -72
- package/dist/shared/extensions.DmJvAao6.d.cts +0 -1863
- package/dist/shared/extensions.IF9nv9tR.d.mts +0 -1863
- package/dist/shared/extensions.ITVKw7bK.d.ts +0 -1863
- package/dist/shared/extensions.ymUB12ul.mjs +0 -72
- package/dist/tiptap.cjs +0 -1
- package/dist/tiptap.d.cts +0 -3
- package/dist/tiptap.d.ts +0 -3
- package/dist/types.cjs +0 -1
- package/dist/types.d.cts +0 -385
- package/dist/types.d.ts +0 -385
package/README.md
CHANGED
|
@@ -1,315 +1,315 @@
|
|
|
1
|
-
# @docen/extensions
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
> Curated collection of TipTap extensions with comprehensive TypeScript type definitions for Docen.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- 📦 **All-in-One Package** - All Docen-required extensions in a single dependency
|
|
12
|
-
- 🔒 **Full Type Safety** - Comprehensive TypeScript definitions for all content nodes and marks
|
|
13
|
-
- 🎯 **Curated Selection** - Only includes extensions actively used in Docen, no bloat
|
|
14
|
-
- 📤 **Type Exports** - Direct access to all node types (DocumentNode, ParagraphNode, etc.)
|
|
15
|
-
- 🚀 **Ready to Use** - Pre-configured extension arrays for blocks and marks
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Install with npm
|
|
21
|
-
$ npm install @docen/extensions
|
|
22
|
-
|
|
23
|
-
# Install with yarn
|
|
24
|
-
$ yarn add @docen/extensions
|
|
25
|
-
|
|
26
|
-
# Install with pnpm
|
|
27
|
-
$ pnpm add @docen/extensions
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { tiptapExtensions, tiptapMarkExtensions } from "@docen/extensions";
|
|
34
|
-
|
|
35
|
-
const editor = new Editor({
|
|
36
|
-
extensions: [
|
|
37
|
-
...tiptapExtensions, // All block extensions
|
|
38
|
-
...tiptapMarkExtensions, // All mark extensions
|
|
39
|
-
],
|
|
40
|
-
content: "<p>Hello, world!</p>",
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Exports
|
|
45
|
-
|
|
46
|
-
### Extension Arrays
|
|
47
|
-
|
|
48
|
-
**`tiptapExtensions`** - Block-level extensions:
|
|
49
|
-
|
|
50
|
-
- Document - Root document node
|
|
51
|
-
- Paragraph - Standard paragraphs
|
|
52
|
-
- Heading - H1-H6 headings
|
|
53
|
-
- Blockquote - Blockquote sections
|
|
54
|
-
- CodeBlock - Code blocks with Lowlight syntax highlighting
|
|
55
|
-
- HorizontalRule - Horizontal dividers
|
|
56
|
-
- Image - Image embedding
|
|
57
|
-
- Details - Collapsible details/summary sections
|
|
58
|
-
- Table - Table containers
|
|
59
|
-
- TableRow - Table rows
|
|
60
|
-
- TableCell - Table body cells
|
|
61
|
-
- TableHeader - Table header cells
|
|
62
|
-
- BulletList - Unordered lists
|
|
63
|
-
- OrderedList - Ordered lists with start support
|
|
64
|
-
- ListItem - List item containers
|
|
65
|
-
- TaskList - Task list containers
|
|
66
|
-
- TaskItem - Task items with checkboxes
|
|
67
|
-
|
|
68
|
-
**`tiptapMarkExtensions`** - Text formatting marks:
|
|
69
|
-
|
|
70
|
-
- Bold - **Bold text**
|
|
71
|
-
- Italic - _Italic text_
|
|
72
|
-
- Underline - <u>Underlined text</u>
|
|
73
|
-
- Strike - ~~Strikethrough text~~
|
|
74
|
-
- Code - `Inline code`
|
|
75
|
-
- Highlight - Text highlighting
|
|
76
|
-
- Subscript - Sub~script~
|
|
77
|
-
- Superscript - Super^script^
|
|
78
|
-
- TextStyle - Text styling (colors, fonts, sizes)
|
|
79
|
-
- Link - Hyperlinks with href, target, rel attributes
|
|
80
|
-
|
|
81
|
-
### TypeScript Types
|
|
82
|
-
|
|
83
|
-
This package exports comprehensive TypeScript types for type-safe development:
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
import type {
|
|
87
|
-
// Root and document types
|
|
88
|
-
JSONContent,
|
|
89
|
-
|
|
90
|
-
// Block nodes
|
|
91
|
-
DocumentNode,
|
|
92
|
-
ParagraphNode,
|
|
93
|
-
HeadingNode,
|
|
94
|
-
BlockquoteNode,
|
|
95
|
-
CodeBlockNode,
|
|
96
|
-
HorizontalRuleNode,
|
|
97
|
-
ImageNode,
|
|
98
|
-
DetailsNode,
|
|
99
|
-
|
|
100
|
-
// List nodes
|
|
101
|
-
BulletListNode,
|
|
102
|
-
OrderedListNode,
|
|
103
|
-
ListItemNode,
|
|
104
|
-
TaskListNode,
|
|
105
|
-
TaskItemNode,
|
|
106
|
-
|
|
107
|
-
// Table nodes
|
|
108
|
-
TableNode,
|
|
109
|
-
TableRowNode,
|
|
110
|
-
TableCellNode,
|
|
111
|
-
TableHeaderNode,
|
|
112
|
-
|
|
113
|
-
// Text nodes
|
|
114
|
-
TextNode,
|
|
115
|
-
HardBreakNode,
|
|
116
|
-
|
|
117
|
-
// Type unions
|
|
118
|
-
BlockNode,
|
|
119
|
-
TextContent,
|
|
120
|
-
} from "@docen/extensions";
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Type Definitions
|
|
124
|
-
|
|
125
|
-
**Content Nodes:**
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
// Paragraph with text alignment and spacing
|
|
129
|
-
interface ParagraphNode {
|
|
130
|
-
type: "paragraph";
|
|
131
|
-
attrs?: {
|
|
132
|
-
textAlign?: "left" | "right" | "center" | "justify";
|
|
133
|
-
indentLeft?: number;
|
|
134
|
-
indentRight?: number;
|
|
135
|
-
indentFirstLine?: number;
|
|
136
|
-
spacingBefore?: number;
|
|
137
|
-
spacingAfter?: number;
|
|
138
|
-
};
|
|
139
|
-
content?: Array<TextContent>;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Heading with level and spacing
|
|
143
|
-
interface HeadingNode {
|
|
144
|
-
type: "heading";
|
|
145
|
-
attrs: {
|
|
146
|
-
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
147
|
-
indentLeft?: number;
|
|
148
|
-
indentRight?: number;
|
|
149
|
-
indentFirstLine?: number;
|
|
150
|
-
spacingBefore?: number;
|
|
151
|
-
spacingAfter?: number;
|
|
152
|
-
};
|
|
153
|
-
content?: Array<TextContent>;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Table with colspan/rowspan
|
|
157
|
-
interface TableCellNode {
|
|
158
|
-
type: "tableCell" | "tableHeader";
|
|
159
|
-
attrs?: {
|
|
160
|
-
colspan?: number;
|
|
161
|
-
rowspan?: number;
|
|
162
|
-
colwidth?: number[] | null;
|
|
163
|
-
};
|
|
164
|
-
content?: Array<ParagraphNode>;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Image with attributes (extended from TipTap)
|
|
168
|
-
interface ImageNode {
|
|
169
|
-
type: "image";
|
|
170
|
-
attrs?: {
|
|
171
|
-
src: string;
|
|
172
|
-
alt?: string | null;
|
|
173
|
-
title?: string | null;
|
|
174
|
-
width?: number | null;
|
|
175
|
-
height?: number | null;
|
|
176
|
-
rotation?: number; // Rotation in degrees (not in TipTap core)
|
|
177
|
-
floating?: ImageFloatingOptions; // Floating positioning options (not in TipTap core)
|
|
178
|
-
outline?: ImageOutlineOptions; // Border/outline options (not in TipTap core)
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Text and Marks:**
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
// Text node with marks
|
|
187
|
-
interface TextNode {
|
|
188
|
-
type: "text";
|
|
189
|
-
text: string;
|
|
190
|
-
marks?: Array<Mark>;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Mark with attributes
|
|
194
|
-
interface Mark {
|
|
195
|
-
type:
|
|
196
|
-
| "bold"
|
|
197
|
-
| "italic"
|
|
198
|
-
| "underline"
|
|
199
|
-
| "strike"
|
|
200
|
-
| "code"
|
|
201
|
-
| "textStyle"
|
|
202
|
-
| "link"
|
|
203
|
-
| "highlight"
|
|
204
|
-
| "subscript"
|
|
205
|
-
| "superscript";
|
|
206
|
-
attrs?: {
|
|
207
|
-
// TextStyle attributes
|
|
208
|
-
color?: string;
|
|
209
|
-
backgroundColor?: string;
|
|
210
|
-
fontSize?: string;
|
|
211
|
-
fontFamily?: string;
|
|
212
|
-
lineHeight?: string;
|
|
213
|
-
|
|
214
|
-
// Link attributes
|
|
215
|
-
href?: string;
|
|
216
|
-
target?: string;
|
|
217
|
-
rel?: string;
|
|
218
|
-
class?: string | null;
|
|
219
|
-
|
|
220
|
-
// Other attributes
|
|
221
|
-
[key: string]: unknown;
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
## Usage Examples
|
|
227
|
-
|
|
228
|
-
### Type-Safe Content Creation
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
import type { JSONContent, ParagraphNode } from "@docen/extensions";
|
|
232
|
-
|
|
233
|
-
const doc: JSONContent = {
|
|
234
|
-
type: "doc",
|
|
235
|
-
content: [
|
|
236
|
-
{
|
|
237
|
-
type: "paragraph",
|
|
238
|
-
content: [
|
|
239
|
-
{
|
|
240
|
-
type: "text",
|
|
241
|
-
marks: [{ type: "bold" }],
|
|
242
|
-
text: "Hello, world!",
|
|
243
|
-
},
|
|
244
|
-
],
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
// Type narrowing with type guards
|
|
250
|
-
function isParagraph(node: JSONContent): node is ParagraphNode {
|
|
251
|
-
return node.type === "paragraph";
|
|
252
|
-
}
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Working with Tables
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
import type { TableNode, TableCellNode } from "@docen/extensions";
|
|
259
|
-
|
|
260
|
-
const table: TableNode = {
|
|
261
|
-
type: "table",
|
|
262
|
-
content: [
|
|
263
|
-
{
|
|
264
|
-
type: "tableRow",
|
|
265
|
-
content: [
|
|
266
|
-
{
|
|
267
|
-
type: "tableHeader",
|
|
268
|
-
attrs: { colspan: 2, rowspan: 1 },
|
|
269
|
-
content: [
|
|
270
|
-
{
|
|
271
|
-
type: "paragraph",
|
|
272
|
-
content: [{ type: "text", text: "Header" }],
|
|
273
|
-
},
|
|
274
|
-
],
|
|
275
|
-
},
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
],
|
|
279
|
-
};
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Custom Editor Setup
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
import { Editor } from "@tiptap/core";
|
|
286
|
-
import { tiptapExtensions } from "@docen/extensions";
|
|
287
|
-
|
|
288
|
-
const editor = new Editor({
|
|
289
|
-
extensions: [
|
|
290
|
-
...tiptapExtensions,
|
|
291
|
-
// Add your custom extensions here
|
|
292
|
-
],
|
|
293
|
-
});
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
## Import Paths
|
|
297
|
-
|
|
298
|
-
This package provides two import paths for flexibility:
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
// Main entry point - extensions and types
|
|
302
|
-
import { tiptapExtensions, tiptapMarkExtensions } from "@docen/extensions";
|
|
303
|
-
import type { JSONContent, ParagraphNode } from "@docen/extensions";
|
|
304
|
-
|
|
305
|
-
// Types-only path for type definitions
|
|
306
|
-
import type { JSONContent } from "@docen/extensions/types";
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
## Contributing
|
|
310
|
-
|
|
311
|
-
Contributions are welcome! Please read our [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) and submit pull requests to the [main repository](https://github.com/DemoMacro/docen).
|
|
312
|
-
|
|
313
|
-
## License
|
|
314
|
-
|
|
315
|
-
- [MIT](LICENSE) © [Demo Macro](https://imst.xyz/)
|
|
1
|
+
# @docen/extensions
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
> Curated collection of TipTap extensions with comprehensive TypeScript type definitions for Docen.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 📦 **All-in-One Package** - All Docen-required extensions in a single dependency
|
|
12
|
+
- 🔒 **Full Type Safety** - Comprehensive TypeScript definitions for all content nodes and marks
|
|
13
|
+
- 🎯 **Curated Selection** - Only includes extensions actively used in Docen, no bloat
|
|
14
|
+
- 📤 **Type Exports** - Direct access to all node types (DocumentNode, ParagraphNode, etc.)
|
|
15
|
+
- 🚀 **Ready to Use** - Pre-configured extension arrays for blocks and marks
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install with npm
|
|
21
|
+
$ npm install @docen/extensions
|
|
22
|
+
|
|
23
|
+
# Install with yarn
|
|
24
|
+
$ yarn add @docen/extensions
|
|
25
|
+
|
|
26
|
+
# Install with pnpm
|
|
27
|
+
$ pnpm add @docen/extensions
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { tiptapExtensions, tiptapMarkExtensions } from "@docen/extensions";
|
|
34
|
+
|
|
35
|
+
const editor = new Editor({
|
|
36
|
+
extensions: [
|
|
37
|
+
...tiptapExtensions, // All block extensions
|
|
38
|
+
...tiptapMarkExtensions, // All mark extensions
|
|
39
|
+
],
|
|
40
|
+
content: "<p>Hello, world!</p>",
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Exports
|
|
45
|
+
|
|
46
|
+
### Extension Arrays
|
|
47
|
+
|
|
48
|
+
**`tiptapExtensions`** - Block-level extensions:
|
|
49
|
+
|
|
50
|
+
- Document - Root document node
|
|
51
|
+
- Paragraph - Standard paragraphs
|
|
52
|
+
- Heading - H1-H6 headings
|
|
53
|
+
- Blockquote - Blockquote sections
|
|
54
|
+
- CodeBlock - Code blocks with Lowlight syntax highlighting
|
|
55
|
+
- HorizontalRule - Horizontal dividers
|
|
56
|
+
- Image - Image embedding
|
|
57
|
+
- Details - Collapsible details/summary sections
|
|
58
|
+
- Table - Table containers
|
|
59
|
+
- TableRow - Table rows
|
|
60
|
+
- TableCell - Table body cells
|
|
61
|
+
- TableHeader - Table header cells
|
|
62
|
+
- BulletList - Unordered lists
|
|
63
|
+
- OrderedList - Ordered lists with start support
|
|
64
|
+
- ListItem - List item containers
|
|
65
|
+
- TaskList - Task list containers
|
|
66
|
+
- TaskItem - Task items with checkboxes
|
|
67
|
+
|
|
68
|
+
**`tiptapMarkExtensions`** - Text formatting marks:
|
|
69
|
+
|
|
70
|
+
- Bold - **Bold text**
|
|
71
|
+
- Italic - _Italic text_
|
|
72
|
+
- Underline - <u>Underlined text</u>
|
|
73
|
+
- Strike - ~~Strikethrough text~~
|
|
74
|
+
- Code - `Inline code`
|
|
75
|
+
- Highlight - Text highlighting
|
|
76
|
+
- Subscript - Sub~script~
|
|
77
|
+
- Superscript - Super^script^
|
|
78
|
+
- TextStyle - Text styling (colors, fonts, sizes)
|
|
79
|
+
- Link - Hyperlinks with href, target, rel attributes
|
|
80
|
+
|
|
81
|
+
### TypeScript Types
|
|
82
|
+
|
|
83
|
+
This package exports comprehensive TypeScript types for type-safe development:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import type {
|
|
87
|
+
// Root and document types
|
|
88
|
+
JSONContent,
|
|
89
|
+
|
|
90
|
+
// Block nodes
|
|
91
|
+
DocumentNode,
|
|
92
|
+
ParagraphNode,
|
|
93
|
+
HeadingNode,
|
|
94
|
+
BlockquoteNode,
|
|
95
|
+
CodeBlockNode,
|
|
96
|
+
HorizontalRuleNode,
|
|
97
|
+
ImageNode,
|
|
98
|
+
DetailsNode,
|
|
99
|
+
|
|
100
|
+
// List nodes
|
|
101
|
+
BulletListNode,
|
|
102
|
+
OrderedListNode,
|
|
103
|
+
ListItemNode,
|
|
104
|
+
TaskListNode,
|
|
105
|
+
TaskItemNode,
|
|
106
|
+
|
|
107
|
+
// Table nodes
|
|
108
|
+
TableNode,
|
|
109
|
+
TableRowNode,
|
|
110
|
+
TableCellNode,
|
|
111
|
+
TableHeaderNode,
|
|
112
|
+
|
|
113
|
+
// Text nodes
|
|
114
|
+
TextNode,
|
|
115
|
+
HardBreakNode,
|
|
116
|
+
|
|
117
|
+
// Type unions
|
|
118
|
+
BlockNode,
|
|
119
|
+
TextContent,
|
|
120
|
+
} from "@docen/extensions";
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Type Definitions
|
|
124
|
+
|
|
125
|
+
**Content Nodes:**
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
// Paragraph with text alignment and spacing
|
|
129
|
+
interface ParagraphNode {
|
|
130
|
+
type: "paragraph";
|
|
131
|
+
attrs?: {
|
|
132
|
+
textAlign?: "left" | "right" | "center" | "justify";
|
|
133
|
+
indentLeft?: number;
|
|
134
|
+
indentRight?: number;
|
|
135
|
+
indentFirstLine?: number;
|
|
136
|
+
spacingBefore?: number;
|
|
137
|
+
spacingAfter?: number;
|
|
138
|
+
};
|
|
139
|
+
content?: Array<TextContent>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Heading with level and spacing
|
|
143
|
+
interface HeadingNode {
|
|
144
|
+
type: "heading";
|
|
145
|
+
attrs: {
|
|
146
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
147
|
+
indentLeft?: number;
|
|
148
|
+
indentRight?: number;
|
|
149
|
+
indentFirstLine?: number;
|
|
150
|
+
spacingBefore?: number;
|
|
151
|
+
spacingAfter?: number;
|
|
152
|
+
};
|
|
153
|
+
content?: Array<TextContent>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Table with colspan/rowspan
|
|
157
|
+
interface TableCellNode {
|
|
158
|
+
type: "tableCell" | "tableHeader";
|
|
159
|
+
attrs?: {
|
|
160
|
+
colspan?: number;
|
|
161
|
+
rowspan?: number;
|
|
162
|
+
colwidth?: number[] | null;
|
|
163
|
+
};
|
|
164
|
+
content?: Array<ParagraphNode>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Image with attributes (extended from TipTap)
|
|
168
|
+
interface ImageNode {
|
|
169
|
+
type: "image";
|
|
170
|
+
attrs?: {
|
|
171
|
+
src: string;
|
|
172
|
+
alt?: string | null;
|
|
173
|
+
title?: string | null;
|
|
174
|
+
width?: number | null;
|
|
175
|
+
height?: number | null;
|
|
176
|
+
rotation?: number; // Rotation in degrees (not in TipTap core)
|
|
177
|
+
floating?: ImageFloatingOptions; // Floating positioning options (not in TipTap core)
|
|
178
|
+
outline?: ImageOutlineOptions; // Border/outline options (not in TipTap core)
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Text and Marks:**
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// Text node with marks
|
|
187
|
+
interface TextNode {
|
|
188
|
+
type: "text";
|
|
189
|
+
text: string;
|
|
190
|
+
marks?: Array<Mark>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Mark with attributes
|
|
194
|
+
interface Mark {
|
|
195
|
+
type:
|
|
196
|
+
| "bold"
|
|
197
|
+
| "italic"
|
|
198
|
+
| "underline"
|
|
199
|
+
| "strike"
|
|
200
|
+
| "code"
|
|
201
|
+
| "textStyle"
|
|
202
|
+
| "link"
|
|
203
|
+
| "highlight"
|
|
204
|
+
| "subscript"
|
|
205
|
+
| "superscript";
|
|
206
|
+
attrs?: {
|
|
207
|
+
// TextStyle attributes
|
|
208
|
+
color?: string;
|
|
209
|
+
backgroundColor?: string;
|
|
210
|
+
fontSize?: string;
|
|
211
|
+
fontFamily?: string;
|
|
212
|
+
lineHeight?: string;
|
|
213
|
+
|
|
214
|
+
// Link attributes
|
|
215
|
+
href?: string;
|
|
216
|
+
target?: string;
|
|
217
|
+
rel?: string;
|
|
218
|
+
class?: string | null;
|
|
219
|
+
|
|
220
|
+
// Other attributes
|
|
221
|
+
[key: string]: unknown;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Usage Examples
|
|
227
|
+
|
|
228
|
+
### Type-Safe Content Creation
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
import type { JSONContent, ParagraphNode } from "@docen/extensions";
|
|
232
|
+
|
|
233
|
+
const doc: JSONContent = {
|
|
234
|
+
type: "doc",
|
|
235
|
+
content: [
|
|
236
|
+
{
|
|
237
|
+
type: "paragraph",
|
|
238
|
+
content: [
|
|
239
|
+
{
|
|
240
|
+
type: "text",
|
|
241
|
+
marks: [{ type: "bold" }],
|
|
242
|
+
text: "Hello, world!",
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Type narrowing with type guards
|
|
250
|
+
function isParagraph(node: JSONContent): node is ParagraphNode {
|
|
251
|
+
return node.type === "paragraph";
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Working with Tables
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import type { TableNode, TableCellNode } from "@docen/extensions";
|
|
259
|
+
|
|
260
|
+
const table: TableNode = {
|
|
261
|
+
type: "table",
|
|
262
|
+
content: [
|
|
263
|
+
{
|
|
264
|
+
type: "tableRow",
|
|
265
|
+
content: [
|
|
266
|
+
{
|
|
267
|
+
type: "tableHeader",
|
|
268
|
+
attrs: { colspan: 2, rowspan: 1 },
|
|
269
|
+
content: [
|
|
270
|
+
{
|
|
271
|
+
type: "paragraph",
|
|
272
|
+
content: [{ type: "text", text: "Header" }],
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
};
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Custom Editor Setup
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { Editor } from "@tiptap/core";
|
|
286
|
+
import { tiptapExtensions } from "@docen/extensions";
|
|
287
|
+
|
|
288
|
+
const editor = new Editor({
|
|
289
|
+
extensions: [
|
|
290
|
+
...tiptapExtensions,
|
|
291
|
+
// Add your custom extensions here
|
|
292
|
+
],
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Import Paths
|
|
297
|
+
|
|
298
|
+
This package provides two import paths for flexibility:
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
// Main entry point - extensions and types
|
|
302
|
+
import { tiptapExtensions, tiptapMarkExtensions } from "@docen/extensions";
|
|
303
|
+
import type { JSONContent, ParagraphNode } from "@docen/extensions";
|
|
304
|
+
|
|
305
|
+
// Types-only path for type definitions
|
|
306
|
+
import type { JSONContent } from "@docen/extensions/types";
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Contributions are welcome! Please read our [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) and submit pull requests to the [main repository](https://github.com/DemoMacro/docen).
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
- [MIT](LICENSE) © [Demo Macro](https://imst.xyz/)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Document } from "@tiptap/extension-document";
|
|
2
|
+
import { Text } from "@tiptap/extension-text";
|
|
3
|
+
import { Paragraph } from "@tiptap/extension-paragraph";
|
|
4
|
+
import { Heading } from "@tiptap/extension-heading";
|
|
5
|
+
import { Blockquote } from "@tiptap/extension-blockquote";
|
|
6
|
+
import { HorizontalRule } from "@tiptap/extension-horizontal-rule";
|
|
7
|
+
import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
|
|
8
|
+
import { BulletList } from "@tiptap/extension-bullet-list";
|
|
9
|
+
import { OrderedList } from "@tiptap/extension-ordered-list";
|
|
10
|
+
import { ListItem } from "@tiptap/extension-list-item";
|
|
11
|
+
import { TaskList } from "@tiptap/extension-task-list";
|
|
12
|
+
import { TaskItem } from "@tiptap/extension-task-item";
|
|
13
|
+
import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
|
|
14
|
+
import { Image } from "@tiptap/extension-image";
|
|
15
|
+
import { HardBreak } from "@tiptap/extension-hard-break";
|
|
16
|
+
import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details";
|
|
17
|
+
import { Emoji } from "@tiptap/extension-emoji";
|
|
18
|
+
import { Mention } from "@tiptap/extension-mention";
|
|
19
|
+
import { Mathematics } from "@tiptap/extension-mathematics";
|
|
20
|
+
import { Bold } from "@tiptap/extension-bold";
|
|
21
|
+
import { Italic } from "@tiptap/extension-italic";
|
|
22
|
+
import { Underline } from "@tiptap/extension-underline";
|
|
23
|
+
import { Strike } from "@tiptap/extension-strike";
|
|
24
|
+
import { Code } from "@tiptap/extension-code";
|
|
25
|
+
import { Link } from "@tiptap/extension-link";
|
|
26
|
+
import { Highlight } from "@tiptap/extension-highlight";
|
|
27
|
+
import { Subscript } from "@tiptap/extension-subscript";
|
|
28
|
+
import { Superscript } from "@tiptap/extension-superscript";
|
|
29
|
+
import { BackgroundColor, Color, FontFamily, FontSize, LineHeight, TextStyle } from "@tiptap/extension-text-style";
|
|
30
|
+
import { TextAlign } from "@tiptap/extension-text-align";
|
|
31
|
+
export { Superscript as A, Underline as B, ListItem as C, Paragraph as D, OrderedList as E, TaskItem as F, TaskList as I, Text as L, TableCell as M, TableHeader as N, Strike as O, TableRow as P, TextAlign as R, Link as S, Mention as T, Highlight as _, Code as a, Italic as b, Details as c, Document as d, Emoji as f, Heading as g, HardBreak as h, BulletList as i, Table as j, Subscript as k, DetailsContent as l, FontSize as m, Blockquote as n, CodeBlockLowlight as o, FontFamily as p, Bold as r, Color as s, BackgroundColor as t, DetailsSummary as u, HorizontalRule as v, Mathematics as w, LineHeight as x, Image as y, TextStyle as z };
|