js.documents 1.90.0 → 1.91.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.
@@ -75,7 +75,10 @@ const DOCUMENT_FORMAT_CODECS = {
75
75
  return require_odf_formula_read.readOdfFormulaContent(require_package_codec.decodeDocumentPackage("odf", requireArrayBufferBytes(bytes)));
76
76
  } } },
77
77
  markdown: { content: {
78
- read: (bytes, options) => require_markdown_read.readMarkdownContent(require_markdown_text.decodeMarkdownText(bytes), { signal: options?.signal }),
78
+ read: (bytes, options) => require_markdown_read.readMarkdownContent(require_markdown_text.decodeMarkdownText(bytes), {
79
+ signal: options?.signal,
80
+ images: options?.images
81
+ }),
79
82
  write: (content) => require_markdown_text.encodeMarkdownText(require_markdown_write.buildMarkdownText(content))
80
83
  } },
81
84
  pdf: { layout: {
@@ -1,10 +1,12 @@
1
1
  import { DocumentFormat } from "../convert/port.cjs";
2
2
  import { ContentCodec, LayoutCodec } from "document-schema.js";
3
+ import { MarkdownImageResolver } from "markdown-codec";
3
4
  //#region src/codecs/registry.d.ts
4
5
  declare function isArrayBufferBacked(bytes: Uint8Array): bytes is Uint8Array<ArrayBuffer>;
5
6
  declare function requireArrayBufferBytes(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
6
7
  interface DocumentCodecOptions {
7
8
  readonly signal?: AbortSignal;
9
+ readonly images?: MarkdownImageResolver;
8
10
  }
9
11
  interface DocumentFormatCodecs {
10
12
  readonly content?: ContentCodec<DocumentCodecOptions>;
@@ -1,10 +1,12 @@
1
1
  import { DocumentFormat } from "../convert/port.js";
2
2
  import { ContentCodec, LayoutCodec } from "document-schema.js";
3
+ import { MarkdownImageResolver } from "markdown-codec";
3
4
  //#region src/codecs/registry.d.ts
4
5
  declare function isArrayBufferBacked(bytes: Uint8Array): bytes is Uint8Array<ArrayBuffer>;
5
6
  declare function requireArrayBufferBytes(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
6
7
  interface DocumentCodecOptions {
7
8
  readonly signal?: AbortSignal;
9
+ readonly images?: MarkdownImageResolver;
8
10
  }
9
11
  interface DocumentFormatCodecs {
10
12
  readonly content?: ContentCodec<DocumentCodecOptions>;
@@ -74,7 +74,10 @@ const DOCUMENT_FORMAT_CODECS = {
74
74
  return readOdfFormulaContent(decodeDocumentPackage("odf", requireArrayBufferBytes(bytes)));
75
75
  } } },
76
76
  markdown: { content: {
77
- read: (bytes, options) => readMarkdownContent(decodeMarkdownText(bytes), { signal: options?.signal }),
77
+ read: (bytes, options) => readMarkdownContent(decodeMarkdownText(bytes), {
78
+ signal: options?.signal,
79
+ images: options?.images
80
+ }),
78
81
  write: (content) => encodeMarkdownText(buildMarkdownText(content))
79
82
  } },
80
83
  pdf: { layout: {
@@ -186,10 +186,10 @@ function collectRangeElements(children, tag, repeatAttr, start, end) {
186
186
  function wrapRepeatRange(tableElement, memberTag, repeatAttr, wrapperTag, range, buildEmpty, pkg) {
187
187
  require_edit_ods_address.replaceRun(tableElement.children, require_edit_ods_address.isElementWithTag(memberTag), range.start, repeatAttr, buildEmpty);
188
188
  require_edit_ods_address.replaceRun(tableElement.children, require_edit_ods_address.isElementWithTag(memberTag), range.end, repeatAttr, buildEmpty);
189
+ for (const entry of collectRangeElements(tableElement.children, memberTag, repeatAttr, 0, range.end)) if (memberTag === "table:table-column") require_edit_ods_column_row.ensureColumnElementDefaultWidth(pkg, entry.element);
190
+ else require_edit_ods_column_row.ensureRowElementDefaultHeight(pkg, entry.element);
189
191
  const found = collectRangeElements(tableElement.children, memberTag, repeatAttr, range.start, range.end);
190
192
  if (found.length === 0) return;
191
- for (const entry of found) if (memberTag === "table:table-column") require_edit_ods_column_row.ensureColumnElementDefaultWidth(pkg, entry.element);
192
- else require_edit_ods_column_row.ensureRowElementDefaultHeight(pkg, entry.element);
193
193
  const firstPosition = found[0].position;
194
194
  const elements = found.map((entry) => entry.element);
195
195
  const positions = found.map((entry) => entry.position);
@@ -185,10 +185,10 @@ function collectRangeElements(children, tag, repeatAttr, start, end) {
185
185
  function wrapRepeatRange(tableElement, memberTag, repeatAttr, wrapperTag, range, buildEmpty, pkg) {
186
186
  replaceRun(tableElement.children, isElementWithTag(memberTag), range.start, repeatAttr, buildEmpty);
187
187
  replaceRun(tableElement.children, isElementWithTag(memberTag), range.end, repeatAttr, buildEmpty);
188
+ for (const entry of collectRangeElements(tableElement.children, memberTag, repeatAttr, 0, range.end)) if (memberTag === "table:table-column") ensureColumnElementDefaultWidth(pkg, entry.element);
189
+ else ensureRowElementDefaultHeight(pkg, entry.element);
188
190
  const found = collectRangeElements(tableElement.children, memberTag, repeatAttr, range.start, range.end);
189
191
  if (found.length === 0) return;
190
- for (const entry of found) if (memberTag === "table:table-column") ensureColumnElementDefaultWidth(pkg, entry.element);
191
- else ensureRowElementDefaultHeight(pkg, entry.element);
192
192
  const firstPosition = found[0].position;
193
193
  const elements = found.map((entry) => entry.element);
194
194
  const positions = found.map((entry) => entry.position);
@@ -380,13 +380,13 @@ function wrapRadical(radicand, index, ctx) {
380
380
  const ascentPt = metrics.radicalExtraAscenderPt + ruleThicknessPt + gapPt + radicand.ascentPt;
381
381
  const descentPt = radicand.descentPt;
382
382
  const items = [];
383
- const stretched = ctx.metrics.stretch(8730, "vertical", signHeightPt, ctx.sizePt);
383
+ const stretched = ctx.metrics.stretch(8730, "vertical", signHeightPt - metrics.radicalExtraAscenderPt, ctx.sizePt);
384
384
  let signWidthPt;
385
385
  if (stretched !== void 0) {
386
386
  const placements = stretched.placements.map((placement) => ({
387
387
  glyphId: placement.glyphId,
388
388
  xPt: signOriginXPt,
389
- yPt: stretched.inkAscentPt - placement.offsetPt
389
+ yPt: metrics.radicalExtraAscenderPt + stretched.inkAscentPt - placement.offsetPt
390
390
  }));
391
391
  items.push({
392
392
  kind: "assembled-glyphs",
@@ -379,13 +379,13 @@ function wrapRadical(radicand, index, ctx) {
379
379
  const ascentPt = metrics.radicalExtraAscenderPt + ruleThicknessPt + gapPt + radicand.ascentPt;
380
380
  const descentPt = radicand.descentPt;
381
381
  const items = [];
382
- const stretched = ctx.metrics.stretch(8730, "vertical", signHeightPt, ctx.sizePt);
382
+ const stretched = ctx.metrics.stretch(8730, "vertical", signHeightPt - metrics.radicalExtraAscenderPt, ctx.sizePt);
383
383
  let signWidthPt;
384
384
  if (stretched !== void 0) {
385
385
  const placements = stretched.placements.map((placement) => ({
386
386
  glyphId: placement.glyphId,
387
387
  xPt: signOriginXPt,
388
- yPt: stretched.inkAscentPt - placement.offsetPt
388
+ yPt: metrics.radicalExtraAscenderPt + stretched.inkAscentPt - placement.offsetPt
389
389
  }));
390
390
  items.push({
391
391
  kind: "assembled-glyphs",
@@ -16,10 +16,10 @@ const REBUILD_FORMATS = {
16
16
  function isRebuildFormat(format) {
17
17
  return format in REBUILD_FORMATS;
18
18
  }
19
- function readContentForFormat(format, bytes) {
19
+ function readContentForFormat(format, bytes, options) {
20
20
  const content = require_codecs_registry.DOCUMENT_FORMAT_CODECS[format].content;
21
21
  if (!content) throw new Error(`RebuildFormat '${format}' has no content codec in DOCUMENT_FORMAT_CODECS -- this is an internal invariant violation, not a caller error`);
22
- return content.read(bytes);
22
+ return content.read(bytes, options);
23
23
  }
24
24
  function buildBytesForRebuildFormat(format, content) {
25
25
  const codec = require_codecs_registry.DOCUMENT_FORMAT_CODECS[format].content;
@@ -57,7 +57,10 @@ function setDocumentMetadata(sourceFormat, targetFormat, bytes, overrides, optio
57
57
  };
58
58
  return (0, pdf_codec.writePdf)(patched, { signal: options?.signal });
59
59
  }
60
- const content = readContentForFormat(writePath.format, bytes);
60
+ const content = readContentForFormat(writePath.format, bytes, {
61
+ signal: options?.signal,
62
+ images: options?.images
63
+ });
61
64
  const nextContent = {
62
65
  ...content,
63
66
  metadata: mergeMetadata(content.metadata, overrides)
@@ -1,4 +1,5 @@
1
1
  import { DocumentFormat } from "../convert/port.cjs";
2
+ import { MarkdownImageResolver } from "markdown-codec";
2
3
  //#region src/metadata/write.d.ts
3
4
  interface MetadataOverrides {
4
5
  readonly title?: string;
@@ -8,6 +9,7 @@ interface MetadataOverrides {
8
9
  }
9
10
  interface SetDocumentMetadataOptions {
10
11
  readonly signal?: AbortSignal;
12
+ readonly images?: MarkdownImageResolver;
11
13
  }
12
14
  declare function setDocumentMetadata(sourceFormat: DocumentFormat, targetFormat: DocumentFormat, bytes: Uint8Array<ArrayBuffer>, overrides: MetadataOverrides, options?: SetDocumentMetadataOptions): Uint8Array<ArrayBuffer>;
13
15
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { DocumentFormat } from "../convert/port.js";
2
+ import { MarkdownImageResolver } from "markdown-codec";
2
3
  //#region src/metadata/write.d.ts
3
4
  interface MetadataOverrides {
4
5
  readonly title?: string;
@@ -8,6 +9,7 @@ interface MetadataOverrides {
8
9
  }
9
10
  interface SetDocumentMetadataOptions {
10
11
  readonly signal?: AbortSignal;
12
+ readonly images?: MarkdownImageResolver;
11
13
  }
12
14
  declare function setDocumentMetadata(sourceFormat: DocumentFormat, targetFormat: DocumentFormat, bytes: Uint8Array<ArrayBuffer>, overrides: MetadataOverrides, options?: SetDocumentMetadataOptions): Uint8Array<ArrayBuffer>;
13
15
  //#endregion
@@ -15,10 +15,10 @@ const REBUILD_FORMATS = {
15
15
  function isRebuildFormat(format) {
16
16
  return format in REBUILD_FORMATS;
17
17
  }
18
- function readContentForFormat(format, bytes) {
18
+ function readContentForFormat(format, bytes, options) {
19
19
  const content = DOCUMENT_FORMAT_CODECS[format].content;
20
20
  if (!content) throw new Error(`RebuildFormat '${format}' has no content codec in DOCUMENT_FORMAT_CODECS -- this is an internal invariant violation, not a caller error`);
21
- return content.read(bytes);
21
+ return content.read(bytes, options);
22
22
  }
23
23
  function buildBytesForRebuildFormat(format, content) {
24
24
  const codec = DOCUMENT_FORMAT_CODECS[format].content;
@@ -56,7 +56,10 @@ function setDocumentMetadata(sourceFormat, targetFormat, bytes, overrides, optio
56
56
  };
57
57
  return writePdf(patched, { signal: options?.signal });
58
58
  }
59
- const content = readContentForFormat(writePath.format, bytes);
59
+ const content = readContentForFormat(writePath.format, bytes, {
60
+ signal: options?.signal,
61
+ images: options?.images
62
+ });
60
63
  const nextContent = {
61
64
  ...content,
62
65
  metadata: mergeMetadata(content.metadata, overrides)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "1.90.0",
3
+ "version": "1.91.0",
4
4
  "description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {