@stll/docx-core 0.41.0 → 0.42.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.
- package/dist/ops/documentOps.d.ts +26 -1
- package/dist/ops/documentOps.js +36 -1
- package/package.json +5 -3
|
@@ -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
|
@@ -16447,6 +16447,41 @@ const compareBatchOrder = (left, right) => {
|
|
|
16447
16447
|
/** Order operations once from addresses captured before the batch changes the document. */
|
|
16448
16448
|
const orderBatchOperations = (operations, addressOf) => operations.toSorted((left, right) => compareBatchOrder(addressOf(left), addressOf(right)));
|
|
16449
16449
|
/**
|
|
16450
|
+
* Whether deleting a block takes it out of the document. A container (a
|
|
16451
|
+
* story, cell, note or text box) has to end with a paragraph, so deleting its
|
|
16452
|
+
* last one with no paragraph the batch keeps before it to take its break only
|
|
16453
|
+
* empties it: it stays, and can still be addressed.
|
|
16454
|
+
*/
|
|
16455
|
+
const deletionRemovesBlock = (deletion) => !deletion.endsContainer || deletion.hasKeptParagraphBefore;
|
|
16456
|
+
/**
|
|
16457
|
+
* A batch equals its operations applied one at a time with every operation
|
|
16458
|
+
* that addresses a block before any operation that removes that block: a
|
|
16459
|
+
* single edit can only address a block that still stands. Each operation
|
|
16460
|
+
* that addresses a block another one ahead of it removes moves to just before
|
|
16461
|
+
* the earliest such remover; every other operation keeps its place.
|
|
16462
|
+
*/
|
|
16463
|
+
const orderAddressingBeforeRemoval = (ordered, accessOf) => {
|
|
16464
|
+
const result = [...ordered];
|
|
16465
|
+
const removesAny = (remover, blocks) => {
|
|
16466
|
+
const { removes } = accessOf(remover);
|
|
16467
|
+
return blocks.some((block) => removes.includes(block));
|
|
16468
|
+
};
|
|
16469
|
+
for (let round = 0; round <= result.length * result.length; round += 1) {
|
|
16470
|
+
const from = result.findIndex((operation, at) => {
|
|
16471
|
+
const { addresses } = accessOf(operation);
|
|
16472
|
+
return addresses.length > 0 && result.slice(0, at).some((earlier) => removesAny(earlier, addresses));
|
|
16473
|
+
});
|
|
16474
|
+
if (from < 0) return result;
|
|
16475
|
+
const operation = result[from];
|
|
16476
|
+
if (operation === void 0) return result;
|
|
16477
|
+
const { addresses } = accessOf(operation);
|
|
16478
|
+
const to = result.findIndex((candidate) => removesAny(candidate, addresses));
|
|
16479
|
+
result.splice(from, 1);
|
|
16480
|
+
result.splice(to, 0, operation);
|
|
16481
|
+
}
|
|
16482
|
+
throw new Error("A batch has no order that addresses each block before removing it");
|
|
16483
|
+
};
|
|
16484
|
+
/**
|
|
16450
16485
|
* Partition an ordered batch into execution runs. Insertions at the same
|
|
16451
16486
|
* position share a run; every other operation remains a singleton.
|
|
16452
16487
|
*
|
|
@@ -16480,4 +16515,4 @@ const groupInsertionRuns = (operations, insertionPositionOf, keepsGap = () => fa
|
|
|
16480
16515
|
}
|
|
16481
16516
|
return groups;
|
|
16482
16517
|
};
|
|
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 };
|
|
16518
|
+
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.0",
|
|
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",
|