@portone/docx-editor 0.6.0 → 0.6.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 (136) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/DocxEditor.js +84 -26
  3. package/dist/docx/exportDocx.d.ts +2 -1
  4. package/dist/docx/exportDocx.js +3 -9
  5. package/dist/docx/headersFooters.js +35 -23
  6. package/dist/docx/identities.d.ts +28 -0
  7. package/dist/docx/identities.js +42 -10
  8. package/dist/docx/importDocx.js +25 -26
  9. package/dist/docx/importParagraph.d.ts +1 -4
  10. package/dist/docx/importParagraph.js +4 -18
  11. package/dist/docx/invariants.d.ts +1 -1
  12. package/dist/docx/invariants.js +45 -4
  13. package/dist/docx/notes/newNote.d.ts +39 -0
  14. package/dist/docx/notes/newNote.js +122 -0
  15. package/dist/docx/notes/numbering.d.ts +27 -0
  16. package/dist/docx/notes/numbering.js +120 -0
  17. package/dist/docx/notes/reading.d.ts +58 -0
  18. package/dist/docx/notes/reading.js +98 -0
  19. package/dist/docx/notes/writing.d.ts +19 -0
  20. package/dist/docx/notes/writing.js +96 -0
  21. package/dist/docx/partPlan.d.ts +3 -0
  22. package/dist/docx/partPlanners.d.ts +13 -0
  23. package/dist/docx/partPlanners.js +48 -0
  24. package/dist/docx/sections.d.ts +5 -0
  25. package/dist/docx/sections.js +7 -2
  26. package/dist/docx/serializeParagraph.js +7 -2
  27. package/dist/docx/session.d.ts +5 -0
  28. package/dist/docx/session.js +6 -0
  29. package/dist/docx/storyParts.d.ts +112 -0
  30. package/dist/docx/storyParts.js +289 -0
  31. package/dist/editor/clipboard/htmlReader.d.ts +24 -4
  32. package/dist/editor/clipboard/htmlReader.js +39 -4
  33. package/dist/editor/clipboard/internalChannel.d.ts +30 -3
  34. package/dist/editor/clipboard/internalChannel.js +43 -3
  35. package/dist/editor/clipboard/normalizers.d.ts +35 -8
  36. package/dist/editor/clipboard/normalizers.js +60 -11
  37. package/dist/editor/clipboard/plugin.js +42 -22
  38. package/dist/editor/commands/index.d.ts +1 -0
  39. package/dist/editor/commands/index.js +18 -0
  40. package/dist/editor/commands/noteCommands.d.ts +47 -0
  41. package/dist/editor/commands/noteCommands.js +95 -0
  42. package/dist/editor/commands/noteQueries.d.ts +22 -3
  43. package/dist/editor/commands/noteQueries.js +21 -13
  44. package/dist/editor/createEditor.js +21 -3
  45. package/dist/editor/documentStyles.d.ts +3 -0
  46. package/dist/editor/documentStyles.js +2 -1
  47. package/dist/editor/editorDocument.d.ts +24 -0
  48. package/dist/editor/editorDocument.js +34 -4
  49. package/dist/editor/notes/noteSurface.d.ts +53 -0
  50. package/dist/editor/notes/noteSurface.js +246 -0
  51. package/dist/editor/plugins/compositionSelection.d.ts +20 -0
  52. package/dist/editor/plugins/compositionSelection.js +19 -0
  53. package/dist/editor/plugins/keymap.d.ts +14 -0
  54. package/dist/editor/plugins/keymap.js +13 -1
  55. package/dist/editor/plugins/noteLifecycle.d.ts +18 -0
  56. package/dist/editor/plugins/noteLifecycle.js +117 -0
  57. package/dist/editor/plugins/noteNavigation.d.ts +45 -0
  58. package/dist/editor/plugins/noteNavigation.js +86 -0
  59. package/dist/editor/plugins/noteNumbering.d.ts +13 -0
  60. package/dist/editor/plugins/noteNumbering.js +58 -0
  61. package/dist/editor/plugins/rowResize.js +2 -7
  62. package/dist/editor/plugins/tabLayout.js +2 -7
  63. package/dist/editor/stories/storyMarkup.d.ts +24 -0
  64. package/dist/editor/stories/storyMarkup.js +35 -0
  65. package/dist/editor/stories/storyState.d.ts +34 -0
  66. package/dist/editor/stories/storyState.js +74 -0
  67. package/dist/editor/stories/storyView.d.ts +115 -0
  68. package/dist/editor/stories/storyView.js +144 -0
  69. package/dist/numbering/spellers.d.ts +1 -1
  70. package/dist/numbering/spellers.js +6 -1
  71. package/dist/page/blockKinds.d.ts +23 -4
  72. package/dist/page/demands/footnoteDemands.d.ts +18 -0
  73. package/dist/page/demands/footnoteDemands.js +51 -0
  74. package/dist/page/demands/index.d.ts +43 -0
  75. package/dist/page/demands/index.js +8 -0
  76. package/dist/page/kinds/paragraphKind.js +7 -1
  77. package/dist/page/kinds/tableKind.js +9 -1
  78. package/dist/page/measureBlocks.d.ts +2 -0
  79. package/dist/page/measureBlocks.js +31 -10
  80. package/dist/page/pageDecorations.d.ts +9 -2
  81. package/dist/page/pageDecorations.js +18 -5
  82. package/dist/page/pageLayout.d.ts +77 -1
  83. package/dist/page/pageLayout.js +186 -9
  84. package/dist/page/usePageLayout.d.ts +57 -2
  85. package/dist/page/usePageLayout.js +50 -5
  86. package/dist/schema/attrRoles.js +3 -2
  87. package/dist/schema/docxSchema.js +5 -2
  88. package/dist/schema/editGuard.d.ts +1 -1
  89. package/dist/schema/guards.js +1 -2
  90. package/dist/schema/preservedGuards.d.ts +4 -6
  91. package/dist/schema/preservedGuards.js +0 -9
  92. package/dist/schema/stories.d.ts +34 -2
  93. package/dist/schema/stories.js +22 -5
  94. package/dist/styles/classNames.d.ts +21 -6
  95. package/dist/styles/classNames.js +21 -6
  96. package/dist/styles/inlineStyle.d.ts +7 -0
  97. package/dist/styles/inlineStyle.js +11 -5
  98. package/dist/styles/visualScale.d.ts +19 -0
  99. package/dist/styles/visualScale.js +26 -0
  100. package/dist/styles.css +89 -32
  101. package/dist/ui/InsertImageButton.d.ts +3 -1
  102. package/dist/ui/InsertImageButton.js +3 -2
  103. package/dist/ui/TableMenu.d.ts +5 -2
  104. package/dist/ui/TableMenu.js +18 -1
  105. package/dist/ui/TextMenu.d.ts +5 -2
  106. package/dist/ui/TextMenu.js +21 -6
  107. package/dist/ui/Toolbar.d.ts +17 -2
  108. package/dist/ui/Toolbar.js +23 -10
  109. package/dist/ui/comments/useCommentRailLayout.js +2 -4
  110. package/dist/ui/noteItems.d.ts +21 -0
  111. package/dist/ui/noteItems.js +30 -0
  112. package/dist/ui/notes/NoteAreas.d.ts +73 -0
  113. package/dist/ui/notes/NoteAreas.js +131 -0
  114. package/dist/ui/notes/NoteList.d.ts +25 -0
  115. package/dist/ui/notes/NoteList.js +58 -0
  116. package/dist/ui/notes/StoryRow.d.ts +75 -0
  117. package/dist/ui/notes/StoryRow.js +122 -0
  118. package/dist/ui/notes/noteBands.d.ts +100 -0
  119. package/dist/ui/notes/noteBands.js +142 -0
  120. package/dist/ui/notes/noteHeights.d.ts +10 -0
  121. package/dist/ui/notes/noteHeights.js +24 -0
  122. package/dist/ui/notes/noteSeparator.d.ts +12 -0
  123. package/dist/ui/notes/noteSeparator.js +9 -0
  124. package/dist/ui/notes/useStorySurface.d.ts +68 -0
  125. package/dist/ui/notes/useStorySurface.js +95 -0
  126. package/dist/ui/runCommand.d.ts +8 -1
  127. package/dist/ui/runCommand.js +2 -2
  128. package/dist/ui/shortcutLabels.d.ts +16 -0
  129. package/dist/ui/shortcutLabels.js +9 -0
  130. package/dist/ui/usePageRoom.d.ts +13 -0
  131. package/dist/ui/usePageRoom.js +31 -0
  132. package/package.json +1 -1
  133. package/dist/docx/notes.d.ts +0 -27
  134. package/dist/docx/notes.js +0 -55
  135. package/dist/ui/NotesPanel.d.ts +0 -6
  136. package/dist/ui/NotesPanel.js +0 -33
