@stll/folio-core 0.47.4 → 0.47.5
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/compare/inline-atoms.js +218 -31
- package/dist/compare/section-boundary-properties.js +1 -0
- package/dist/content-controls/mutateContentControls.js +1 -3
- package/dist/docx/commentRangeIntegrity.js +7 -0
- package/dist/docx/documentParser.js +55 -3
- package/dist/docx/inlineWrapperContent.d.ts +18 -16
- package/dist/docx/inlineWrapperContent.js +18 -16
- package/dist/docx/normalizeBaseDirection.js +4 -0
- package/dist/docx/rezip.js +1 -0
- package/dist/docx/serializer/documentSerializer.js +16 -1
- package/dist/docx/serializer/paragraphSerializer.js +8 -0
- package/dist/docx/serializer/tableSerializer.js +5 -2
- package/dist/docx/server/createBilingualDocument.js +23 -14
- package/dist/docx/tableParser.js +101 -75
- package/dist/markdown/renderRuns.js +4 -0
- package/dist/markdown/renderTable.js +46 -12
- package/dist/prosemirror/attrs/index.js +67 -3
- package/dist/prosemirror/commentReferenceAttrs.js +2 -2
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +7 -3
- package/dist/prosemirror/commentReferenceIntegrity.js +9 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +74 -18
- package/dist/prosemirror/conversion/toProseDoc.js +75 -42
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +13 -6
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +24 -6
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +9 -5
- package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -2
- package/dist/prosemirror/schema/marks.d.ts +11 -0
- package/dist/prosemirror/schema/nodes.d.ts +6 -4
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -1
- package/dist/prosemirror/trackedRunInlineAtoms.js +1 -1
- package/dist/prosemirror/validation.js +48 -7
- package/dist/types/content.d.ts +2 -2
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/mergeDocumentContent.js +1 -7
- package/package.json +2 -2
|
@@ -49,7 +49,7 @@ const validateBookmarkBoundaryStructure = (doc, issues) => {
|
|
|
49
49
|
const { id, name, path, paragraph, origin } = boundary;
|
|
50
50
|
const previousOrigin = startedBy.get(id);
|
|
51
51
|
if (previousOrigin !== void 0) {
|
|
52
|
-
if (origin === "attr" && previousOrigin === "attr") return false;
|
|
52
|
+
if (origin === "paragraph-attr" && previousOrigin === "paragraph-attr") return false;
|
|
53
53
|
issues.push({
|
|
54
54
|
path,
|
|
55
55
|
message: `${describeBookmark(id, name)} has more than one start boundary (${paragraph}).`
|
|
@@ -81,7 +81,7 @@ const validateBookmarkBoundaryStructure = (doc, issues) => {
|
|
|
81
81
|
name: bookmark.name,
|
|
82
82
|
path: bookmarkPath,
|
|
83
83
|
paragraph: enclosingParagraph,
|
|
84
|
-
origin: "attr"
|
|
84
|
+
origin: "paragraph-attr"
|
|
85
85
|
})) openedAttrBookmarks.push({
|
|
86
86
|
id: bookmark.id,
|
|
87
87
|
path: bookmarkPath
|
|
@@ -100,21 +100,62 @@ const validateBookmarkBoundaryStructure = (doc, issues) => {
|
|
|
100
100
|
name: attrs.name ?? null,
|
|
101
101
|
path,
|
|
102
102
|
paragraph: enclosingParagraph,
|
|
103
|
-
origin: "
|
|
103
|
+
origin: "boundary"
|
|
104
104
|
});
|
|
105
105
|
else registerEnd(attrs.id, path, enclosingParagraph);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
let positionedBookmarks = [];
|
|
109
|
+
if (node.type.name === "table") {
|
|
110
|
+
const result = readTableAttrs(node);
|
|
111
|
+
if (result.ok) positionedBookmarks = result.value._bookmarks ?? [];
|
|
112
|
+
} else if (node.type.name === "tableRow") {
|
|
113
|
+
const result = readTableRowAttrs(node);
|
|
114
|
+
if (result.ok) positionedBookmarks = result.value._bookmarks ?? [];
|
|
115
|
+
}
|
|
116
|
+
const positionedBookmarksByChildIndex = /* @__PURE__ */ new Map();
|
|
117
|
+
for (const [index, positioned] of positionedBookmarks.entries()) {
|
|
118
|
+
const markerPath = `${path}.${node.type.name}.attrs._bookmarks[${index}]`;
|
|
119
|
+
if (positioned.index > node.childCount) {
|
|
120
|
+
issues.push({
|
|
121
|
+
path: `${markerPath}.index`,
|
|
122
|
+
message: `Expected a child position between 0 and ${node.childCount}.`
|
|
123
|
+
});
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const markers = positionedBookmarksByChildIndex.get(positioned.index);
|
|
127
|
+
const atPosition = {
|
|
128
|
+
marker: positioned.marker,
|
|
129
|
+
path: markerPath
|
|
130
|
+
};
|
|
131
|
+
if (markers === void 0) positionedBookmarksByChildIndex.set(positioned.index, [atPosition]);
|
|
132
|
+
else markers.push(atPosition);
|
|
133
|
+
}
|
|
134
|
+
const visitPositionedBookmarks = (childIndex) => {
|
|
135
|
+
for (const { marker, path: markerPath } of positionedBookmarksByChildIndex.get(childIndex) ?? []) if (marker.type === "bookmarkStart") registerStart({
|
|
136
|
+
id: marker.id,
|
|
137
|
+
name: marker.name,
|
|
138
|
+
path: markerPath,
|
|
139
|
+
paragraph: enclosingParagraph,
|
|
140
|
+
origin: "positioned"
|
|
141
|
+
});
|
|
142
|
+
else if (open.has(marker.id)) registerEnd(marker.id, markerPath, enclosingParagraph);
|
|
143
|
+
};
|
|
108
144
|
node.forEach((child, _offset, index) => {
|
|
145
|
+
visitPositionedBookmarks(index);
|
|
109
146
|
visit(child, `${path}.content[${index}]`, enclosingParagraph);
|
|
110
147
|
});
|
|
148
|
+
visitPositionedBookmarks(node.childCount);
|
|
111
149
|
for (const { id, path: bookmarkPath } of openedAttrBookmarks) registerEnd(id, bookmarkPath, enclosingParagraph);
|
|
112
150
|
};
|
|
113
151
|
visit(doc, "doc", "the document root");
|
|
114
|
-
for (const boundary of open.values())
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
152
|
+
for (const boundary of open.values()) {
|
|
153
|
+
if (boundary.origin === "positioned") continue;
|
|
154
|
+
issues.push({
|
|
155
|
+
path: boundary.path,
|
|
156
|
+
message: `${describeBookmark(boundary.id, boundary.name)} has no matching end boundary (${boundary.paragraph}).`
|
|
157
|
+
});
|
|
158
|
+
}
|
|
118
159
|
};
|
|
119
160
|
const assertValidProseMirrorDocument = (doc, context) => {
|
|
120
161
|
if (validDocumentCache.has(doc)) return;
|
package/dist/types/content.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBody, DrawingContent, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots } from "@stll/docx-core/model";
|
|
2
|
-
export type { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBody, DrawingContent, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots };
|
|
1
|
+
import { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DrawingContent, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots } from "@stll/docx-core/model";
|
|
2
|
+
export type { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DrawingContent, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ type ComplexField = document_d_exports.ComplexField;
|
|
|
12
12
|
type ConditionalFormatStyle = document_d_exports.ConditionalFormatStyle;
|
|
13
13
|
type DocDefaults = document_d_exports.DocDefaults;
|
|
14
14
|
type Document = document_d_exports.Document;
|
|
15
|
+
type DocumentBackground = document_d_exports.DocumentBackground;
|
|
16
|
+
type DocumentBackgroundDrawing = document_d_exports.DocumentBackgroundDrawing;
|
|
15
17
|
type DocumentBody = document_d_exports.DocumentBody;
|
|
16
18
|
type DocxConformanceClass = document_d_exports.DocxConformanceClass;
|
|
17
19
|
type DocxPackage = document_d_exports.DocxPackage;
|
|
@@ -115,4 +117,4 @@ type ThemeFont = document_d_exports.ThemeFont;
|
|
|
115
117
|
type ThemeFontScheme = document_d_exports.ThemeFontScheme;
|
|
116
118
|
type UnderlineStyle = document_d_exports.UnderlineStyle;
|
|
117
119
|
type VerticalAlign = document_d_exports.VerticalAlign;
|
|
118
|
-
export type { AbstractNumbering, BlockContent, BookmarkEnd, BookmarkStart, BorderSpec, BreakContent, CellMargins, ColorValue, Column, ComplexField, ConditionalFormatStyle, DocDefaults, Document, DocumentBody, DocxConformanceClass, DocxPackage, DrawingContent, DrawingRawXmlMode, EmbeddedFontRef, EmphasisMark, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FloatingTableProperties, FontCharset, FontInfo, FontTable, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, InstrTextContent, LevelLegacy, LevelOverride, LevelSuffix, LineNumberRestart, LineSpacingRule, ListLevel, ListRendering, MediaFile, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, NumberFormat, NumberingDefinitions, NumberingInstance, PageOrientation, Paragraph, ParagraphAlignment, ParagraphContent, ParagraphFormatting, PositionalTab, Relationship, RelationshipMap, RelationshipType, Run, RunContent, SchemeColorSlot, Section, SectionProperties, SectionStart, ShadingProperties, Shape, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, Style, StyleDefinitions, StyleType, SymbolContent, TabContent, TabLeader, TabStop, TabStopAlignment, Table, TableBorders, TableCell, TableCellFormatting, TableFormatting, TableGridChange, TableLook, TableMeasurement, TableRow, TableRowFormatting, TableWidthType, TextBox, TextContent, TextEffect, TextFormatting, Theme, ThemeColor, ThemeColorScheme, ThemeColorValue, ThemeFont, ThemeFontScheme, UnderlineStyle, VerticalAlign };
|
|
120
|
+
export type { AbstractNumbering, BlockContent, BookmarkEnd, BookmarkStart, BorderSpec, BreakContent, CellMargins, ColorValue, Column, ComplexField, ConditionalFormatStyle, DocDefaults, Document, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DocxConformanceClass, DocxPackage, DrawingContent, DrawingRawXmlMode, EmbeddedFontRef, EmphasisMark, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FloatingTableProperties, FontCharset, FontInfo, FontTable, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, InstrTextContent, LevelLegacy, LevelOverride, LevelSuffix, LineNumberRestart, LineSpacingRule, ListLevel, ListRendering, MediaFile, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, NumberFormat, NumberingDefinitions, NumberingInstance, PageOrientation, Paragraph, ParagraphAlignment, ParagraphContent, ParagraphFormatting, PositionalTab, Relationship, RelationshipMap, RelationshipType, Run, RunContent, SchemeColorSlot, Section, SectionProperties, SectionStart, ShadingProperties, Shape, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, Style, StyleDefinitions, StyleType, SymbolContent, TabContent, TabLeader, TabStop, TabStopAlignment, Table, TableBorders, TableCell, TableCellFormatting, TableFormatting, TableGridChange, TableLook, TableMeasurement, TableRow, TableRowFormatting, TableWidthType, TextBox, TextContent, TextEffect, TextFormatting, Theme, ThemeColor, ThemeColorScheme, ThemeColorValue, ThemeFont, ThemeFontScheme, UnderlineStyle, VerticalAlign };
|
|
@@ -92,12 +92,6 @@ function remapBlock(block, numIdRemap, abstractNumIdRemap) {
|
|
|
92
92
|
};
|
|
93
93
|
return block;
|
|
94
94
|
}
|
|
95
|
-
/** A cell holds no content control, so the walk stays inside its own union. */
|
|
96
|
-
function remapCellBlock(block, numIdRemap, abstractNumIdRemap) {
|
|
97
|
-
if (block.type === "paragraph") return remapParagraph(block, numIdRemap, abstractNumIdRemap);
|
|
98
|
-
if (block.type === "table") return remapTable(block, numIdRemap, abstractNumIdRemap);
|
|
99
|
-
return block;
|
|
100
|
-
}
|
|
101
95
|
function remapTable(table, numIdRemap, abstractNumIdRemap) {
|
|
102
96
|
return {
|
|
103
97
|
...table,
|
|
@@ -105,7 +99,7 @@ function remapTable(table, numIdRemap, abstractNumIdRemap) {
|
|
|
105
99
|
...row,
|
|
106
100
|
cells: row.cells.map((cell) => ({
|
|
107
101
|
...cell,
|
|
108
|
-
content: cell.content.map((item) =>
|
|
102
|
+
content: cell.content.map((item) => remapBlock(item, numIdRemap, abstractNumIdRemap))
|
|
109
103
|
}))
|
|
110
104
|
}))
|
|
111
105
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.5",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"perf": "bun scripts/profile-editor.ts"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"@stll/docx-core": "^0.25.
|
|
131
|
+
"@stll/docx-core": "^0.25.3",
|
|
132
132
|
"@stll/docx-utils": "^0.1.0",
|
|
133
133
|
"@stll/template-conditions": ">=0.4.0 <1.0.0",
|
|
134
134
|
"better-result": "3.0.1",
|