@officedk/pptxdk 0.2.0 → 0.2.1

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.
Files changed (296) hide show
  1. package/dist/build.d.ts +5 -8
  2. package/dist/build.js +44 -52
  3. package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
  4. package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
  5. package/dist/core/dist/capabilities/audio/entry.js +122 -0
  6. package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
  7. package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
  8. package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
  9. package/dist/core/dist/capabilities/box/entry.js +2 -0
  10. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
  11. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
  12. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
  13. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
  14. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
  15. package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
  16. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
  17. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
  18. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
  19. package/dist/core/dist/capabilities/chart/entry.js +2 -0
  20. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
  21. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
  22. package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
  23. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
  24. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
  25. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
  26. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
  27. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
  28. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
  29. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
  30. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
  31. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
  32. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
  33. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
  34. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
  35. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
  36. package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
  37. package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
  38. package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
  39. package/dist/core/dist/capabilities/comment/comment.js +141 -0
  40. package/dist/core/dist/capabilities/comment/entry.js +1 -0
  41. package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
  42. package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
  43. package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
  44. package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
  45. package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
  46. package/dist/core/dist/capabilities/group/entry.js +2 -0
  47. package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
  48. package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
  49. package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
  50. package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
  51. package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
  52. package/dist/core/dist/capabilities/image/entry.js +4 -0
  53. package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
  54. package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
  55. package/dist/core/dist/capabilities/image/image-import.js +26 -0
  56. package/dist/core/dist/capabilities/image/image.js +57 -0
  57. package/dist/core/dist/capabilities/line/entry.js +3 -0
  58. package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
  59. package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
  60. package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
  61. package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
  62. package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
  63. package/dist/core/dist/capabilities/masters/entry.js +1 -0
  64. package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
  65. package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
  66. package/dist/core/dist/capabilities/motion/entry.js +5 -0
  67. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
  68. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
  69. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
  70. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
  71. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
  72. package/dist/core/dist/capabilities/notes/entry.js +2 -0
  73. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
  74. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
  75. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
  76. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
  77. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
  78. package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
  79. package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
  80. package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
  81. package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
  82. package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
  83. package/dist/core/dist/capabilities/shape/entry.js +6 -0
  84. package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
  85. package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
  86. package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
  87. package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
  88. package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
  89. package/dist/core/dist/capabilities/shared/date-time.js +98 -0
  90. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
  91. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
  92. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
  93. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
  94. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
  95. package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
  96. package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
  97. package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
  98. package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
  99. package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
  100. package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
  101. package/dist/core/dist/capabilities/shared/line-match.js +78 -0
  102. package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
  103. package/dist/core/dist/capabilities/shared/media-import.js +156 -0
  104. package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
  105. package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
  106. package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
  107. package/dist/core/dist/capabilities/shared/media-source.js +107 -0
  108. package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
  109. package/dist/core/dist/capabilities/shared/media.js +134 -0
  110. package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
  111. package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
  112. package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
  113. package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
  114. package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
  115. package/dist/core/dist/capabilities/shared/picture.js +510 -0
  116. package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
  117. package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
  118. package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
  119. package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
  120. package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
  121. package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
  122. package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
  123. package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
  124. package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
  125. package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
  126. package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
  127. package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
  128. package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
  129. package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
  130. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
  131. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
  132. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
  133. package/dist/core/dist/capabilities/table/entry.js +2 -0
  134. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
  135. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
  136. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
  137. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
  138. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
  139. package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
  140. package/dist/core/dist/capabilities/text/entry.js +3 -0
  141. package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
  142. package/dist/core/dist/capabilities/text/text-import.js +468 -0
  143. package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
  144. package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
  145. package/dist/core/dist/capabilities/transition/entry.js +3 -0
  146. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
  147. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
  148. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
  149. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
  150. package/dist/core/dist/capabilities/video/entry.js +77 -0
  151. package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
  152. package/dist/core/dist/capabilities/video/video-source.js +42 -0
  153. package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
  154. package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
  155. package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
  156. package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
  157. package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
  158. package/dist/core/dist/document/all.js +41 -0
  159. package/dist/core/dist/document/default.js +10 -0
  160. package/dist/core/dist/document/document.js +218 -0
  161. package/dist/core/dist/document/index.js +62 -0
  162. package/dist/core/dist/document/stages.js +54 -0
  163. package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
  164. package/dist/core/dist/emit/index.js +6 -0
  165. package/dist/core/dist/emit/ooxml.js +241 -0
  166. package/dist/{import/dist → core/dist/import}/import.js +221 -187
  167. package/dist/core/dist/import/index.js +19 -0
  168. package/dist/{import/dist → core/dist/import}/masters.js +253 -317
  169. package/dist/core/dist/import/media-timing.js +233 -0
  170. package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
  171. package/dist/core/dist/index.js +47 -15
  172. package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
  173. package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
  174. package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
  175. package/dist/core/dist/kernel/build.js +4 -0
  176. package/dist/core/dist/kernel/capability.js +17 -0
  177. package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
  178. package/dist/core/dist/kernel/container-slots.js +104 -0
  179. package/dist/core/dist/kernel/date-time-format.js +18 -0
  180. package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
  181. package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
  182. package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
  183. package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
  184. package/dist/core/dist/{document.js → kernel/document.js} +6 -5
  185. package/dist/core/dist/kernel/drawing-units.js +14 -0
  186. package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
  187. package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
  188. package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
  189. package/dist/core/dist/{host.js → kernel/host.js} +1 -1
  190. package/dist/core/dist/kernel/index.js +24 -0
  191. package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
  192. package/dist/core/dist/kernel/layout-definition.js +7 -0
  193. package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
  194. package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
  195. package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
  196. package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
  197. package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
  198. package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
  199. package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
  200. package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
  201. package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
  202. package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
  203. package/dist/core/dist/kernel/pptx-read/index.js +15 -0
  204. package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
  205. package/dist/core/dist/kernel/pptx-read/media.js +26 -0
  206. package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
  207. package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
  208. package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
  209. package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
  210. package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
  211. package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
  212. package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
  213. package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
  214. package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
  215. package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
  216. package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
  217. package/dist/core/dist/{query.js → kernel/query.js} +5 -1
  218. package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
  219. package/dist/core/dist/kernel/resolve-work.js +58 -0
  220. package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
  221. package/dist/core/dist/kernel/resource-source.js +11 -0
  222. package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
  223. package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
  224. package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
  225. package/dist/core/dist/kernel/xml-values.js +13 -0
  226. package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
  227. package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
  228. package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
  229. package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
  230. package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
  231. package/dist/index.d.ts +7 -8
  232. package/dist/index.js +68 -66
  233. package/dist/node.d.ts +16 -14
  234. package/dist/node.js +86 -43
  235. package/dist/pptxdk/src/cli-commands.js +9 -5
  236. package/dist/pptxdk/src/compose.js +28 -29
  237. package/dist/pptxdk/src/preview-result.js +24 -0
  238. package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
  239. package/dist/preview/dist/index.js +84 -34
  240. package/dist/preview/dist/options.js +8 -4
  241. package/dist/preview/dist/raster.js +66 -0
  242. package/dist/preview/dist/svg-guard.js +8 -7
  243. package/dist/preview.d.ts +3 -9
  244. package/dist/preview.js +7 -25
  245. package/dist/react/dist/append.js +3 -3
  246. package/dist/react/dist/author/audio-elements.js +14 -0
  247. package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
  248. package/dist/react/dist/author/chart-elements.js +14 -0
  249. package/dist/react/dist/author/comment-elements.js +15 -0
  250. package/dist/react/dist/author/group-elements.js +14 -0
  251. package/dist/react/dist/author/image-elements.js +14 -0
  252. package/dist/react/dist/author/line-elements.js +14 -0
  253. package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
  254. package/dist/react/dist/author/notes-elements.js +14 -0
  255. package/dist/react/dist/author/placeholder-elements.js +14 -0
  256. package/dist/react/dist/author/shape-elements.js +14 -0
  257. package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
  258. package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
  259. package/dist/react/dist/author/video-elements.js +14 -0
  260. package/dist/react/dist/document-adapter.js +4 -4
  261. package/dist/react/dist/elements.js +7 -4
  262. package/dist/react/dist/from-vanilla.js +3 -3
  263. package/dist/react/dist/index.js +17 -3
  264. package/dist/react/dist/reconciler.js +3 -3
  265. package/dist/react.d.ts +103 -69
  266. package/dist/react.js +28 -28
  267. package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
  268. package/dist/vanilla.d.ts +4 -4
  269. package/dist/vanilla.js +14 -15
  270. package/package.json +2 -5
  271. package/dist/build-zrZuX4fK.d.ts +0 -3
  272. package/dist/capabilities/dist/all.js +0 -34
  273. package/dist/capabilities/dist/chart/chart-elements.js +0 -12
  274. package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
  275. package/dist/capabilities/dist/document.js +0 -168
  276. package/dist/capabilities/dist/group/group-elements.js +0 -12
  277. package/dist/capabilities/dist/image/image-codegen.js +0 -164
  278. package/dist/capabilities/dist/image/image-declaration.js +0 -8
  279. package/dist/capabilities/dist/image/image-elements.js +0 -12
  280. package/dist/capabilities/dist/image/image-xml.js +0 -12
  281. package/dist/capabilities/dist/image/image.js +0 -552
  282. package/dist/capabilities/dist/line/line-elements.js +0 -12
  283. package/dist/capabilities/dist/notes/notes-elements.js +0 -12
  284. package/dist/capabilities/dist/notes/notes-xml.js +0 -38
  285. package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
  286. package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
  287. package/dist/capabilities/dist/shape/shape-elements.js +0 -12
  288. package/dist/capabilities/dist/shape/shape-import.js +0 -628
  289. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
  290. package/dist/capabilities/dist/text/text-import.js +0 -1224
  291. package/dist/core/dist/build.js +0 -4
  292. package/dist/core/dist/capability.js +0 -15
  293. package/dist/emit/dist/index.js +0 -5
  294. package/dist/import/dist/index.js +0 -16
  295. package/dist/pptxdk/src/slide.js +0 -9
  296. package/dist/transition-6n8GZxSg.d.ts +0 -9
