@uniweb/press 0.4.4 → 0.4.6
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 +4 -2
- package/src/DocumentProvider.jsx +56 -18
- package/src/ThemeContext.js +237 -0
- package/src/adapters/docx.js +276 -11
- package/src/adapters/latex.js +18 -0
- package/src/adapters/typst.js +34 -2
- package/src/compileRegistrations.js +4 -4
- package/src/docx/BrandLogo.jsx +59 -0
- package/src/docx/Math.jsx +22 -0
- package/src/docx/PageChrome.jsx +109 -0
- package/src/docx/Paragraph.jsx +93 -17
- package/src/docx/Table.jsx +156 -21
- package/src/docx/TextRun.jsx +83 -4
- package/src/docx/index.js +14 -1
- package/src/docx/parseStyledString.js +59 -6
- package/src/docx/units.js +21 -0
- package/src/format/index.jsx +171 -0
- package/src/index.js +6 -0
- package/src/ir/attributes.js +145 -0
- package/src/styles/buildStylePack.js +190 -0
- package/src/typst/Math.jsx +23 -0
- package/src/typst/Paragraph.jsx +26 -12
- package/src/typst/Sequence.jsx +15 -0
- package/src/typst/index.js +1 -0
package/src/typst/Paragraph.jsx
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { parseStyledString } from '../docx/parseStyledString.js'
|
|
15
15
|
import TextRun from './TextRun.jsx'
|
|
16
|
+
import Math from './Math.jsx'
|
|
16
17
|
|
|
17
18
|
export default function Paragraph({ as: Tag = 'p', data, children, ...props }) {
|
|
18
19
|
if (data) {
|
|
@@ -20,17 +21,30 @@ export default function Paragraph({ as: Tag = 'p', data, children, ...props }) {
|
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
23
|
<Tag data-type="paragraph" {...props}>
|
|
23
|
-
{parts.map((part, i) =>
|
|
24
|
-
part.type === 'link'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
{parts.map((part, i) => {
|
|
25
|
+
if (part.type === 'link') {
|
|
26
|
+
return (
|
|
27
|
+
<a
|
|
28
|
+
key={i}
|
|
29
|
+
data-type="link"
|
|
30
|
+
data-href={part.href}
|
|
31
|
+
href={part.href}
|
|
32
|
+
>
|
|
33
|
+
<span data-type="text">{part.content}</span>
|
|
34
|
+
</a>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
if (part.type === 'math') {
|
|
38
|
+
return (
|
|
39
|
+
<Math
|
|
40
|
+
key={i}
|
|
41
|
+
latex={part.latex}
|
|
42
|
+
display={part.display}
|
|
43
|
+
id={part.id}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
return (
|
|
34
48
|
<TextRun
|
|
35
49
|
key={i}
|
|
36
50
|
bold={part.bold}
|
|
@@ -41,7 +55,7 @@ export default function Paragraph({ as: Tag = 'p', data, children, ...props }) {
|
|
|
41
55
|
{part.content}
|
|
42
56
|
</TextRun>
|
|
43
57
|
)
|
|
44
|
-
)}
|
|
58
|
+
})}
|
|
45
59
|
</Tag>
|
|
46
60
|
)
|
|
47
61
|
}
|
package/src/typst/Sequence.jsx
CHANGED
|
@@ -33,6 +33,7 @@ import CodeBlock from './CodeBlock.jsx'
|
|
|
33
33
|
import List from './List.jsx'
|
|
34
34
|
import BlockQuote from './BlockQuote.jsx'
|
|
35
35
|
import Image from './Image.jsx'
|
|
36
|
+
import Math from './Math.jsx'
|
|
36
37
|
|
|
37
38
|
function renderElement(element, key) {
|
|
38
39
|
if (!element || typeof element !== 'object') return null
|
|
@@ -92,6 +93,20 @@ function renderElement(element, key) {
|
|
|
92
93
|
/>
|
|
93
94
|
)
|
|
94
95
|
|
|
96
|
+
case 'math':
|
|
97
|
+
// Block (display:true) and inline (display:false) share the
|
|
98
|
+
// builder. Inline math doesn't reach the sequence walker —
|
|
99
|
+
// it's wrapped inside paragraph HTML — but render the same
|
|
100
|
+
// way for safety in case a future caller surfaces it here.
|
|
101
|
+
return (
|
|
102
|
+
<Math
|
|
103
|
+
key={key}
|
|
104
|
+
latex={element.latex || ''}
|
|
105
|
+
display={element.display !== false}
|
|
106
|
+
id={element.id || undefined}
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
|
|
95
110
|
// Skipped: dataBlock (not prose), video (not in print), inset (Phase 3).
|
|
96
111
|
default:
|
|
97
112
|
return null
|
package/src/typst/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export { default as CodeBlock } from './CodeBlock.jsx'
|
|
|
20
20
|
export { default as List, BulletList, NumberedList } from './List.jsx'
|
|
21
21
|
export { default as BlockQuote } from './BlockQuote.jsx'
|
|
22
22
|
export { default as Image } from './Image.jsx'
|
|
23
|
+
export { default as Math } from './Math.jsx'
|
|
23
24
|
export { Table, Tr, Td } from './Table.jsx'
|
|
24
25
|
export { default as Asterism } from './Asterism.jsx'
|
|
25
26
|
export { default as Raw } from './Raw.jsx'
|