@docen/extensions 0.0.12 → 0.0.13

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 CHANGED
@@ -1,315 +1,315 @@
1
- # @docen/extensions
2
-
3
- ![npm version](https://img.shields.io/npm/v/@docen/extensions)
4
- ![npm downloads](https://img.shields.io/npm/dw/@docen/extensions)
5
- ![npm license](https://img.shields.io/npm/l/@docen/extensions)
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) &copy; [Demo Macro](https://imst.xyz/)
1
+ # @docen/extensions
2
+
3
+ ![npm version](https://img.shields.io/npm/v/@docen/extensions)
4
+ ![npm downloads](https://img.shields.io/npm/dw/@docen/extensions)
5
+ ![npm license](https://img.shields.io/npm/l/@docen/extensions)
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) &copy; [Demo Macro](https://imst.xyz/)
package/dist/index.mjs CHANGED
@@ -180,6 +180,41 @@ const Paragraph = Paragraph$1.extend({ addAttributes() {
180
180
  default: null,
181
181
  parseHTML: (element) => element.style.marginBottom || null,
182
182
  renderHTML: (attributes) => attributes.spacingAfter ? { style: `margin-bottom: ${attributes.spacingAfter}` } : {}
183
+ },
184
+ shading: {
185
+ default: null,
186
+ parseHTML: (element) => {
187
+ const bg = element.style.backgroundColor;
188
+ if (!bg) return null;
189
+ return {
190
+ fill: bg.startsWith("#") ? bg : `#${bg}`,
191
+ type: "clear"
192
+ };
193
+ },
194
+ renderHTML: (attributes) => {
195
+ if (!attributes.shading?.fill) return {};
196
+ return { style: `background-color: ${attributes.shading.fill}` };
197
+ }
198
+ },
199
+ borderTop: {
200
+ default: null,
201
+ parseHTML: () => null,
202
+ renderHTML: () => ({})
203
+ },
204
+ borderBottom: {
205
+ default: null,
206
+ parseHTML: () => null,
207
+ renderHTML: () => ({})
208
+ },
209
+ borderLeft: {
210
+ default: null,
211
+ parseHTML: () => null,
212
+ renderHTML: () => ({})
213
+ },
214
+ borderRight: {
215
+ default: null,
216
+ parseHTML: () => null,
217
+ renderHTML: () => ({})
183
218
  }
184
219
  };
185
220
  } });
package/dist/types.d.mts CHANGED
@@ -1,7 +1,220 @@
1
1
  import { JSONContent } from "@tiptap/core";
2
- import { IFloating, IHorizontalPositionOptions, IImageOptions, IVerticalPositionOptions } from "docx";
3
2
 
3
+ //#region ../../node_modules/.pnpm/docx@9.6.1/node_modules/docx/dist/index.d.ts
4
+ declare const CompoundLine: {
5
+ readonly SINGLE: "sng";
6
+ readonly DOUBLE: "dbl";
7
+ readonly THICK_THIN: "thickThin";
8
+ readonly THIN_THICK: "thinThick";
9
+ readonly TRI: "tri";
10
+ };
11
+ declare type CoreImageOptions = {
12
+ readonly transformation: IMediaTransformation;
13
+ readonly floating?: IFloating;
14
+ readonly altText?: DocPropertiesOptions;
15
+ readonly outline?: OutlineOptions;
16
+ readonly solidFill?: SolidFillOptions;
17
+ };
18
+ declare type DocPropertiesOptions = {
19
+ readonly name: string;
20
+ readonly description?: string;
21
+ readonly title?: string;
22
+ readonly id?: string;
23
+ };
24
+ declare const HorizontalPositionAlign: {
25
+ readonly CENTER: "center";
26
+ readonly INSIDE: "inside";
27
+ readonly LEFT: "left";
28
+ readonly OUTSIDE: "outside";
29
+ readonly RIGHT: "right";
30
+ };
31
+ declare const HorizontalPositionRelativeFrom: {
32
+ readonly CHARACTER: "character";
33
+ readonly COLUMN: "column";
34
+ readonly INSIDE_MARGIN: "insideMargin";
35
+ readonly LEFT_MARGIN: "leftMargin";
36
+ readonly MARGIN: "margin";
37
+ readonly OUTSIDE_MARGIN: "outsideMargin";
38
+ readonly PAGE: "page";
39
+ readonly RIGHT_MARGIN: "rightMargin";
40
+ };
41
+ declare type IDistance = {
42
+ readonly distT?: number;
43
+ readonly distB?: number;
44
+ readonly distL?: number;
45
+ readonly distR?: number;
46
+ };
47
+ declare type IFloating = {
48
+ readonly horizontalPosition: IHorizontalPositionOptions;
49
+ readonly verticalPosition: IVerticalPositionOptions;
50
+ readonly allowOverlap?: boolean;
51
+ readonly lockAnchor?: boolean;
52
+ readonly behindDocument?: boolean;
53
+ readonly layoutInCell?: boolean;
54
+ readonly margins?: IMargins;
55
+ readonly wrap?: ITextWrapping;
56
+ readonly zIndex?: number;
57
+ };
58
+ declare type IHorizontalPositionOptions = {
59
+ readonly relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];
60
+ readonly align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];
61
+ readonly offset?: number;
62
+ };
63
+ declare type IImageOptions = (RegularImageOptions | SvgMediaOptions) & CoreImageOptions;
64
+ declare type IMargins = {
65
+ readonly left?: number;
66
+ readonly bottom?: number;
67
+ readonly top?: number;
68
+ readonly right?: number;
69
+ };
70
+ declare type IMediaTransformation = {
71
+ readonly offset?: {
72
+ readonly top?: number;
73
+ readonly left?: number;
74
+ };
75
+ readonly width: number;
76
+ readonly height: number;
77
+ readonly flip?: {
78
+ readonly vertical?: boolean;
79
+ readonly horizontal?: boolean;
80
+ };
81
+ readonly rotation?: number;
82
+ };
83
+ declare type ITextWrapping = {
84
+ readonly type: (typeof TextWrappingType)[keyof typeof TextWrappingType];
85
+ readonly side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
86
+ readonly margins?: IDistance;
87
+ };
88
+ declare type IVerticalPositionOptions = {
89
+ readonly relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];
90
+ readonly align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];
91
+ readonly offset?: number;
92
+ };
93
+ declare const LineCap: {
94
+ readonly ROUND: "rnd";
95
+ readonly SQUARE: "sq";
96
+ readonly FLAT: "flat";
97
+ };
98
+ declare type OutlineAttributes = {
99
+ readonly width?: number;
100
+ readonly cap?: keyof typeof LineCap;
101
+ readonly compoundLine?: keyof typeof CompoundLine;
102
+ readonly align?: keyof typeof PenAlignment;
103
+ };
104
+ declare type OutlineFillProperties = OutlineNoFill | OutlineSolidFill;
105
+ declare type OutlineNoFill = {
106
+ readonly type: "noFill";
107
+ };
108
+ declare type OutlineOptions = OutlineAttributes & OutlineFillProperties;
109
+ declare type OutlineRgbSolidFill = {
110
+ readonly type: "solidFill";
111
+ readonly solidFillType: "rgb";
112
+ readonly value: string;
113
+ };
114
+ declare type OutlineSchemeSolidFill = {
115
+ readonly type: "solidFill";
116
+ readonly solidFillType: "scheme";
117
+ readonly value: (typeof SchemeColor)[keyof typeof SchemeColor];
118
+ };
119
+ declare type OutlineSolidFill = OutlineRgbSolidFill | OutlineSchemeSolidFill;
120
+ declare const PenAlignment: {
121
+ readonly CENTER: "ctr";
122
+ readonly INSET: "in";
123
+ };
124
+ declare type RegularImageOptions = {
125
+ readonly type: "jpg" | "png" | "gif" | "bmp";
126
+ readonly data: Buffer | string | Uint8Array | ArrayBuffer;
127
+ };
128
+ declare type RgbColorOptions = {
129
+ readonly type: "rgb";
130
+ readonly value: string;
131
+ };
132
+ declare const SchemeColor: {
133
+ readonly BG1: "bg1";
134
+ readonly TX1: "tx1";
135
+ readonly BG2: "bg2";
136
+ readonly TX2: "tx2";
137
+ readonly ACCENT1: "accent1";
138
+ readonly ACCENT2: "accent2";
139
+ readonly ACCENT3: "accent3";
140
+ readonly ACCENT4: "accent4";
141
+ readonly ACCENT5: "accent5";
142
+ readonly ACCENT6: "accent6";
143
+ readonly HLINK: "hlink";
144
+ readonly FOLHLINK: "folHlink";
145
+ readonly DK1: "dk1";
146
+ readonly LT1: "lt1";
147
+ readonly DK2: "dk2";
148
+ readonly LT2: "lt2";
149
+ readonly PHCLR: "phClr";
150
+ };
151
+ declare type SchemeColorOptions = {
152
+ readonly type: "scheme";
153
+ readonly value: (typeof SchemeColor)[keyof typeof SchemeColor];
154
+ };
155
+ declare type SolidFillOptions = RgbColorOptions | SchemeColorOptions;
156
+ declare type SvgMediaOptions = {
157
+ readonly type: "svg";
158
+ readonly data: Buffer | string | Uint8Array | ArrayBuffer;
159
+ readonly fallback: RegularImageOptions;
160
+ };
161
+ declare const TextWrappingSide: {
162
+ readonly BOTH_SIDES: "bothSides";
163
+ readonly LEFT: "left";
164
+ readonly RIGHT: "right";
165
+ readonly LARGEST: "largest";
166
+ };
167
+ declare const TextWrappingType: {
168
+ readonly NONE: 0;
169
+ readonly SQUARE: 1;
170
+ readonly TIGHT: 2;
171
+ readonly TOP_AND_BOTTOM: 3;
172
+ };
173
+ declare const VerticalPositionAlign: {
174
+ readonly BOTTOM: "bottom";
175
+ readonly CENTER: "center";
176
+ readonly INSIDE: "inside";
177
+ readonly OUTSIDE: "outside";
178
+ readonly TOP: "top";
179
+ };
180
+ declare const VerticalPositionRelativeFrom: {
181
+ readonly BOTTOM_MARGIN: "bottomMargin";
182
+ readonly INSIDE_MARGIN: "insideMargin";
183
+ readonly LINE: "line";
184
+ readonly MARGIN: "margin";
185
+ readonly OUTSIDE_MARGIN: "outsideMargin";
186
+ readonly PAGE: "page";
187
+ readonly PARAGRAPH: "paragraph";
188
+ readonly TOP_MARGIN: "topMargin";
189
+ };
190
+ //#endregion
4
191
  //#region src/types.d.ts