@@ -0,0 +1,96 @@
1
+ // src/docx/notes/writing.ts
2
+ import { elementXml } from "../../ooxml/element.js";
3
+ import { wName } from "../../ooxml/names.js";
4
+ import { R_NS } from "../../ooxml/xml.js";
5
+ import { storyEntriesPlanner } from "../storyParts.js";
6
+ var NOTE_CONTENT_TYPES = {
7
+ footnote: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
8
+ endnote: "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"
9
+ };
10
+ var SEPARATORS = [
11
+ { type: "separator", id: -1 },
12
+ { type: "continuationSeparator", id: 0 }
13
+ ];
14
+ var DECIMAL = /^-?\d+$/;
15
+ function separatorIds(taken) {
16
+ const held = Array.from(taken).filter((id) => DECIMAL.test(id)).map(Number);
17
+ return SEPARATORS.reduce((chosen, { id }) => {
18
+ const used = [...held, ...chosen];
19
+ return [...chosen, used.includes(id) ? Math.min(0, ...used) - 1 : id];
20
+ }, []);
21
+ }
22
+ function separatorXml(kind, type, id) {
23
+ const paragraph = elementXml(
24
+ wName("p"),
25
+ [],
26
+ [
27
+ elementXml(
28
+ wName("pPr"),
29
+ [],
30
+ [
31
+ elementXml(wName("spacing"), [
32
+ [wName("after"), "0"],
33
+ [wName("line"), "240"],
34
+ [wName("lineRule"), "auto"]
35
+ ])
36
+ ]
37
+ ),
38
+ elementXml(wName("r"), [], [elementXml(wName(type), [])])
39
+ ]
40
+ );
41
+ return elementXml(
42
+ wName(kind),
43
+ [
44
+ [wName("type"), type],
45
+ [wName("id"), String(id)]
46
+ ],
47
+ [paragraph]
48
+ );
49
+ }
50
+ function separatorsXml(kind, taken) {
51
+ const ids = separatorIds(taken);
52
+ return SEPARATORS.map(
53
+ ({ type }, at) => separatorXml(kind, type, ids[at] ?? 0)
54
+ ).join("");
55
+ }
56
+ function frozenNotes(session, kind) {
57
+ return new Set(
58
+ Array.from(session.specialNotes).filter((key) => key.startsWith(`${kind}:`))
59
+ );
60
+ }
61
+ function referenceIds(doc, kind) {
62
+ const ids = /* @__PURE__ */ new Set();
63
+ doc.descendants((node) => {
64
+ const id = node.attrs.id;
65
+ if (node.type.name === "noteReference" && node.attrs.kind === kind && typeof id === "string") {
66
+ ids.add(id);
67
+ }
68
+ return true;
69
+ });
70
+ return ids;
71
+ }
72
+ function notesPart(kind) {
73
+ const plural = `${kind}s`;
74
+ return {
75
+ name: plural,
76
+ kind,
77
+ relType: `${R_NS}/${plural}`,
78
+ contentType: NOTE_CONTENT_TYPES[kind],
79
+ stem: plural,
80
+ root: plural,
81
+ entry: kind,
82
+ referencedIds: (doc) => referenceIds(doc, kind),
83
+ frozenEntries: (session) => frozenNotes(session, kind),
84
+ prelude: (taken) => separatorsXml(kind, taken)
85
+ };
86
+ }
87
+ var FOOTNOTES_PART = notesPart("footnote");
88
+ var ENDNOTES_PART = notesPart("endnote");
89
+ var footnotesPlanner = storyEntriesPlanner(FOOTNOTES_PART);
90
+ var endnotesPlanner = storyEntriesPlanner(ENDNOTES_PART);
91
+ export {
92
+ ENDNOTES_PART,
93
+ FOOTNOTES_PART,
94
+ endnotesPlanner,
95
+ footnotesPlanner
96
+ };
@@ -7,12 +7,15 @@
7
7
  * for, so no planner writes either of them itself and none can write over what another declared.
