@portone/docx-editor 0.1.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.
Files changed (347) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/CONTRIBUTING.md +63 -0
  3. package/LICENSE +203 -0
  4. package/README.md +48 -0
  5. package/assets/editor.png +0 -0
  6. package/dist/DocxEditor.d.ts +123 -0
  7. package/dist/DocxEditor.js +348 -0
  8. package/dist/core.d.ts +36 -0
  9. package/dist/core.js +38 -0
  10. package/dist/docx/comments/constants.d.ts +8 -0
  11. package/dist/docx/comments/constants.js +20 -0
  12. package/dist/docx/comments/model.d.ts +37 -0
  13. package/dist/docx/comments/model.js +104 -0
  14. package/dist/docx/comments/reading.d.ts +36 -0
  15. package/dist/docx/comments/reading.js +149 -0
  16. package/dist/docx/comments/writing.d.ts +11 -0
  17. package/dist/docx/comments/writing.js +327 -0
  18. package/dist/docx/comments.d.ts +3 -0
  19. package/dist/docx/comments.js +4 -0
  20. package/dist/docx/container.d.ts +12 -0
  21. package/dist/docx/container.js +130 -0
  22. package/dist/docx/documentSettings.d.ts +4 -0
  23. package/dist/docx/documentSettings.js +14 -0
  24. package/dist/docx/exportDocx.d.ts +15 -0
  25. package/dist/docx/exportDocx.js +163 -0
  26. package/dist/docx/exportRefs.d.ts +16 -0
  27. package/dist/docx/exportRefs.js +10 -0
  28. package/dist/docx/formatting/direct.d.ts +30 -0
  29. package/dist/docx/formatting/direct.js +201 -0
  30. package/dist/docx/formatting/effectiveParagraph.d.ts +15 -0
  31. package/dist/docx/formatting/effectiveParagraph.js +81 -0
  32. package/dist/docx/formatting/styles.d.ts +67 -0
  33. package/dist/docx/formatting/styles.js +165 -0
  34. package/dist/docx/formatting/tabStops.d.ts +8 -0
  35. package/dist/docx/formatting/tabStops.js +65 -0
  36. package/dist/docx/formatting.d.ts +4 -0
  37. package/dist/docx/formatting.js +4 -0
  38. package/dist/docx/headersFooters.d.ts +36 -0
  39. package/dist/docx/headersFooters.js +218 -0
  40. package/dist/docx/hyperlink.d.ts +75 -0
  41. package/dist/docx/hyperlink.js +71 -0
  42. package/dist/docx/importDocx.d.ts +21 -0
  43. package/dist/docx/importDocx.js +263 -0
  44. package/dist/docx/importParagraph.d.ts +32 -0
  45. package/dist/docx/importParagraph.js +308 -0
  46. package/dist/docx/importTable.d.ts +9 -0
  47. package/dist/docx/importTable.js +275 -0
  48. package/dist/docx/media.d.ts +60 -0
  49. package/dist/docx/media.js +213 -0
  50. package/dist/docx/notes.d.ts +22 -0
  51. package/dist/docx/notes.js +71 -0
  52. package/dist/docx/pageGeometry.d.ts +75 -0
  53. package/dist/docx/pageGeometry.js +88 -0
  54. package/dist/docx/paraProps.d.ts +74 -0
  55. package/dist/docx/paraProps.js +167 -0
  56. package/dist/docx/propsXml.d.ts +49 -0
  57. package/dist/docx/propsXml.js +302 -0
  58. package/dist/docx/relationships.d.ts +42 -0
  59. package/dist/docx/relationships.js +94 -0
  60. package/dist/docx/runProps.d.ts +51 -0
  61. package/dist/docx/runProps.js +207 -0
  62. package/dist/docx/scan.d.ts +20 -0
  63. package/dist/docx/scan.js +110 -0
  64. package/dist/docx/sdt.d.ts +56 -0
  65. package/dist/docx/sdt.js +104 -0
  66. package/dist/docx/sdtProps.d.ts +18 -0
  67. package/dist/docx/sdtProps.js +11 -0
  68. package/dist/docx/serializeBlock.d.ts +4 -0
  69. package/dist/docx/serializeBlock.js +30 -0
  70. package/dist/docx/serializeParagraph.d.ts +15 -0
  71. package/dist/docx/serializeParagraph.js +208 -0
  72. package/dist/docx/serializeTable.d.ts +12 -0
  73. package/dist/docx/serializeTable.js +134 -0
  74. package/dist/docx/session.d.ts +81 -0
  75. package/dist/docx/session.js +79 -0
  76. package/dist/docx/tableFormatting/editing.d.ts +64 -0
  77. package/dist/docx/tableFormatting/editing.js +318 -0
  78. package/dist/docx/tableFormatting/reading.d.ts +96 -0
  79. package/dist/docx/tableFormatting/reading.js +221 -0
  80. package/dist/docx/tableFormatting.d.ts +2 -0
  81. package/dist/docx/tableFormatting.js +3 -0
  82. package/dist/docx/tableTemplate.d.ts +22 -0
  83. package/dist/docx/tableTemplate.js +111 -0
  84. package/dist/docx/theme.d.ts +40 -0
  85. package/dist/docx/theme.js +61 -0
  86. package/dist/docx/uniqueControls.d.ts +14 -0
  87. package/dist/docx/uniqueControls.js +62 -0
  88. package/dist/download.d.ts +57 -0
  89. package/dist/download.js +44 -0
  90. package/dist/editor/clipboard/images.d.ts +14 -0
  91. package/dist/editor/clipboard/images.js +158 -0
  92. package/dist/editor/clipboard/inlineFormatting.d.ts +21 -0
  93. package/dist/editor/clipboard/inlineFormatting.js +232 -0
  94. package/dist/editor/commands/breakCommands.d.ts +8 -0
  95. package/dist/editor/commands/breakCommands.js +19 -0
  96. package/dist/editor/commands/canRunCommand.d.ts +6 -0
  97. package/dist/editor/commands/canRunCommand.js +10 -0
  98. package/dist/editor/commands/commentCommands.d.ts +3 -0
  99. package/dist/editor/commands/commentCommands.js +4 -0
  100. package/dist/editor/commands/comments/editing.d.ts +21 -0
  101. package/dist/editor/commands/comments/editing.js +305 -0
  102. package/dist/editor/commands/comments/model.d.ts +31 -0
  103. package/dist/editor/commands/comments/model.js +0 -0
  104. package/dist/editor/commands/comments/reading.d.ts +8 -0
  105. package/dist/editor/commands/comments/reading.js +58 -0
  106. package/dist/editor/commands/formatting/editing.d.ts +32 -0
  107. package/dist/editor/commands/formatting/editing.js +138 -0
  108. package/dist/editor/commands/formatting/reading.d.ts +57 -0
  109. package/dist/editor/commands/formatting/reading.js +82 -0
  110. package/dist/editor/commands/formatting/shared.d.ts +32 -0
  111. package/dist/editor/commands/formatting/shared.js +53 -0
  112. package/dist/editor/commands/formattingCommands.d.ts +2 -0
  113. package/dist/editor/commands/formattingCommands.js +3 -0
  114. package/dist/editor/commands/historyCommands.d.ts +11 -0
  115. package/dist/editor/commands/historyCommands.js +16 -0
  116. package/dist/editor/commands/indentCommands.d.ts +15 -0
  117. package/dist/editor/commands/indentCommands.js +44 -0
  118. package/dist/editor/commands/index.d.ts +82 -0
  119. package/dist/editor/commands/index.js +171 -0
  120. package/dist/editor/commands/linkCommands.d.ts +56 -0
  121. package/dist/editor/commands/linkCommands.js +146 -0
  122. package/dist/editor/commands/listCommands.d.ts +58 -0
  123. package/dist/editor/commands/listCommands.js +140 -0
  124. package/dist/editor/commands/lockCommands.d.ts +47 -0
  125. package/dist/editor/commands/lockCommands.js +198 -0
  126. package/dist/editor/commands/noteQueries.d.ts +12 -0
  127. package/dist/editor/commands/noteQueries.js +29 -0
  128. package/dist/editor/commands/paragraphCommands.d.ts +59 -0
  129. package/dist/editor/commands/paragraphCommands.js +113 -0
  130. package/dist/editor/commands/spacingCommands.d.ts +23 -0
  131. package/dist/editor/commands/spacingCommands.js +48 -0
  132. package/dist/editor/commands/tabCommands.d.ts +5 -0
  133. package/dist/editor/commands/tabCommands.js +65 -0
  134. package/dist/editor/createEditor.d.ts +59 -0
  135. package/dist/editor/createEditor.js +160 -0
  136. package/dist/editor/documentStyles.d.ts +60 -0
  137. package/dist/editor/documentStyles.js +80 -0
  138. package/dist/editor/externalClipboard.d.ts +11 -0
  139. package/dist/editor/externalClipboard.js +323 -0
  140. package/dist/editor/imageFiles.d.ts +74 -0
  141. package/dist/editor/imageFiles.js +173 -0
  142. package/dist/editor/insertImage.d.ts +31 -0
  143. package/dist/editor/insertImage.js +35 -0
  144. package/dist/editor/insertTable.d.ts +18 -0
  145. package/dist/editor/insertTable.js +44 -0
  146. package/dist/editor/paragraphEdits.d.ts +42 -0
  147. package/dist/editor/paragraphEdits.js +59 -0
  148. package/dist/editor/plainText.d.ts +3 -0
  149. package/dist/editor/plainText.js +50 -0
  150. package/dist/editor/plugins/bookmarkProtection.d.ts +3 -0
  151. package/dist/editor/plugins/bookmarkProtection.js +28 -0
  152. package/dist/editor/plugins/columnResize.d.ts +27 -0
  153. package/dist/editor/plugins/columnResize.js +192 -0
  154. package/dist/editor/plugins/commentDecorations.d.ts +3 -0
  155. package/dist/editor/plugins/commentDecorations.js +23 -0
  156. package/dist/editor/plugins/commentReservations.d.ts +5 -0
  157. package/dist/editor/plugins/commentReservations.js +26 -0
  158. package/dist/editor/plugins/dropCaret.d.ts +10 -0
  159. package/dist/editor/plugins/dropCaret.js +11 -0
  160. package/dist/editor/plugins/imagePaste.d.ts +8 -0
  161. package/dist/editor/plugins/imagePaste.js +265 -0
  162. package/dist/editor/plugins/keymap.d.ts +5 -0
  163. package/dist/editor/plugins/keymap.js +94 -0
  164. package/dist/editor/plugins/linkPanel.d.ts +23 -0
  165. package/dist/editor/plugins/linkPanel.js +39 -0
  166. package/dist/editor/plugins/listInputRules.d.ts +14 -0
  167. package/dist/editor/plugins/listInputRules.js +36 -0
  168. package/dist/editor/plugins/lockedContent.d.ts +6 -0
  169. package/dist/editor/plugins/lockedContent.js +41 -0
  170. package/dist/editor/plugins/noteProtection.d.ts +3 -0
  171. package/dist/editor/plugins/noteProtection.js +25 -0
  172. package/dist/editor/plugins/numberingDecorations.d.ts +42 -0
  173. package/dist/editor/plugins/numberingDecorations.js +110 -0
  174. package/dist/editor/plugins/rowResize.d.ts +15 -0
  175. package/dist/editor/plugins/rowResize.js +196 -0
  176. package/dist/editor/plugins/styledParagraphs.d.ts +15 -0
  177. package/dist/editor/plugins/styledParagraphs.js +65 -0
  178. package/dist/editor/plugins/tabCaret.d.ts +3 -0
  179. package/dist/editor/plugins/tabCaret.js +126 -0
  180. package/dist/editor/plugins/tabDecorations.d.ts +11 -0
  181. package/dist/editor/plugins/tabDecorations.js +87 -0
  182. package/dist/editor/plugins/tabLayout.d.ts +16 -0
  183. package/dist/editor/plugins/tabLayout.js +328 -0
  184. package/dist/editor/plugins/tabPointer.d.ts +7 -0
  185. package/dist/editor/plugins/tabPointer.js +95 -0
  186. package/dist/editor/plugins/tableContextMenu.d.ts +21 -0
  187. package/dist/editor/plugins/tableContextMenu.js +88 -0
  188. package/dist/editor/plugins/textContextMenu.d.ts +15 -0
  189. package/dist/editor/plugins/textContextMenu.js +90 -0
  190. package/dist/editor/views/imageResize.d.ts +53 -0
  191. package/dist/editor/views/imageResize.js +167 -0
  192. package/dist/editor/views/runMarkView.d.ts +15 -0
  193. package/dist/editor/views/runMarkView.js +9 -0
  194. package/dist/editor/views/tableView.d.ts +24 -0
  195. package/dist/editor/views/tableView.js +32 -0
  196. package/dist/index.d.ts +44 -0
  197. package/dist/index.js +38 -0
  198. package/dist/model/format.d.ts +240 -0
  199. package/dist/model/format.js +305 -0
  200. package/dist/model/tabStops.d.ts +17 -0
  201. package/dist/model/tabStops.js +22 -0
  202. package/dist/numbering/listTemplate.d.ts +29 -0
  203. package/dist/numbering/listTemplate.js +83 -0
  204. package/dist/numbering/markers.d.ts +24 -0
  205. package/dist/numbering/markers.js +93 -0
  206. package/dist/numbering/parseNumbering.d.ts +65 -0
  207. package/dist/numbering/parseNumbering.js +116 -0
  208. package/dist/numbering/writeNumbering.d.ts +13 -0
  209. package/dist/numbering/writeNumbering.js +49 -0
  210. package/dist/ooxml/errors.d.ts +39 -0
  211. package/dist/ooxml/errors.js +21 -0
  212. package/dist/ooxml/image.d.ts +88 -0
  213. package/dist/ooxml/image.js +106 -0
  214. package/dist/ooxml/tabStops.d.ts +3 -0
  215. package/dist/ooxml/tabStops.js +51 -0
  216. package/dist/ooxml/units.d.ts +37 -0
  217. package/dist/ooxml/units.js +116 -0
  218. package/dist/ooxml/xml.d.ts +36 -0
  219. package/dist/ooxml/xml.js +89 -0
  220. package/dist/page/PageGuides.d.ts +16 -0
  221. package/dist/page/PageGuides.js +114 -0
  222. package/dist/page/measureBlocks.d.ts +25 -0
  223. package/dist/page/measureBlocks.js +80 -0
  224. package/dist/page/pageDecorations.d.ts +36 -0
  225. package/dist/page/pageDecorations.js +211 -0
  226. package/dist/page/pageLayout.d.ts +176 -0
  227. package/dist/page/pageLayout.js +157 -0
  228. package/dist/page/tableMeasurements.d.ts +10 -0
  229. package/dist/page/tableMeasurements.js +115 -0
  230. package/dist/page/usePageLayout.d.ts +57 -0
  231. package/dist/page/usePageLayout.js +141 -0
  232. package/dist/schema/docxSchema.d.ts +9 -0
  233. package/dist/schema/docxSchema.js +863 -0
  234. package/dist/schema/index.d.ts +2 -0
  235. package/dist/schema/index.js +9 -0
  236. package/dist/schema/locks.d.ts +112 -0
  237. package/dist/schema/locks.js +211 -0
  238. package/dist/schema/rendering.d.ts +6 -0
  239. package/dist/schema/rendering.js +46 -0
  240. package/dist/styles/classNames.d.ts +214 -0
  241. package/dist/styles/classNames.js +208 -0
  242. package/dist/styles/colors.d.ts +11 -0
  243. package/dist/styles/colors.js +14 -0
  244. package/dist/styles/fontSizes.d.ts +6 -0
  245. package/dist/styles/fontSizes.js +20 -0
  246. package/dist/styles/fontStack.d.ts +55 -0
  247. package/dist/styles/fontStack.js +262 -0
  248. package/dist/styles/fonts.d.ts +6 -0
  249. package/dist/styles/fonts.js +11 -0
  250. package/dist/styles/inlineStyle.d.ts +67 -0
  251. package/dist/styles/inlineStyle.js +212 -0
  252. package/dist/styles/lineSpacings.d.ts +11 -0
  253. package/dist/styles/lineSpacings.js +10 -0
  254. package/dist/styles.css +1650 -0
  255. package/dist/table/cellBorders.d.ts +12 -0
  256. package/dist/table/cellBorders.js +9 -0
  257. package/dist/table/cellFormatting.d.ts +57 -0
  258. package/dist/table/cellFormatting.js +173 -0
  259. package/dist/table/columns.d.ts +25 -0
  260. package/dist/table/columns.js +155 -0
  261. package/dist/table/commands.d.ts +19 -0
  262. package/dist/table/commands.js +63 -0
  263. package/dist/table/format.d.ts +35 -0
  264. package/dist/table/format.js +26 -0
  265. package/dist/table/gridBorders.d.ts +42 -0
  266. package/dist/table/gridBorders.js +192 -0
  267. package/dist/table/index.d.ts +16 -0
  268. package/dist/table/index.js +52 -0
  269. package/dist/table/merge.d.ts +36 -0
  270. package/dist/table/merge.js +125 -0
  271. package/dist/table/resize.d.ts +55 -0
  272. package/dist/table/resize.js +66 -0
  273. package/dist/table/rowResize.d.ts +14 -0
  274. package/dist/table/rowResize.js +44 -0
  275. package/dist/table/rows.d.ts +32 -0
  276. package/dist/table/rows.js +89 -0
  277. package/dist/table/widths.d.ts +69 -0
  278. package/dist/table/widths.js +97 -0
  279. package/dist/ui/AlignMenu.d.ts +15 -0
  280. package/dist/ui/AlignMenu.js +64 -0
  281. package/dist/ui/CellStyleGroup.d.ts +15 -0
  282. package/dist/ui/CellStyleGroup.js +232 -0
  283. package/dist/ui/ColorPicker.d.ts +13 -0
  284. package/dist/ui/ColorPicker.js +165 -0
  285. package/dist/ui/CommentsPanel.d.ts +15 -0
  286. package/dist/ui/CommentsPanel.js +348 -0
  287. package/dist/ui/FontFamilySelect.d.ts +14 -0
  288. package/dist/ui/FontFamilySelect.js +59 -0
  289. package/dist/ui/FontSizeSelect.d.ts +11 -0
  290. package/dist/ui/FontSizeSelect.js +49 -0
  291. package/dist/ui/InsertImageButton.d.ts +9 -0
  292. package/dist/ui/InsertImageButton.js +47 -0
  293. package/dist/ui/LinkCard.d.ts +12 -0
  294. package/dist/ui/LinkCard.js +127 -0
  295. package/dist/ui/LinkPanel.d.ts +9 -0
  296. package/dist/ui/LinkPanel.js +121 -0
  297. package/dist/ui/MenuChoice.d.ts +11 -0
  298. package/dist/ui/MenuChoice.js +32 -0
  299. package/dist/ui/NotesPanel.d.ts +6 -0
  300. package/dist/ui/NotesPanel.js +33 -0
  301. package/dist/ui/ParagraphStyleSelect.d.ts +11 -0
  302. package/dist/ui/ParagraphStyleSelect.js +62 -0
  303. package/dist/ui/Popover.d.ts +22 -0
  304. package/dist/ui/Popover.js +74 -0
  305. package/dist/ui/SpacingMenu.d.ts +12 -0
  306. package/dist/ui/SpacingMenu.js +54 -0
  307. package/dist/ui/TableMenu.d.ts +12 -0
  308. package/dist/ui/TableMenu.js +112 -0
  309. package/dist/ui/TableSizePicker.d.ts +9 -0
  310. package/dist/ui/TableSizePicker.js +53 -0
  311. package/dist/ui/TextMenu.d.ts +15 -0
  312. package/dist/ui/TextMenu.js +194 -0
  313. package/dist/ui/Toolbar.d.ts +19 -0
  314. package/dist/ui/Toolbar.js +448 -0
  315. package/dist/ui/ToolbarButton.d.ts +23 -0
  316. package/dist/ui/ToolbarButton.js +56 -0
  317. package/dist/ui/Tooltip.d.ts +19 -0
  318. package/dist/ui/Tooltip.js +47 -0
  319. package/dist/ui/ZoomSelect.d.ts +7 -0
  320. package/dist/ui/ZoomSelect.js +44 -0
  321. package/dist/ui/comments/CommentComposer.d.ts +17 -0
  322. package/dist/ui/comments/CommentComposer.js +59 -0
  323. package/dist/ui/comments/useCommentRailLayout.d.ts +18 -0
  324. package/dist/ui/comments/useCommentRailLayout.js +183 -0
  325. package/dist/ui/keyboardWalk.d.ts +22 -0
  326. package/dist/ui/keyboardWalk.js +70 -0
  327. package/dist/ui/openAddress.d.ts +11 -0
  328. package/dist/ui/openAddress.js +16 -0
  329. package/dist/ui/panelPlacement.d.ts +51 -0
  330. package/dist/ui/panelPlacement.js +71 -0
  331. package/dist/ui/presets.d.ts +11 -0
  332. package/dist/ui/presets.js +0 -0
  333. package/dist/ui/rovingFocus.d.ts +20 -0
  334. package/dist/ui/rovingFocus.js +61 -0
  335. package/dist/ui/runCommand.d.ts +5 -0
  336. package/dist/ui/runCommand.js +13 -0
  337. package/dist/ui/useDismiss.d.ts +6 -0
  338. package/dist/ui/useDismiss.js +31 -0
  339. package/dist/ui/useFitWidthZoom.d.ts +2 -0
  340. package/dist/ui/useFitWidthZoom.js +26 -0
  341. package/dist/ui/useGridKeyboard.d.ts +12 -0
  342. package/dist/ui/useGridKeyboard.js +90 -0
  343. package/dist/ui/useMenuKeyboard.d.ts +12 -0
  344. package/dist/ui/useMenuKeyboard.js +56 -0
  345. package/dist/ui/zoom.d.ts +4 -0
  346. package/dist/ui/zoom.js +21 -0
  347. package/package.json +120 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Image node view with aspect-ratio-locked corner resizing. Dragging previews in the DOM and