192
+ /**
193
+ * Border definition (compatible with docx.js BorderOptions)
194
+ * Used by paragraphs, table cells, and blockquotes
195
+ */
196
+ interface Border {
197
+ /** Border color (hex without #, e.g., "FF0000" or "auto") */
198
+ color?: string;
199
+ /** Border size (eighth-points, 1/8 pt) */
200
+ size?: number;
201
+ /** Border style */
202
+ style?: "single" | "dashed" | "dotted" | "double" | "dotDash" | "dotDotDash" | "none";
203
+ /** Space between border and content (points) */
204
+ space?: number;
205
+ }
206
+ /**
207
+ * Shading definition (compatible with docx.js ShadingOptions)
208
+ * Used for paragraph and table cell background colors
209
+ */
210
+ interface Shading {
211
+ /** Fill color (hex without #, e.g., "FF0000") */
212
+ fill?: string;
213
+ /** Pattern color (hex without #) */
214
+ color?: string;
215
+ /** Shading pattern type (e.g., "clear", "percent-10") */
216
+ type?: string;
217
+ }
5
218
  type ImageFloatingOptions = {
6
219
  horizontalPosition: IHorizontalPositionOptions;
7
220
  verticalPosition: IVerticalPositionOptions;
@@ -44,6 +257,11 @@ interface ParagraphNode extends JSONContent {
44
257
  indentFirstLine?: string;
45
258
  spacingBefore?: string;
46
259
  spacingAfter?: string;
260
+ shading?: Shading;
261
+ borderTop?: Border;
262
+ borderBottom?: Border;
263
+ borderLeft?: Border;
264
+ borderRight?: Border;
47
265
  };
48
266
  content?: Array<TextNode | HardBreakNode | ImageNode>;
49
267
  }
