@docen/docx 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockquote-DY80QC06.d.mts +21 -0
- package/dist/bullet-list-DF60pnSL.d.mts +12 -0
- package/dist/converters/docx.d.mts +1 -1
- package/dist/converters/docx.mjs +121 -24
- package/dist/converters/html.d.mts +1 -1
- package/dist/converters/html.mjs +1 -1
- package/dist/converters/markdown.d.mts +1 -1
- package/dist/converters/markdown.mjs +1 -1
- package/dist/converters/patch.d.mts +1 -1
- package/dist/converters/prepare.d.mts +1 -1
- package/dist/converters/prepare.mjs +6 -9
- package/dist/{core-B8ba_FNi.mjs → core-BnF8XhVE.mjs} +180 -31
- package/dist/core-DC0_-WcE.d.mts +387 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/details-Dd5MqqmR.d.mts +17 -0
- package/dist/editor.d.mts +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/extensions/blockquote.d.mts +2 -22
- package/dist/extensions/bullet-list.d.mts +2 -0
- package/dist/extensions/bullet-list.mjs +21 -0
- package/dist/extensions/code-block.d.mts +1 -18
- package/dist/extensions/column-break.d.mts +1 -30
- package/dist/extensions/column-break.mjs +1 -1
- package/dist/extensions/details.d.mts +2 -18
- package/dist/extensions/document.mjs +2 -1
- package/dist/extensions/extensions.d.mts +10 -6
- package/dist/extensions/extensions.mjs +9 -4
- package/dist/extensions/formatting-marks.d.mts +1 -37
- package/dist/extensions/formatting-marks.mjs +1 -1
- package/dist/extensions/image.d.mts +1 -1
- package/dist/extensions/image.mjs +20 -4
- package/dist/extensions/index.d.mts +15 -2
- package/dist/extensions/index.mjs +17 -2
- package/dist/extensions/link.d.mts +2 -0
- package/dist/extensions/link.mjs +56 -0
- package/dist/extensions/mention.d.mts +2 -24
- package/dist/extensions/ordered-list.d.mts +1 -24
- package/dist/extensions/ordered-list.mjs +10 -1
- package/dist/extensions/page-break.d.mts +1 -1
- package/dist/extensions/page-break.mjs +1 -1
- package/dist/extensions/paragraph.mjs +13 -0
- package/dist/extensions/passthrough.d.mts +2 -2
- package/dist/extensions/passthrough.mjs +2 -2
- package/dist/extensions/scroll.d.mts +2 -0
- package/dist/extensions/scroll.mjs +33 -0
- package/dist/extensions/section-break.d.mts +1 -43
- package/dist/extensions/section-break.mjs +1 -1
- package/dist/extensions/tab.d.mts +2 -0
- package/dist/extensions/tab.mjs +2 -0
- package/dist/extensions/task-item.d.mts +2 -26
- package/dist/extensions/tiptap.d.mts +1 -1
- package/dist/extensions/toc-field.d.mts +1 -1
- package/dist/extensions/toc-field.mjs +1 -1
- package/dist/extensions/wpg-group.d.mts +2 -2
- package/dist/extensions/wpg-group.mjs +2 -2
- package/dist/extensions/wps-shape.d.mts +1 -1
- package/dist/extensions/wps-shape.mjs +1 -1
- package/dist/index.d.mts +31 -7
- package/dist/index.mjs +17 -2
- package/dist/link-BawPjQZR.d.mts +6 -0
- package/dist/mention-BGLzLVYw.d.mts +23 -0
- package/dist/ordered-list-DFAe-YEV.d.mts +25 -0
- package/dist/scroll-ZNeThJsJ.d.mts +18 -0
- package/dist/task-item-B0ntvQ1Y.d.mts +25 -0
- package/dist/{tiptap-pZsNPsvV.d.mts → tiptap-BKqn41uT.d.mts} +2 -2
- package/package.json +3 -3
- package/dist/core-DRaLI8nd.d.mts +0 -203
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Blockquote, Bold, Code, CodeBlockLowlight, Details, DetailsContent, DetailsSummary, Emoji, HardBreak, Highlight, HorizontalRule, Italic, ListItem, Mathematics, Mention, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, Underline } from "./extensions/tiptap.mjs";
|
|
2
|
+
import { BulletList } from "./extensions/bullet-list.mjs";
|
|
3
|
+
import { CodeBlock } from "./extensions/code-block.mjs";
|
|
4
|
+
import { C as ColumnBreak, S as FormattingMarks, _ as Tab, a as DocxKit, b as Passthrough, c as tiptapNodeExtensions, g as TocField, h as wpsShapeStyles, l as WpsShape, o as docxExtensions, s as tiptapMarkExtensions, u as WpgGroup, v as SectionBreak, x as PageBreak, y as InlinePassthrough } from "./core-BnF8XhVE.mjs";
|
|
2
5
|
import { resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, twipsToMm } from "./extensions/utils.mjs";
|
|
3
6
|
import { Document, createDocument } from "./extensions/document.mjs";
|
|
7
|
+
import { Heading } from "./extensions/heading.mjs";
|
|
8
|
+
import { Image } from "./extensions/image.mjs";
|
|
9
|
+
import { scrollCaretToTop, scrollContainerOf } from "./extensions/scroll.mjs";
|
|
10
|
+
import { Link } from "./extensions/link.mjs";
|
|
11
|
+
import { OrderedList } from "./extensions/ordered-list.mjs";
|
|
12
|
+
import { Paragraph } from "./extensions/paragraph.mjs";
|
|
13
|
+
import { Strike } from "./extensions/strike.mjs";
|
|
14
|
+
import { Table } from "./extensions/table.mjs";
|
|
15
|
+
import { TableCell } from "./extensions/table-cell.mjs";
|
|
16
|
+
import { TableHeader } from "./extensions/table-header.mjs";
|
|
17
|
+
import { TableRow } from "./extensions/table-row.mjs";
|
|
18
|
+
import { TextStyle } from "./extensions/text-style.mjs";
|
|
4
19
|
import { createDocxEditor } from "./editor.mjs";
|
|
5
20
|
import { fetchImageHandler, prepareDocument, prepareImages } from "./converters/prepare.mjs";
|
|
6
21
|
import { effectiveRunProps, inlineStyles, quickStyles, stylesToCss } from "./converters/styles.mjs";
|
|
@@ -10,4 +25,4 @@ import { generateHTML, parseHTML } from "./converters/html.mjs";
|
|
|
10
25
|
import { generateMarkdown, parseMarkdown } from "./converters/markdown.mjs";
|
|
11
26
|
import { sectionMarginDefaults, sectionPageSizeDefaults } from "@office-open/docx";
|
|
12
27
|
import { convertMillimetersToTwip } from "@office-open/core";
|
|
13
|
-
export { Document, DocxKit, DocxManager, PageBreak, compileDocument, convertMillimetersToTwip, createDocument, createDocxEditor, docxExtensions, effectiveRunProps, fetchImageHandler, generateDOCX, generateDOCXStream, generateDOCXSync, generateHTML, generateMarkdown, inlineStyles, parseDOCX, parseHTML, parseMarkdown, patchDOCX, prepareDocument, prepareImages, quickStyles, resolveDocument, resolveFontName, resolvePageSize, sectionLinePitchCss, sectionMarginCss, sectionMarginDefaults, sectionPageSizeDefaults, stylesToCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm };
|
|
28
|
+
export { Blockquote, Bold, BulletList, Code, CodeBlock, CodeBlockLowlight, ColumnBreak, Details, DetailsContent, DetailsSummary, Document, DocxKit, DocxManager, Emoji, FormattingMarks, HardBreak, Heading, Highlight, HorizontalRule, Image, InlinePassthrough, Italic, Link, ListItem, Mathematics, Mention, OrderedList, PageBreak, Paragraph, Passthrough, SectionBreak, Strike, Subscript, Superscript, Tab, Table, TableCell, TableHeader, TableRow, TaskItem, TaskList, Text, TextAlign, TextStyle, TocField, Underline, WpgGroup, WpsShape, compileDocument, convertMillimetersToTwip, createDocument, createDocxEditor, docxExtensions, effectiveRunProps, fetchImageHandler, generateDOCX, generateDOCXStream, generateDOCXSync, generateHTML, generateMarkdown, inlineStyles, parseDOCX, parseHTML, parseMarkdown, patchDOCX, prepareDocument, prepareImages, quickStyles, resolveDocument, resolveFontName, resolvePageSize, scrollCaretToTop, scrollContainerOf, sectionLinePitchCss, sectionMarginCss, sectionMarginDefaults, sectionPageSizeDefaults, stylesToCss, tiptapMarkExtensions, tiptapNodeExtensions, twipsToMm, wpsShapeStyles };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/extensions/mention.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Mention extension — owns the DOCX expression of an inline mention.
|
|
4
|
+
*
|
|
5
|
+
* A mention is an atom node carrying `{ id, label }`. DOCX has no mention
|
|
6
|
+
* element, but an inline text-SDT (CT_SdtRun) is a reversible carrier: the
|
|
7
|
+
* `id` rides in the SDT alias, the `label` as the SDT's run text, and a fixed
|
|
8
|
+
* tag marks the type so resolve can recover the mention. (customXml would also
|
|
9
|
+
* carry the id but triggers Word's i4i patent warning; SDT does not.)
|
|
10
|
+
*/
|
|
11
|
+
/** SDT tag marking a mention content control. */
|
|
12
|
+
declare const MENTION_TAG = "docen-mention";
|
|
13
|
+
/** Inline text-SDT carrying a mention (id in alias, label as run text). */
|
|
14
|
+
declare function createMention(id: string, label: string): Record<string, unknown>;
|
|
15
|
+
/** True if an inline SDT child carries a mention. */
|
|
16
|
+
declare function isMention(child: unknown): boolean;
|
|
17
|
+
/** Read a mention SDT → `{ id, label }`. */
|
|
18
|
+
declare function readMention(child: unknown): {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { readMention as i, createMention as n, isMention as r, MENTION_TAG as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LevelsOptions } from "@office-open/docx";
|
|
2
|
+
|
|
3
|
+
//#region src/extensions/ordered-list.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* OrderedList extension — owns the DOCX expression of an ordered list.
|
|
6
|
+
*
|
|
7
|
+
* A Tiptap orderedList maps to a sequence of paragraphs referencing one
|
|
8
|
+
* abstractNum (decimal). The reference is keyed by `start` so lists with the
|
|
9
|
+
* same start share a definition; DocxManager gives each list its own instance
|
|
10
|
+
* for independent counting. This module owns that abstractNum shape; DocxManager
|
|
11
|
+
* owns the cross-paragraph tree walk, start recovery, and numbering-instance
|
|
12
|
+
* bookkeeping.
|
|
13
|
+
*/
|
|
14
|
+
/** Reference prefix for generated ordered-list abstractNum definitions. */
|
|
15
|
+
declare const ORDERED_REFERENCE_PREFIX = "docen-ordered";
|
|
16
|
+
/** lvlText per nesting depth (level 0 → "%1.", … level 8 → "%9."). */
|
|
17
|
+
declare const ORDERED_LEVEL_TEXT: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Build nine decimal numbering levels for an ordered list. Level 0 carries
|
|
20
|
+
* `start`; deeper levels restart at 1 (Word convention).
|
|
21
|
+
*/
|
|
22
|
+
declare function buildOrderedLevels(start: number): LevelsOptions[];
|
|
23
|
+
declare const OrderedList: import("@tiptap/core").Node<import("@tiptap/extension-ordered-list").OrderedListOptions, any>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { buildOrderedLevels as i, ORDERED_REFERENCE_PREFIX as n, OrderedList as r, ORDERED_LEVEL_TEXT as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EditorView } from "@tiptap/pm/view";
|
|
2
|
+
|
|
3
|
+
//#region src/extensions/scroll.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Scroll helpers shared by the editor and the docx engine's link-click handler,
|
|
6
|
+
* so every "jump then scroll" path (outline heading, search result, find, TOC
|
|
7
|
+
* Ctrl+Click, post-reflow caret follow) scrolls the SAME way — to the top of the
|
|
8
|
+
* viewport, Word-style. ProseMirror's default `tr.scrollIntoView()` parks the
|
|
9
|
+
* caret at the bottom edge, which reads wrong for a page/heading/TOC jump.
|
|
10
|
+
*/
|
|
11
|
+
/** Nearest scrollable ancestor of the editor surface (e.g. the docen-canvas). */
|
|
12
|
+
declare function scrollContainerOf(view: EditorView): HTMLElement | null;
|
|
13
|
+
/** Scroll the caret to the TOP of the viewport when it has left the visible area
|
|
14
|
+
* (Word-style page follow). No-op while the caret stays in view, so normal
|
|
15
|
+
* typing doesn't fight the user's scroll. Replaces PM's default scrollIntoView. */
|
|
16
|
+
declare function scrollCaretToTop(view: EditorView): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { scrollContainerOf as n, scrollCaretToTop as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/extensions/task-item.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* TaskItem extension — owns the DOCX expression of a task-list checkbox.
|
|
4
|
+
*
|
|
5
|
+
* DOCX has no native task list, but a clickable checkbox is reversible via an
|
|
6
|
+
* inline content-control SDT (w14:checkbox). Each task paragraph carries a
|
|
7
|
+
* leading checkbox SDT tagged "docen-task" so resolve can tell task items apart
|
|
8
|
+
* from ordinary paragraphs that happen to contain an SDT. The checked state
|
|
9
|
+
* round-trips through the SDT; DocxManager injects/strips the SDT at the
|
|
10
|
+
* paragraph boundary and rebuilds the taskList/taskItem tree.
|
|
11
|
+
*/
|
|
12
|
+
/** SDT tag marking our task-item checkbox content control. */
|
|
13
|
+
declare const TASK_CHECKBOX_TAG = "docen-task";
|
|
14
|
+
/**
|
|
15
|
+
* Inline checkbox SDT (w14:checkbox) for a task item, as a ParagraphChild.
|
|
16
|
+
* Tagged so resolve can distinguish task items from ordinary SDT-bearing
|
|
17
|
+
* paragraphs.
|
|
18
|
+
*/
|
|
19
|
+
declare function createTaskCheckbox(checked: boolean): Record<string, unknown>;
|
|
20
|
+
/** True if an inline ParagraphChild is our task checkbox SDT. */
|
|
21
|
+
declare function isTaskCheckbox(child: unknown): boolean;
|
|
22
|
+
/** Read the checked state of a task checkbox SDT child (false if not one). */
|
|
23
|
+
declare function readCheckboxState(child: unknown): boolean;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { readCheckboxState as i, createTaskCheckbox as n, isTaskCheckbox as r, TASK_CHECKBOX_TAG as t };
|
|
@@ -22,10 +22,10 @@ import { Italic } from "@tiptap/extension-italic";
|
|
|
22
22
|
import { Underline } from "@tiptap/extension-underline";
|
|
23
23
|
import { Strike } from "@tiptap/extension-strike";
|
|
24
24
|
import { Code } from "@tiptap/extension-code";
|
|
25
|
-
import { Link } from "@tiptap/extension-link";
|
|
25
|
+
import { Link as Link$1 } from "@tiptap/extension-link";
|
|
26
26
|
import { Highlight } from "@tiptap/extension-highlight";
|
|
27
27
|
import { Subscript } from "@tiptap/extension-subscript";
|
|
28
28
|
import { Superscript } from "@tiptap/extension-superscript";
|
|
29
29
|
import { TextStyle } from "@tiptap/extension-text-style";
|
|
30
30
|
import { TextAlign } from "@tiptap/extension-text-align";
|
|
31
|
-
export { TaskItem as A, Strike as C, TableCell as D, Table as E, Underline as F, Text as M, TextAlign as N, TableHeader as O, TextStyle as P, Paragraph as S, Superscript as T, Link as _, CodeBlockLowlight as a, Mention as b, DetailsSummary as c, HardBreak as d, Heading as f, Italic as g, Image as h, Code as i, TaskList as j, TableRow as k, Document as l, HorizontalRule as m, Bold as n, Details as o, Highlight as p, BulletList as r, DetailsContent as s, Blockquote as t, Emoji as u, ListItem as v, Subscript as w, OrderedList as x, Mathematics as y };
|
|
31
|
+
export { TaskItem as A, Strike as C, TableCell as D, Table as E, Underline as F, Text as M, TextAlign as N, TableHeader as O, TextStyle as P, Paragraph as S, Superscript as T, Link$1 as _, CodeBlockLowlight as a, Mention as b, DetailsSummary as c, HardBreak as d, Heading as f, Italic as g, Image as h, Code as i, TaskList as j, TableRow as k, Document as l, HorizontalRule as m, Bold as n, Details as o, Highlight as p, BulletList as r, DetailsContent as s, Blockquote as t, Emoji as u, ListItem as v, Subscript as w, OrderedList as x, Mathematics as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docen/docx",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "DOCX editor and converter powered by @office-open/docx with Tiptap editing layer, supporting bidirectional conversion between DOCX, HTML, and Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"converter",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@office-open/core": "0.10.
|
|
63
|
-
"@office-open/docx": "0.10.
|
|
62
|
+
"@office-open/core": "0.10.11",
|
|
63
|
+
"@office-open/docx": "0.10.11",
|
|
64
64
|
"@tiptap/core": "3.27.1",
|
|
65
65
|
"@tiptap/extension-blockquote": "3.27.1",
|
|
66
66
|
"@tiptap/extension-bold": "3.27.1",
|
package/dist/core-DRaLI8nd.d.mts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { AnyExtension, Editor, Extension, Extensions, JSONContent as JSONContent$1, Mark, Node } from "@tiptap/core";
|
|
2
|
-
import { TextAlign } from "@tiptap/extension-text-align";
|
|
3
|
-
|
|
4
|
-
//#region src/extensions/image.d.ts
|
|
5
|
-
type CropRect = {
|
|
6
|
-
left?: number;
|
|
7
|
-
top?: number;
|
|
8
|
-
right?: number;
|
|
9
|
-
bottom?: number;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Tiptap JSON image node → CoreImageOptions-shaped object.
|
|
13
|
-
*
|
|
14
|
-
* Returns `{ image: ImageOptions }` (structural wrapper) or null when no
|
|
15
|
-
* embedded image data is available (external URLs need pre-fetching).
|
|
16
|
-
* rotation is carried via transformation.rotation (not dropped).
|
|
17
|
-
*/
|
|
18
|
-
declare function renderDocx(node: JSONContent$1): Record<string, unknown> | null;
|
|
19
|
-
/**
|
|
20
|
-
* ImageOptions-shaped object → Tiptap attrs.
|
|
21
|
-
*
|
|
22
|
-
* Near-identity unpack: transformation → width/height/rotation, altText → alt/title,
|
|
23
|
-
* floating/srcRect(→crop)/outline passed through verbatim. src is reconstructed by
|
|
24
|
-
* DocxManager from the image data bytes (kept out of parseDocx).
|
|
25
|
-
*/
|
|
26
|
-
declare function parseDocx(imageOpts: Record<string, unknown>): Record<string, unknown>;
|
|
27
|
-
/** Extent-box dimensions needed to size the inner <img> for a cropped image. */
|
|
28
|
-
interface CropRenderContext {
|
|
29
|
-
width?: number;
|
|
30
|
-
height?: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Render crop as the inner <img> style for byte-accurate four-sided srcRect.
|
|
34
|
-
*
|
|
35
|
-
* object-fit:cover scales uniformly, so it only matches single-axis crops.
|
|
36
|
-
* Instead the inner <img> is sized to the un-cropped display size per axis
|
|
37
|
-
* (imgW = W/visibleW, imgH = H/visibleH) and translated so the visible srcRect
|
|
38
|
-
* region maps exactly onto the extent box; the outer box clips (overflow:hidden)
|
|
39
|
-
* the cropped-out left/top region. Mathematically equivalent to a
|
|
40
|
-
* background-size/background-position crop, but keeps a real <img> (alt,
|
|
41
|
-
* accessibility, semantics, drag-to-save).
|
|
42
|
-
*/
|
|
43
|
-
declare function renderCropAttrs(crop: Record<string, unknown> | CropRect, ctx?: CropRenderContext): {
|
|
44
|
-
style: string;
|
|
45
|
-
};
|
|
46
|
-
declare const Image: import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/extensions/wpg-group.d.ts
|
|
49
|
-
interface FillColor {
|
|
50
|
-
value?: string;
|
|
51
|
-
}
|
|
52
|
-
interface Fill {
|
|
53
|
-
type?: string;
|
|
54
|
-
color?: FillColor;
|
|
55
|
-
}
|
|
56
|
-
interface Outline {
|
|
57
|
-
type?: string;
|
|
58
|
-
color?: FillColor;
|
|
59
|
-
width?: number;
|
|
60
|
-
dash?: string;
|
|
61
|
-
}
|
|
62
|
-
/** wps shape data (WpsShapeCoreOptions subset used for rendering). */
|
|
63
|
-
interface WpsBodyProperties {
|
|
64
|
-
rotation?: number;
|
|
65
|
-
lIns?: number;
|
|
66
|
-
tIns?: number;
|
|
67
|
-
rIns?: number;
|
|
68
|
-
bIns?: number;
|
|
69
|
-
vert?: string;
|
|
70
|
-
}
|
|
71
|
-
interface WpsData {
|
|
72
|
-
fill?: Fill;
|
|
73
|
-
outline?: Outline;
|
|
74
|
-
bodyProperties?: WpsBodyProperties & Record<string, unknown>;
|
|
75
|
-
children?: unknown[];
|
|
76
|
-
}
|
|
77
|
-
type Spec = ReadonlyArray<unknown>;
|
|
78
|
-
/** wps text-body paragraphs (office-open ParagraphOptions[]) → inline HTML runs
|
|
79
|
-
* so a text-box shape shows its text. Each paragraph's run defaults merge with
|
|
80
|
-
* each text run; renderRunStyles converts font/color/size/… to CSS. Advanced run
|
|
81
|
-
* props (shadow w14RawXml, kern) are carried in attrs but not rendered. */
|
|
82
|
-
declare function renderWpsText(children: unknown): Spec[];
|
|
83
|
-
/**
|
|
84
|
-
* Render a wps shape's interior (fill/outline/insets/rotation/writing-mode + text
|
|
85
|
-
* body) as a positioned div. Shared by the wpg group's inline wps children and
|
|
86
|
-
* the standalone wpsShape node, so a text-box shape renders identically whether
|
|
87
|
-
* it floats alone (wp:anchor > wps:wsp) or sits inside a group. `positionStyle`
|
|
88
|
-
* carries the placement — absolute group coords for a group child, the floating
|
|
89
|
-
* anchor CSS for a standalone shape. `opts.rotation` overrides bodyPr rotation
|
|
90
|
-
* (a group child's rotation may come from the group transform, not bodyPr).
|
|
91
|
-
*/
|
|
92
|
-
declare function renderWpsInterior(data: WpsData, positionStyle: string, opts?: {
|
|
93
|
-
rotation?: number;
|
|
94
|
-
attrs?: Record<string, string>;
|
|
95
|
-
}): Spec;
|
|
96
|
-
declare const WpgGroup: Node<any, any>;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/extensions/wps-shape.d.ts
|
|
99
|
-
declare const WpsShape: Node<any, any>;
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/extensions/passthrough.d.ts
|
|
102
|
-
/**
|
|
103
|
-
* Passthrough — block atom carrying an opaque {@link SectionChild} that has
|
|
104
|
-
* no native Tiptap representation (rawXml, bookmarkStart/End, textbox,
|
|
105
|
-
* altChunk, subDoc, customXml).
|
|
106
|
-
*
|
|
107
|
-
* The full SectionChild is stored as JSON in `attrs.data` so the DOCX→JSON→DOCX
|
|
108
|
-
* round-trip stays byte-faithful: office-open's stringify handles the inner
|
|
109
|
-
* structure verbatim (including a textbox's nested children, which remain as
|
|
110
|
-
* structured ParagraphOptions inside the blob rather than editable Tiptap
|
|
111
|
-
* nodes). The node is not editable — it renders a read-only placeholder in HTML.
|
|
112
|
-
*
|
|
113
|
-
* DOCX serialization is inlined in DocxManager (compile/resolve read/write
|
|
114
|
-
* `attrs.data` directly), so no renderDocx/parseDocx is needed here.
|
|
115
|
-
*/
|
|
116
|
-
declare const Passthrough: Node<any, any>;
|
|
117
|
-
//#endregion
|
|
118
|
-
//#region src/extensions/toc-field.d.ts
|
|
119
|
-
/**
|
|
120
|
-
* TOC field (`tocField`) — a block container representing a DOCX table of
|
|
121
|
-
* contents, with the rendered entries as editable `content` and the TOC field
|
|
122
|
-
* switches on `attrs.options`.
|
|
123
|
-
*
|
|
124
|
-
* Named `tocField` (not `tableOfContents`) to avoid colliding with the official
|
|
125
|
-
* `@tiptap/extension-table-of-contents`, which is an `Extension` (a live outline
|
|
126
|
-
* generator injected into the editor) that already owns the `tableOfContents`
|
|
127
|
-
* name. Same-name extensions dedupe in Tiptap, and since the official one is not
|
|
128
|
-
* a node it would erase this node type from the schema. The two coexist for
|
|
129
|
-
* different purposes: this node persists a DOCX's rendered TOC; the official
|
|
130
|
-
* extension drives the heading-outline pane.
|
|
131
|
-
*
|
|
132
|
-
* Structuring the TOC as a node (instead of opaque passthrough) is what fixes
|
|
133
|
-
* the export crash. Each entry paragraph's `w:hyperlink` wraps a HYPERLINK field
|
|
134
|
-
* whose content-less runs (fldChar begin/separate/end) office-open parses as
|
|
135
|
-
* `null`. As opaque passthrough those nulls survived verbatim to
|
|
136
|
-
* `generateDocument`, where office-open's `stringifyRunInline(null).break`
|
|
137
|
-
* crashed. Resolving the entries through `resolveParagraphChildren` drops the
|
|
138
|
-
* nulls (the existing `child !== null` guard), so compile rebuilds clean entries
|
|
139
|
-
* and the generate path never sees a null — no office-open change required.
|
|
140
|
-
*
|
|
141
|
-
* DOCX serialization is inlined in DocxManager (resolve/compile read/write
|
|
142
|
-
* `attrs.options` + the entry content directly), so no renderDocx/parseDocx is
|
|
143
|
-
* needed here — the same pattern as the details extension.
|
|
144
|
-
*/
|
|
145
|
-
declare const TocField: Node<any, any>;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/extensions/extensions.d.ts
|
|
148
|
-
declare const tiptapNodeExtensions: AnyExtension[];
|
|
149
|
-
declare const tiptapMarkExtensions: AnyExtension[];
|
|
150
|
-
declare const docxExtensions: AnyExtension[];
|
|
151
|
-
interface DocxKitOptions {
|
|
152
|
-
bold?: Record<string, any> | false;
|
|
153
|
-
blockquote?: Record<string, any> | false;
|
|
154
|
-
bulletList?: Record<string, any> | false;
|
|
155
|
-
code?: Record<string, any> | false;
|
|
156
|
-
codeBlock?: Record<string, any> | false;
|
|
157
|
-
document?: false;
|
|
158
|
-
hardBreak?: Record<string, any> | false;
|
|
159
|
-
heading?: Record<string, any> | false;
|
|
160
|
-
horizontalRule?: Record<string, any> | false;
|
|
161
|
-
italic?: Record<string, any> | false;
|
|
162
|
-
listItem?: Record<string, any> | false;
|
|
163
|
-
link?: Record<string, any> | false;
|
|
164
|
-
orderedList?: Record<string, any> | false;
|
|
165
|
-
paragraph?: Record<string, any> | false;
|
|
166
|
-
strike?: Record<string, any> | false;
|
|
167
|
-
text?: false;
|
|
168
|
-
underline?: Record<string, any> | false;
|
|
169
|
-
}
|
|
170
|
-
declare const DocxKit: Extension<DocxKitOptions, any>;
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region src/extensions/page-break.d.ts
|
|
173
|
-
/**
|
|
174
|
-
* PageBreak — inline atom node for DOCX page breaks (`<w:br w:type="page"/>`).
|
|
175
|
-
*
|
|
176
|
-
* OOXML page breaks live inside a run (inline), so the Tiptap node is inline
|
|
177
|
-
* too (group "inline"). This keeps a break inside its paragraph on round-trip
|
|
178
|
-
* — a break mid-paragraph stays mid-paragraph instead of splitting the
|
|
179
|
-
* paragraph into separate blocks (which would lose the original structure).
|
|
180
|
-
* Sibling to HardBreak: both render `<w:br>`, differing only by type.
|
|
181
|
-
*
|
|
182
|
-
* The DOCX payload (`{ pageBreak: true }`) is inlined in DocxManager — a
|
|
183
|
-
* one-liner with no per-node variance, so no extension helper for it.
|
|
184
|
-
*
|
|
185
|
-
* Inserting a page break must also visually reflow (the C-route paginator only
|
|
186
|
-
* forces a new page after a block *containing* a pageBreak atom). So
|
|
187
|
-
* `setPageBreak` inserts the atom then splits the paragraph — the atom lands at
|
|
188
|
-
* the end of the first half, the trailing text becomes a fresh paragraph, and
|
|
189
|
-
* the paginator's `forcesPageBreakAfter` moves it to the next page (matching
|
|
190
|
-
* Word's Ctrl+Enter behavior).
|
|
191
|
-
*/
|
|
192
|
-
declare const PageBreak: Node<any, any>;
|
|
193
|
-
declare module "@tiptap/core" {
|
|
194
|
-
interface Commands<ReturnType> {
|
|
195
|
-
pageBreak: {
|
|
196
|
-
/** Insert a page break at the cursor and split the paragraph so the
|
|
197
|
-
* trailing content reflows to the next page. */
|
|
198
|
-
setPageBreak: () => ReturnType;
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
|
-
export { Image as C, renderDocx as E, CropRenderContext as S, renderCropAttrs as T, WpsShape as _, JSONContent$1 as a, renderWpsInterior as b, PageBreak as c, TextAlign as d, docxExtensions as f, Passthrough as g, TocField as h, Extensions as i, DocxKit as l, tiptapNodeExtensions as m, Editor as n, Mark as o, tiptapMarkExtensions as p, Extension as r, Node as s, AnyExtension as t, DocxKitOptions as u, WpgGroup as v, parseDocx as w, renderWpsText as x, WpsData as y };
|