@stll/docx-core 0.41.0 → 0.42.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.
- package/dist/index.js +0 -4
- package/dist/ops/documentOps.d.ts +26 -1
- package/dist/ops/documentOps.js +40 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1449,10 +1449,6 @@ const validateTable = (table, path, ctx) => {
|
|
|
1449
1449
|
for (const [index, row] of table.rows.entries()) validateTableRow(row, `${path}.rows[${index}]`, ctx);
|
|
1450
1450
|
};
|
|
1451
1451
|
const validateTableRow = (row, path, ctx) => {
|
|
1452
|
-
if (row.cells.length === 0) {
|
|
1453
|
-
addError(ctx, `${path}.cells`, "Table row must contain at least one cell.");
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
1452
|
for (const [index, cell] of row.cells.entries()) validateTableCell(cell, `${path}.cells[${index}]`, ctx);
|
|
1457
1453
|
};
|
|
1458
1454
|
const validateTableCell = (cell, path, ctx) => {
|
|
@@ -1836,6 +1836,31 @@ export declare const contentRank: (operation: ContentRankOperation, target: {
|
|
|
1836
1836
|
export declare const compareBatchOrder: (left: BatchOrderAddress, right: BatchOrderAddress) => number;
|
|
1837
1837
|
/** Order operations once from addresses captured before the batch changes the document. */
|
|
1838
1838
|
export declare const orderBatchOperations: <T>(operations: readonly T[], addressOf: (operation: T) => BatchOrderAddress) => T[];
|
|
1839
|
+
/** The pre-batch blocks an operation names and the ones it takes away. */
|
|
1840
|
+
type BatchBlockAccess<Block> = {
|
|
1841
|
+
/** Blocks the operation edits or places something beside. */
|
|
1842
|
+
addresses: readonly Block[];
|
|
1843
|
+
/** Blocks the operation deletes, or merges into the block before them. */
|
|
1844
|
+
removes: readonly Block[];
|
|
1845
|
+
};
|
|
1846
|
+
/**
|
|
1847
|
+
* Whether deleting a block takes it out of the document. A container (a
|
|
1848
|
+
* story, cell, note or text box) has to end with a paragraph, so deleting its
|
|
1849
|
+
* last one with no paragraph the batch keeps before it to take its break only
|
|
1850
|
+
* empties it: it stays, and can still be addressed.
|
|
1851
|
+
*/
|
|
1852
|
+
export declare const deletionRemovesBlock: (deletion: {
|
|
1853
|
+
endsContainer: boolean;
|
|
1854
|
+
hasKeptParagraphBefore: boolean;
|
|
1855
|
+
}) => boolean;
|
|
1856
|
+
/**
|
|
1857
|
+
* A batch equals its operations applied one at a time with every operation
|
|
1858
|
+
* that addresses a block before any operation that removes that block: a
|
|
1859
|
+
* single edit can only address a block that still stands. Each operation
|
|
1860
|
+
* that addresses a block another one ahead of it removes moves to just before
|
|
1861
|
+
* the earliest such remover; every other operation keeps its place.
|
|
1862
|
+
*/
|
|
1863
|
+
export declare const orderAddressingBeforeRemoval: <T, Block>(ordered: readonly T[], accessOf: (operation: T) => BatchBlockAccess<Block>) => T[];
|
|
1839
1864
|
/**
|
|
1840
1865
|
* Partition an ordered batch into execution runs. Insertions at the same
|
|
1841
1866
|
* position share a run; every other operation remains a singleton.
|
|
@@ -1848,4 +1873,4 @@ export declare const orderBatchOperations: <T>(operations: readonly T[], address
|
|
|
1848
1873
|
* requested sequence, which no series of single edits produces.
|
|
1849
1874
|
*/
|
|
1850
1875
|
export declare const groupInsertionRuns: <T>(operations: readonly T[], insertionPositionOf: (operation: T) => number | null, keepsGap?: (operation: T) => boolean) => T[][];
|
|
1851
|
-
export type { AddNoteOp, AppliedDocumentOp, BatchOrderAddress, BatchRejectionReason, BlockInsertionPoint, BoundaryOccurrence, CommentAnchor, CommentExhaustionInput, CommentState, CopyOriginAncestorList, CreateCommentOp, CreateHeaderFooterOp, CreateNumberingInstanceOp, DeleteBlocksOp, DeleteColumnOp, DeleteCommentOp, DeleteNumberingInstanceOp, DeleteRangeOp, DeleteRowOp, DeleteTableOp, DocumentBatch, DocumentOp, DocumentOpEnvelope, DocumentOpRefusalReason, DocumentOpType, EditorIntent, EditorIntentMode, EmptyPropertySet, FormattingPatch, HeaderFooterStory, InlineSlice, InsertBlocksOp, InsertColumnOp, InsertContentOp, InsertRowOp, InsertTableOp, InsertTextOp, InsertedRunProps, JoinBlocksOp, JoinInlineOp, MergeCellsOp, NewIds, NoteStory, NumberingPartState, OpStory, PackageResourceEntry, PackageResourceEntryChange, PackageResourceMapChange, PackageResourceMedia, PackageResourcePart, PackageResources, ParagraphContentVerdict, ParagraphPropsPatch, ParagraphReviewFields, PlanTrackedDeletionOptions, PlanTrackedReplaceOptions, RemoveHeaderFooterOp, RemoveNoteOp, ReplaceBlocksOp, ReplaceInlineOp, ResolveRevisionOp, RestoreCommentStateOp, RestoreStoryPartsOp, RevisionDecision, RevisionStamp, RunPropsPatch, SectionEndpoint, SectionMapState, SectionPropertiesState, SectionViewEntry, SectionViewState, SequencedBatch, SetCellPropsOp, SetCommentResolutionOp, SetContainerBlocksOp, SetPackageResourcesOp, SetParagraphPropsOp, SetParagraphReviewOp, SetRowPropsOp, SetRunPropsOp, SetSectionEndpointOp, SetSectionPropsOp, SetTableGridOp, SetTableOp, SetTablePropsOp, SetTableRowsOp, SplitBlockOp, SplitCellOp, SplitHalf, SplitInlineOp, SplitParagraphFields, TableEditOp, TableIntentOperation, TextPosition, TouchedBlocks, UpdateCommentContentOp, WellFormedRangePlan, ZeroWidthItem };
|
|
1876
|
+
export type { AddNoteOp, AppliedDocumentOp, BatchBlockAccess, BatchOrderAddress, BatchRejectionReason, BlockInsertionPoint, BoundaryOccurrence, CommentAnchor, CommentExhaustionInput, CommentState, CopyOriginAncestorList, CreateCommentOp, CreateHeaderFooterOp, CreateNumberingInstanceOp, DeleteBlocksOp, DeleteColumnOp, DeleteCommentOp, DeleteNumberingInstanceOp, DeleteRangeOp, DeleteRowOp, DeleteTableOp, DocumentBatch, DocumentOp, DocumentOpEnvelope, DocumentOpRefusalReason, DocumentOpType, EditorIntent, EditorIntentMode, EmptyPropertySet, FormattingPatch, HeaderFooterStory, InlineSlice, InsertBlocksOp, InsertColumnOp, InsertContentOp, InsertRowOp, InsertTableOp, InsertTextOp, InsertedRunProps, JoinBlocksOp, JoinInlineOp, MergeCellsOp, NewIds, NoteStory, NumberingPartState, OpStory, PackageResourceEntry, PackageResourceEntryChange, PackageResourceMapChange, PackageResourceMedia, PackageResourcePart, PackageResources, ParagraphContentVerdict, ParagraphPropsPatch, ParagraphReviewFields, PlanTrackedDeletionOptions, PlanTrackedReplaceOptions, RemoveHeaderFooterOp, RemoveNoteOp, ReplaceBlocksOp, ReplaceInlineOp, ResolveRevisionOp, RestoreCommentStateOp, RestoreStoryPartsOp, RevisionDecision, RevisionStamp, RunPropsPatch, SectionEndpoint, SectionMapState, SectionPropertiesState, SectionViewEntry, SectionViewState, SequencedBatch, SetCellPropsOp, SetCommentResolutionOp, SetContainerBlocksOp, SetPackageResourcesOp, SetParagraphPropsOp, SetParagraphReviewOp, SetRowPropsOp, SetRunPropsOp, SetSectionEndpointOp, SetSectionPropsOp, SetTableGridOp, SetTableOp, SetTablePropsOp, SetTableRowsOp, SplitBlockOp, SplitCellOp, SplitHalf, SplitInlineOp, SplitParagraphFields, TableEditOp, TableIntentOperation, TextPosition, TouchedBlocks, UpdateCommentContentOp, WellFormedRangePlan, ZeroWidthItem };
|
package/dist/ops/documentOps.js
CHANGED
|
@@ -13123,6 +13123,8 @@ const refuse = (message, reason = DOCUMENT_OP_REFUSAL_REASONS.UNTRACKABLE) => Re
|
|
|
13123
13123
|
const editable = (items) => items.every((item) => {
|
|
13124
13124
|
switch (item.type) {
|
|
13125
13125
|
case "run": return (item.propertyChanges?.length ?? 0) === 0;
|
|
13126
|
+
case "simpleField":
|
|
13127
|
+
case "complexField":
|
|
13126
13128
|
case "bookmarkStart":
|
|
13127
13129
|
case "bookmarkEnd": return true;
|
|
13128
13130
|
case "hyperlink": return editable(item.children);
|
|
@@ -13148,6 +13150,8 @@ const linkedChildren = (items, intent) => {
|
|
|
13148
13150
|
case "run":
|
|
13149
13151
|
children.push(intent.type === "setHyperlink" ? styledRun(item, intent) : item);
|
|
13150
13152
|
break;
|
|
13153
|
+
case "simpleField":
|
|
13154
|
+
case "complexField":
|
|
13151
13155
|
case "bookmarkStart":
|
|
13152
13156
|
case "bookmarkEnd":
|
|
13153
13157
|
children.push(item);
|
|
@@ -16447,6 +16451,41 @@ const compareBatchOrder = (left, right) => {
|
|
|
16447
16451
|
/** Order operations once from addresses captured before the batch changes the document. */
|
|
16448
16452
|
const orderBatchOperations = (operations, addressOf) => operations.toSorted((left, right) => compareBatchOrder(addressOf(left), addressOf(right)));
|
|
16449
16453
|
/**
|
|
16454
|
+
* Whether deleting a block takes it out of the document. A container (a
|
|
16455
|
+
* story, cell, note or text box) has to end with a paragraph, so deleting its
|
|
16456
|
+
* last one with no paragraph the batch keeps before it to take its break only
|
|
16457
|
+
* empties it: it stays, and can still be addressed.
|
|
16458
|
+
*/
|
|
16459
|
+
const deletionRemovesBlock = (deletion) => !deletion.endsContainer || deletion.hasKeptParagraphBefore;
|
|
16460
|
+
/**
|
|
16461
|
+
* A batch equals its operations applied one at a time with every operation
|
|
16462
|
+
* that addresses a block before any operation that removes that block: a
|
|
16463
|
+
* single edit can only address a block that still stands. Each operation
|
|
16464
|
+
* that addresses a block another one ahead of it removes moves to just before
|
|
16465
|
+
* the earliest such remover; every other operation keeps its place.
|
|
16466
|
+
*/
|
|
16467
|
+
const orderAddressingBeforeRemoval = (ordered, accessOf) => {
|
|
16468
|
+
const result = [...ordered];
|
|
16469
|
+
const removesAny = (remover, blocks) => {
|
|
16470
|
+
const { removes } = accessOf(remover);
|
|
16471
|
+
return blocks.some((block) => removes.includes(block));
|
|
16472
|
+
};
|
|
16473
|
+
for (let round = 0; round <= result.length * result.length; round += 1) {
|
|
16474
|
+
const from = result.findIndex((operation, at) => {
|
|
16475
|
+
const { addresses } = accessOf(operation);
|
|
16476
|
+
return addresses.length > 0 && result.slice(0, at).some((earlier) => removesAny(earlier, addresses));
|
|
16477
|
+
});
|
|
16478
|
+
if (from < 0) return result;
|
|
16479
|
+
const operation = result[from];
|
|
16480
|
+
if (operation === void 0) return result;
|
|
16481
|
+
const { addresses } = accessOf(operation);
|
|
16482
|
+
const to = result.findIndex((candidate) => removesAny(candidate, addresses));
|
|
16483
|
+
result.splice(from, 1);
|
|
16484
|
+
result.splice(to, 0, operation);
|
|
16485
|
+
}
|
|
16486
|
+
throw new Error("A batch has no order that addresses each block before removing it");
|
|
16487
|
+
};
|
|
16488
|
+
/**
|
|
16450
16489
|
* Partition an ordered batch into execution runs. Insertions at the same
|
|
16451
16490
|
* position share a run; every other operation remains a singleton.
|
|
16452
16491
|
*
|
|
@@ -16480,4 +16519,4 @@ const groupInsertionRuns = (operations, insertionPositionOf, keepsGap = () => fa
|
|
|
16480
16519
|
}
|
|
16481
16520
|
return groups;
|
|
16482
16521
|
};
|
|
16483
|
-
export { BATCH_REJECTION_REASONS, BATCH_WIRE_OP_TYPES, BatchRejection, DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_SCHEMA_VERSION, DOCUMENT_OP_TYPES, DocumentOpRefusal, DocumentOpsContractError, EMPTY_PROPERTY_SETS, INHERIT_RUN_PROPS, MAX_BATCH_WIRE_BYTES, OBJECT_REPLACEMENT_CHARACTER, OP_STORIES, PARAGRAPH_MARK_FORMATTING_KEYS, PROPERTY_REVIEW_POLICIES, REVISION_DECISIONS, SPLIT_HALVES, acceptCopyOriginAncestors, addCopyOriginAncestor, allocateCommentAnchorIds, applyDocumentOp, applyDocumentOpEnvelope, applyDocumentOps, captureDocumentOp, combineEdits, commentDocumentIssue, compareBatchOrder, compareGaps, compileEditorIntent, contentRank, createClient, createEditorIntentIdAllocator, createSequencer, defaultInsertionGap, documentStories, editorParagraphGroups, editorPositionAtPhysicalPosition, findStoryBody, formattingEquals, freshCommentId, groupInsertionRuns, idKey, inlineLeafSpans, isCommentAnchorCarrierType, isCommentExhausted, isCopyOriginAncestors, isTextOnlyRun, mapTocBookmarkPosition, mergeRunContent, normalizeForOps, noteUsesCustomMark, orderBatchOperations, packageParagraphIds, packageResourcesOpOf, paragraphContentVerdict, paragraphIdsIn, paragraphLength, paragraphLogicalText, paragraphMarkOutcome, paragraphRemains, paragraphVisibleText, parseDocumentBatch, physicalOffsetAtVisibleOffset, physicalPositionAtEditorOffset, planTrackedDeletion, planTrackedReplace, planWellFormedRanges, reconcileDocumentPartRelationships, registerParagraphPropertySnapshot, rejectCopyOriginAncestors, revisionIdDemand, runsMergeable, sameStory, sectionPropertiesAt, shiftCopyOriginAncestors, storyBody, survivingComments, toOpEnvelope, transformBatch, validateDocumentBatch, validateOpsDocument, validateSequencedBatch, withBodyContent, withoutCommentThreads, zeroWidthLeavesAt };
|
|
16522
|
+
export { BATCH_REJECTION_REASONS, BATCH_WIRE_OP_TYPES, BatchRejection, DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_SCHEMA_VERSION, DOCUMENT_OP_TYPES, DocumentOpRefusal, DocumentOpsContractError, EMPTY_PROPERTY_SETS, INHERIT_RUN_PROPS, MAX_BATCH_WIRE_BYTES, OBJECT_REPLACEMENT_CHARACTER, OP_STORIES, PARAGRAPH_MARK_FORMATTING_KEYS, PROPERTY_REVIEW_POLICIES, REVISION_DECISIONS, SPLIT_HALVES, acceptCopyOriginAncestors, addCopyOriginAncestor, allocateCommentAnchorIds, applyDocumentOp, applyDocumentOpEnvelope, applyDocumentOps, captureDocumentOp, combineEdits, commentDocumentIssue, compareBatchOrder, compareGaps, compileEditorIntent, contentRank, createClient, createEditorIntentIdAllocator, createSequencer, defaultInsertionGap, deletionRemovesBlock, documentStories, editorParagraphGroups, editorPositionAtPhysicalPosition, findStoryBody, formattingEquals, freshCommentId, groupInsertionRuns, idKey, inlineLeafSpans, isCommentAnchorCarrierType, isCommentExhausted, isCopyOriginAncestors, isTextOnlyRun, mapTocBookmarkPosition, mergeRunContent, normalizeForOps, noteUsesCustomMark, orderAddressingBeforeRemoval, orderBatchOperations, packageParagraphIds, packageResourcesOpOf, paragraphContentVerdict, paragraphIdsIn, paragraphLength, paragraphLogicalText, paragraphMarkOutcome, paragraphRemains, paragraphVisibleText, parseDocumentBatch, physicalOffsetAtVisibleOffset, physicalPositionAtEditorOffset, planTrackedDeletion, planTrackedReplace, planWellFormedRanges, reconcileDocumentPartRelationships, registerParagraphPropertySnapshot, rejectCopyOriginAncestors, revisionIdDemand, runsMergeable, sameStory, sectionPropertiesAt, shiftCopyOriginAncestors, storyBody, survivingComments, toOpEnvelope, transformBatch, validateDocumentBatch, validateOpsDocument, validateSequencedBatch, withBodyContent, withoutCommentThreads, zeroWidthLeavesAt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/docx-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "Typed OOXML/DOCX model, validation, serialization, legal-source compilation, and browser-native package projection.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"skills",
|
|
28
28
|
"README.md",
|
|
29
29
|
"LICENSE",
|
|
30
|
-
"NOTICE.md"
|
|
30
|
+
"NOTICE.md",
|
|
31
|
+
"licenses",
|
|
32
|
+
"THIRD_PARTY_NOTICES.md"
|
|
31
33
|
],
|
|
32
34
|
"type": "module",
|
|
33
35
|
"sideEffects": false,
|
|
@@ -100,7 +102,7 @@
|
|
|
100
102
|
"@stll/docx-utils": "^0.2.0",
|
|
101
103
|
"@stll/utf8-boundaries": "0.2.0",
|
|
102
104
|
"better-result": "3.0.1",
|
|
103
|
-
"marked": "^18.1.
|
|
105
|
+
"marked": "^18.1.2"
|
|
104
106
|
},
|
|
105
107
|
"devDependencies": {
|
|
106
108
|
"bun-types": "1.4.4",
|