3
+ * commits one EMU transaction on release so undo history receives a single step.
4
+ */
5
+ import { type Node as PMNode } from "prosemirror-model";
6
+ import type { EditorState, Transaction } from "prosemirror-state";
7
+ import type { EditorView, NodeView } from "prosemirror-view";
8
+ /** The corners an image can be grabbed by */
9
+ declare const CORNERS: readonly ["nw", "ne", "sw", "se"];
10
+ export type ImageCorner = (typeof CORNERS)[number];
11
+ /** A size on screen, in pixels */
12
+ export interface ImageSizePx {
13
+ width: number;
14
+ height: number;
15
+ }
16
+ /**
17
+ * The size a corner drag asks for, with the ratio locked.
18
+ *
19
+ * The two distances are turned into relative ones and averaged into a single scale. That
20
+ * way a drag along the image's own diagonal follows the pointer exactly, and a drag along
21
+ * one axis alone still resizes.
22
+ */
23
+ export declare function resizedImagePx(start: ImageSizePx, corner: ImageCorner, dx: number, dy: number): ImageSizePx;
24
+ /**
25
+ * Records a new display size on the image at this position.
26
+ * Null when there is no image there, or when the size is the one it already holds, so a
27
+ * drag that moved nothing leaves no step in the history.
28
+ */
29
+ export declare function buildResizeImageTransaction(state: EditorState, pos: number, size: ImageSizePx): Transaction | null;
30
+ export declare class ImageNodeView implements NodeView {
31
+ readonly dom: HTMLElement;
32
+ private readonly view;
33
+ private readonly getPos;
34
+ private readonly img;
35
+ private node;
36
+ private drag;
37
+ constructor(node: PMNode, view: EditorView, getPos: () => number | undefined);
38
+ update(node: PMNode): boolean;
39
+ /** Only an editable image shows its handles: there is nothing to drag in a read-only document */
40
+ selectNode(): void;
41
+ deselectNode(): void;
42
+ /** A press on a handle is ours alone. It must not move the selection or start a drag of the image */
43
+ stopEvent(event: Event): boolean;
44
+ destroy(): void;
45
+ /** The size the image stands at now: the one the document records, or the drawn size when it records none */
46
+ private currentSizePx;
47
+ private readonly onMouseDown;
48
+ private readonly onMove;
49
+ private readonly onUp;
50
+ private readonly onKey;
51
+ private stopDrag;
52
+ }
53
+ export {};
@@ -0,0 +1,167 @@
1
+ // src/editor/views/imageResize.ts
2
+ import { DOMSerializer } from "prosemirror-model";
3
+ import { emuToPx, pxToEmu, toImageExtent } from "../../ooxml/image.js";
4
+ import { docxSchema, imageNodeSpec } from "../../schema/index.js";
5
+ import { editorAttributes, editorClassNames } from "../../styles/classNames.js";
6
+ var CORNERS = ["nw", "ne", "sw", "se"];
7
+ var MIN_IMAGE_PX = 16;
8
+ function resizedImagePx(start, corner, dx, dy) {
9
+ const sideways = (corner === "ne" || corner === "se" ? dx : -dx) / start.width;
10
+ const downward = (corner === "sw" || corner === "se" ? dy : -dy) / start.height;
11
+ const scale = Math.max(
12
+ 1 + (sideways + downward) / 2,
13
+ MIN_IMAGE_PX / start.width,
14
+ MIN_IMAGE_PX / start.height
15
+ );
16
+ return {
17
+ width: Math.round(start.width * scale),
18
+ height: Math.round(start.height * scale)
19
+ };
20
+ }
21
+ function buildResizeImageTransaction(state, pos, size) {
22
+ const node = state.doc.nodeAt(pos);
23
+ if (node?.type !== docxSchema.nodes.image) return null;
24
+ const extent = { cx: pxToEmu(size.width), cy: pxToEmu(size.height) };
25
+ const current = toImageExtent(node.attrs.extent);
26
+ if (current?.cx === extent.cx && current.cy === extent.cy) return null;
27
+ return state.tr.setNodeMarkup(pos, void 0, { ...node.attrs, extent });
28
+ }
29
+ function renderImage(node) {
30
+ const { dom } = DOMSerializer.renderSpec(document, imageNodeSpec(node.attrs));
31
+ if (!(dom instanceof HTMLImageElement)) {
32
+ throw new Error("the image was not rendered as an img element");
33
+ }
34
+ return dom;
35
+ }
36
+ function syncAttributes(img, node) {
37
+ const next = renderImage(node);
38
+ for (const name of img.getAttributeNames()) {
39
+ if (!next.hasAttribute(name)) img.removeAttribute(name);
40
+ }
41
+ for (const name of next.getAttributeNames()) {
42
+ const value = next.getAttribute(name) ?? "";
43
+ if (img.getAttribute(name) !== value) img.setAttribute(name, value);
44
+ }
45
+ }
46
+ function handleElement(corner) {
47
+ const handle = document.createElement("span");
48
+ handle.className = editorClassNames.imageHandle;
49
+ handle.setAttribute(editorAttributes.imageCorner, corner);
50
+ return handle;
51
+ }
52
+ function cornerAt(target) {
53
+ const element = target instanceof Element ? target : null;
54
+ const corner = element?.getAttribute(editorAttributes.imageCorner);
55
+ return CORNERS.find((one) => one === corner) ?? null;
56
+ }
57
+ function showSize(img, size) {
58
+ img.width = size.width;
59
+ img.height = size.height;
60
+ }
61
+ var ImageNodeView = class {
62
+ dom;
63
+ view;
64
+ getPos;
65
+ img;
66
+ node;
67
+ drag = null;
68
+ constructor(node, view, getPos) {
69
+ this.node = node;
70
+ this.view = view;
71
+ this.getPos = getPos;
72
+ this.img = renderImage(node);
73
+ this.dom = document.createElement("span");
74
+ this.dom.className = editorClassNames.imageBox;
75
+ this.dom.append(this.img, ...CORNERS.map(handleElement));
76
+ this.dom.addEventListener("mousedown", this.onMouseDown);
77
+ }
78
+ update(node) {
79
+ if (node.type !== this.node.type) return false;
80
+ this.node = node;
81
+ syncAttributes(this.img, node);
82
+ return true;
83
+ }
84
+ /** Only an editable image shows its handles: there is nothing to drag in a read-only document */
85
+ selectNode() {
86
+ if (this.view.editable) {
87
+ this.dom.classList.add(editorClassNames.imageSelected);
88
+ }
89
+ }
90
+ deselectNode() {
91
+ this.dom.classList.remove(editorClassNames.imageSelected);
92
+ }
93
+ /** A press on a handle is ours alone. It must not move the selection or start a drag of the image */
94
+ stopEvent(event) {
95
+ return cornerAt(event.target) !== null;
96
+ }
97
+ destroy() {
98
+ this.stopDrag();
99
+ this.dom.removeEventListener("mousedown", this.onMouseDown);
100
+ }
101
+ /** The size the image stands at now: the one the document records, or the drawn size when it records none */
102
+ currentSizePx() {
103
+ const extent = toImageExtent(this.node.attrs.extent);
104
+ if (extent) {
105
+ return { width: emuToPx(extent.cx), height: emuToPx(extent.cy) };
106
+ }
107
+ const rect = this.img.getBoundingClientRect();
108
+ if (!(rect.width > 0) || !(rect.height > 0)) return null;
109
+ return { width: rect.width, height: rect.height };
110
+ }
111
+ onMouseDown = (event) => {
112
+ const corner = cornerAt(event.target);
113
+ if (corner === null || this.drag || event.button !== 0) return;
114
+ if (!this.view.editable) return;
115
+ const start = this.currentSizePx();
116
+ if (!start) return;
117
+ event.preventDefault();
118
+ this.drag = {
119
+ corner,
120
+ startX: event.clientX,
121
+ startY: event.clientY,
122
+ start,
123
+ size: start
124
+ };
125
+ window.addEventListener("mousemove", this.onMove, true);
126
+ window.addEventListener("mouseup", this.onUp, true);
127
+ window.addEventListener("keydown", this.onKey, true);
128
+ };
129
+ onMove = (event) => {
130
+ const drag = this.drag;
131
+ if (!drag) return;
132
+ event.preventDefault();
133
+ drag.size = resizedImagePx(
134
+ drag.start,
135
+ drag.corner,
136
+ event.clientX - drag.startX,
137
+ event.clientY - drag.startY
138
+ );
139
+ showSize(this.img, drag.size);
140
+ };
141
+ onUp = () => {
142
+ const size = this.drag?.size;
143
+ const pos = this.getPos();
144
+ this.stopDrag();
145
+ if (!size || pos === void 0) return;
146
+ const tr = buildResizeImageTransaction(this.view.state, pos, size);
147
+ if (tr) this.view.dispatch(tr);
148
+ };
149
+ onKey = (event) => {
150
+ if (event.key !== "Escape") return;
151
+ event.preventDefault();
152
+ this.stopDrag();
153
+ };
154
+ stopDrag() {
155
+ if (!this.drag) return;
156
+ window.removeEventListener("mousemove", this.onMove, true);
157
+ window.removeEventListener("mouseup", this.onUp, true);
158
+ window.removeEventListener("keydown", this.onKey, true);
159
+ this.drag = null;
160
+ syncAttributes(this.img, this.node);
161
+ }
162
+ };
163
+ export {
164
+ ImageNodeView,
165
+ buildResizeImageTransaction,
166
+ resizedImagePx
167
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Draws the run spans inside one editor.
3
+ *
4
+ * The fallback fonts belong to the editor, not to the schema: the schema is one
5
+ * shared value, so its `toDOM` can only ever draw with the default fallbacks.
6
+ * A mark view is where the view gets to draw a run itself, so the fallbacks handed
7
+ * to this editor are the ones that apply.
8
+ *
9
+ * The span is built from the same spec `toDOM` returns and rendered by the same
10
+ * renderer, so with the default fallbacks the DOM is exactly what the schema would
11
+ * have drawn.
12
+ */
13
+ import type { MarkViewConstructor } from "prosemirror-view";
14
+ import type { FontFallbacks } from "../../styles/fontStack";
15
+ export declare function runMarkView(fontFallbacks: FontFallbacks): MarkViewConstructor;
@@ -0,0 +1,9 @@
1
+ // src/editor/views/runMarkView.ts
2
+ import { DOMSerializer } from "prosemirror-model";
3
+ import { runMarkSpec } from "../../schema/index.js";
4
+ function runMarkView(fontFallbacks) {
5
+ return (mark) => DOMSerializer.renderSpec(document, runMarkSpec(mark.attrs, fontFallbacks));
6
+ }
7
+ export {
8
+ runMarkView
9
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Renders a table from the schema's `toDOM`, and keeps ProseMirror from reverting the `colgroup`
3
+ * we edit ourselves while column widths are being dragged.
4
+ *
5
+ * When an attribute changes inside the editor DOM, ProseMirror treats it as "DOM out of sync
6
+ * with the document" and redraws that spot from the document. That is why the `col` widths
7
+ * written by the preview get wiped on the next microtask, and dragging moves nothing on screen.
8
+ * `prosemirror-tables`' `TableView` does the same thing for the same reason (MIT; we borrowed
9
+ * only the approach).
10
+ */
11
+ import { type Node as PMNode } from "prosemirror-model";
12
+ import type { NodeView, ViewMutationRecord } from "prosemirror-view";
13
+ export declare class TableNodeView implements NodeView {
14
+ readonly dom: HTMLElement;
15
+ readonly contentDOM: HTMLElement | undefined;
16
+ /** A table whose grid is unknown has no colgroup */
17
+ private readonly colgroup;
18
+ constructor(node: PMNode);
19
+ /**
20
+ * Attribute changes on the table and its grid are ones we made ourselves, so they are not
21
+ * re-read from the document. Changes that happen inside cells are seen by ProseMirror as usual.
22
+ */
23
+ ignoreMutation(record: ViewMutationRecord): boolean;
24
+ }
@@ -0,0 +1,32 @@
1
+ // src/editor/views/tableView.ts
2
+ import { DOMSerializer } from "prosemirror-model";
3
+ var TableNodeView = class {
4
+ dom;
5
+ contentDOM;
6
+ /** A table whose grid is unknown has no colgroup */
7
+ colgroup;
8
+ constructor(node) {
9
+ const toDOM = node.type.spec.toDOM;
10
+ if (!toDOM) {
11
+ throw new Error("the schema has no way to render a table");
12
+ }
13
+ const rendered = DOMSerializer.renderSpec(document, toDOM(node));
14
+ if (!(rendered.dom instanceof HTMLElement)) {
15
+ throw new Error("the table was not rendered as an element");
16
+ }
17
+ this.dom = rendered.dom;
18
+ this.contentDOM = rendered.contentDOM;
19
+ this.colgroup = this.dom.querySelector(":scope > colgroup");
20
+ }
21
+ /**
22
+ * Attribute changes on the table and its grid are ones we made ourselves, so they are not
23
+ * re-read from the document. Changes that happen inside cells are seen by ProseMirror as usual.
24
+ */
25
+ ignoreMutation(record) {
26
+ if (record.type !== "attributes") return false;
27
+ return record.target === this.dom || this.colgroup?.contains(record.target) === true;
28
+ }
29
+ };
30
+ export {
31
+ TableNodeView
32
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The React editor surface: the editor component, the download helper, and the
3
+ * document structure and format values those two hand out.
4
+ *
5
+ * The engine underneath is the `./core` entry, which knows nothing about React
6
+ * or the DOM. The ProseMirror handles re-exported here are the ones from the
7
+ * copy the editor itself runs on, which is the consumer's own copy: the packages
8
+ * are peer dependencies.
9
+ * `docs/architecture.md` has the line between the two entries and why the one
10
+ * copy matters.
11
+ */
12
+ export type { Command } from "prosemirror-state";
13
+ export { EditorState, Plugin, PluginKey, TextSelection, } from "prosemirror-state";
14
+ export { EditorView } from "prosemirror-view";
15
+ export type { DocxEditorHandle, DocxEditorMode, DocxEditorProps, } from "./DocxEditor";
16
+ export { DocxEditor } from "./DocxEditor";
17
+ export type { DocxBytes, DocxSource } from "./docx/importDocx";
18
+ export type { DownloadDocxOptions, DownloadDocxResult, } from "./download";
19
+ export { downloadDocx } from "./download";
20
+ export type { CommentAuthor } from "./editor/commands/commentCommands";
21
+ export type { CellFormat, CellVerticalAlign, DocumentDefaults, HighlightName, LineSpacing, NumberingRef, ParagraphAlign, ParagraphFormat, RowFormat, RowHeight, RunFormat, TableFormat, TableWidth, TableWidthType, UnderlineKind, VerticalAlign, } from "./model/format";
22
+ export type { DocxExportErrorCode, DocxImportErrorCode, } from "./ooxml/errors";
23
+ export { DocxExportError, DocxImportError } from "./ooxml/errors";
24
+ export { docxSchema } from "./schema";
25
+ /**
26
+ * The lists the built-in pickers offer. They are exported so that a toolbar of your own can
27
+ * offer the same ones without writing them out again; the pickers themselves read these very
28
+ * lists, so there is only ever one of each.
29
+ * A list of your own goes back the other way through `presets` on `DocxEditor`, which the
30
+ * built-in pickers then offer in place of these.
31
+ */
32
+ export type { ColorRow } from "./styles/colors";
33
+ export { DEFAULT_COLORS } from "./styles/colors";
34
+ export { DEFAULT_FONT_SIZES } from "./styles/fontSizes";
35
+ export type { FontFallbackGroup, FontFallbacks } from "./styles/fontStack";
36
+ export { DEFAULT_FONT_FALLBACKS } from "./styles/fontStack";
37
+ export { DEFAULT_FONTS } from "./styles/fonts";
38
+ export type { LineSpacingOption } from "./styles/lineSpacings";
39
+ export { DEFAULT_LINE_SPACINGS } from "./styles/lineSpacings";
40
+ export type { CellBorderOption } from "./table/cellBorders";
41
+ export { DEFAULT_CELL_BORDERS } from "./table/cellBorders";
42
+ export type { DocxEditorPresets } from "./ui/presets";
43
+ export type { DocxEditorZoom } from "./ui/zoom";
44
+ export { DEFAULT_ZOOM_LEVELS } from "./ui/zoom";
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ // src/index.ts
2
+ import {
3
+ EditorState,
4
+ Plugin,
5
+ PluginKey,
6
+ TextSelection
7
+ } from "prosemirror-state";
8
+ import { EditorView } from "prosemirror-view";
9
+ import { DocxEditor } from "./DocxEditor.js";
10
+ import { downloadDocx } from "./download.js";
11
+ import { DocxExportError, DocxImportError } from "./ooxml/errors.js";
12
+ import { docxSchema } from "./schema/index.js";
13
+ import { DEFAULT_COLORS } from "./styles/colors.js";
14
+ import { DEFAULT_FONT_SIZES } from "./styles/fontSizes.js";
15
+ import { DEFAULT_FONT_FALLBACKS } from "./styles/fontStack.js";
16
+ import { DEFAULT_FONTS } from "./styles/fonts.js";
17
+ import { DEFAULT_LINE_SPACINGS } from "./styles/lineSpacings.js";
18
+ import { DEFAULT_CELL_BORDERS } from "./table/cellBorders.js";
19
+ import { DEFAULT_ZOOM_LEVELS } from "./ui/zoom.js";
20
+ export {
21
+ DEFAULT_CELL_BORDERS,
22
+ DEFAULT_COLORS,
23
+ DEFAULT_FONTS,
24
+ DEFAULT_FONT_FALLBACKS,
25
+ DEFAULT_FONT_SIZES,
26
+ DEFAULT_LINE_SPACINGS,
27
+ DEFAULT_ZOOM_LEVELS,
28
+ DocxEditor,
29
+ DocxExportError,
30
+ DocxImportError,
31
+ EditorState,
32
+ EditorView,
33
+ Plugin,
34
+ PluginKey,
35
+ TextSelection,
36
+ docxSchema,
37
+ downloadDocx
38
+ };
@@ -0,0 +1,240 @@
1
+ /**
2
+ * The formatting values to render on screen, and the checks that they have the shape
3
+ * they should.
4
+ *
5
+ * These values are produced by reading the original formatting XML (`w:pPr`, `w:rPr`,
6
+ * `w:tblPr`, ...) and are only ever used for rendering. What goes back into the document
7
+ * is always the original XML string.
8
+ *
9
+ * A value enters as a node attribute, leaves for the DOM as `data-fmt`, and comes back
10
+ * in again. So that a value tampered with along that path cannot leak into a CSS
11
+ * declaration, the checks that let through only the shapes the read functions produce
12
+ * live here alongside them.
13
+ */
14
+ import type { TabStop } from "./tabStops";
15
+ declare const ALIGNS: readonly ["left", "center", "right", "justify"];
16
+ export type ParagraphAlign = (typeof ALIGNS)[number];
17
+ declare const VERTICAL_ALIGNS: readonly ["superscript", "subscript"];
18
+ export type VerticalAlign = (typeof VERTICAL_ALIGNS)[number];
19
+ declare const CELL_VERTICAL_ALIGNS: readonly ["top", "center", "bottom"];
20
+ export type CellVerticalAlign = (typeof CELL_VERTICAL_ALIGNS)[number];
21
+ /**
22
+ * The fill of something whose document says to paint nothing (`w:shd w:fill="auto"`).
23
+ * A fill nobody mentioned is absent instead, so a style's fill comes back only in that case.
24
+ * The lines use the same word for the same reason.
25
+ */
26
+ export declare const NO_FILL = "none";
27
+ /**
28
+ * The underline kinds OOXML defines (`ST_Underline`). "No underline" (`none`) is not
29
+ * included
30
+ */
31
+ declare const UNDERLINES: readonly ["single", "words", "double", "thick", "dotted", "dottedHeavy", "dash", "dashedHeavy", "dashLong", "dashLongHeavy", "dotDash", "dashDotHeavy", "dotDotDash", "dashDotDotHeavy", "wave", "wavyHeavy", "wavyDouble"];
32
+ export type UnderlineKind = (typeof UNDERLINES)[number];
33
+ /**
34
+ * The highlight names OOXML defines (`ST_HighlightColor`). "No highlight" (`none`) is
35
+ * not included
36
+ */
37
+ declare const HIGHLIGHTS: readonly ["black", "blue", "cyan", "darkBlue", "darkCyan", "darkGray", "darkGreen", "darkMagenta", "darkRed", "darkYellow", "green", "lightGray", "magenta", "red", "white", "yellow"];
38
+ export type HighlightName = (typeof HIGHLIGHTS)[number];
39
+ export declare function isUnderlineKind(value: unknown): value is UnderlineKind;
40
+ export declare function isHighlightName(value: unknown): value is HighlightName;
41
+ /**
42
+ * The width a table or a cell has recorded.
43
+ * `auto` and `nil` leave the width up to the layout, so they carry no number at all.
44
+ */
45
+ export type TableWidth = {
46
+ type: "dxa";
47
+ twips: number;
48
+ } | {
49
+ type: "pct";
50
+ fiftieths: number;
51
+ } | {
52
+ type: "auto";
53
+ } | {
54
+ type: "nil";
55
+ };
56
+ export type TableWidthType = TableWidth["type"];
57
+ /** The number a width records, in the unit its type names */
58
+ export declare function widthNumber(width: TableWidth): number | null;
59
+ export declare function withWidthNumber(width: TableWidth, value: number): TableWidth;
60
+ /**
61
+ * Line spacing.
62
+ * `auto` states a multiple of one line's height; the others pin the height down in
63
+ * points.
64
+ */
65
+ export type LineSpacing = {
66
+ rule: "auto";
67
+ lines: number;
68
+ } | {
69
+ rule: "exact";
70
+ pt: number;
71
+ } | {
72
+ rule: "atLeast";
73
+ pt: number;
74
+ };
75
+ /**
76
+ * Which list this paragraph belongs to and which of its levels it sits at. The number
77
+ * itself is computed at render time
78
+ */
79
+ export interface NumberingRef {
80
+ numId: number;
81
+ ilvl: number;
82
+ }
83
+ /** The paragraph formatting to render on screen. Lengths are in points */
84
+ export interface ParagraphFormat {
85
+ align?: ParagraphAlign;
86
+ /** The paragraph's logical text direction (`w:bidi`). */
87
+ direction?: "ltr" | "rtl";
88
+ indentLeftPt?: number;
89
+ indentRightPt?: number;
90
+ /** Logical leading and trailing indents from Strict `w:start` and `w:end`. */
91
+ indentStartPt?: number;
92
+ indentEndPt?: number;
93
+ /** Positive when only the first line is indented further, negative for a hanging indent */
94
+ textIndentPt?: number;
95
+ spaceBeforePt?: number;
96
+ spaceAfterPt?: number;
97
+ lineSpacing?: LineSpacing;
98
+ numbering?: NumberingRef;
99
+ /** Effective custom tab stops after the paragraph-property hierarchy is resolved. */
100
+ tabStops?: readonly TabStop[];
101
+ /**
102
+ * Set when the document records that a new page starts at this paragraph. Read by the
103
+ * page boundary guides
104
+ */
105
+ pageBreakBefore?: true;
106
+ /** A CSS border in the form `1pt solid #000000` */
107
+ borderTop?: string;
108
+ borderBottom?: string;
109
+ borderLeft?: string;
110
+ borderRight?: string;
111
+ background?: string;
112
+ }
113
+ /** The character formatting to render on screen */
114
+ export interface RunFormat {
115
+ bold?: true;
116
+ italic?: true;
117
+ /** The underline kind. Absent entirely when there is no underline */
118
+ underline?: UnderlineKind;
119
+ strike?: true;
120
+ smallCaps?: true;
121
+ fontSizePt?: number;
122
+ /** A CSS font name list in the form `"맑은 고딕","Malgun Gothic"` */
123
+ fontFamily?: string;
124
+ color?: string;
125
+ highlight?: HighlightName;
126
+ background?: string;
127
+ verticalAlign?: VerticalAlign;
128
+ /**
129
+ * The language the run records (`w:lang`), drawn as the `lang` attribute of its span.
130
+ * Han characters are written differently in Japanese, in simplified Chinese and in
131
+ * traditional Chinese, and this is the only thing that tells the browser which of
132
+ * those shapes to draw. It is read for display only and never written back.
133
+ */
134
+ lang?: string;
135
+ }
136
+ /**
137
+ * The table formatting to render on screen. The inner lines between cells are folded
138
+ * into the cell formatting
139
+ */
140
+ export interface TableFormat {
141
+ borderTop?: string;
142
+ borderBottom?: string;
143
+ borderLeft?: string;
144
+ borderRight?: string;
145
+ background?: string;
146
+ align?: ParagraphAlign;
147
+ indentLeftPt?: number;
148
+ }
149
+ /**
150
+ * The lines that divide the inside of a table (`insideH`, `insideV`).
151
+ * They are held by the table but drawn by the cells, so they become the defaults for cell
152
+ * formatting. A side with nothing written down is null.
153
+ */
154
+ export interface InsideBorders {
155
+ horizontal: string | null;
156
+ vertical: string | null;
157
+ }
158
+ /**
159
+ * The cell margins a table or its style lays down, in points, one per side.
160
+ * They are held by the table but drawn by the cells, so they become the padding a cell
161
+ * that wrote none of its own falls back on. A side with nothing written down is null.
162
+ */
163
+ export interface CellMargins {
164
+ topPt: number | null;
165
+ rightPt: number | null;
166
+ bottomPt: number | null;
167
+ leftPt: number | null;
168
+ }
169
+ /**
170
+ * How high a row stands, in points.
171
+ * `atLeast` is a floor the row grows past when its text needs the room, and `exact` pins
172
+ * the height down.
173
+ */
174
+ export type RowHeight = {
175
+ rule: "atLeast";
176
+ pt: number;
177
+ } | {
178
+ rule: "exact";
179
+ pt: number;
180
+ };
181
+ /** The formatting of a single table row to render on screen */
182
+ export interface RowFormat {
183
+ /** What `w:trHeight` writes down */
184
+ height?: RowHeight;
185
+ /** Whether this row is repeated at the top of a continued table */
186
+ repeatHeader?: boolean;
187
+ /** Whether this row must stay whole when the table continues on another page */
188
+ cantSplit?: boolean;
189
+ }
190
+ /** The formatting of a single table cell to render on screen */
191
+ export interface CellFormat {
192
+ borderTop?: string;
193
+ borderBottom?: string;
194
+ borderLeft?: string;
195
+ borderRight?: string;
196
+ background?: string;
197
+ verticalAlign?: CellVerticalAlign;
198
+ paddingTopPt?: number;
199
+ paddingRightPt?: number;
200
+ paddingBottomPt?: number;
201
+ paddingLeftPt?: number;
202
+ }
203
+ /**
204
+ * The defaults that apply to the whole document. Null when absent; the on-screen
205
+ * fallback is decided by the presentation layer
206
+ */
207
+ export interface DocumentDefaults {
208
+ fontSizePt: number | null;
209
+ fontFamily: string | null;
210
+ lineSpacing: LineSpacing | null;
211
+ }
212
+ export declare function toParagraphFormat(value: unknown): ParagraphFormat | null;
213
+ export declare function toRunFormat(value: unknown): RunFormat | null;
214
+ export declare function toTableWidth(value: unknown): TableWidth | null;
215
+ /** The sequence of column widths (dxa) that `w:tblGrid` defines */
216
+ export declare function toGridCols(value: unknown): number[];
217
+ /** The cell widths (px) `prosemirror-tables` uses. Our documents usually leave it empty */
218
+ export declare function toColWidth(value: unknown): number[] | null;
219
+ export declare function toTableFormat(value: unknown): TableFormat | null;
220
+ /**
221
+ * The inside lines a table style laid down, as they come back in from `data-style-inside`.
222
+ * A table with no line on either side is the same as the attribute not being there at all,
223
+ * so it is null.
224
+ */
225
+ export declare function toInsideBorders(value: unknown): InsideBorders | null;
226
+ /**
227
+ * The cell margins a table style laid down, as they come back in from `data-style-margins`.
228
+ * A table with a margin on none of its four sides is the same as the attribute not being
229
+ * there at all, so it is null.
230
+ */
231
+ export declare function toCellMargins(value: unknown): CellMargins | null;
232
+ export declare function toRowFormat(value: unknown): RowFormat | null;
233
+ export declare function toCellFormat(value: unknown): CellFormat | null;
234
+ /**
235
+ * A merge count (colspan, rowspan).
236
+ * Because it feeds grid arithmetic and loop steps, only positive integers are let
237
+ * through. The fallback of 1 means "not merged".
238
+ */
239
+ export declare function spanCount(value: unknown): number;
240
+ export {};