mdast2docx 0.0.0-beta.0 → 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/README.md +203 -170
- package/dist/chunk-3ZZBJC3M.mjs +1 -0
- package/dist/chunk-7LR5HC5O.mjs +4 -0
- package/dist/chunk-7W4N3GRD.mjs +75 -0
- package/dist/chunk-GM6UUFDK.mjs +2 -0
- package/dist/chunk-TASCVLMX.mjs +1 -0
- package/dist/chunk-UXY5TDOP.mjs +1 -0
- package/dist/chunk-XIRSNIMN.mjs +1 -0
- package/dist/chunk-YKZOUIFR.mjs +1 -0
- package/dist/chunk-Z5DPYROV.mjs +31 -0
- package/dist/chunk-ZKNVKZAF.mjs +1 -0
- package/dist/index.d.ts +7 -8
- package/dist/index.js +2 -38
- package/dist/index.mjs +1 -1
- package/dist/multipart-parser-WKN2UV32.mjs +2 -0
- package/dist/plugins/html.d.ts +0 -0
- package/dist/plugins/html.js +1 -0
- package/dist/plugins/image.d.ts +37 -0
- package/dist/plugins/image.js +1 -0
- package/dist/plugins/image.mjs +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +75 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/plugins/list.d.ts +57 -0
- package/dist/plugins/list.js +1 -0
- package/dist/plugins/list.mjs +1 -0
- package/dist/plugins/math.d.ts +11 -0
- package/dist/plugins/math.js +75 -0
- package/dist/plugins/math.mjs +1 -0
- package/dist/plugins/node-image.d.ts +27 -0
- package/dist/plugins/node-image.js +35 -0
- package/dist/plugins/node-image.mjs +1 -0
- package/dist/plugins/node.d.ts +1 -0
- package/dist/plugins/node.js +35 -0
- package/dist/plugins/node.mjs +1 -0
- package/dist/plugins/table.d.ts +26 -0
- package/dist/plugins/table.js +1 -0
- package/dist/plugins/table.mjs +1 -0
- package/dist/section.d.ts +9 -8
- package/dist/section.js +2 -38
- package/dist/section.mjs +1 -1
- package/dist/utils.d.ts +75 -20
- package/dist/utils.js +1 -37
- package/dist/utils.mjs +1 -1
- package/package.json +6 -20
- package/dist/chunk-KRMGJ4HN.mjs +0 -2
- package/dist/chunk-O6BHSWEF.mjs +0 -37
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AlignmentType, type ITableCellOptions, type ITableOptions, type ITableRowOptions, VerticalAlign } from "@mayank1513/docx";
|
|
2
|
+
import { IPlugin, Optional } from "../utils";
|
|
3
|
+
export type RowProps = Omit<ITableRowOptions, "children">;
|
|
4
|
+
export type TableProps = Omit<ITableOptions, "rows">;
|
|
5
|
+
export type CellProps = Omit<ITableCellOptions, "children">;
|
|
6
|
+
export interface ITableAlignments {
|
|
7
|
+
defaultVerticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
|
8
|
+
defaultHorizontalAlign?: (typeof AlignmentType)[keyof typeof AlignmentType];
|
|
9
|
+
/**
|
|
10
|
+
* Use MDAST data for horizontal aligning columns
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
preferMdData?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface IDefaultTablePluginProps {
|
|
16
|
+
tableProps: TableProps;
|
|
17
|
+
rowProps: RowProps;
|
|
18
|
+
cellProps: CellProps;
|
|
19
|
+
firstRowProps: RowProps;
|
|
20
|
+
firstRowCellProps: CellProps;
|
|
21
|
+
alignments: ITableAlignments;
|
|
22
|
+
}
|
|
23
|
+
type ITablePluginProps = Optional<IDefaultTablePluginProps>;
|
|
24
|
+
export declare const defaultTableOptions: IDefaultTablePluginProps;
|
|
25
|
+
export declare const tablePlugin: (options?: ITablePluginProps) => IPlugin;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var H=(t,l)=>{for(var r in l)P(t,r,{get:l[r],enumerable:!0})},M=(t,l,r,n)=>{if(l&&typeof l=="object"||typeof l=="function")for(let o of V(l))!z.call(t,o)&&o!==r&&P(t,o,{get:()=>l[o],enumerable:!(n=D(l,o))||n.enumerable});return t};var N=t=>M(P({},"__esModule",{value:!0}),t);var S={};H(S,{defaultTableOptions:()=>g,tablePlugin:()=>k});module.exports=N(S);var e=require("@mayank1513/docx"),i={style:e.BorderStyle.SINGLE,color:"auto",size:1},g={tableProps:{width:{size:100,type:e.WidthType.PERCENTAGE},margins:{top:(0,e.convertMillimetersToTwip)(2),right:(0,e.convertMillimetersToTwip)(4),bottom:(0,e.convertMillimetersToTwip)(2),left:(0,e.convertMillimetersToTwip)(4)},borders:{top:i,right:i,bottom:i,left:i,insideHorizontal:i,insideVertical:i}},rowProps:{},cellProps:{},firstRowProps:{tableHeader:!0},firstRowCellProps:{shading:{type:e.ShadingType.SOLID,fill:"b79c2f"}},alignments:{defaultVerticalAlign:e.VerticalAlign.CENTER,defaultHorizontalAlign:e.AlignmentType.CENTER,preferMdData:!0}},k=t=>({block:async(l,r,n,o,T)=>{var c;if(r.type!=="table")return[];let{Table:b,TableRow:u,TableCell:m,Paragraph:w}=l,{tableProps:y,firstRowProps:d,firstRowCellProps:R,rowProps:A,cellProps:h,alignments:a}={...g,...t},p=(c=r.align)==null?void 0:c.map(s=>{switch(s){case"left":return l.AlignmentType.LEFT;case"right":return l.AlignmentType.RIGHT;case"center":return l.AlignmentType.CENTER;default:return}}),I=async(s,f)=>new u({...A,...f===0?d:{},children:await Promise.all(s.children.map(async(O,E)=>new m({verticalAlign:a.defaultVerticalAlign,...h,...f===0?R:{},children:[new w({children:await T(O),alignment:a.preferMdData?p==null?void 0:p[E]:a.defaultHorizontalAlign})]})))}),C=await Promise.all(r.children.map(I));return r.type="",[new b({...y,rows:C})]}});0&&(module.exports={defaultTableOptions,tablePlugin});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"../chunk-UXY5TDOP.mjs";import"../chunk-3ZZBJC3M.mjs";export{a as defaultTableOptions,b as tablePlugin};
|
package/dist/section.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Root } from "mdast";
|
|
|
2
2
|
import type { Definitions, FootnoteDefinitions, IMdastToDocxSectionProps } from "./utils";
|
|
3
3
|
import { Paragraph } from "@mayank1513/docx";
|
|
4
4
|
import type { ISectionOptions } from "@mayank1513/docx";
|
|
5
|
+
import * as docx from "@mayank1513/docx";
|
|
5
6
|
/**
|
|
6
7
|
* Defines properties for a document section, omitting the "children" property from ISectionOptions.
|
|
7
8
|
*/
|
|
@@ -15,16 +16,16 @@ export type ISectionProps = Omit<ISectionOptions, "children"> & IMdastToDocxSect
|
|
|
15
16
|
* @returns A DOCX section representation
|
|
16
17
|
*/
|
|
17
18
|
export declare const toSection: (node: Root, definitions: Definitions, footnoteDefinitions: FootnoteDefinitions, props?: ISectionProps) => Promise<{
|
|
18
|
-
children: Paragraph[];
|
|
19
|
+
children: (Paragraph | docx.Table)[];
|
|
19
20
|
headers?: {
|
|
20
|
-
readonly default?:
|
|
21
|
-
readonly first?:
|
|
22
|
-
readonly even?:
|
|
21
|
+
readonly default?: docx.Header;
|
|
22
|
+
readonly first?: docx.Header;
|
|
23
|
+
readonly even?: docx.Header;
|
|
23
24
|
};
|
|
24
25
|
footers?: {
|
|
25
|
-
readonly default?:
|
|
26
|
-
readonly first?:
|
|
27
|
-
readonly even?:
|
|
26
|
+
readonly default?: docx.Footer;
|
|
27
|
+
readonly first?: docx.Footer;
|
|
28
|
+
readonly even?: docx.Footer;
|
|
28
29
|
};
|
|
29
|
-
properties?:
|
|
30
|
+
properties?: docx.ISectionPropertiesOptions;
|
|
30
31
|
}>;
|