@json-to-office/core-docx 0.7.0 → 0.8.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.
- package/dist/components/columns.d.ts.map +1 -1
- package/dist/components/heading.d.ts.map +1 -1
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/list.d.ts.map +1 -1
- package/dist/components/paragraph.d.ts.map +1 -1
- package/dist/components/statistic.d.ts +1 -1
- package/dist/components/statistic.d.ts.map +1 -1
- package/dist/core/structure.d.ts.map +1 -1
- package/dist/index.js +211 -145
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +211 -145
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/styles/utils/componentDefaults.d.ts +1 -6
- package/dist/styles/utils/componentDefaults.d.ts.map +1 -1
- package/dist/styles/utils/resolveComponentTree.d.ts +19 -0
- package/dist/styles/utils/resolveComponentTree.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../src/components/columns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EAON,MAAM,MAAM,CAAC;AACd,OAAO,EACL,mBAAmB,EACnB,aAAa,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../src/components/columns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EAON,MAAM,MAAM,CAAC;AACd,OAAO,EACL,mBAAmB,EACnB,aAAa,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CA0BhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/components/heading.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAsB,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/components/heading.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAsB,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,GAChB,SAAS,EAAE,CAuCb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAoB,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAoB,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CA2BtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/components/list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/components/list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAA8B,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAkJxC;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,GAChB,SAAS,EAAE,CA4Cb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../src/components/paragraph.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../src/components/paragraph.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AA6DxC;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,GAChB,SAAS,EAAE,CAiIb"}
|
|
@@ -8,5 +8,5 @@ import { ThemeConfig } from '../styles';
|
|
|
8
8
|
/**
|
|
9
9
|
* Render statistic component
|
|
10
10
|
*/
|
|
11
|
-
export declare function renderStatisticComponent(component: ComponentDefinition,
|
|
11
|
+
export declare function renderStatisticComponent(component: ComponentDefinition, _theme: ThemeConfig): Paragraph[];
|
|
12
12
|
//# sourceMappingURL=statistic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistic.d.ts","sourceRoot":"","sources":["../../src/components/statistic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"statistic.d.ts","sourceRoot":"","sources":["../../src/components/statistic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,mBAAmB,EAC9B,MAAM,EAAE,WAAW,GAClB,SAAS,EAAE,CAkBb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/core/structure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,yBAAyB,EACzB,aAAa,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/core/structure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,yBAAyB,EACzB,aAAa,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,MAAM,CAAC,EAAE,mBAAmB,EAAE,GAAG,gBAAgB,CAAC;IAClD,MAAM,CAAC,EAAE,mBAAmB,EAAE,GAAG,gBAAgB,CAAC;IAClD,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,GAAG;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC5E,OAAO,CAAC,EAAE;YACR,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,MAAM,CAAC,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,yBAAyB,EACnC,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,iBAAiB,CAAC,CA6C5B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAQ3E;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAoE7B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAmDhC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,GAChB,aAAa,CA0Bf"}
|
package/dist/index.js
CHANGED
|
@@ -1953,24 +1953,175 @@ var formatDate = (date, formatString = "MMMM d, yyyy") => {
|
|
|
1953
1953
|
return format(date, formatString);
|
|
1954
1954
|
};
|
|
1955
1955
|
|
|
1956
|
+
// src/styles/utils/componentDefaults.ts
|
|
1957
|
+
import { mergeWithDefaults } from "@json-to-office/shared";
|
|
1958
|
+
import { mergeWithDefaults as mergeWithDefaults2 } from "@json-to-office/shared";
|
|
1959
|
+
function getComponentDefaults(theme) {
|
|
1960
|
+
return theme.componentDefaults || {};
|
|
1961
|
+
}
|
|
1962
|
+
function getHeadingDefaults(theme) {
|
|
1963
|
+
const defaults = getComponentDefaults(theme);
|
|
1964
|
+
return defaults?.heading || {};
|
|
1965
|
+
}
|
|
1966
|
+
function getHeadingDefaultsForLevel(theme, level) {
|
|
1967
|
+
const defaults = {};
|
|
1968
|
+
if (theme.styles) {
|
|
1969
|
+
const styleKey = `heading${level}`;
|
|
1970
|
+
const headingStyle = theme.styles[styleKey];
|
|
1971
|
+
if (headingStyle?.alignment) {
|
|
1972
|
+
defaults.alignment = headingStyle.alignment;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
return defaults;
|
|
1976
|
+
}
|
|
1977
|
+
function getTextDefaults(theme) {
|
|
1978
|
+
const defaults = getComponentDefaults(theme);
|
|
1979
|
+
return defaults?.paragraph || {};
|
|
1980
|
+
}
|
|
1981
|
+
function getImageDefaults(theme) {
|
|
1982
|
+
const defaults = getComponentDefaults(theme);
|
|
1983
|
+
return defaults?.image || {};
|
|
1984
|
+
}
|
|
1985
|
+
function getStatisticDefaults(theme) {
|
|
1986
|
+
const defaults = getComponentDefaults(theme);
|
|
1987
|
+
return defaults?.statistic || {};
|
|
1988
|
+
}
|
|
1989
|
+
function getTableDefaults(theme) {
|
|
1990
|
+
const defaults = getComponentDefaults(theme);
|
|
1991
|
+
return defaults?.table || {};
|
|
1992
|
+
}
|
|
1993
|
+
function getSectionDefaults(theme) {
|
|
1994
|
+
const defaults = getComponentDefaults(theme);
|
|
1995
|
+
return defaults?.section || {};
|
|
1996
|
+
}
|
|
1997
|
+
function getColumnsDefaults(theme) {
|
|
1998
|
+
const defaults = getComponentDefaults(theme);
|
|
1999
|
+
return defaults?.columns || {};
|
|
2000
|
+
}
|
|
2001
|
+
function getListDefaults(theme) {
|
|
2002
|
+
const defaults = getComponentDefaults(theme);
|
|
2003
|
+
return defaults?.list || {};
|
|
2004
|
+
}
|
|
2005
|
+
function resolveHeadingProps(props, theme) {
|
|
2006
|
+
const defaults = getHeadingDefaults(theme);
|
|
2007
|
+
return mergeWithDefaults(props, defaults);
|
|
2008
|
+
}
|
|
2009
|
+
function resolveParagraphProps(props, theme) {
|
|
2010
|
+
const defaults = getTextDefaults(theme);
|
|
2011
|
+
return mergeWithDefaults(props, defaults);
|
|
2012
|
+
}
|
|
2013
|
+
function resolveImageProps(props, theme) {
|
|
2014
|
+
const defaults = getImageDefaults(theme);
|
|
2015
|
+
return mergeWithDefaults(props, defaults);
|
|
2016
|
+
}
|
|
2017
|
+
function resolveStatisticProps(props, theme) {
|
|
2018
|
+
const defaults = getStatisticDefaults(theme);
|
|
2019
|
+
return mergeWithDefaults(props, defaults);
|
|
2020
|
+
}
|
|
2021
|
+
function resolveTableProps(props, theme) {
|
|
2022
|
+
const defaults = getTableDefaults(theme);
|
|
2023
|
+
return mergeWithDefaults(props, defaults);
|
|
2024
|
+
}
|
|
2025
|
+
function resolveSectionProps(props, theme) {
|
|
2026
|
+
const defaults = getSectionDefaults(theme);
|
|
2027
|
+
return mergeWithDefaults(props, defaults);
|
|
2028
|
+
}
|
|
2029
|
+
function resolveColumnsProps(props, theme) {
|
|
2030
|
+
const defaults = getColumnsDefaults(theme);
|
|
2031
|
+
return mergeWithDefaults(props, defaults);
|
|
2032
|
+
}
|
|
2033
|
+
function resolveListProps(props, theme) {
|
|
2034
|
+
const defaults = getListDefaults(theme);
|
|
2035
|
+
return mergeWithDefaults(props, defaults);
|
|
2036
|
+
}
|
|
2037
|
+
function resolveHighchartsProps(props, _theme) {
|
|
2038
|
+
return props;
|
|
2039
|
+
}
|
|
2040
|
+
function getCustomComponentDefaults(theme, componentName) {
|
|
2041
|
+
const defaults = getComponentDefaults(theme);
|
|
2042
|
+
return defaults?.[componentName] || {};
|
|
2043
|
+
}
|
|
2044
|
+
function resolveCustomComponentProps(props, theme, componentName) {
|
|
2045
|
+
const defaults = getCustomComponentDefaults(theme, componentName);
|
|
2046
|
+
return mergeWithDefaults(props, defaults);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
// src/styles/utils/resolveComponentTree.ts
|
|
2050
|
+
function resolveHeadingWithLevelDefaults(props, theme) {
|
|
2051
|
+
const resolved = resolveHeadingProps(props, theme);
|
|
2052
|
+
const level = resolved.level || 1;
|
|
2053
|
+
const levelDefaults = getHeadingDefaultsForLevel(theme, level);
|
|
2054
|
+
return {
|
|
2055
|
+
...resolved,
|
|
2056
|
+
// Only apply level-specific defaults if no explicit alignment in original props
|
|
2057
|
+
...props.alignment ? {} : levelDefaults
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
var RESOLVER_MAP = {
|
|
2061
|
+
heading: resolveHeadingWithLevelDefaults,
|
|
2062
|
+
paragraph: resolveParagraphProps,
|
|
2063
|
+
image: resolveImageProps,
|
|
2064
|
+
statistic: resolveStatisticProps,
|
|
2065
|
+
table: resolveTableProps,
|
|
2066
|
+
section: resolveSectionProps,
|
|
2067
|
+
columns: resolveColumnsProps,
|
|
2068
|
+
list: resolveListProps,
|
|
2069
|
+
highcharts: resolveHighchartsProps
|
|
2070
|
+
};
|
|
2071
|
+
function resolveComponentDefaults(component, theme) {
|
|
2072
|
+
if (!component.props) return component;
|
|
2073
|
+
const resolver = RESOLVER_MAP[component.name];
|
|
2074
|
+
const resolvedProps = resolver ? resolver(component.props, theme) : resolveCustomComponentProps(
|
|
2075
|
+
component.props,
|
|
2076
|
+
theme,
|
|
2077
|
+
component.name
|
|
2078
|
+
);
|
|
2079
|
+
return { ...component, props: resolvedProps };
|
|
2080
|
+
}
|
|
2081
|
+
function resolveComponentTree(components, theme) {
|
|
2082
|
+
return components.map((component) => {
|
|
2083
|
+
const resolved = resolveComponentDefaults(component, theme);
|
|
2084
|
+
const children = resolved.children;
|
|
2085
|
+
if (children && children.length > 0) {
|
|
2086
|
+
return {
|
|
2087
|
+
...resolved,
|
|
2088
|
+
children: resolveComponentTree(children, theme)
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
return resolved;
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
|
|
1956
2095
|
// src/core/structure.ts
|
|
1957
2096
|
async function processDocument(document, theme, themeName) {
|
|
1958
2097
|
const metadata = createDocumentMetadata(document.props);
|
|
2098
|
+
const docDefaults = document.props.componentDefaults;
|
|
2099
|
+
const effectiveTheme = docDefaults ? {
|
|
2100
|
+
...theme,
|
|
2101
|
+
componentDefaults: mergeWithDefaults2(
|
|
2102
|
+
docDefaults,
|
|
2103
|
+
theme.componentDefaults || {}
|
|
2104
|
+
)
|
|
2105
|
+
} : theme;
|
|
1959
2106
|
const context = createRenderContext(
|
|
1960
2107
|
{
|
|
1961
2108
|
metadata,
|
|
1962
2109
|
sections: [],
|
|
1963
|
-
theme,
|
|
2110
|
+
theme: effectiveTheme,
|
|
1964
2111
|
themeName
|
|
1965
2112
|
},
|
|
1966
|
-
|
|
2113
|
+
effectiveTheme,
|
|
1967
2114
|
themeName
|
|
1968
2115
|
);
|
|
1969
|
-
const
|
|
2116
|
+
const resolvedChildren = resolveComponentTree(
|
|
2117
|
+
document.children || [],
|
|
2118
|
+
effectiveTheme
|
|
2119
|
+
);
|
|
2120
|
+
const sections = await extractSections(resolvedChildren, context);
|
|
1970
2121
|
return {
|
|
1971
2122
|
metadata,
|
|
1972
2123
|
sections,
|
|
1973
|
-
theme,
|
|
2124
|
+
theme: effectiveTheme,
|
|
1974
2125
|
themeName
|
|
1975
2126
|
};
|
|
1976
2127
|
}
|
|
@@ -2000,19 +2151,24 @@ async function extractSections(components, context) {
|
|
|
2000
2151
|
Math.max(component.props.level || 1, 1),
|
|
2001
2152
|
6
|
|
2002
2153
|
);
|
|
2003
|
-
sectionComponents.unshift(
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2154
|
+
sectionComponents.unshift(
|
|
2155
|
+
resolveComponentDefaults(
|
|
2156
|
+
{
|
|
2157
|
+
name: "heading",
|
|
2158
|
+
props: {
|
|
2159
|
+
text: component.props.title,
|
|
2160
|
+
level: headingLevel,
|
|
2161
|
+
pageBreak: shouldPageBreak,
|
|
2162
|
+
// Apply zero-spacing to prevent unwanted initial line
|
|
2163
|
+
spacing: {
|
|
2164
|
+
before: 0,
|
|
2165
|
+
after: 0
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
},
|
|
2169
|
+
context.fullTheme
|
|
2170
|
+
)
|
|
2171
|
+
);
|
|
2016
2172
|
}
|
|
2017
2173
|
sections.push({
|
|
2018
2174
|
title: component.props?.title,
|
|
@@ -2052,18 +2208,23 @@ async function flattenComponents(components, context) {
|
|
|
2052
2208
|
Math.max(component.props.level || 1, 1),
|
|
2053
2209
|
6
|
|
2054
2210
|
);
|
|
2055
|
-
flattened.push(
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2211
|
+
flattened.push(
|
|
2212
|
+
resolveComponentDefaults(
|
|
2213
|
+
{
|
|
2214
|
+
name: "heading",
|
|
2215
|
+
props: {
|
|
2216
|
+
text: component.props.title,
|
|
2217
|
+
level: headingLevel,
|
|
2218
|
+
// Apply zero-spacing to prevent unwanted initial line
|
|
2219
|
+
spacing: {
|
|
2220
|
+
before: 0,
|
|
2221
|
+
after: 0
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
},
|
|
2225
|
+
context.fullTheme
|
|
2226
|
+
)
|
|
2227
|
+
);
|
|
2067
2228
|
}
|
|
2068
2229
|
flattened.push(...await flattenComponents(component.children, context));
|
|
2069
2230
|
} else {
|
|
@@ -3853,93 +4014,6 @@ function getComponentCacheStats() {
|
|
|
3853
4014
|
return componentCache.getStats();
|
|
3854
4015
|
}
|
|
3855
4016
|
|
|
3856
|
-
// src/styles/utils/componentDefaults.ts
|
|
3857
|
-
function getComponentDefaults(theme) {
|
|
3858
|
-
return theme.componentDefaults || {};
|
|
3859
|
-
}
|
|
3860
|
-
function getHeadingDefaults(theme) {
|
|
3861
|
-
const defaults = getComponentDefaults(theme);
|
|
3862
|
-
return defaults?.heading || {};
|
|
3863
|
-
}
|
|
3864
|
-
function getHeadingDefaultsForLevel(theme, level) {
|
|
3865
|
-
const defaults = {};
|
|
3866
|
-
if (theme.styles) {
|
|
3867
|
-
const styleKey = `heading${level}`;
|
|
3868
|
-
const headingStyle = theme.styles[styleKey];
|
|
3869
|
-
if (headingStyle?.alignment) {
|
|
3870
|
-
defaults.alignment = headingStyle.alignment;
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
return defaults;
|
|
3874
|
-
}
|
|
3875
|
-
function getTextDefaults(theme) {
|
|
3876
|
-
const defaults = getComponentDefaults(theme);
|
|
3877
|
-
return defaults?.paragraph || {};
|
|
3878
|
-
}
|
|
3879
|
-
function getImageDefaults(theme) {
|
|
3880
|
-
const defaults = getComponentDefaults(theme);
|
|
3881
|
-
return defaults?.image || {};
|
|
3882
|
-
}
|
|
3883
|
-
function getStatisticDefaults(theme) {
|
|
3884
|
-
const defaults = getComponentDefaults(theme);
|
|
3885
|
-
return defaults?.statistic || {};
|
|
3886
|
-
}
|
|
3887
|
-
function getColumnsDefaults(theme) {
|
|
3888
|
-
const defaults = getComponentDefaults(theme);
|
|
3889
|
-
return defaults?.columns || {};
|
|
3890
|
-
}
|
|
3891
|
-
function getListDefaults(theme) {
|
|
3892
|
-
const defaults = getComponentDefaults(theme);
|
|
3893
|
-
return defaults?.list || {};
|
|
3894
|
-
}
|
|
3895
|
-
function deepMerge(target, source) {
|
|
3896
|
-
const output = { ...target };
|
|
3897
|
-
if (isObject(target) && isObject(source)) {
|
|
3898
|
-
Object.keys(source).forEach((key) => {
|
|
3899
|
-
if (isObject(source[key])) {
|
|
3900
|
-
if (!(key in target)) {
|
|
3901
|
-
output[key] = source[key];
|
|
3902
|
-
} else {
|
|
3903
|
-
output[key] = deepMerge(target[key], source[key]);
|
|
3904
|
-
}
|
|
3905
|
-
} else {
|
|
3906
|
-
output[key] = source[key];
|
|
3907
|
-
}
|
|
3908
|
-
});
|
|
3909
|
-
}
|
|
3910
|
-
return output;
|
|
3911
|
-
}
|
|
3912
|
-
function isObject(item) {
|
|
3913
|
-
return item !== null && typeof item === "object" && !Array.isArray(item);
|
|
3914
|
-
}
|
|
3915
|
-
function mergeWithDefaults(userConfig, themeDefaults) {
|
|
3916
|
-
return deepMerge(themeDefaults, userConfig);
|
|
3917
|
-
}
|
|
3918
|
-
function resolveHeadingProps(props, theme) {
|
|
3919
|
-
const defaults = getHeadingDefaults(theme);
|
|
3920
|
-
return mergeWithDefaults(props, defaults);
|
|
3921
|
-
}
|
|
3922
|
-
function resolveParagraphProps(props, theme) {
|
|
3923
|
-
const defaults = getTextDefaults(theme);
|
|
3924
|
-
return mergeWithDefaults(props, defaults);
|
|
3925
|
-
}
|
|
3926
|
-
function resolveImageProps(props, theme) {
|
|
3927
|
-
const defaults = getImageDefaults(theme);
|
|
3928
|
-
return mergeWithDefaults(props, defaults);
|
|
3929
|
-
}
|
|
3930
|
-
function resolveStatisticProps(props, theme) {
|
|
3931
|
-
const defaults = getStatisticDefaults(theme);
|
|
3932
|
-
return mergeWithDefaults(props, defaults);
|
|
3933
|
-
}
|
|
3934
|
-
function resolveColumnsProps(props, theme) {
|
|
3935
|
-
const defaults = getColumnsDefaults(theme);
|
|
3936
|
-
return mergeWithDefaults(props, defaults);
|
|
3937
|
-
}
|
|
3938
|
-
function resolveListProps(props, theme) {
|
|
3939
|
-
const defaults = getListDefaults(theme);
|
|
3940
|
-
return mergeWithDefaults(props, defaults);
|
|
3941
|
-
}
|
|
3942
|
-
|
|
3943
4017
|
// src/core/content.ts
|
|
3944
4018
|
import {
|
|
3945
4019
|
Paragraph,
|
|
@@ -5153,35 +5227,28 @@ function createFooterElement(children, _options) {
|
|
|
5153
5227
|
// src/components/heading.ts
|
|
5154
5228
|
function renderHeadingComponent(component, theme, themeName) {
|
|
5155
5229
|
if (!isHeadingComponent(component)) return [];
|
|
5156
|
-
const
|
|
5157
|
-
const
|
|
5158
|
-
const levelDefaults = getHeadingDefaultsForLevel(theme, level);
|
|
5159
|
-
const finalConfig = {
|
|
5160
|
-
...resolvedConfig,
|
|
5161
|
-
// Only apply level defaults if no explicit alignment was provided in the original props
|
|
5162
|
-
...component.props.alignment ? {} : levelDefaults
|
|
5163
|
-
};
|
|
5164
|
-
const bookmarkId = component.id || globalBookmarkRegistry.generateId(finalConfig.text, "heading");
|
|
5230
|
+
const config = component.props;
|
|
5231
|
+
const bookmarkId = component.id || globalBookmarkRegistry.generateId(config.text, "heading");
|
|
5165
5232
|
const header = createHeading(
|
|
5166
|
-
|
|
5167
|
-
|
|
5233
|
+
config.text,
|
|
5234
|
+
config.level || 1,
|
|
5168
5235
|
theme,
|
|
5169
5236
|
themeName,
|
|
5170
5237
|
{
|
|
5171
|
-
alignment:
|
|
5172
|
-
spacing:
|
|
5173
|
-
lineSpacing:
|
|
5174
|
-
columnBreak:
|
|
5238
|
+
alignment: config.alignment,
|
|
5239
|
+
spacing: config.spacing,
|
|
5240
|
+
lineSpacing: config.lineSpacing,
|
|
5241
|
+
columnBreak: config.columnBreak,
|
|
5175
5242
|
// Local font overrides
|
|
5176
|
-
fontFamily:
|
|
5177
|
-
fontSize:
|
|
5178
|
-
fontColor:
|
|
5179
|
-
bold:
|
|
5180
|
-
italic:
|
|
5181
|
-
underline:
|
|
5243
|
+
fontFamily: config.font?.family,
|
|
5244
|
+
fontSize: config.font?.size,
|
|
5245
|
+
fontColor: config.font?.color,
|
|
5246
|
+
bold: config.font?.bold,
|
|
5247
|
+
italic: config.font?.italic,
|
|
5248
|
+
underline: config.font?.underline,
|
|
5182
5249
|
// Pagination control
|
|
5183
|
-
keepNext:
|
|
5184
|
-
keepLines:
|
|
5250
|
+
keepNext: config.keepNext,
|
|
5251
|
+
keepLines: config.keepLines,
|
|
5185
5252
|
// Bookmark ID for internal linking
|
|
5186
5253
|
bookmarkId
|
|
5187
5254
|
}
|
|
@@ -5226,7 +5293,7 @@ function parseMarkdownList(text) {
|
|
|
5226
5293
|
}
|
|
5227
5294
|
function renderParagraphComponent(component, theme, themeName) {
|
|
5228
5295
|
if (!isParagraphComponent(component)) return [];
|
|
5229
|
-
const resolvedConfig =
|
|
5296
|
+
const resolvedConfig = component.props;
|
|
5230
5297
|
const listData = parseMarkdownList(resolvedConfig.text);
|
|
5231
5298
|
if (listData) {
|
|
5232
5299
|
const reference = globalNumberingRegistry.generateReference("markdown-list");
|
|
@@ -5411,7 +5478,7 @@ function fillMissingLevels(levels, maxLevel) {
|
|
|
5411
5478
|
}
|
|
5412
5479
|
function renderListComponent(component, theme, themeName) {
|
|
5413
5480
|
if (!isListComponent(component)) return [];
|
|
5414
|
-
const resolvedConfig =
|
|
5481
|
+
const resolvedConfig = component.props;
|
|
5415
5482
|
const maxLevel = getMaxLevelFromItems(resolvedConfig.items);
|
|
5416
5483
|
const reference = resolvedConfig.reference || globalNumberingRegistry.generateReference("list");
|
|
5417
5484
|
if (!globalNumberingRegistry.has(reference)) {
|
|
@@ -5442,7 +5509,7 @@ function renderListComponent(component, theme, themeName) {
|
|
|
5442
5509
|
// src/components/image.ts
|
|
5443
5510
|
async function renderImageComponent(component, theme, themeName) {
|
|
5444
5511
|
if (!isImageComponent(component)) return [];
|
|
5445
|
-
const resolvedConfig =
|
|
5512
|
+
const resolvedConfig = component.props;
|
|
5446
5513
|
const imageSource = resolvedConfig.base64 || resolvedConfig.path;
|
|
5447
5514
|
if (!imageSource) {
|
|
5448
5515
|
throw new Error(
|
|
@@ -5802,7 +5869,6 @@ async function renderColumnsComponent(component, theme, themeName, context) {
|
|
|
5802
5869
|
if (context.parent && isTextBoxComponent(context.parent)) {
|
|
5803
5870
|
return await renderColumnsAsTable(component, theme, themeName, context);
|
|
5804
5871
|
}
|
|
5805
|
-
resolveColumnsProps(component.props, theme);
|
|
5806
5872
|
const elements = [];
|
|
5807
5873
|
if (component.children) {
|
|
5808
5874
|
for (const child of component.children) {
|
|
@@ -5914,9 +5980,9 @@ async function renderColumnsAsTable(component, theme, themeName, context) {
|
|
|
5914
5980
|
}
|
|
5915
5981
|
|
|
5916
5982
|
// src/components/statistic.ts
|
|
5917
|
-
function renderStatisticComponent(component,
|
|
5983
|
+
function renderStatisticComponent(component, _theme) {
|
|
5918
5984
|
if (!isStatisticComponent(component)) return [];
|
|
5919
|
-
const resolvedConfig =
|
|
5985
|
+
const resolvedConfig = component.props;
|
|
5920
5986
|
return createStatistic(
|
|
5921
5987
|
{
|
|
5922
5988
|
number: resolvedConfig.number,
|