@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.
@@ -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
- <a
26
- key={i}
27
- data-type="link"
28
- data-href={part.href}
29
- href={part.href}
30
- >
31
- <span data-type="text">{part.content}</span>
32
- </a>
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
  }
@@ -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
@@ -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'