@blocknote/xl-docx-exporter 0.41.1 → 0.42.1

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.
@@ -4,7 +4,13 @@ import {
4
4
  createPageBreakBlockSpec,
5
5
  } from "@blocknote/core";
6
6
  import { testDocument } from "@shared/testDocument.js";
7
- import { BlobReader, Entry, TextWriter, ZipReader } from "@zip.js/zip.js";
7
+ import {
8
+ BlobReader,
9
+ Entry,
10
+ FileEntry,
11
+ TextWriter,
12
+ ZipReader,
13
+ } from "@zip.js/zip.js";
8
14
  import { Packer, Paragraph, TextRun } from "docx";
9
15
  import { describe, expect, it } from "vitest";
10
16
  import xmlFormat from "xml-formatter";
@@ -15,8 +21,8 @@ import { partialBlocksToBlocksForTesting } from "@shared/formatConversionTestUti
15
21
 
16
22
  const getZIPEntryContent = (entries: Entry[], fileName: string) => {
17
23
  const entry = entries.find((entry) => {
18
- return entry.filename === fileName;
19
- });
24
+ return entry.filename === fileName && !entry.directory;
25
+ }) as FileEntry | undefined;
20
26
 
21
27
  if (!entry) {
22
28
  return "";
@@ -55,11 +55,15 @@ export const Table = (
55
55
  ? undefined
56
56
  : {
57
57
  type: ShadingType.SOLID,
58
- color:
59
- t.options.colors[
60
- cell.props
61
- .backgroundColor as keyof typeof t.options.colors
62
- ].background.slice(1),
58
+ color: (() => {
59
+ const color =
60
+ t.options.colors[cell.props.backgroundColor]
61
+ ?.background;
62
+ if (!color) {
63
+ return undefined;
64
+ }
65
+ return color.slice(1);
66
+ })(),
63
67
  },
64
68
  children: [
65
69
  new Paragraph({
@@ -88,9 +92,14 @@ export const Table = (
88
92
  color:
89
93
  cell.props.textColor === "default" || !cell.props.textColor
90
94
  ? undefined
91
- : t.options.colors[
92
- cell.props.textColor as keyof typeof t.options.colors
93
- ].text.slice(1),
95
+ : (() => {
96
+ const color =
97
+ t.options.colors[cell.props.textColor]?.text;
98
+ if (!color) {
99
+ return undefined;
100
+ }
101
+ return color.slice(1);
102
+ })(),
94
103
  },
95
104
  }),
96
105
  ],