@sobree/core 0.1.45 → 0.1.47
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/dist/doc/styles.d.ts +15 -0
- package/dist/docx/import/runProperties.d.ts +26 -0
- package/dist/docx/import/runs.d.ts +2 -2
- package/dist/docx/shared/xml.d.ts +15 -0
- package/dist/docx/types.d.ts +0 -33
- package/dist/editor/view/docRenderer/inline.d.ts +2 -2
- package/dist/editor/view/docRenderer/properties.d.ts +2 -2
- package/dist/index.js +2179 -2199
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/doc/styles.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { NamedStyle, ParagraphProperties, RunProperties, SobreeDocument } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Merge one run-property layer of the STYLE hierarchy onto the accumulated
|
|
4
|
+
* base. Non-toggle fields override (leaf wins). For toggle fields the layer's
|
|
5
|
+
* value decides:
|
|
6
|
+
* - absent (`undefined`) → keep the inherited value;
|
|
7
|
+
* - `true` (a `<w:b/>` re-declaration) → XOR: toggle the inherited value, so
|
|
8
|
+
* a `caps` style based on another `caps` style CANCELS to off;
|
|
9
|
+
* - `false` (an explicit `<w:b w:val="0"/>`) → RESET to off. An explicit off
|
|
10
|
+
* is a definite "not bold", not a toggle — so a style that turns off the
|
|
11
|
+
* bold it inherited (ACM's `ACMRef` off `Titledocument`) renders upright.
|
|
12
|
+
*
|
|
13
|
+
* NOT used for DIRECT run formatting: there a plain spread applies, so an
|
|
14
|
+
* explicit run-level `false` overrides the resolved style value outright.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mergeRunStyleLayer(base: RunProperties, over: RunProperties): RunProperties;
|
|
2
17
|
/**
|
|
3
18
|
* Style-cascade resolver — walks `styleId` up its `basedOn` chain and
|
|
4
19
|
* merges defaults base-first, leaf-last. The result is what the
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RunProperties } from '../../doc/types';
|
|
2
|
+
/**
|
|
3
|
+
* The single reader for a `<w:rPr>` (run-properties) element.
|
|
4
|
+
*
|
|
5
|
+
* `<w:rPr>` is ONE OOXML concept with two homes: inside a `<w:r>` (direct
|
|
6
|
+
* run formatting) and inside a `<w:style>` (a style's run defaults). It
|
|
7
|
+
* must therefore have ONE reader — parsing it in two places is what let
|
|
8
|
+
* the run and style paths drift (direct runs silently lost double
|
|
9
|
+
* underline and colour="auto"; the tri-state toggle logic was written,
|
|
10
|
+
* and bug-fixed, twice). Both importers call this; the two homes can no
|
|
11
|
+
* longer diverge.
|
|
12
|
+
*
|
|
13
|
+
* The result is the native `RunProperties` shape directly — no
|
|
14
|
+
* intermediate "RunFormat" type, no mapping layer.
|
|
15
|
+
*
|
|
16
|
+
* Toggle properties (b/i/strike/caps) are read TRI-STATE via
|
|
17
|
+
* {@link wToggleOn}: present→true, `w:val="0"`→false, absent→undefined.
|
|
18
|
+
* The `false` is load-bearing at both sites (see `wToggleOn`). Combining
|
|
19
|
+
* toggles across the style hierarchy (XOR / reset) is the resolver's job
|
|
20
|
+
* (doc/styles.ts `mergeRunStyleLayer`), not this reader's — here we only
|
|
21
|
+
* record each element's raw value.
|
|
22
|
+
*
|
|
23
|
+
* Returns `undefined` when the rPr contributes nothing, so callers can
|
|
24
|
+
* treat "no properties" uniformly.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readRunProperties(rPr: Element): RunProperties | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RunProperties } from '../../doc/types';
|
|
2
2
|
/** Frame-of-reference choices the importer carries through; mapped 1:1 to
|
|
3
3
|
* the `DrawingAnchor.relativeFromH` / `relativeFromV` AST values. */
|
|
4
4
|
export interface ImportedAnchor {
|
|
@@ -26,7 +26,7 @@ export interface ImportedDrawing {
|
|
|
26
26
|
*/
|
|
27
27
|
export interface ImportedRun {
|
|
28
28
|
text: string;
|
|
29
|
-
format:
|
|
29
|
+
format: RunProperties;
|
|
30
30
|
/** True if this run was `<w:br/>`; `text` is empty in that case. */
|
|
31
31
|
isHardBreak: boolean;
|
|
32
32
|
/** Type of break for `isHardBreak` runs — line (Shift-Enter), page
|
|
@@ -29,6 +29,21 @@ export declare function wVal(el: Element | null): string | null;
|
|
|
29
29
|
* a page break before every paragraph.
|
|
30
30
|
*/
|
|
31
31
|
export declare function wOnOff(root: Document | Element, localName: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* TRI-STATE read of an OOXML toggle property (`CT_OnOff`: `<w:b>`,
|
|
34
|
+
* `<w:caps>`, …) from an already-resolved element. Unlike {@link wOnOff}
|
|
35
|
+
* this distinguishes "absent" from "explicit-off":
|
|
36
|
+
* - element absent (`null`) → `undefined` (inherit);
|
|
37
|
+
* - present, no `w:val` (bare `<w:b/>`) → `true`;
|
|
38
|
+
* - `w:val` "0" / "false" → `false` (explicit off).
|
|
39
|
+
*
|
|
40
|
+
* The `false` is load-bearing at BOTH `<w:rPr>` sites: a direct run's
|
|
41
|
+
* `<w:caps w:val="0"/>` overrides an inherited toggle, and a style's
|
|
42
|
+
* explicit-off resets it as the cascade combines (`mergeRunStyleLayer`).
|
|
43
|
+
* Toggle XOR-combination across the style hierarchy is the resolver's job
|
|
44
|
+
* (doc/styles.ts), not the reader's — this only records the raw value.
|
|
45
|
+
*/
|
|
46
|
+
export declare function wToggleOn(el: Element | null): boolean | undefined;
|
|
32
47
|
/** Build an XML declaration header + root element. Used by the exporter. */
|
|
33
48
|
export declare function xmlDocument(rootXml: string): string;
|
|
34
49
|
/**
|
package/dist/docx/types.d.ts
CHANGED
|
@@ -16,39 +16,6 @@ export interface DocxExportResult {
|
|
|
16
16
|
bytes: Uint8Array;
|
|
17
17
|
warnings: string[];
|
|
18
18
|
}
|
|
19
|
-
/** A single inline run's formatting flags — what `<w:rPr>` tells us. */
|
|
20
|
-
export interface RunFormat {
|
|
21
|
-
/** `<w:rStyle w:val="…">` — a character style applied to the run. Its
|
|
22
|
-
* rPr (colour, underline, …) is resolved against the style cascade at
|
|
23
|
-
* render time, under any direct run formatting. */
|
|
24
|
-
styleId?: string;
|
|
25
|
-
bold?: boolean;
|
|
26
|
-
italic?: boolean;
|
|
27
|
-
underline?: boolean;
|
|
28
|
-
strike?: boolean;
|
|
29
|
-
/** `<w:caps/>` — render the run with `text-transform: uppercase`. */
|
|
30
|
-
caps?: boolean;
|
|
31
|
-
/** CSS-ready `#rrggbb`. */
|
|
32
|
-
color?: string;
|
|
33
|
-
/** Highlight colour name or CSS-ready `#rrggbb`. */
|
|
34
|
-
highlight?: string;
|
|
35
|
-
/** CSS-ready `font-family` value. */
|
|
36
|
-
fontFamily?: string;
|
|
37
|
-
/** Size in pt. */
|
|
38
|
-
fontSizePt?: number;
|
|
39
|
-
verticalAlign?: "subscript" | "superscript";
|
|
40
|
-
/**
|
|
41
|
-
* `<w:rPrChange>` — a snapshot of the run's properties before the
|
|
42
|
-
* most recent tracked format edit. The inner `<w:rPr>` is parsed
|
|
43
|
-
* into the same `RunFormat` shape (recursion-free: the snapshot
|
|
44
|
-
* itself doesn't carry an `revisionFormat`).
|
|
45
|
-
*/
|
|
46
|
-
revisionFormat?: {
|
|
47
|
-
before: RunFormat;
|
|
48
|
-
author?: string;
|
|
49
|
-
date?: string;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
19
|
/** Paragraph-level formatting — from `<w:pPr>`. */
|
|
53
20
|
export interface ParagraphFormat {
|
|
54
21
|
/** 1..6 if the paragraph carries a `Heading{N}` style; 0 otherwise. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InlineRun, NamedStyle } from '../../../doc/types';
|
|
1
|
+
import { InlineRun, NamedStyle, RunProperties } from '../../../doc/types';
|
|
2
2
|
/**
|
|
3
3
|
* Render a list of InlineRuns into DOM children of `parent`. Empty run
|
|
4
4
|
* lists produce a `<br>` placeholder so contenteditable can place a
|
|
@@ -7,7 +7,7 @@ import { InlineRun, NamedStyle } from '../../../doc/types';
|
|
|
7
7
|
* `rawParts` is threaded through so `DrawingRun` can resolve its
|
|
8
8
|
* `partPath` to an `<img src>` via a blob URL / data URI.
|
|
9
9
|
*/
|
|
10
|
-
export declare function appendInlineRuns(parent: HTMLElement, runs: readonly InlineRun[], rawParts?: Record<string, Uint8Array>, styles?: readonly NamedStyle[]): void;
|
|
10
|
+
export declare function appendInlineRuns(parent: HTMLElement, runs: readonly InlineRun[], rawParts?: Record<string, Uint8Array>, styles?: readonly NamedStyle[], paragraphRunDefaults?: RunProperties): void;
|
|
11
11
|
/** Convert a raw part's bytes (from `doc.rawParts`) into a blob URL
|
|
12
12
|
* the browser can render as `<img src>` / `background-image`. Exported
|
|
13
13
|
* for the section-frame renderer in `block.ts` which paints the
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NamedStyle, ParagraphProperties } from '../../../doc/types';
|
|
2
|
-
export declare function applyParagraphProps(el: HTMLElement, props: ParagraphProperties, styles?: readonly NamedStyle[]):
|
|
1
|
+
import { NamedStyle, ParagraphProperties, RunProperties } from '../../../doc/types';
|
|
2
|
+
export declare function applyParagraphProps(el: HTMLElement, props: ParagraphProperties, styles?: readonly NamedStyle[]): RunProperties;
|