@@ -57,6 +275,11 @@ interface HeadingNode extends JSONContent {
57
275
  spacingBefore?: string;
58
276
  spacingAfter?: string;
59
277
  textAlign?: "left" | "right" | "center" | "justify";
278
+ shading?: Shading;
279
+ borderTop?: Border;
280
+ borderBottom?: Border;
281
+ borderLeft?: Border;
282
+ borderRight?: Border;
60
283
  };
61
284
  content?: Array<TextNode | HardBreakNode>;
62
285
  }
@@ -102,11 +325,6 @@ interface TaskItemNode extends JSONContent {
102
325
  };
103
326
  content?: Array<ParagraphNode>;
104
327
  }
105
- interface TableCellBorder {
106
- color?: string;
107
- width?: number;
108
- style?: "solid" | "dashed" | "dotted" | "double" | "none";
109
- }
110
328
  interface TableNode extends JSONContent {
111
329
  type: "table";
112
330
  attrs?: {
@@ -132,10 +350,10 @@ interface TableCellNode extends JSONContent {
132
350
  colwidth?: number[] | null;
133
351
  backgroundColor?: string | null;
134
352
  verticalAlign?: "top" | "middle" | "bottom" | null;
135
- borderTop?: TableCellBorder | null;
136
- borderBottom?: TableCellBorder | null;
137
- borderLeft?: TableCellBorder | null;
138
- borderRight?: TableCellBorder | null;
353
+ borderTop?: Border;
354
+ borderBottom?: Border;
355
+ borderLeft?: Border;
356
+ borderRight?: Border;
139
357
  };
140
358
  content?: Array<ParagraphNode>;
141
359
  }
@@ -147,10 +365,10 @@ interface TableHeaderNode extends JSONContent {
147
365
  colwidth?: number[] | null;
148
366
  backgroundColor?: string | null;
149
367
  verticalAlign?: "top" | "middle" | "bottom" | null;
150
- borderTop?: TableCellBorder | null;
151
- borderBottom?: TableCellBorder | null;
152
- borderLeft?: TableCellBorder | null;
153
- borderRight?: TableCellBorder | null;
368
+ borderTop?: Border;
369
+ borderBottom?: Border;
370
+ borderLeft?: Border;
371
+ borderRight?: Border;
154
372
  };
155
373
  content?: Array<ParagraphNode>;
156
374
  }