8
8
  */
9
9
  import type { Node as PMNode } from "prosemirror-model";
10
+ import type { FidelityCollector } from "./fidelity";
10
11
  import { type ContentTypeWriter } from "./packageParts";
11
12
  import { type RelationshipWriter } from "./relationships";
12
13
  import type { SessionStore } from "./session";
13
14
  export interface PartPlanContext {
14
15
  readonly relationships: RelationshipWriter;
15
16
  readonly contentTypes: ContentTypeWriter;
17
+ /** Where a story writer records an approximation it had to make, beside the body writer's */
18
+ readonly notes: FidelityCollector;
16
19
  }
17
20
  export interface PartPlanner {
18
21
  readonly name: string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The parts written beside the body, and what each of their planners carries into the file.
3
+ *
4
+ * `docx/exportDocx` runs these planners and `docx/invariants` reads what they write off the same
5
+ * list, so the two cannot disagree about which change has a writer.
6
+ */
7
+ import type { PartPlanner } from "./partPlan";
8
+ import { type StoryEntriesPart, type StoryWriting } from "./storyParts";
9
+ export declare const PART_PLANNERS: readonly PartPlanner[];
10
+ /** What every planner writes back of the side stories the document holds */
11
+ export declare const STORY_WRITINGS: readonly StoryWriting[];
12
+ /** The parts written one entry per story, which the identity pass walks as one part apiece */
13
+ export declare const STORY_ENTRIES_PARTS: readonly StoryEntriesPart[];
@@ -0,0 +1,48 @@
1
+ // src/docx/partPlanners.ts
2
+ import { HEADER_FOOTER_KINDS } from "../schema/stories.js";
3
+ import { commentsPlanner } from "./comments.js";
4
+ import { headerFooterPlanner } from "./headersFooters.js";
5
+ import {
6
+ ENDNOTES_PART,
7
+ endnotesPlanner,
8
+ FOOTNOTES_PART,
9
+ footnotesPlanner
10
+ } from "./notes/writing.js";
11
+ import { numberingPlanner } from "./numberingPlanner.js";
12
+ import {
13
+ EVERY_STORY_CHANGE,
14
+ storyEntriesWriting,
15
+ storyWriting
16
+ } from "./storyParts.js";
17
+ function entriesWriter(planner, part) {
18
+ return { planner, writes: [storyEntriesWriting(part)], entriesPart: part };
19
+ }
20
+ var PART_WRITERS = [
21
+ { planner: numberingPlanner, writes: [], entriesPart: null },
22
+ {
23
+ planner: commentsPlanner,
24
+ writes: [storyWriting("comment", EVERY_STORY_CHANGE)],
25
+ entriesPart: null
26
+ },
27
+ {
28
+ planner: headerFooterPlanner,
29
+ writes: HEADER_FOOTER_KINDS.map((kind) => storyWriting(kind, ["edited"])),
30
+ entriesPart: null
31
+ },
32
+ entriesWriter(footnotesPlanner, FOOTNOTES_PART),
33
+ entriesWriter(endnotesPlanner, ENDNOTES_PART)
34
+ ];
35
+ var PART_PLANNERS = PART_WRITERS.map(
36
+ ({ planner }) => planner
37
+ );
38
+ var STORY_WRITINGS = PART_WRITERS.flatMap(
39
+ ({ writes }) => writes
40
+ );
41
+ var STORY_ENTRIES_PARTS = PART_WRITERS.flatMap(
42
+ ({ entriesPart }) => entriesPart === null ? [] : [entriesPart]
43
+ );
44
+ export {
45
+ PART_PLANNERS,
46
+ STORY_ENTRIES_PARTS,
47
+ STORY_WRITINGS
48
+ };
@@ -11,6 +11,7 @@
11
11
  * arrived as, and a rewritten child is swapped into the spot `CT_SectPr` lays down.
12
12
  */
13
13
  import type { Node as PMNode } from "prosemirror-model";
14
+ import { type NoteNumberingProps } from "./notes/reading";
14
15
  import { type PageGeometry } from "./pageGeometry";
15
16
  export type HeaderFooterVariant = "default" | "first" | "even";
16
17
  /** The variants a `w:headerReference` or a `w:footerReference` may name. §17.6.12, §17.6.5 */
@@ -35,6 +36,10 @@ export interface SectionProperties {
35
36
  pageNumberStart: number | null;
36
37
  /** §17.6.22 `w:type/@w:val`; null when omitted (nextPage) */
37
38
  type: "continuous" | "evenPage" | "nextPage" | "oddPage" | "nextColumn" | null;
39
+ /** §17.11.11 `w:footnotePr`; null where the section counts footnotes as the settings do */
40
+ footnotePr: Partial<NoteNumberingProps> | null;
41
+ /** §17.11.5 `w:endnotePr`; null where the section counts endnotes as the settings do */
42
+ endnotePr: Partial<NoteNumberingProps> | null;
38
43
  }
39
44
  /** What a section the document does not spell out lays down: the paper every document used to be drawn on */
40
45
  export declare const DEFAULT_SECTION: SectionProperties;
@@ -15,6 +15,7 @@ import {
15
15
  R_NS,
16
16
  W_NS
17
17
  } from "../ooxml/xml.js";
18
+ import { readNoteProps } from "./notes/reading.js";
18
19
  import {
19
20
  A4_PORTRAIT,
20
21
  readPageGeometry
@@ -32,7 +33,9 @@ var DEFAULT_SECTION = {
32
33
  footerRefs: NO_REFS,
33
34
  titlePg: false,
34
35
  pageNumberStart: null,
35
- type: null
36
+ type: null,
37
+ footnotePr: null,
38
+ endnotePr: null
36
39
  };
37
40
  var SECTION_TYPES = [
38
41
  "continuous",
@@ -86,7 +89,9 @@ function readSectionProperties(sectPr) {
86
89
  footerRefs: storyRefs(sectPr, "footer"),
87
90
  titlePg: isOnElement(childByLocalName(sectPr, "titlePg")),
88
91
  pageNumberStart: pageNumberStart(sectPr),
89
- type: sectionType(sectPr)
92
+ type: sectionType(sectPr),
93
+ footnotePr: readNoteProps(childByLocalName(sectPr, "footnotePr")),
94
+ endnotePr: readNoteProps(childByLocalName(sectPr, "endnotePr"))
90
95
  };
91
96
  }
92
97
  function parseSectionProperties(xml) {
@@ -1,5 +1,9 @@
1
1
  // src/docx/serializeParagraph.ts
2
- import { elementXml, emptyTagXml, openTagXml } from "../ooxml/element.js";
2
+ import {
3
+ elementXml,
4
+ emptyTagXml,
5
+ openTagXml
6
+ } from "../ooxml/element.js";
3
7
  import { DocxExportError } from "../ooxml/errors.js";
4
8
  import {
5
9
  imageDrawingXml,
@@ -85,8 +89,9 @@ function renderInline(node, images) {
85
89
  if (typeof original === "string") return original;
86
90
  const id = node.attrs.id;
87
91
  const name = node.attrs.kind === "endnote" ? "endnoteReference" : "footnoteReference";
92
+ const customMark = node.attrs.customMarkFollows === true ? [[wName("customMarkFollows"), "1"]] : [];
88
93
  if (typeof id === "string") {
89
- return elementXml(wName(name), [[wName("id"), id]]);
94
+ return elementXml(wName(name), [...customMark, [wName("id"), id]]);
90
95
  }
91
96
  throw new DocxExportError(
92
97
  "lost-original",
@@ -14,6 +14,7 @@ import { type StoryKey } from "../schema/stories";
14
14
  import type { ImportedComments } from "./comments/reading";
15
15
  import { type FormattingContext, type ParagraphStyleOption } from "./formatting";
16
16
  import type { HeaderFooterStories } from "./headersFooters";
17
+ import type { NoteNumbering } from "./notes/reading";
17
18
  import type { PageGeometry } from "./pageGeometry";
18
19
  import type { ImportedStory } from "./story";
19
20
  export interface ImportedBlock {
@@ -83,6 +84,10 @@ export declare class SessionStore implements DocxSession, SessionIdentity {
83
84
  * instead (`docx/story`), so the two compare the way a body block and its original do.
84
85
  */
85
86
  readonly stories: ReadonlyMap<StoryKey, ImportedStory>;
87
+ /** How the settings count each kind of note, which a section may override (`docx/notes/numbering`) */
88
+ readonly noteNumbering: NoteNumbering;
89
+ /** The note entries that lay out the page rather than say anything: separators and the continuation notice */
90
+ readonly specialNotes: ReadonlySet<StoryKey>;
86
91
  constructor(opened: Omit<SessionStore, "kind" | "blocksOf">);
87
92
  /**
88
93
  * The blocks of one story as it arrived, which is what a block key of that story indexes into.
@@ -51,6 +51,10 @@ var SessionStore = class {
51
51
  * instead (`docx/story`), so the two compare the way a body block and its original do.
52
52
  */
53
53
  stories;
54
+ /** How the settings count each kind of note, which a section may override (`docx/notes/numbering`) */
55
+ noteNumbering;
56
+ /** The note entries that lay out the page rather than say anything: separators and the continuation notice */
57
+ specialNotes;
54
58
  constructor(opened) {
55
59
  this.sessionId = opened.sessionId;
56
60
  this.parts = opened.parts;
@@ -70,6 +74,8 @@ var SessionStore = class {
70
74
  this.commentReferenceIds = opened.commentReferenceIds;
71
75
  this.headerFooterStories = opened.headerFooterStories;
72
76
  this.stories = opened.stories;
77
+ this.noteNumbering = opened.noteNumbering;
78
+ this.specialNotes = opened.specialNotes;
73
79
  }
74
80
  /**
75
81
  * The blocks of one story as it arrived, which is what a block key of that story indexes into.
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The side stories a part beside the body is written from, told apart by what an edit did to each.
3
+ *
4
+ * Whether a story has to be written again is one question every story writer asks, so it is asked
5
+ * here once. A writer answering it for itself would be free to keep a story another writer drops,
6
+ * and the export invariants would have a third answer of their own.
7
+ */
8
+ import type { Node as PMNode } from "prosemirror-model";
9
+ import type { DocxExportErrorCode } from "../ooxml/errors";
10
+ import { type StoryKey, type StoryKind } from "../schema/stories";
11
+ import { type StoryToSettle } from "./identities";
12
+ import type { PartPlanner } from "./partPlan";
13
+ import type { SessionStore } from "./session";
14
+ import type { ImportedStory } from "./story";
15
+ export type StoryChange = {
16
+ readonly change: "kept";
17
+ readonly imported: ImportedStory;
18
+ } | {
19
+ readonly change: "edited";
20
+ readonly imported: ImportedStory;
21
+ readonly current: PMNode;
22
+ } | {
23
+ readonly change: "removed";
24
+ readonly imported: ImportedStory;
25
+ } | {
26
+ readonly change: "added";
27
+ readonly key: StoryKey;
28
+ readonly current: PMNode;
29
+ };
30
+ /** The id a key of this kind names */
31
+ export declare function storyIdOf(key: StoryKey, kind: StoryKind): string;
32
+ /** Every story of this kind the package arrived with or the document now holds, in part order then id order */
33
+ export declare function storyChangesOf(doc: PMNode, session: SessionStore, kind: StoryKind): readonly StoryChange[];
34
+ export type StoryChanged = Exclude<StoryChange["change"], "kept">;
35
+ export declare const EVERY_STORY_CHANGE: readonly StoryChanged[];
36
+ /**
37
+ * What one part writer carries into the file: the kind of story it writes and the changes to one
38
+ * it writes back. A change it leaves out has nowhere to go, and `docx/invariants` refuses it.
39
+ */
40
+ export interface StoryWriting {
41
+ readonly kind: StoryKind;
42
+ readonly changes: readonly StoryChanged[];
43
+ /** The stories it writes as the bytes they arrived as, whose change it therefore carries nowhere */
44
+ frozenEntries(session: SessionStore): ReadonlySet<StoryKey>;
45
+ }
46
+ /** What a part holding one entry per story writes, which is every change to a story of its kind */
47
+ export declare function storyEntriesWriting(part: StoryEntriesPart): StoryWriting;
48
+ /** A writer that takes these changes to every story of the kind, freezing none of them */
49
+ export declare function storyWriting(kind: StoryKind, changes: readonly StoryChanged[]): StoryWriting;
50
+ /**
51
+ * Every change the document made to a side story that no part writer carries into the file, as the
52
+ * key it stands under and what was done to it.
53
+ *
54
+ * A story changes on the document node whether or not a writer carries it, so a kind with no
55
+ * writer at all, a change a writer leaves out - a header story added or removed, which the header
56
+ * writer does not write - and a change to an entry written as it arrived are all reported here
57
+ * rather than dropped from the file without a word.
58
+ */
59
+ export declare function unwrittenStoryChanges(writings: readonly StoryWriting[], doc: PMNode, session: SessionStore): readonly {
60
+ readonly key: StoryKey;
61
+ readonly change: StoryChanged;
62
+ }[];
63
+ /** A part holding one entry per story, e.g. `w:footnotes` holding a `w:footnote` apiece */
64
+ export interface StoryEntriesPart {
65
+ readonly name: string;
66
+ readonly kind: StoryKind;
67
+ readonly relType: string;
68
+ readonly contentType: string;
69
+ /** The file name a part this planner creates takes beside the main part, ahead of any number */
70
+ readonly stem: string;
71
+ /** The local name of the part's root element */
72
+ readonly root: string;
73
+ /** The local name of the element each story stands in */
74
+ readonly entry: string;
75
+ /** The ids the document's references to this part name, which a part this planner creates keeps clear of */
76
+ referencedIds(doc: PMNode): ReadonlySet<string>;
77
+ /**
78
+ * The stories this part writes as the bytes they arrived as, whatever the document now says of
79
+ * them, and none for a part that writes every story it holds. `docx/invariants` refuses a change
80
+ * to one before anything is written.
81
+ */
82
+ frozenEntries(session: SessionStore): ReadonlySet<StoryKey>;
83
+ /** The entries a part this planner creates opens with, before any story */
84
+ prelude(taken: ReadonlySet<string>): string;
85
+ }
86
+ /**
87
+ * The stories a part is written with, in the order it writes them, and none where no story of its
88
+ * kind changed and the part is not written at all. The identity pass runs over this list as one
89
+ * part, and the export invariants ask the same list.
90
+ */
91
+ export declare function storyEntriesOf(part: StoryEntriesPart, doc: PMNode, session: SessionStore): readonly StoryToSettle[];
92
+ /** One reason the part cannot take the changes its stories went through */
93
+ export interface StoryPartProblem {
94
+ readonly code: DocxExportErrorCode;
95
+ readonly message: string;
96
+ }
97
+ /**
98
+ * Why the part cannot take what the document did to its stories, or none when it can. The part the
99
+ * package holds is rewritten around its root element, and a part the package lacks is declared in
100
+ * the content types part, which the export does not write from nothing.
101
+ */
102
+ export declare function storyEntriesProblems(part: StoryEntriesPart, doc: PMNode, session: SessionStore): readonly StoryPartProblem[];
103
+ /**
104
+ * A planner for a part holding one entry per story.
105
+ *
106
+ * Nothing is written while every story of the kind stands as it arrived, so an untouched package
107
+ * hands the part back as its own bytes. Once one changed, the part is written in the order it holds
108
+ * its entries: an untouched entry as it arrived, an edited one again, a removed one not at all,
109
+ * and every story added since after them in id order. A package holding no such part gets one,
110
+ * with its relationship, its content type, and the entries `prelude` opens it with.
111
+ */
112
+ export declare function storyEntriesPlanner(part: StoryEntriesPart): PartPlanner;