remark-docx 0.0.6 → 0.0.7

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
@@ -64,7 +64,7 @@ const text = "# hello world";
64
64
 
65
65
  | Key | Default | Type | Description |
66
66
  | -------------- | --------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
67
- | output | "buffer" | `"buffer"` `"blob"` `"raw"` | Set output type of `VFile.result`. `buffer` is `Promise<ArrayBuffer>`. `blob` is `Promise<Blob>`. `raw` is internal data for testing. |
67
+ | output | "buffer" | `"buffer"` `"blob"` | Set output type of `VFile.result`. `buffer` is `Promise<Buffer>`. `blob` is `Promise<Blob>`.for testing. |
68
68
  | imageResolver | undefined | ImageResolver? | **You must set** if your markdown includes images. See example for [browser](https://github.com/inokawa/remark-docx/blob/main/stories/playground.stories.tsx) and [Node.js](https://github.com/inokawa/remark-docx/blob/main/src/index.spec.ts). |
69
69
  | title | undefined | string? | |
70
70
  | subject | undefined | string? | |
package/lib/index.js CHANGED
@@ -157,8 +157,10 @@ var error = function (message) {
157
157
  };
158
158
  function mdastToDocx(node, _a, images) {
159
159
  var output = _a.output, title = _a.title, subject = _a.subject, creator = _a.creator, keywords = _a.keywords, description = _a.description, lastModifiedBy = _a.lastModifiedBy, revision = _a.revision, styles = _a.styles, background = _a.background;
160
- var ctx = { deco: {}, images: images };
161
- var nodes = convertNodes(node.children, ctx);
160
+ var nodes = convertNodes(node.children, {
161
+ deco: {},
162
+ images: images,
163
+ });
162
164
  var doc = new docx__namespace.Document({
163
165
  title: title,
164
166
  subject: subject,
@@ -184,8 +186,6 @@ function mdastToDocx(node, _a, images) {
184
186
  return docx.Packer.toBuffer(doc);
185
187
  case "blob":
186
188
  return docx.Packer.toBlob(doc);
187
- case "raw":
188
- return doc;
189
189
  }
190
190
  }
191
191
  function convertNodes(nodes, ctx) {
package/lib/index.mjs CHANGED
@@ -136,8 +136,10 @@ var error = function (message) {
136
136
  };
137
137
  function mdastToDocx(node, _a, images) {
138
138
  var output = _a.output, title = _a.title, subject = _a.subject, creator = _a.creator, keywords = _a.keywords, description = _a.description, lastModifiedBy = _a.lastModifiedBy, revision = _a.revision, styles = _a.styles, background = _a.background;
139
- var ctx = { deco: {}, images: images };
140
- var nodes = convertNodes(node.children, ctx);
139
+ var nodes = convertNodes(node.children, {
140
+ deco: {},
141
+ images: images,
142
+ });
141
143
  var doc = new docx.Document({
142
144
  title: title,
143
145
  subject: subject,
@@ -163,8 +165,6 @@ function mdastToDocx(node, _a, images) {
163
165
  return Packer.toBuffer(doc);
164
166
  case "blob":
165
167
  return Packer.toBlob(doc);
166
- case "raw":
167
- return doc;
168
168
  }
169
169
  }
170
170
  function convertNodes(nodes, ctx) {
@@ -11,7 +11,7 @@ export declare type ImageData = {
11
11
  };
12
12
  export declare type ImageResolver = (url: string) => Promise<ImageData> | ImageData;
13
13
  export declare type Opts = {
14
- output?: "buffer" | "blob" | "raw";
14
+ output?: "buffer" | "blob";
15
15
  imageResolver?: ImageResolver;
16
16
  } & Pick<IPropertiesOptions, "title" | "subject" | "creator" | "keywords" | "description" | "lastModifiedBy" | "revision" | "styles" | "background">;
17
- export declare function mdastToDocx(node: mdast.Root, { output, title, subject, creator, keywords, description, lastModifiedBy, revision, styles, background, }: Opts, images: ImageDataMap): Promise<any> | docx.File;
17
+ export declare function mdastToDocx(node: mdast.Root, { output, title, subject, creator, keywords, description, lastModifiedBy, revision, styles, background, }: Opts, images: ImageDataMap): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remark-docx",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "remark plugin to compile markdown to docx.",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
@@ -29,9 +29,11 @@
29
29
  "@storybook/addon-essentials": "6.4.9",
30
30
  "@storybook/addon-links": "6.4.9",
31
31
  "@storybook/react": "6.4.9",
32
+ "@types/adm-zip": "^0.4.34",
32
33
  "@types/jest": "^27.4.0",
33
34
  "@types/mdast": "^3.0.10",
34
35
  "@types/unist": "2.0.6",
36
+ "adm-zip": "^0.5.9",
35
37
  "babel-jest": "27.4.6",
36
38
  "file-saver": "^2.0.5",
37
39
  "jest": "27.4.7",