@@ -182,4 +400,4 @@ interface DetailsContentNode extends JSONContent {
182
400
  type TextContent = TextNode | HardBreakNode;
183
401
  type BlockNode = ParagraphNode | HeadingNode | BlockquoteNode | CodeBlockNode | HorizontalRuleNode | BulletListNode | OrderedListNode | TaskListNode | TableNode | ImageNode | DetailsNode;
184
402
  //#endregion
185
- export { BlockNode, BlockquoteNode, BulletListNode, CodeBlockNode, DetailsContentNode, DetailsNode, DetailsSummaryNode, DocumentNode, HardBreakNode, HeadingNode, HorizontalRuleNode, ImageFloatingOptions, ImageNode, ImageOutlineOptions, type JSONContent, ListItemNode, Mark, OrderedListNode, ParagraphNode, TableCellBorder, TableCellNode, TableHeaderNode, TableNode, TableRowNode, TaskItemNode, TaskListNode, TextContent, TextNode };
403
+ export { BlockNode, BlockquoteNode, Border, BulletListNode, CodeBlockNode, DetailsContentNode, DetailsNode, DetailsSummaryNode, DocumentNode, HardBreakNode, HeadingNode, HorizontalRuleNode, ImageFloatingOptions, ImageNode, ImageOutlineOptions, type JSONContent, ListItemNode, Mark, OrderedListNode, ParagraphNode, Shading, TableCellNode, TableHeaderNode, TableNode, TableRowNode, TaskItemNode, TaskListNode, TextContent, TextNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docen/extensions",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Collection of TipTap extensions with TypeScript type definitions for Docen",
5
5
  "keywords": [
6
6
  "docen",
@@ -47,37 +47,42 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@tiptap/core": "3.20.1",
51
- "@tiptap/extension-blockquote": "3.20.1",
52
- "@tiptap/extension-bold": "3.20.1",
53
- "@tiptap/extension-bullet-list": "3.20.1",
54
- "@tiptap/extension-code": "3.20.1",
55
- "@tiptap/extension-code-block-lowlight": "3.20.1",
56
- "@tiptap/extension-details": "3.20.1",
57
- "@tiptap/extension-document": "3.20.1",
58
- "@tiptap/extension-emoji": "3.20.1",
59
- "@tiptap/extension-hard-break": "3.20.1",
60
- "@tiptap/extension-heading": "3.20.1",
61
- "@tiptap/extension-highlight": "3.20.1",
62
- "@tiptap/extension-horizontal-rule": "3.20.1",
63
- "@tiptap/extension-image": "3.20.1",
64
- "@tiptap/extension-italic": "3.20.1",
65
- "@tiptap/extension-link": "3.20.1",
66
- "@tiptap/extension-list-item": "3.20.1",
67
- "@tiptap/extension-mathematics": "3.20.1",
68
- "@tiptap/extension-mention": "3.20.1",
69
- "@tiptap/extension-ordered-list": "3.20.1",
70
- "@tiptap/extension-paragraph": "3.20.1",
71
- "@tiptap/extension-strike": "3.20.1",
72
- "@tiptap/extension-subscript": "3.20.1",
73
- "@tiptap/extension-superscript": "3.20.1",
74
- "@tiptap/extension-table": "3.20.1",
75
- "@tiptap/extension-task-item": "3.20.1",
76
- "@tiptap/extension-task-list": "3.20.1",
77
- "@tiptap/extension-text": "3.20.1",
78
- "@tiptap/extension-text-align": "3.20.1",
79
- "@tiptap/extension-text-style": "3.20.1",
80
- "@tiptap/extension-underline": "3.20.1",
50
+ "@tiptap/core": "3.20.0",
51
+ "@tiptap/extension-blockquote": "3.20.0",
52
+ "@tiptap/extension-bold": "3.20.0",
53
+ "@tiptap/extension-bullet-list": "3.20.0",
54
+ "@tiptap/extension-code": "3.20.0",
55
+ "@tiptap/extension-code-block": "3.20.0",
56
+ "@tiptap/extension-code-block-lowlight": "3.20.0",
57
+ "@tiptap/extension-details": "3.20.0",
58
+ "@tiptap/extension-document": "3.20.0",
59
+ "@tiptap/extension-emoji": "3.20.0",
60
+ "@tiptap/extension-hard-break": "3.20.0",
61
+ "@tiptap/extension-heading": "3.20.0",
62
+ "@tiptap/extension-highlight": "3.20.0",
63
+ "@tiptap/extension-horizontal-rule": "3.20.0",
64
+ "@tiptap/extension-image": "3.20.0",
65
+ "@tiptap/extension-italic": "3.20.0",
66
+ "@tiptap/extension-link": "3.20.0",
67
+ "@tiptap/extension-list": "3.20.0",
68
+ "@tiptap/extension-list-item": "3.20.0",
69
+ "@tiptap/extension-mathematics": "3.20.0",
70
+ "@tiptap/extension-mention": "3.20.0",
71
+ "@tiptap/extension-ordered-list": "3.20.0",
72
+ "@tiptap/extension-paragraph": "3.20.0",
73
+ "@tiptap/extension-strike": "3.20.0",
74
+ "@tiptap/extension-subscript": "3.20.0",
75
+ "@tiptap/extension-superscript": "3.20.0",
76
+ "@tiptap/extension-table": "3.20.0",
77
+ "@tiptap/extension-task-item": "3.20.0",
78
+ "@tiptap/extension-task-list": "3.20.0",
79
+ "@tiptap/extension-text": "3.20.0",
80
+ "@tiptap/extension-text-align": "3.20.0",
81
+ "@tiptap/extension-text-style": "3.20.0",
82
+ "@tiptap/extension-underline": "3.20.0",
83
+ "@tiptap/suggestion": "3.20.0"
84
+ },
85
+ "devDependencies": {
81
86
  "docx": "9.6.1"
82
87
  },
83
88
  "scripts": {