@uurtech/jdf 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uurtech/jdf",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Render JDF (JSON Document Format) documents in the browser. Drop-in replacement for embedding PDFs — point at a .jdf file and it appears on the page, fully styled, searchable, with a clickable TOC.",
5
5
  "license": "MIT",
6
6
  "author": "Ugur Kazdal <ugur@uurtech.com>",
@@ -103,6 +103,7 @@ function textTag(h: TextElement["heading"]): keyof HTMLElementTagNameMap {
103
103
  // ── richtext ────────────────────────────────────────────────────────────────
104
104
  function renderRichText(el: RichTextElement, ctx: RenderContext): HTMLElement {
105
105
  const p = document.createElement("p");
106
+ p.style.whiteSpace = "pre-wrap"; // keep "\n" line breaks (folded paragraphs) — same as the reader
106
107
  p.className = "jdfjs-richtext";
107
108
  p.style.margin = "0";
108
109
  applyStyle(p, resolveStyle(el.style, ctx.styles));
@@ -1,3 +1,4 @@
1
+ import { unitToPx } from "@jdf/core";
1
2
  import type { Style, StyleRef } from "@jdf/core";
2
3
 
3
4
  function paddingToCss(p: NonNullable<Style["padding"]>): string {
@@ -16,6 +17,8 @@ export function styleToCss(style: Style): Record<string, string> {
16
17
  if (style.color) css["color"] = style.color;
17
18
  if (style.backgroundColor) css["background-color"] = style.backgroundColor;
18
19
  if (style.textAlign) css["text-align"] = style.textAlign;
20
+ if (style.lineHeight) css["line-height"] = String(style.lineHeight); // unitless, same as the reader
21
+ if (style.textIndent) css["text-indent"] = `${unitToPx(style.textIndent)}px`;
19
22
  if (style.textDecoration) {
20
23
  const td = style.textDecoration === "strikethrough" ? "line-through" : style.textDecoration;
21
24
  css["text-decoration"] = td;