@sobree/core 0.1.47 → 0.1.48

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.
@@ -14,6 +14,17 @@ export interface ParagraphProperties {
14
14
  indent?: ParagraphIndent;
15
15
  borders?: ParagraphBorders;
16
16
  shading?: Shading;
17
+ /**
18
+ * `<w:contextualSpacing/>` (ECMA-376 §17.3.1.9) — omit this
19
+ * paragraph's before/after spacing when the adjacent paragraph uses
20
+ * the SAME paragraph style. Word/LibreOffice collapse the inter-
21
+ * paragraph gap to zero between consecutive same-style paragraphs
22
+ * (the classic case: double-spaced thesis body, or tight bulleted
23
+ * lists). The renderer suppresses the corresponding margin only when
24
+ * the neighbour shares this paragraph's style — see
25
+ * `applyParagraphProps`.
26
+ */
27
+ contextualSpacing?: boolean;
17
28
  /** Keep this paragraph on the same page as the next one. */
18
29
  keepNext?: boolean;
19
30
  /** Don't allow this paragraph to break across pages. */
@@ -33,6 +33,9 @@ export interface ParagraphFormat {
33
33
  spacingAfterTwips?: number;
34
34
  /** Explicit `<w:spacing w:before>` in twips. */
35
35
  spacingBeforeTwips?: number;
36
+ /** `<w:contextualSpacing/>` toggle — omit before/after spacing between
37
+ * same-style neighbours (ECMA-376 §17.3.1.9). */
38
+ contextualSpacing?: boolean;
36
39
  /** Raw numbering reference (`numId`, `ilvl`) if this para is part of a list. */
37
40
  numId?: number;
38
41
  numLevel?: number;
@@ -1,2 +1,3 @@
1
1
  import { NamedStyle, Paragraph } from '../../../doc/types';
2
- export declare function renderParagraph(p: Paragraph, styles: readonly NamedStyle[], rawParts: Record<string, Uint8Array>): HTMLElement;
2
+ import { ContextualNeighbors } from './properties';
3
+ export declare function renderParagraph(p: Paragraph, styles: readonly NamedStyle[], rawParts: Record<string, Uint8Array>, contextualNeighbors?: ContextualNeighbors): HTMLElement;
@@ -1,2 +1,14 @@
1
1
  import { NamedStyle, ParagraphProperties, RunProperties } from '../../../doc/types';
2
- export declare function applyParagraphProps(el: HTMLElement, props: ParagraphProperties, styles?: readonly NamedStyle[]): RunProperties;
2
+ /**
3
+ * Whether each side of a paragraph sits next to a same-style paragraph.
4
+ * Used to resolve `<w:contextualSpacing/>`: the before/after margin is
5
+ * dropped only when the corresponding neighbour shares this paragraph's
6
+ * style. The block walker (`renderBlocks`) owns the sequence and computes
7
+ * these; `applyParagraphProps` combines them with the resolved
8
+ * `contextualSpacing` flag (which may come from the style cascade).
9
+ */
10
+ export interface ContextualNeighbors {
11
+ prevSameStyle: boolean;
12
+ nextSameStyle: boolean;
13
+ }
14
+ export declare function applyParagraphProps(el: HTMLElement, props: ParagraphProperties, styles?: readonly NamedStyle[], contextualNeighbors?: ContextualNeighbors): RunProperties;