@@ -1,1224 +0,0 @@
1
- import { schemeColorNameSchema } from "../../../core/dist/theme.js";
2
- import { placeholderStyleSchema } from "../../../core/dist/placeholders.js";
3
- import "../../../core/dist/capability.js";
4
- import { A_NS, EMU_PER_PX, P_NS, XML_NS, emuToPx } from "../../../import/dist/namespaces.js";
5
- import { extentEmuFragmentSchema, hexRgb6Schema, normalizeBulletCharacter, offsetEmuFragmentSchema, ooxmlAutoNumStartAtSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlLineSpacingPercentSchema, ooxmlLineSpacingPointsSchema, ooxmlListLevelSchema, ooxmlNonNegativeIntSchema, ooxmlParagraphSpacingPointsSchema, ooxmlWritableExtentEmuSchema, readOoxmlBoxInsets, readOoxmlRunAttrStyles, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
6
- import { readRunFontSlots } from "../../../import/dist/fonts.js";
7
- import "../../../import/dist/index.js";
8
- import { readNonVisualCommonProperties } from "../shape/shape-import.js";
9
- import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, hasPlaceholderElement } from "../shared/identity.js";
10
- import { directElementChild, directPlaceholderElement, emitPlaceholderUnbindDiagnostic, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, stripPlaceholderClearSentinels } from "../shared/placeholder-import.js";
11
- import { resolvePlaceholderBaseTextStyle, resolvePlaceholderLevelTextStyle } from "../shared/style-inheritance.js";
12
- import { paragraphStyleKeys, paragraphStyleSchema, textBoxStyleSchema } from "../shared/text-schemas.js";
13
- import { readSpPrAppearance, readSpPrVisuals } from "../shared/visual.js";
14
- import { createParagraphNode, createSlideNumberNode, createSpanNode, createSubNode, createSupNode, createTextNode } from "./text-declaration.js";
15
- import { z } from "zod";
16
- // ../capabilities/dist/text/text-import.js
17
- const NonVisualSpPrFlagsSchema = z.object({ txBox: ooxmlBoolSchema.optional() });
18
- const BodyPrFragmentSchema = z.object({
19
- wrap: z.enum(["square", "none"]).optional(),
20
- rtlCol: ooxmlBoolSchema.optional(),
21
- anchor: z.enum([
22
- "t",
23
- "ctr",
24
- "b"
25
- ]).optional(),
26
- anchorCtr: ooxmlBoolSchema.optional(),
27
- spcFirstLastPara: ooxmlBoolSchema.optional(),
28
- numCol: z.string().optional(),
29
- spcCol: z.string().optional()
30
- });
31
- const ParagraphAlignSchema = z.enum([
32
- "l",
33
- "ctr",
34
- "r",
35
- "just"
36
- ]);
37
- const SpacingPointsXmlSchema = z.object({ val: ooxmlParagraphSpacingPointsSchema });
38
- const LineSpacingPointsXmlSchema = z.object({ val: ooxmlLineSpacingPointsSchema });
39
- const SpacingPercentXmlSchema = z.object({ val: ooxmlLineSpacingPercentSchema });
40
- const TextFieldXmlSchema = z.object({
41
- id: z.string().min(1),
42
- type: z.string().min(1)
43
- });
44
- const OuterShadowXmlSchema = z.object({
45
- blurRad: ooxmlWritableExtentEmuSchema.optional(),
46
- dist: ooxmlWritableExtentEmuSchema.optional(),
47
- dir: ooxmlIntSchema.optional(),
48
- algn: z.string().optional(),
49
- rotWithShape: ooxmlBoolSchema.optional()
50
- });
51
- const PercentModifierSchema = z.object({ val: ooxmlNonNegativeIntSchema });
52
- const SrgbColorSchema = z.object({ val: hexRgb6Schema });
53
- const SchemeColorSchema = z.object({ val: schemeColorNameSchema });
54
- const anchorToVerticalAlign = {
55
- t: "top",
56
- ctr: "middle",
57
- b: "bottom"
58
- };
59
- const algnToTextAlign = {
60
- l: "left",
61
- ctr: "center",
62
- r: "right",
63
- just: "justify"
64
- };
65
- const textCompatiblePlaceholderRoles = /* @__PURE__ */ new Set([
66
- "title",
67
- "ctrTitle",
68
- "subTitle",
69
- "body",
70
- "hdr",
71
- "obj"
72
- ]);
73
- const footerPlaceholderRoles = /* @__PURE__ */ new Set([
74
- "dt",
75
- "ftr",
76
- "sldNum"
77
- ]);
78
- /** Side-effect-free predicate distinguishing `<p:sp>` text boxes (`txBox="1"`) from shapes and placeholders. */
79
- function isTextBoxSpElement(cursor) {
80
- if (hasPlaceholderElement(cursor)) return false;
81
- const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
82
- if (nvSpPr === void 0) return false;
83
- const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
84
- if (cNvSpPr === void 0) return false;
85
- const txBox = cNvSpPr.getAttribute("txBox");
86
- return txBox === "1" || txBox === "true";
87
- }
88
- /** Side-effect-free predicate matching non-footer populated `<p:sp>` placeholder elements. */
89
- function isTextPlaceholderSpElement(cursor) {
90
- const ph = directPlaceholderElement(cursor, "nvSpPr");
91
- if (ph === void 0) return false;
92
- if (directElementChild(cursor.element, "http://schemas.openxmlformats.org/presentationml/2006/main", "txBody") === void 0) return false;
93
- const rawType = ph.getAttribute("type");
94
- const role = rawType === null || rawType === "" ? "obj" : rawType;
95
- return !footerPlaceholderRoles.has(role);
96
- }
97
- function readColorModifier(colorCursor, localName) {
98
- const mod = colorCursor.child(A_NS, localName);
99
- if (mod === void 0) return void 0;
100
- const parsed = PercentModifierSchema.safeParse(mod.attrsObject(["val"]));
101
- return parsed.success ? parsed.data.val / 1e5 : void 0;
102
- }
103
- function readColorElement(containerCursor, part, slideIndex, diagnostics) {
104
- const srgb = containerCursor.child(A_NS, "srgbClr");
105
- const scheme = srgb === void 0 ? containerCursor.child(A_NS, "schemeClr") : void 0;
106
- const colorCursor = srgb ?? scheme;
107
- if (colorCursor === void 0) return void 0;
108
- let baseString;
109
- let schemeSlot;
110
- if (srgb !== void 0) {
111
- const raw = srgb.attrsObject(["val"]);
112
- const parsed = SrgbColorSchema.safeParse(raw);
113
- if (!parsed.success) {
114
- diagnostics.push({
115
- code: "invalid-xml-value",
116
- category: "corrupt-input",
117
- disposition: "omitted",
118
- location: {
119
- part,
120
- xpath: srgb.xpath,
121
- slideIndex
122
- },
123
- attributeOrElement: "a:srgbClr/@val",
124
- rawValue: raw["val"] ?? ""
125
- });
126
- return;
127
- }
128
- baseString = `#${parsed.data.val.toUpperCase()}`;
129
- } else if (scheme !== void 0) {
130
- const raw = scheme.attrsObject(["val"]);
131
- const parsed = SchemeColorSchema.safeParse(raw);
132
- if (!parsed.success) {
133
- diagnostics.push({
134
- code: "invalid-xml-value",
135
- category: "corrupt-input",
136
- disposition: "omitted",
137
- location: {
138
- part,
139
- xpath: scheme.xpath,
140
- slideIndex
141
- },
142
- attributeOrElement: "a:schemeClr/@val",
143
- rawValue: raw["val"] ?? ""
144
- });
145
- return;
146
- }
147
- schemeSlot = parsed.data.val;
148
- }
149
- const lumMod = readColorModifier(colorCursor, "lumMod");
150
- const lumOff = readColorModifier(colorCursor, "lumOff");
151
- const alpha = readColorModifier(colorCursor, "alpha");
152
- const baseColor = schemeSlot !== void 0 && lumMod !== void 0 ? {
153
- slot: schemeSlot,
154
- lumMod: Math.min(1, lumMod),
155
- ...lumOff === void 0 ? {} : { lumOff: Math.min(1, lumOff) }
156
- } : schemeSlot ?? baseString;
157
- if (baseColor === void 0) return void 0;
158
- if (alpha !== void 0) return {
159
- color: baseColor,
160
- alpha: Math.min(1, alpha)
161
- };
162
- return baseColor;
163
- }
164
- function readOuterShadow(rPrCursor, part, slideIndex, diagnostics, allowShadowNone = false) {
165
- const effectLst = rPrCursor.child(A_NS, "effectLst");
166
- if (effectLst === void 0) return void 0;
167
- const outerShdw = effectLst.child(A_NS, "outerShdw");
168
- if (outerShdw === void 0) return allowShadowNone && effectLst.element.children.length === 0 ? "none" : void 0;
169
- const raw = outerShdw.attrsObject([
170
- "blurRad",
171
- "dist",
172
- "dir",
173
- "algn",
174
- "rotWithShape"
175
- ]);
176
- const parsed = OuterShadowXmlSchema.safeParse(raw);
177
- if (!parsed.success) {
178
- diagnostics.push({
179
- code: "invalid-xml-value",
180
- category: "corrupt-input",
181
- disposition: "omitted",
182
- location: {
183
- part,
184
- xpath: outerShdw.xpath,
185
- slideIndex
186
- },
187
- attributeOrElement: "a:outerShdw",
188
- rawValue: JSON.stringify(raw)
189
- });
190
- outerShdw.suppressUnconsumed();
191
- return;
192
- }
193
- const color = readColorElement(outerShdw, part, slideIndex, diagnostics);
194
- const blur = parsed.data.blurRad === void 0 ? void 0 : emuToPx(parsed.data.blurRad);
195
- const distance = parsed.data.dist === void 0 ? void 0 : emuToPx(parsed.data.dist);
196
- const angle = parsed.data.dir === void 0 ? void 0 : parsed.data.dir / 6e4;
197
- return {
198
- ...color === void 0 ? {} : { color },
199
- ...blur === void 0 ? {} : { blur },
200
- ...distance === void 0 ? {} : { distance },
201
- ...angle === void 0 ? {} : { angle }
202
- };
203
- }
204
- function readRunProperties(rPrCursor, part, slideIndex, diagnostics, allowShadowNone = false) {
205
- const attrStyles = readOoxmlRunAttrStyles({
206
- rPrCursor,
207
- location: {
208
- part,
209
- slideIndex
210
- },
211
- diagnostics,
212
- allowBaseline: true,
213
- allowNoneTextDecoration: true,
214
- diagnoseUnsupportedEnums: true
215
- });
216
- let color;
217
- const solidFill = rPrCursor.child(A_NS, "solidFill");
218
- if (solidFill !== void 0) color = readColorElement(solidFill, part, slideIndex, diagnostics);
219
- const textShadow = readOuterShadow(rPrCursor, part, slideIndex, diagnostics, allowShadowNone);
220
- const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPrCursor);
221
- return {
222
- style: {
223
- ...fontFamily === void 0 ? {} : { fontFamily },
224
- ...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily },
225
- ...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
226
- ...attrStyles.fontWeight === void 0 ? {} : { fontWeight: attrStyles.fontWeight },
227
- ...attrStyles.fontStyle === void 0 ? {} : { fontStyle: attrStyles.fontStyle },
228
- ...color === void 0 ? {} : { color },
229
- ...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
230
- ...attrStyles.textTransform === void 0 ? {} : { textTransform: attrStyles.textTransform },
231
- ...attrStyles.textDecoration === void 0 ? {} : { textDecoration: attrStyles.textDecoration },
232
- ...textShadow === void 0 ? {} : { textShadow },
233
- ...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang },
234
- ...attrStyles.baselineShift === void 0 ? {} : { baselineShift: attrStyles.baselineShift }
235
- },
236
- ...attrStyles.sizePt === void 0 ? {} : { sizePt: attrStyles.sizePt },
237
- ...attrStyles.inlineKind === void 0 ? {} : { inlineKind: attrStyles.inlineKind }
238
- };
239
- }
240
- /**
241
- * Import handler for `<a:fld type="slidenum">` inline text fields (`text-field-slidenum`).
242
- */
243
- const textFieldSlideNumImportHandler = {
244
- target: "text-inline",
245
- localName: "fld",
246
- matches(cursor) {
247
- return cursor.element.getAttribute("type") === "slidenum";
248
- },
249
- read(context) {
250
- const { cursor, part, slideIndex } = context;
251
- const diagnostics = [];
252
- const rawField = cursor.attrsObject(["id", "type"]);
253
- const parsedField = TextFieldXmlSchema.safeParse(rawField);
254
- const rPrCursor = cursor.child(A_NS, "rPr");
255
- cursor.ignoreEmptyChild(A_NS, "pPr");
256
- const tCursor = cursor.child(A_NS, "t");
257
- if (tCursor !== void 0) tCursor.consumeAttr("space", XML_NS);
258
- const fallbackText = tCursor?.textContent ?? "";
259
- if (!parsedField.success) {
260
- diagnostics.push({
261
- code: "invalid-xml-value",
262
- category: "corrupt-input",
263
- disposition: "omitted",
264
- location: {
265
- part,
266
- xpath: cursor.xpath,
267
- slideIndex
268
- },
269
- attributeOrElement: "a:fld",
270
- rawValue: JSON.stringify(rawField)
271
- });
272
- return {
273
- kind: "unsupported",
274
- fieldType: rawField["type"] ?? "",
275
- ...rPrCursor === void 0 ? {} : { rPrCursor },
276
- fallbackText,
277
- diagnostics
278
- };
279
- }
280
- if (parsedField.data.type !== "slidenum") {
281
- diagnostics.push({
282
- code: "unsupported-mechanism",
283
- category: "unsupported",
284
- disposition: "omitted",
285
- location: {
286
- part,
287
- xpath: cursor.xpath,
288
- slideIndex
289
- },
290
- namespaceUri: cursor.namespaceUri,
291
- localName: cursor.localName,
292
- mechanismHint: `text-field:${parsedField.data.type}`
293
- });
294
- return {
295
- kind: "unsupported",
296
- fieldType: parsedField.data.type,
297
- ...rPrCursor === void 0 ? {} : { rPrCursor },
298
- fallbackText,
299
- diagnostics
300
- };
301
- }
302
- return {
303
- kind: "slide-number",
304
- fieldType: "slidenum",
305
- ...rPrCursor === void 0 ? {} : { rPrCursor },
306
- fallbackText,
307
- diagnostics
308
- };
309
- }
310
- };
311
- function readParagraph(pCursor, part, slideIndex, diagnostics, allowShadowNone = false) {
312
- const pPr = pCursor.child(A_NS, "pPr");
313
- let align;
314
- let lvl;
315
- let buNone = false;
316
- let list;
317
- let lnSpcNode;
318
- let spcAftNode;
319
- let defParaSizePt;
320
- if (pPr !== void 0) {
321
- const rawPPr = pPr.attrsObject([
322
- "algn",
323
- "rtl",
324
- "lvl",
325
- "marL",
326
- "indent",
327
- "fontAlgn",
328
- "eaLnBrk",
329
- "latinLnBrk",
330
- "hangingPunct",
331
- "defTabSz"
332
- ]);
333
- if (rawPPr["algn"] !== void 0) {
334
- const parsedAlgn = ParagraphAlignSchema.safeParse(rawPPr["algn"]);
335
- if (parsedAlgn.success) align = algnToTextAlign[parsedAlgn.data];
336
- else diagnostics.push({
337
- code: "invalid-xml-value",
338
- category: "corrupt-input",
339
- disposition: "recovered",
340
- location: {
341
- part,
342
- xpath: `${pPr.xpath}/@algn`,
343
- slideIndex
344
- },
345
- attributeOrElement: "@algn",
346
- rawValue: rawPPr["algn"]
347
- });
348
- }
349
- if (rawPPr["rtl"] !== void 0 && !ooxmlBoolSchema.safeParse(rawPPr["rtl"]).success) diagnostics.push({
350
- code: "invalid-xml-value",
351
- category: "corrupt-input",
352
- disposition: "recovered",
353
- location: {
354
- part,
355
- xpath: `${pPr.xpath}/@rtl`,
356
- slideIndex
357
- },
358
- attributeOrElement: "@rtl",
359
- rawValue: rawPPr["rtl"]
360
- });
361
- if (rawPPr["lvl"] !== void 0) {
362
- const parsedLvl = ooxmlListLevelSchema.safeParse(rawPPr["lvl"]);
363
- if (parsedLvl.success) lvl = parsedLvl.data;
364
- else diagnostics.push({
365
- code: "invalid-xml-value",
366
- category: "corrupt-input",
367
- disposition: "recovered",
368
- location: {
369
- part,
370
- xpath: `${pPr.xpath}/@lvl`,
371
- slideIndex
372
- },
373
- attributeOrElement: "@lvl",
374
- rawValue: rawPPr["lvl"]
375
- });
376
- }
377
- const spcBefNode = pPr.child(A_NS, "spcBef");
378
- if (spcBefNode !== void 0) {
379
- spcBefNode.child(A_NS, "spcPts")?.consumeAttr("val");
380
- spcBefNode.child(A_NS, "spcPct")?.consumeAttr("val");
381
- }
382
- lnSpcNode = pPr.child(A_NS, "lnSpc");
383
- spcAftNode = pPr.child(A_NS, "spcAft");
384
- if (pPr.child("http://schemas.openxmlformats.org/drawingml/2006/main", "buNone") !== void 0) buNone = true;
385
- pPr.child(A_NS, "buFont")?.attrsObject([
386
- "typeface",
387
- "pitchFamily",
388
- "charset",
389
- "panose"
390
- ]);
391
- const buChar = pPr.child(A_NS, "buChar");
392
- const buAutoNum = pPr.child(A_NS, "buAutoNum");
393
- if (buChar !== void 0) {
394
- const rawBu = buChar.attrsObject(["char"]);
395
- const normalized = normalizeBulletCharacter(rawBu["char"]);
396
- if (normalized.recovered) diagnostics.push({
397
- code: "invalid-xml-value",
398
- category: "corrupt-input",
399
- disposition: "recovered",
400
- location: {
401
- part,
402
- xpath: buChar.xpath,
403
- slideIndex
404
- },
405
- attributeOrElement: "a:buChar/@char",
406
- rawValue: rawBu["char"] ?? ""
407
- });
408
- list = {
409
- type: "bullet",
410
- character: normalized.character,
411
- ...lvl === void 0 ? {} : { level: lvl }
412
- };
413
- } else if (buAutoNum !== void 0) {
414
- const rawNum = buAutoNum.attrsObject(["type", "startAt"]);
415
- const rawType = rawNum["type"];
416
- if (rawType === void 0 || rawType.length === 0) diagnostics.push({
417
- code: "invalid-xml-value",
418
- category: "corrupt-input",
419
- disposition: "omitted",
420
- location: {
421
- part,
422
- xpath: buAutoNum.xpath,
423
- slideIndex
424
- },
425
- attributeOrElement: "a:buAutoNum",
426
- rawValue: JSON.stringify(rawNum)
427
- });
428
- else {
429
- if (rawType !== "arabicPeriod") diagnostics.push({
430
- code: "invalid-xml-value",
431
- category: "corrupt-input",
432
- disposition: "recovered",
433
- location: {
434
- part,
435
- xpath: `${buAutoNum.xpath}/@type`,
436
- slideIndex
437
- },
438
- attributeOrElement: "a:buAutoNum/@type",
439
- rawValue: rawType
440
- });
441
- let startAt;
442
- if (rawNum["startAt"] !== void 0) {
443
- const parsedStart = ooxmlAutoNumStartAtSchema.safeParse(rawNum["startAt"]);
444
- if (parsedStart.success) startAt = parsedStart.data;
445
- else diagnostics.push({
446
- code: "invalid-xml-value",
447
- category: "corrupt-input",
448
- disposition: "omitted",
449
- location: {
450
- part,
451
- xpath: `${buAutoNum.xpath}/@startAt`,
452
- slideIndex
453
- },
454
- attributeOrElement: "a:buAutoNum/@startAt",
455
- rawValue: rawNum["startAt"]
456
- });
457
- }
458
- list = {
459
- type: "number",
460
- style: "arabicPeriod",
461
- ...startAt === void 0 ? {} : { startAt },
462
- ...lvl === void 0 ? {} : { level: lvl }
463
- };
464
- }
465
- }
466
- const defRPr = pPr.child(A_NS, "defRPr");
467
- if (defRPr !== void 0) defParaSizePt = readRunProperties(defRPr, part, slideIndex, diagnostics, allowShadowNone).sizePt;
468
- }
469
- const runs = [];
470
- let endParaSizePt;
471
- for (const child of pCursor.remainingElementChildren()) {
472
- if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
473
- const rPr = child.child(A_NS, "rPr");
474
- const parsedRPr = rPr === void 0 ? { style: {} } : readRunProperties(rPr, part, slideIndex, diagnostics, allowShadowNone);
475
- const t = child.child(A_NS, "t");
476
- if (t !== void 0) {
477
- t.consumeAttr("space", XML_NS);
478
- runs.push({
479
- kind: parsedRPr.inlineKind ?? "text",
480
- text: t.textContent,
481
- style: parsedRPr.style,
482
- ...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
483
- });
484
- }
485
- continue;
486
- }
487
- if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "br") {
488
- const rPr = child.child(A_NS, "rPr");
489
- const parsedRPr = rPr === void 0 ? { style: {} } : readRunProperties(rPr, part, slideIndex, diagnostics, allowShadowNone);
490
- runs.push({
491
- kind: parsedRPr.inlineKind ?? "text",
492
- text: "\n",
493
- style: parsedRPr.style,
494
- ...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
495
- });
496
- continue;
497
- }
498
- if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
499
- const outcome = textFieldSlideNumImportHandler.read({
500
- cursor: child,
501
- part,
502
- slideIndex
503
- });
504
- diagnostics.push(...outcome.diagnostics);
505
- if (outcome.kind === "slide-number") {
506
- const parsedRPr = outcome.rPrCursor === void 0 ? { style: {} } : readRunProperties(outcome.rPrCursor, part, slideIndex, diagnostics, allowShadowNone);
507
- const fieldStyle = parsedRPr.inlineKind === void 0 ? parsedRPr.style : {
508
- ...parsedRPr.style,
509
- baselineShift: parsedRPr.inlineKind === "sup" ? "30%" : "-25%"
510
- };
511
- runs.push({
512
- kind: "slide-number",
513
- style: fieldStyle,
514
- ...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
515
- });
516
- }
517
- continue;
518
- }
519
- if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
520
- endParaSizePt = readRunProperties(child, part, slideIndex, diagnostics, allowShadowNone).sizePt;
521
- continue;
522
- }
523
- diagnostics.push({
524
- code: "unconsumed-xml",
525
- category: "unsupported",
526
- disposition: "omitted",
527
- kind: "element",
528
- location: {
529
- part,
530
- xpath: child.xpath,
531
- slideIndex
532
- },
533
- namespaceUri: child.namespaceUri,
534
- localName: child.localName
535
- });
536
- }
537
- const baseFontPt = runs.find((run) => run.sizePt !== void 0)?.sizePt ?? endParaSizePt ?? defParaSizePt ?? 18;
538
- let lineHeight;
539
- if (lnSpcNode !== void 0) {
540
- const spcPts = lnSpcNode.child(A_NS, "spcPts");
541
- const spcPct = spcPts === void 0 ? lnSpcNode.child(A_NS, "spcPct") : void 0;
542
- if (spcPts !== void 0) {
543
- const raw = spcPts.attrsObject(["val"]);
544
- const parsed = LineSpacingPointsXmlSchema.safeParse(raw);
545
- if (!parsed.success) diagnostics.push({
546
- code: "invalid-xml-value",
547
- category: "corrupt-input",
548
- disposition: "omitted",
549
- location: {
550
- part,
551
- xpath: spcPts.xpath,
552
- slideIndex
553
- },
554
- attributeOrElement: "a:spcPts/@val",
555
- rawValue: raw["val"] ?? ""
556
- });
557
- else lineHeight = `${parsed.data.val / 100}pt`;
558
- } else if (spcPct !== void 0) {
559
- const raw = spcPct.attrsObject(["val"]);
560
- const parsed = SpacingPercentXmlSchema.safeParse(raw);
561
- if (!parsed.success) diagnostics.push({
562
- code: "invalid-xml-value",
563
- category: "corrupt-input",
564
- disposition: "omitted",
565
- location: {
566
- part,
567
- xpath: spcPct.xpath,
568
- slideIndex
569
- },
570
- attributeOrElement: "a:spcPct/@val",
571
- rawValue: raw["val"] ?? ""
572
- });
573
- else lineHeight = `${parsed.data.val / 1e3}%`;
574
- }
575
- }
576
- let spacingAfter;
577
- if (spcAftNode !== void 0) {
578
- const spcPts = spcAftNode.child(A_NS, "spcPts");
579
- const spcPct = spcPts === void 0 ? spcAftNode.child(A_NS, "spcPct") : void 0;
580
- if (spcPts !== void 0) {
581
- const raw = spcPts.attrsObject(["val"]);
582
- const parsed = SpacingPointsXmlSchema.safeParse(raw);
583
- if (!parsed.success) diagnostics.push({
584
- code: "invalid-xml-value",
585
- category: "corrupt-input",
586
- disposition: "omitted",
587
- location: {
588
- part,
589
- xpath: spcPts.xpath,
590
- slideIndex
591
- },
592
- attributeOrElement: "a:spcPts/@val",
593
- rawValue: raw["val"] ?? ""
594
- });
595
- else spacingAfter = parsed.data.val / 75;
596
- } else if (spcPct !== void 0) {
597
- const raw = spcPct.attrsObject(["val"]);
598
- const parsed = ooxmlNonNegativeIntSchema.safeParse(raw["val"]);
599
- const computed = parsed.success ? baseFontPt * parsed.data / 1e5 * (4 / 3) : void 0;
600
- if (computed === void 0 || !Number.isFinite(computed) || Math.round(computed * 75) > 158400) diagnostics.push({
601
- code: "invalid-xml-value",
602
- category: "corrupt-input",
603
- disposition: "omitted",
604
- location: {
605
- part,
606
- xpath: spcPct.xpath,
607
- slideIndex
608
- },
609
- attributeOrElement: "a:spcPct/@val",
610
- rawValue: raw["val"] ?? ""
611
- });
612
- else spacingAfter = computed;
613
- }
614
- }
615
- return {
616
- runs,
617
- style: {
618
- ...align === void 0 ? {} : { align },
619
- ...lineHeight === void 0 ? {} : { lineHeight },
620
- ...spacingAfter === void 0 ? {} : { spacingAfter },
621
- ...list === void 0 ? {} : { list }
622
- },
623
- ...lvl === void 0 ? {} : { level0: lvl },
624
- ...buNone ? { buNone: true } : {}
625
- };
626
- }
627
- /**
628
- * Shared rich-text body reader for text boxes, shapes, table cells, and speaker notes.
629
- */
630
- function readRichTextBody(txBody, part, slideIndex, diagnostics, _clrMap, options) {
631
- let paddingTop;
632
- let paddingRight;
633
- let paddingBottom;
634
- let paddingLeft;
635
- let verticalAlign;
636
- let textWrap;
637
- const bodyPr = txBody.child(A_NS, "bodyPr");
638
- if (bodyPr !== void 0) {
639
- const rawBodyPr = bodyPr.attrsObject([
640
- "wrap",
641
- "rtlCol",
642
- "lIns",
643
- "tIns",
644
- "rIns",
645
- "bIns",
646
- "anchor",
647
- "anchorCtr",
648
- "spcFirstLastPara",
649
- "numCol",
650
- "spcCol"
651
- ]);
652
- const parsedBodyPr = BodyPrFragmentSchema.safeParse(rawBodyPr);
653
- if (!parsedBodyPr.success) diagnostics.push({
654
- code: "invalid-xml-value",
655
- category: "corrupt-input",
656
- disposition: "recovered",
657
- location: {
658
- part,
659
- xpath: bodyPr.xpath,
660
- slideIndex
661
- },
662
- attributeOrElement: "a:bodyPr",
663
- rawValue: JSON.stringify(rawBodyPr)
664
- });
665
- else {
666
- const b = parsedBodyPr.data;
667
- if (b.wrap === "none") textWrap = "nowrap";
668
- else if (b.wrap === "square") textWrap = "normal";
669
- if (b.anchor !== void 0) verticalAlign = anchorToVerticalAlign[b.anchor];
670
- }
671
- const insets = readOoxmlBoxInsets({
672
- rawAttrs: rawBodyPr,
673
- attrNames: {
674
- left: "lIns",
675
- top: "tIns",
676
- right: "rIns",
677
- bottom: "bIns"
678
- },
679
- elementXpath: bodyPr.xpath,
680
- location: {
681
- part,
682
- slideIndex
683
- },
684
- diagnostics
685
- });
686
- paddingLeft = insets.paddingLeft;
687
- paddingTop = insets.paddingTop;
688
- paddingRight = insets.paddingRight;
689
- paddingBottom = insets.paddingBottom;
690
- bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
691
- bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
692
- bodyPr.child(A_NS, "normAutofit")?.attrsObject(["fontScale", "lnSpcReduction"]);
693
- }
694
- txBody.ignoreEmptyChild(A_NS, "lstStyle");
695
- const importedParagraphs = txBody.children(A_NS, "p").map((pCursor) => readParagraph(pCursor, part, slideIndex, diagnostics, options?.allowShadowNone === true));
696
- return {
697
- boxStyle: {
698
- ...paddingTop === void 0 ? {} : { paddingTop },
699
- ...paddingRight === void 0 ? {} : { paddingRight },
700
- ...paddingBottom === void 0 ? {} : { paddingBottom },
701
- ...paddingLeft === void 0 ? {} : { paddingLeft },
702
- ...verticalAlign === void 0 ? {} : { verticalAlign },
703
- ...textWrap === void 0 ? {} : { textWrap }
704
- },
705
- importedParagraphs
706
- };
707
- }
708
- /** Populates a `RichTextContainer` (`TextNode`, `ShapeNode`, `CellNode`, `NotesNode`) from imported paragraphs. */
709
- function populateRichTextNode(target, importedParagraphs) {
710
- const paragraphNodes = importedParagraphs.map((para) => {
711
- const pNode = createParagraphNode(Object.keys(para.style).length === 0 ? {} : { style: para.style });
712
- if (para.runs.length === 1 && para.runs[0].kind === "text" && Object.keys(para.runs[0].style).length === 0) pNode.content(para.runs[0].text);
713
- else if (para.runs.length > 0) pNode.content(...para.runs.map((run) => {
714
- if (run.kind === "slide-number") return createSlideNumberNode(Object.keys(run.style).length === 0 ? {} : { style: run.style });
715
- const runProps = Object.keys(run.style).length === 0 ? {} : { style: run.style };
716
- if (run.kind === "sup") return createSupNode(runProps).content(run.text);
717
- if (run.kind === "sub") return createSubNode(runProps).content(run.text);
718
- return Object.keys(run.style).length === 0 ? run.text : createSpanNode({ style: run.style }).content(run.text);
719
- }));
720
- return pNode;
721
- });
722
- target.content(...paragraphNodes);
723
- }
724
- function textBoxVisualStyle(appearanceStyle, borderArrows, geometry, boxSize, rotate, location, diagnostics) {
725
- const { border: rawBorder, ...restVisualStyle } = appearanceStyle;
726
- const border = rawBorder;
727
- const hasHeadArrow = borderArrows?.startArrow !== void 0;
728
- const hasTailArrow = borderArrows?.endArrow !== void 0;
729
- if (hasHeadArrow || hasTailArrow) diagnostics.push({
730
- code: "unsupported-mechanism",
731
- category: "unsupported",
732
- disposition: "omitted",
733
- location,
734
- namespaceUri: A_NS,
735
- localName: hasHeadArrow ? "headEnd" : "tailEnd",
736
- mechanismHint: "textbox-line-arrow"
737
- });
738
- let borderRadius;
739
- if (geometry === "roundRect") {
740
- if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
741
- } else if (typeof geometry === "object" && geometry.type === "preset") {
742
- if (geometry.name === "roundRect") {
743
- if (boxSize !== void 0) {
744
- const adj = geometry.adjust?.["adj"] ?? 16667;
745
- if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
746
- }
747
- } else if (geometry.name !== "rect") diagnostics.push({
748
- code: "unsupported-mechanism",
749
- category: "unsupported",
750
- disposition: "omitted",
751
- location,
752
- namespaceUri: A_NS,
753
- localName: "prstGeom",
754
- mechanismHint: `textbox-preset:${geometry.name}`
755
- });
756
- } else if (typeof geometry === "object" && geometry.type === "custom") diagnostics.push({
757
- code: "unsupported-mechanism",
758
- category: "unsupported",
759
- disposition: "omitted",
760
- location,
761
- namespaceUri: A_NS,
762
- localName: "custGeom",
763
- mechanismHint: "textbox-custGeom"
764
- });
765
- return {
766
- ...restVisualStyle,
767
- ...border === void 0 ? {} : { border },
768
- ...borderRadius === void 0 ? {} : { borderRadius },
769
- ...rotate === void 0 ? {} : { rotate }
770
- };
771
- }
772
- function flattenImportedTextBody(imported, visualStyle) {
773
- const importedParagraphs = imported?.importedParagraphs ?? [];
774
- const singleParagraph = importedParagraphs.length === 1 ? importedParagraphs[0] : void 0;
775
- const singleTextRun = singleParagraph !== void 0 && singleParagraph.style.list === void 0 && singleParagraph.runs.length === 1 && singleParagraph.runs[0].kind === "text" && singleParagraph.runs[0].style.baselineShift === void 0 ? singleParagraph.runs[0] : void 0;
776
- const singleEmptyParagraph = singleParagraph !== void 0 && singleParagraph.style.list === void 0 && singleParagraph.runs.length === 0;
777
- const flatParagraphStyle = singleTextRun === void 0 && !singleEmptyParagraph || singleParagraph === void 0 ? void 0 : (() => {
778
- const { list: _list, ...rest } = singleParagraph.style;
779
- return rest;
780
- })();
781
- const { baselineShift: _baselineShift, ...hoistableRunStyle } = singleTextRun === void 0 ? {} : singleTextRun.style;
782
- const boxStyle = {
783
- ...imported?.boxStyle,
784
- ...visualStyle,
785
- ...flatParagraphStyle,
786
- ...hoistableRunStyle
787
- };
788
- if (singleTextRun !== void 0) return {
789
- boxStyle,
790
- singleText: singleTextRun.text
791
- };
792
- if (!singleEmptyParagraph && importedParagraphs.length > 0) return {
793
- boxStyle,
794
- paragraphsToPopulate: importedParagraphs
795
- };
796
- return { boxStyle };
797
- }
798
- /**
799
- * Reads a Transitional `<p:sp>` text box (`<p:cNvSpPr txBox="1"/>` without `<p:ph>`) into an editable `TextNode`.
800
- */
801
- function readTextBoxSp(context) {
802
- const { cursor, part, slideIndex, package: pkg } = context;
803
- const diagnostics = [];
804
- const nvSpPr = cursor.child(P_NS, "nvSpPr");
805
- if (nvSpPr === void 0) {
806
- diagnostics.push({
807
- code: "corrupt-part",
808
- category: "corrupt-input",
809
- disposition: "omitted",
810
- location: {
811
- part,
812
- xpath: cursor.xpath,
813
- slideIndex
814
- }
815
- });
816
- return { diagnostics };
817
- }
818
- const cNvPr = nvSpPr.child(P_NS, "cNvPr");
819
- const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
820
- cNvPr?.ignoreEmptyChild(A_NS, "extLst");
821
- const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
822
- if (cNvSpPr !== void 0) {
823
- const rawFlags = cNvSpPr.attrsObject(["txBox"]);
824
- NonVisualSpPrFlagsSchema.safeParse(rawFlags);
825
- cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
826
- "noGrp",
827
- "noRot",
828
- "noChangeAspect",
829
- "noMove",
830
- "noResize",
831
- "noSelect"
832
- ]);
833
- }
834
- consumeNonPlaceholderNvPr(nvSpPr);
835
- const location = {
836
- part,
837
- slideIndex,
838
- ...objectId === void 0 ? {} : { objectId },
839
- ...objectName === void 0 ? {} : { objectName }
840
- };
841
- const spPr = cursor.child(P_NS, "spPr");
842
- const txBody = cursor.child(P_NS, "txBody");
843
- if (spPr === void 0 || txBody === void 0) {
844
- diagnostics.push({
845
- code: "corrupt-part",
846
- category: "corrupt-input",
847
- disposition: "omitted",
848
- location: {
849
- ...location,
850
- xpath: cursor.xpath
851
- }
852
- });
853
- return { diagnostics };
854
- }
855
- const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
856
- if (visuals === void 0) return { diagnostics };
857
- const { background: rawBg, border: rawBorder, ...restFreeVisuals } = textBoxVisualStyle(visuals.style, visuals.borderArrows, visuals.geometry, {
858
- width: visuals.transform.width,
859
- height: visuals.transform.height
860
- }, visuals.transform.rotate, location, diagnostics);
861
- const visualStyle = {
862
- ...restFreeVisuals,
863
- ...rawBg === void 0 || rawBg === "none" ? {} : { background: rawBg },
864
- ...rawBorder === void 0 || rawBorder === "none" ? {} : { border: rawBorder }
865
- };
866
- const { boxStyle, singleText, paragraphsToPopulate } = flattenImportedTextBody(readRichTextBody(txBody, part, slideIndex, diagnostics), visualStyle);
867
- const props = {
868
- ...objectName === void 0 ? {} : { name: objectName },
869
- ...link === void 0 ? {} : { link },
870
- style: {
871
- position: "absolute",
872
- left: visuals.transform.x,
873
- top: visuals.transform.y,
874
- width: visuals.transform.width,
875
- height: visuals.transform.height,
876
- ...boxStyle
877
- }
878
- };
879
- const node = createTextNode(props);
880
- if (singleText !== void 0) node.content(singleText);
881
- else if (paragraphsToPopulate !== void 0) populateRichTextNode(node, paragraphsToPopulate);
882
- attachDeferredSlideLink(node, deferredSlideLink, context);
883
- return {
884
- node,
885
- diagnostics
886
- };
887
- }
888
- /**
889
- * Reads a Transitional `<p:sp>` bound placeholder (`<p:nvPr><p:ph .../></p:nvPr>`)
890
- * into a layout-bound `TextNode` preserving differential transforms and styles.
891
- */
892
- function readTextPlaceholderSp(context) {
893
- const { cursor, part, slideIndex, package: pkg } = context;
894
- const diagnostics = [];
895
- const nvSpPr = cursor.child(P_NS, "nvSpPr");
896
- if (nvSpPr === void 0) {
897
- diagnostics.push({
898
- code: "corrupt-part",
899
- category: "corrupt-input",
900
- disposition: "omitted",
901
- location: {
902
- part,
903
- xpath: cursor.xpath,
904
- slideIndex
905
- }
906
- });
907
- return { diagnostics };
908
- }
909
- const cNvPr = nvSpPr.child(P_NS, "cNvPr");
910
- const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
911
- cNvPr?.ignoreEmptyChild(A_NS, "extLst");
912
- const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
913
- if (cNvSpPr !== void 0) {
914
- cNvSpPr.consumeAttr("txBox");
915
- cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
916
- "noGrp",
917
- "noRot",
918
- "noChangeAspect",
919
- "noMove",
920
- "noResize",
921
- "noSelect"
922
- ]);
923
- }
924
- const location = {
925
- part,
926
- slideIndex,
927
- ...objectId === void 0 ? {} : { objectId },
928
- ...objectName === void 0 ? {} : { objectName }
929
- };
930
- const nvPr = nvSpPr.child(P_NS, "nvPr");
931
- const phResult = readNvPrPlaceholder(nvPr, {
932
- ...location,
933
- xpath: cursor.xpath
934
- }, diagnostics);
935
- if (phResult.kind === "none") {
936
- diagnostics.push({
937
- code: "corrupt-part",
938
- category: "corrupt-input",
939
- disposition: "omitted",
940
- location: {
941
- ...location,
942
- xpath: cursor.xpath
943
- }
944
- });
945
- return { diagnostics };
946
- }
947
- if (phResult.kind === "error") return { diagnostics };
948
- const nativeRef = phResult.nativeRef;
949
- const spPr = cursor.child(P_NS, "spPr");
950
- if (spPr === void 0) {
951
- diagnostics.push({
952
- code: "corrupt-part",
953
- category: "corrupt-input",
954
- disposition: "omitted",
955
- location: {
956
- ...location,
957
- xpath: cursor.xpath
958
- }
959
- });
960
- return { diagnostics };
961
- }
962
- let localBox;
963
- let rotate;
964
- let flipH;
965
- let flipV;
966
- let fallbackUnits = {
967
- w: 0,
968
- h: 0
969
- };
970
- const xfrm = spPr.child(A_NS, "xfrm");
971
- if (xfrm !== void 0) {
972
- const hasExplicitFlipH = xfrm.element.hasAttribute("flipH");
973
- const hasExplicitFlipV = xfrm.element.hasAttribute("flipV");
974
- const rawXfrm = xfrm.attrsObject([
975
- "rot",
976
- "flipH",
977
- "flipV"
978
- ]);
979
- const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
980
- if (parsedXfrm.success) {
981
- if (parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0) rotate = parsedXfrm.data.rot / 6e4;
982
- if (hasExplicitFlipH && parsedXfrm.data.flipH !== void 0) flipH = parsedXfrm.data.flipH;
983
- if (hasExplicitFlipV && parsedXfrm.data.flipV !== void 0) flipV = parsedXfrm.data.flipV;
984
- }
985
- const off = xfrm.child(A_NS, "off");
986
- const ext = xfrm.child(A_NS, "ext");
987
- if (off !== void 0 && ext !== void 0) {
988
- const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
989
- const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
990
- if (!parsedOff.success || !parsedExt.success) diagnostics.push({
991
- code: "invalid-xml-value",
992
- category: "corrupt-input",
993
- disposition: "recovered",
994
- location: {
995
- ...location,
996
- xpath: xfrm.xpath
997
- },
998
- attributeOrElement: "a:xfrm"
999
- });
1000
- else {
1001
- fallbackUnits = {
1002
- w: parsedExt.data.cx,
1003
- h: parsedExt.data.cy
1004
- };
1005
- localBox = {
1006
- x: emuToPx(parsedOff.data.x),
1007
- y: emuToPx(parsedOff.data.y),
1008
- width: emuToPx(parsedExt.data.cx),
1009
- height: emuToPx(parsedExt.data.cy)
1010
- };
1011
- }
1012
- }
1013
- }
1014
- const claim = resolvePlaceholderImportClaim({
1015
- context,
1016
- nativeRef,
1017
- compatibleRoles: textCompatiblePlaceholderRoles,
1018
- allowMasterDirectFallback: true
1019
- });
1020
- const layoutPlaceholder = claim.layoutPlaceholder;
1021
- const masterPlaceholder = claim.masterPlaceholder;
1022
- const layoutPhWidth = typeof layoutPlaceholder?.style?.width === "number" ? layoutPlaceholder.style.width : void 0;
1023
- const layoutPhHeight = typeof layoutPlaceholder?.style?.height === "number" ? layoutPlaceholder.style.height : void 0;
1024
- const masterPhWidth = typeof masterPlaceholder?.style?.width === "number" ? masterPlaceholder.style.width : void 0;
1025
- const masterPhHeight = typeof masterPlaceholder?.style?.height === "number" ? masterPlaceholder.style.height : void 0;
1026
- const inheritedWidth = layoutPhWidth ?? masterPhWidth;
1027
- const inheritedHeight = layoutPhHeight ?? masterPhHeight;
1028
- const inheritedPlaceholderBox = inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
1029
- width: inheritedWidth,
1030
- height: inheritedHeight
1031
- } : void 0;
1032
- const effectiveFallbackUnits = localBox === void 0 && inheritedPlaceholderBox !== void 0 ? {
1033
- w: Math.round(inheritedPlaceholderBox.width * EMU_PER_PX),
1034
- h: Math.round(inheritedPlaceholderBox.height * EMU_PER_PX)
1035
- } : fallbackUnits;
1036
- const appearance = readSpPrAppearance(spPr, pkg, effectiveFallbackUnits, location, diagnostics, { preservePlaceholderClears: true });
1037
- const visualStyle = textBoxVisualStyle(appearance.style, appearance.borderArrows, appearance.geometry, localBox ?? inheritedPlaceholderBox, rotate, location, diagnostics);
1038
- const txBody = cursor.child(P_NS, "txBody");
1039
- const imported = txBody === void 0 ? void 0 : readRichTextBody(txBody, part, slideIndex, diagnostics, void 0, { allowShadowNone: true });
1040
- if (!claim.bound) {
1041
- const resolvedBox = resolveUnboundPlaceholderBox({
1042
- inheritanceContext: claim.inheritanceContext,
1043
- ...localBox === void 0 ? {} : { localBox },
1044
- requireHeight: false
1045
- });
1046
- if (resolvedBox === void 0) {
1047
- diagnostics.push({
1048
- code: "unsupported-mechanism",
1049
- category: "unsupported",
1050
- disposition: "omitted",
1051
- location: {
1052
- ...location,
1053
- xpath: cursor.xpath
1054
- },
1055
- namespaceUri: P_NS,
1056
- localName: "ph",
1057
- mechanismHint: "orphan-placeholder-without-box"
1058
- });
1059
- return { diagnostics };
1060
- }
1061
- const freeVisualStyle = materializeUnboundVisualStyle({
1062
- inheritanceContext: claim.inheritanceContext,
1063
- localVisualStyle: {
1064
- ...visualStyle,
1065
- ...flipH === void 0 ? {} : { flipH },
1066
- ...flipV === void 0 ? {} : { flipV }
1067
- },
1068
- ...appearance.geometry === void 0 ? {} : { localGeometry: appearance.geometry },
1069
- boxSize: {
1070
- width: resolvedBox.width,
1071
- height: resolvedBox.height ?? 100
1072
- }
1073
- });
1074
- const baseTextStyle = stripPlaceholderClearSentinels({ ...resolvePlaceholderBaseTextStyle(claim.inheritanceContext, imported?.boxStyle) });
1075
- const pickParagraphStyle = (source) => {
1076
- const picked = {};
1077
- for (const [k, v] of Object.entries(source)) if (v !== void 0 && paragraphStyleKeys.has(k)) picked[k] = v;
1078
- const cleaned = stripPlaceholderClearSentinels(picked);
1079
- const parsed = paragraphStyleSchema.safeParse(cleaned);
1080
- return parsed.success ? parsed.data : {};
1081
- };
1082
- const importedParagraphs = imported?.importedParagraphs ?? [];
1083
- const p0 = importedParagraphs.length === 1 ? importedParagraphs[0] : void 0;
1084
- const p0LevelRaw = p0 === void 0 ? void 0 : resolvePlaceholderLevelTextStyle(claim.inheritanceContext, p0.level0 ?? 0, p0.style);
1085
- const p0Level = p0LevelRaw !== void 0 && p0?.buNone ? {
1086
- ...p0LevelRaw,
1087
- list: void 0
1088
- } : p0LevelRaw;
1089
- let freeSingleText;
1090
- let freeParagraphs;
1091
- let extraFlatStyle = {};
1092
- const singlePlainRun = p0 !== void 0 && p0.runs.length === 1 && p0.runs[0].kind === "text" && p0.runs[0].style.baselineShift === void 0 ? p0.runs[0] : void 0;
1093
- if (p0 !== void 0 && singlePlainRun !== void 0 && p0Level?.list === void 0) {
1094
- const { baselineShift: _b, ...runRest } = singlePlainRun.style;
1095
- extraFlatStyle = {
1096
- ...pickParagraphStyle(p0Level ?? {}),
1097
- ...runRest
1098
- };
1099
- freeSingleText = singlePlainRun.text;
1100
- } else if (p0 !== void 0 && p0.runs.length === 0 && p0Level?.list === void 0) extraFlatStyle = pickParagraphStyle(p0Level ?? {});
1101
- else if (importedParagraphs.length > 0) freeParagraphs = importedParagraphs.map((para) => {
1102
- const rawLvl = resolvePlaceholderLevelTextStyle(claim.inheritanceContext, para.level0 ?? 0, para.style);
1103
- const lvl = para.buNone ? {
1104
- ...rawLvl,
1105
- list: void 0
1106
- } : rawLvl;
1107
- return {
1108
- runs: para.runs,
1109
- style: pickParagraphStyle(lvl)
1110
- };
1111
- });
1112
- const combinedFreeStyle = stripPlaceholderClearSentinels({
1113
- ...baseTextStyle,
1114
- ...extraFlatStyle,
1115
- ...freeVisualStyle,
1116
- position: "absolute",
1117
- left: resolvedBox.x,
1118
- top: resolvedBox.y,
1119
- width: resolvedBox.width,
1120
- ...resolvedBox.height === void 0 ? {} : { height: resolvedBox.height }
1121
- });
1122
- const parsedFreeStyle = textBoxStyleSchema.safeParse(combinedFreeStyle);
1123
- let validatedFreeStyle;
1124
- if (parsedFreeStyle.success) validatedFreeStyle = parsedFreeStyle.data;
1125
- else {
1126
- diagnostics.push({
1127
- code: "invalid-xml-value",
1128
- category: "corrupt-input",
1129
- disposition: "recovered",
1130
- location: {
1131
- ...location,
1132
- xpath: cursor.xpath
1133
- },
1134
- attributeOrElement: "p:sp",
1135
- rawValue: parsedFreeStyle.error.issues[0]?.message ?? "invalid style"
1136
- });
1137
- validatedFreeStyle = {
1138
- position: "absolute",
1139
- left: resolvedBox.x,
1140
- top: resolvedBox.y,
1141
- width: resolvedBox.width,
1142
- ...resolvedBox.height === void 0 ? {} : { height: resolvedBox.height }
1143
- };
1144
- }
1145
- const freeNode = createTextNode({
1146
- ...objectName === void 0 ? {} : { name: objectName },
1147
- ...link === void 0 ? {} : { link },
1148
- style: validatedFreeStyle
1149
- });
1150
- if (freeSingleText !== void 0) freeNode.content(freeSingleText);
1151
- else if (freeParagraphs !== void 0) populateRichTextNode(freeNode, freeParagraphs);
1152
- attachDeferredSlideLink(freeNode, deferredSlideLink, context);
1153
- emitPlaceholderUnbindDiagnostic({
1154
- diagnostics,
1155
- location: {
1156
- ...location,
1157
- xpath: cursor.xpath
1158
- },
1159
- retainedAs: "text"
1160
- });
1161
- return {
1162
- node: freeNode,
1163
- diagnostics
1164
- };
1165
- }
1166
- const matchedKey = claim.key;
1167
- const { boxStyle, singleText, paragraphsToPopulate } = flattenImportedTextBody(imported, visualStyle);
1168
- const combinedStyle = {
1169
- ...localBox === void 0 ? {} : {
1170
- position: "absolute",
1171
- left: localBox.x,
1172
- top: localBox.y,
1173
- width: localBox.width,
1174
- height: localBox.height
1175
- },
1176
- ...flipH === void 0 ? {} : { flipH },
1177
- ...flipV === void 0 ? {} : { flipV },
1178
- ...boxStyle
1179
- };
1180
- let validatedStyle;
1181
- if (Object.keys(combinedStyle).length > 0) {
1182
- const parsedStyle = placeholderStyleSchema.safeParse(combinedStyle);
1183
- if (parsedStyle.success) validatedStyle = parsedStyle.data;
1184
- else diagnostics.push({
1185
- code: "invalid-xml-value",
1186
- category: "corrupt-input",
1187
- disposition: "recovered",
1188
- location: {
1189
- ...location,
1190
- xpath: cursor.xpath
1191
- },
1192
- attributeOrElement: "p:sp",
1193
- rawValue: parsedStyle.error.issues[0]?.message ?? "invalid style"
1194
- });
1195
- }
1196
- const props = {
1197
- ...objectName === void 0 ? {} : { name: objectName },
1198
- ...link === void 0 ? {} : { link },
1199
- ...matchedKey === void 0 ? {} : { placeholder: matchedKey },
1200
- nativePlaceholder: nativeRef,
1201
- ...validatedStyle === void 0 ? {} : { style: validatedStyle }
1202
- };
1203
- const node = createTextNode(props);
1204
- if (singleText !== void 0) node.content(singleText);
1205
- else if (paragraphsToPopulate !== void 0) populateRichTextNode(node, paragraphsToPopulate);
1206
- attachDeferredSlideLink(node, deferredSlideLink, context);
1207
- return {
1208
- node,
1209
- diagnostics
1210
- };
1211
- }
1212
- const textBoxImportHandler = {
1213
- target: "shape-tree",
1214
- localName: "sp",
1215
- matches: (cursor) => isTextBoxSpElement(cursor) && !isPlaceholderSpElement(cursor),
1216
- read: readTextBoxSp
1217
- };
1218
- const textPlaceholderImportHandler = {
1219
- target: "shape-tree",
1220
- localName: "sp",
1221
- matches: isTextPlaceholderSpElement,
1222
- read: readTextPlaceholderSp
1223
- };
1224
- export { isPlaceholderSpElement, isTextPlaceholderSpElement, populateRichTextNode, readRichTextBody, readTextBoxSp, readTextPlaceholderSp, textBoxImportHandler, textFieldSlideNumImportHandler, textPlaceholderImportHandler };