@stll/folio-core 0.67.0 → 0.68.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/ai-edits/apply.d.ts +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +29 -12
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +28 -1
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +327 -73
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +91 -37
- package/dist/controller/layoutPipeline.js +48 -15
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +17 -0
- package/dist/docx/hostCommentThreads.js +49 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +227 -96
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +6 -0
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +3 -1
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +36 -1
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +46 -17
- package/dist/layout-painter/renderTable.js +7 -4
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +25 -0
- package/dist/prosemirror/commands/comments.js +102 -11
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +76 -31
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +319 -51
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.js +20 -9
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/validation.js +1 -0
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import { resolveColorValueToHex } from "../../docx/drawingUtils.js";
|
|
|
3
3
|
import { isInlineSdtContent, isTrackedChangeWrapperChild } from "../../docx/inlineWrapperContent.js";
|
|
4
4
|
import { listRenderingDefinitionsMatch, resolveListRenderingDefinition } from "../../docx/listRendering.js";
|
|
5
5
|
import { getCachedNumberingMap } from "../../docx/numberingParser.js";
|
|
6
|
-
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, createProseParagraphWithPropertySource, getDocumentParagraphPropertySourceContract, paragraphFormattingWithAuthoredIndentation, proseParagraphAttrsWithoutPropertySource, recreateProseNodeWithParagraphPropertySource, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
|
|
6
|
+
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, createProseParagraphWithPropertySource, getDocumentParagraphPropertySourceContract, paragraphFormattingWithAuthoredIndentation, paragraphPropertySourceState, proseParagraphAttrsWithoutPropertySource, recreateProseNodeWithParagraphPropertySource, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
|
|
7
7
|
import { visitInlineContentSlots, visitInlineContentSlotsInContent } from "../../docx/paragraphTraversal.js";
|
|
8
8
|
import { isBaselineVertAlign } from "../../docx/runParser.js";
|
|
9
9
|
import { replayableShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
|
|
@@ -30,6 +30,7 @@ import { withEnclosingRevision } from "../contentControlRevisions.js";
|
|
|
30
30
|
import { emptyFieldRunPropertyChanges } from "../emptyFieldResultRuns.js";
|
|
31
31
|
import { planEmptyRanges } from "../emptyRangeAnchor.js";
|
|
32
32
|
import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
|
|
33
|
+
import { BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/BlockCommentRangeBoundaryExtension.js";
|
|
33
34
|
import { BLOCK_MOVE_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/BlockMoveRangeBoundaryExtension.js";
|
|
34
35
|
import { COMMENT_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/CommentRangeBoundaryExtension.js";
|
|
35
36
|
import { MOVE_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/MoveRangeBoundaryExtension.js";
|
|
@@ -85,11 +86,10 @@ const pageBreakProjectionWarn = (warn) => warn === void 0 ? noPageBreakProjectio
|
|
|
85
86
|
* span carrying a guessed/copied id could collide with and hijack a real
|
|
86
87
|
* text box anchored in a completely different document.
|
|
87
88
|
*/
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
89
|
+
const newTextBoxGroupSalt = () => Math.random().toString(36).slice(2, 10);
|
|
90
|
+
/** Text-box group ids under one salt, counted from `counter`. */
|
|
91
|
+
const textBoxGroupIdsFrom = (salt, counter) => () => `${salt}:${counter.value++}`;
|
|
92
|
+
const createTextBoxGroupIdFactory = (salt = newTextBoxGroupSalt()) => textBoxGroupIdsFrom(salt, { value: 0 });
|
|
93
93
|
/**
|
|
94
94
|
* The identity mark for one authored `w:r`, or `null` when it carries nothing
|
|
95
95
|
* worth a mark.
|
|
@@ -144,6 +144,11 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
144
144
|
position += 1;
|
|
145
145
|
counts.set(id, count);
|
|
146
146
|
};
|
|
147
|
+
const countMarkersWhere = (markers, stands) => {
|
|
148
|
+
for (const { index, marker } of markers ?? []) if (stands(index)) countBoundary(marker.id, marker.type === "bookmarkStart" ? "start" : "end");
|
|
149
|
+
};
|
|
150
|
+
const countMarkersAt = (markers, at) => countMarkersWhere(markers, (index) => index === at);
|
|
151
|
+
const countMarkersFrom = (markers, from) => countMarkersWhere(markers, (index) => index >= from);
|
|
147
152
|
const visitRun = (run) => {
|
|
148
153
|
for (const content of run.content) if (content.type === "shape" && content.shape.textBody) visitBlocks(content.shape.textBody.content);
|
|
149
154
|
};
|
|
@@ -167,7 +172,8 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
167
172
|
break;
|
|
168
173
|
case "preservedInline": break;
|
|
169
174
|
case "inlineWrapper":
|
|
170
|
-
|
|
175
|
+
case "complexField":
|
|
176
|
+
visitParagraphContent(child);
|
|
171
177
|
break;
|
|
172
178
|
default: panic(`Unsupported hyperlink child: ${JSON.stringify(child)}`);
|
|
173
179
|
}
|
|
@@ -218,11 +224,15 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
218
224
|
for (const content of block.content) visitParagraphContent(content);
|
|
219
225
|
break;
|
|
220
226
|
case "table":
|
|
221
|
-
for (const
|
|
222
|
-
|
|
223
|
-
for (const
|
|
224
|
-
|
|
227
|
+
for (const [rowIndex, row] of block.rows.entries()) {
|
|
228
|
+
countMarkersAt(block.bookmarks, rowIndex);
|
|
229
|
+
for (const [cellIndex, cell] of row.cells.entries()) {
|
|
230
|
+
countMarkersAt(row.bookmarks, cellIndex);
|
|
231
|
+
visitBlocks(cell.content);
|
|
232
|
+
}
|
|
233
|
+
countMarkersFrom(row.bookmarks, row.cells.length);
|
|
225
234
|
}
|
|
235
|
+
countMarkersFrom(block.bookmarks, block.rows.length);
|
|
226
236
|
break;
|
|
227
237
|
case "blockSdt":
|
|
228
238
|
case "blockCustomXml":
|
|
@@ -235,6 +245,8 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
235
245
|
case "bookmarkEnd":
|
|
236
246
|
countBoundary(block.id, "end");
|
|
237
247
|
break;
|
|
248
|
+
case "commentRangeStart":
|
|
249
|
+
case "commentRangeEnd":
|
|
238
250
|
case "moveFromRangeStart":
|
|
239
251
|
case "moveFromRangeEnd":
|
|
240
252
|
case "moveToRangeStart":
|
|
@@ -245,6 +257,143 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
245
257
|
visitBlocks(blocks);
|
|
246
258
|
return new Set([...counts].flatMap(([id, count]) => count.starts === 1 && count.ends === 1 && count.firstStart !== void 0 && count.firstEnd !== void 0 && count.firstStart < count.firstEnd ? [id] : []));
|
|
247
259
|
};
|
|
260
|
+
/** A membership whose answers a block's conversion read, recorded to check later. */
|
|
261
|
+
var RecordedMembership = class {
|
|
262
|
+
answers = /* @__PURE__ */ new Map();
|
|
263
|
+
source;
|
|
264
|
+
constructor(source) {
|
|
265
|
+
this.source = source;
|
|
266
|
+
}
|
|
267
|
+
has(value) {
|
|
268
|
+
const answer = this.source.has(value);
|
|
269
|
+
this.answers.set(value, answer);
|
|
270
|
+
return answer;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const sameIds = (left, right) => left.length === right.length && left.every((value, index) => value === right[index]);
|
|
274
|
+
const setReadsHold = (reads, set) => {
|
|
275
|
+
for (const [value, answer] of reads.answers) if (set.has(value) !== answer) return false;
|
|
276
|
+
return true;
|
|
277
|
+
};
|
|
278
|
+
const storyReadsHold = (reads, state) => (!reads.textBoxGroups.used || reads.textBoxGroups.start === state.textBoxGroups.value) && (reads.hyperlinks.taken === 0 || reads.hyperlinks.start === state.hyperlinks.value) && (reads.noteOccurrences.taken === 0 || reads.noteOccurrences.start === state.noteOccurrences.value) && setReadsHold(reads.pairedBookmarkIds, state.pairedBookmarkIds) && setReadsHold(reads.storyRangedCommentIds, state.storyRangedCommentIds) && sameIds(reads.openCommentIds.start, [...state.openCommentIds]);
|
|
279
|
+
/** Advance the story past a block whose reads hold, as converting it would. */
|
|
280
|
+
const advanceStory = (reads, state) => {
|
|
281
|
+
state.textBoxGroups.value += reads.textBoxGroups.taken;
|
|
282
|
+
state.hyperlinks.value += reads.hyperlinks.taken;
|
|
283
|
+
state.noteOccurrences.value += reads.noteOccurrences.taken;
|
|
284
|
+
state.openCommentIds.clear();
|
|
285
|
+
for (const id of reads.openCommentIds.end) state.openCommentIds.add(id);
|
|
286
|
+
};
|
|
287
|
+
const setReadsOf = (set) => ({ answers: set.answers });
|
|
288
|
+
const sameState = (left, right) => left.length === right.length && left.every((value, index) => value === right[index]);
|
|
289
|
+
/**
|
|
290
|
+
* Converted blocks kept across projections of one story.
|
|
291
|
+
*
|
|
292
|
+
* A block is the same object in the next document when an edit left it, so
|
|
293
|
+
* its nodes can be reused where the story facts its conversion read are the
|
|
294
|
+
* same: the counters it drew from, the comments open at its start, and the
|
|
295
|
+
* bookmark and comment ids it asked about. The package inputs (styles,
|
|
296
|
+
* theme, numbering) are part of the cache: a projection over other ones
|
|
297
|
+
* starts the cache over.
|
|
298
|
+
*/
|
|
299
|
+
var ProjectionBlockCache = class {
|
|
300
|
+
salt = newTextBoxGroupSalt();
|
|
301
|
+
inputs;
|
|
302
|
+
context;
|
|
303
|
+
blocks = /* @__PURE__ */ new WeakMap();
|
|
304
|
+
/** The package context for these inputs, the cache started over if they changed. */
|
|
305
|
+
packageContext(inputs) {
|
|
306
|
+
const current = this.inputs;
|
|
307
|
+
if (this.context !== void 0 && current !== void 0 && current.styles === inputs.styles && current.theme === inputs.theme && current.numbering === inputs.numbering && current.warn === inputs.warn) return this.context;
|
|
308
|
+
this.inputs = inputs;
|
|
309
|
+
this.blocks = /* @__PURE__ */ new WeakMap();
|
|
310
|
+
this.context = {
|
|
311
|
+
styleResolver: createStyleEngine(inputs.styles),
|
|
312
|
+
listRenderings: /* @__PURE__ */ new Map(),
|
|
313
|
+
numbering: inputs.numbering === void 0 ? void 0 : getCachedNumberingMap(inputs.numbering),
|
|
314
|
+
theme: inputs.theme,
|
|
315
|
+
pageBreakRunSourceDescendants: buildPageBreakRunSourceDescendantIndex([]),
|
|
316
|
+
warnPageBreakProjection: pageBreakProjectionWarn(inputs.warn),
|
|
317
|
+
createMark: createMarkInterner(schema)
|
|
318
|
+
};
|
|
319
|
+
return this.context;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The nodes of `paragraph` from the story state it starts at, reused when
|
|
323
|
+
* every story fact its last conversion read still holds, else converted.
|
|
324
|
+
*/
|
|
325
|
+
paragraph(paragraph, state, convert) {
|
|
326
|
+
const known = this.blocks.get(paragraph);
|
|
327
|
+
const sourceState = paragraphPropertySourceState(paragraph);
|
|
328
|
+
if (known !== void 0 && sameState(known.sourceState, sourceState) && storyReadsHold(known.reads, state)) {
|
|
329
|
+
advanceStory(known.reads, state);
|
|
330
|
+
return known.nodes;
|
|
331
|
+
}
|
|
332
|
+
const context = this.context ?? panic("A block cache converts after its package context");
|
|
333
|
+
const textBoxGroups = {
|
|
334
|
+
start: state.textBoxGroups.value,
|
|
335
|
+
taken: 0
|
|
336
|
+
};
|
|
337
|
+
const hyperlinks = {
|
|
338
|
+
start: state.hyperlinks.value,
|
|
339
|
+
taken: 0
|
|
340
|
+
};
|
|
341
|
+
const noteOccurrences = {
|
|
342
|
+
start: state.noteOccurrences.value,
|
|
343
|
+
taken: 0
|
|
344
|
+
};
|
|
345
|
+
const pairedBookmarkIds = new RecordedMembership(state.pairedBookmarkIds);
|
|
346
|
+
const storyRangedCommentIds = new RecordedMembership(state.storyRangedCommentIds);
|
|
347
|
+
const openStart = [...state.openCommentIds];
|
|
348
|
+
const story = {
|
|
349
|
+
nextTextBoxGroupId: () => {
|
|
350
|
+
textBoxGroups.taken += 1;
|
|
351
|
+
return `${this.salt}:${state.textBoxGroups.value++}`;
|
|
352
|
+
},
|
|
353
|
+
nextHyperlinkInstanceIndex: () => {
|
|
354
|
+
hyperlinks.taken += 1;
|
|
355
|
+
return state.hyperlinks.value++;
|
|
356
|
+
},
|
|
357
|
+
nextNoteReferenceOccurrenceId: () => {
|
|
358
|
+
noteOccurrences.taken += 1;
|
|
359
|
+
return `source-note:${state.noteOccurrences.value++}`;
|
|
360
|
+
},
|
|
361
|
+
pairedBookmarkIds,
|
|
362
|
+
storyRangedCommentIds,
|
|
363
|
+
openCommentIds: state.openCommentIds
|
|
364
|
+
};
|
|
365
|
+
const nodes = convert({
|
|
366
|
+
listRenderings: context.listRenderings,
|
|
367
|
+
numbering: context.numbering,
|
|
368
|
+
theme: context.theme,
|
|
369
|
+
pageBreakRunSourceDescendants: context.pageBreakRunSourceDescendants,
|
|
370
|
+
warnPageBreakProjection: context.warnPageBreakProjection,
|
|
371
|
+
createMark: context.createMark,
|
|
372
|
+
...story
|
|
373
|
+
}, story.nextTextBoxGroupId());
|
|
374
|
+
const saltMark = `"${this.salt}:`;
|
|
375
|
+
const reads = {
|
|
376
|
+
textBoxGroups: {
|
|
377
|
+
...textBoxGroups,
|
|
378
|
+
used: nodes.some((node) => JSON.stringify(node.toJSON()).includes(saltMark))
|
|
379
|
+
},
|
|
380
|
+
hyperlinks,
|
|
381
|
+
noteOccurrences,
|
|
382
|
+
pairedBookmarkIds: setReadsOf(pairedBookmarkIds),
|
|
383
|
+
storyRangedCommentIds: setReadsOf(storyRangedCommentIds),
|
|
384
|
+
openCommentIds: {
|
|
385
|
+
start: openStart,
|
|
386
|
+
end: [...state.openCommentIds]
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
this.blocks.set(paragraph, {
|
|
390
|
+
nodes,
|
|
391
|
+
reads,
|
|
392
|
+
sourceState: paragraphPropertySourceState(paragraph)
|
|
393
|
+
});
|
|
394
|
+
return nodes;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
248
397
|
/**
|
|
249
398
|
* Convert a Document to a ProseMirror document
|
|
250
399
|
*
|
|
@@ -254,34 +403,50 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
254
403
|
function toProseDoc(document, options) {
|
|
255
404
|
const paragraphs = document.package.document.content;
|
|
256
405
|
const nodes = [];
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
406
|
+
const cache = options?.blockCache;
|
|
407
|
+
const packageInputs = {
|
|
408
|
+
styles: options?.styles ?? document.package.styles,
|
|
409
|
+
theme: options?.theme ?? document.package.theme ?? null,
|
|
410
|
+
numbering: document.package.numbering,
|
|
411
|
+
warn: options?.warn
|
|
412
|
+
};
|
|
413
|
+
const shared = cache?.packageContext(packageInputs);
|
|
414
|
+
shared?.pageBreakRunSourceDescendants.include(paragraphs);
|
|
415
|
+
const styleResolver = shared?.styleResolver ?? createStyleEngine(packageInputs.styles);
|
|
416
|
+
const salt = cache?.salt ?? options?.textBoxGroupSalt ?? newTextBoxGroupSalt();
|
|
417
|
+
const story = {
|
|
418
|
+
textBoxGroups: { value: 0 },
|
|
419
|
+
hyperlinks: { value: 0 },
|
|
420
|
+
noteOccurrences: { value: 0 },
|
|
421
|
+
pairedBookmarkIds: collectPairedBookmarkIds(paragraphs),
|
|
272
422
|
storyRangedCommentIds: rangedCommentIds(paragraphs),
|
|
273
|
-
openCommentIds: /* @__PURE__ */ new Set()
|
|
274
|
-
|
|
275
|
-
|
|
423
|
+
openCommentIds: /* @__PURE__ */ new Set()
|
|
424
|
+
};
|
|
425
|
+
const conversionContext = {
|
|
426
|
+
listRenderings: shared?.listRenderings ?? /* @__PURE__ */ new Map(),
|
|
427
|
+
numbering: shared?.numbering ?? (packageInputs.numbering === void 0 ? void 0 : getCachedNumberingMap(packageInputs.numbering)),
|
|
428
|
+
theme: shared?.theme ?? packageInputs.theme,
|
|
429
|
+
nextTextBoxGroupId: textBoxGroupIdsFrom(salt, story.textBoxGroups),
|
|
430
|
+
nextHyperlinkInstanceIndex: () => story.hyperlinks.value++,
|
|
431
|
+
nextNoteReferenceOccurrenceId: () => `source-note:${story.noteOccurrences.value++}`,
|
|
432
|
+
pairedBookmarkIds: story.pairedBookmarkIds,
|
|
433
|
+
pageBreakRunSourceDescendants: shared?.pageBreakRunSourceDescendants ?? buildPageBreakRunSourceDescendantIndex(paragraphs),
|
|
434
|
+
storyRangedCommentIds: story.storyRangedCommentIds,
|
|
435
|
+
openCommentIds: story.openCommentIds,
|
|
436
|
+
warnPageBreakProjection: shared?.warnPageBreakProjection ?? pageBreakProjectionWarn(options?.warn),
|
|
437
|
+
createMark: shared?.createMark ?? createMarkInterner(schema)
|
|
276
438
|
};
|
|
277
439
|
const convertBodyBlocks = (blocks) => {
|
|
278
440
|
const out = [];
|
|
279
441
|
for (const block of blocks) switch (block.type) {
|
|
280
442
|
case "paragraph":
|
|
281
|
-
out.push(...convertParagraphWithTextBoxes(block, styleResolver, {
|
|
282
|
-
textBoxGroupId: nextTextBoxGroupId(),
|
|
443
|
+
out.push(...cache === void 0 ? convertParagraphWithTextBoxes(block, styleResolver, {
|
|
444
|
+
textBoxGroupId: conversionContext.nextTextBoxGroupId(),
|
|
283
445
|
context: conversionContext
|
|
284
|
-
}))
|
|
446
|
+
}) : cache.paragraph(block, story, (context, textBoxGroupId) => convertParagraphWithTextBoxes(block, styleResolver, {
|
|
447
|
+
textBoxGroupId,
|
|
448
|
+
context
|
|
449
|
+
})));
|
|
285
450
|
break;
|
|
286
451
|
case "table":
|
|
287
452
|
out.push(convertTable(block, styleResolver, conversionContext));
|
|
@@ -299,6 +464,10 @@ function toProseDoc(document, options) {
|
|
|
299
464
|
case "bookmarkEnd":
|
|
300
465
|
out.push(convertBlockBookmarkBoundary(block));
|
|
301
466
|
break;
|
|
467
|
+
case "commentRangeStart":
|
|
468
|
+
case "commentRangeEnd":
|
|
469
|
+
out.push(convertBlockCommentRangeBoundary(block, conversionContext.openCommentIds));
|
|
470
|
+
break;
|
|
302
471
|
case "moveFromRangeStart":
|
|
303
472
|
case "moveFromRangeEnd":
|
|
304
473
|
case "moveToRangeStart":
|
|
@@ -347,6 +516,16 @@ function convertPreservedBlock(block) {
|
|
|
347
516
|
function convertBlockBookmarkBoundary(block) {
|
|
348
517
|
return schema.node("blockBookmarkBoundary", bookmarkBoundaryAttrsFromMarker(block));
|
|
349
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* A comment range marker standing between blocks, kept between the same two.
|
|
521
|
+
* It opens or closes the comment for the text that follows, as the same
|
|
522
|
+
* marker inside a paragraph does, so the comment's mark covers that text.
|
|
523
|
+
*/
|
|
524
|
+
function convertBlockCommentRangeBoundary(block, openCommentIds) {
|
|
525
|
+
if (block.type === "commentRangeStart") openCommentIds.add(block.id);
|
|
526
|
+
else openCommentIds.delete(block.id);
|
|
527
|
+
return schema.node(BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME, { marker: block });
|
|
528
|
+
}
|
|
350
529
|
/** A move range marker standing between blocks, kept between the same two. */
|
|
351
530
|
function convertBlockMoveRangeBoundary(block) {
|
|
352
531
|
return schema.node(BLOCK_MOVE_RANGE_BOUNDARY_NODE_NAME, { marker: block });
|
|
@@ -544,7 +723,8 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
|
|
|
544
723
|
const paragraphMarkOverrides = getParagraphMarkSuppressionOverrides({
|
|
545
724
|
directFormatting: formatting,
|
|
546
725
|
paragraphMarkFormatting: inheritableParagraphRunFormatting,
|
|
547
|
-
suppressedFormatting
|
|
726
|
+
suppressedFormatting,
|
|
727
|
+
characterStyleFormatting: formatting?.styleId === void 0 ? void 0 : styleResolver?.getRunStyleOwnProperties(formatting.styleId) ?? void 0
|
|
548
728
|
}) ?? (inheritableParagraphRunFormatting ? {} : void 0);
|
|
549
729
|
return {
|
|
550
730
|
formatting: suppressedFormatting,
|
|
@@ -701,7 +881,10 @@ function applyCommentMarks(nodes, commentIds) {
|
|
|
701
881
|
});
|
|
702
882
|
}
|
|
703
883
|
function anchorPointComment(nodes, commentId) {
|
|
704
|
-
const commentMark = schema.marks["comment"]?.create({
|
|
884
|
+
const commentMark = schema.marks["comment"]?.create({
|
|
885
|
+
commentId,
|
|
886
|
+
point: true
|
|
887
|
+
});
|
|
705
888
|
if (!commentMark) return;
|
|
706
889
|
for (let index = nodes.length - 1; index >= 0; index--) {
|
|
707
890
|
const node = nodes[index];
|
|
@@ -742,6 +925,26 @@ const withTrackedRunMark = (node, mark, ancestor) => {
|
|
|
742
925
|
if (canCarryTrackedRunMark(node)) return node.mark(mark.addToSet(node.marks));
|
|
743
926
|
return node;
|
|
744
927
|
};
|
|
928
|
+
/** A revision's info as the review surface reads it: a suggestion's says so. */
|
|
929
|
+
const suggestedRevisionInfo = (info) => info.suggestionId === void 0 ? info : {
|
|
930
|
+
...info,
|
|
931
|
+
provenance: "suggested"
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* The mark a run's property changes ride. Changes that all belong to one
|
|
935
|
+
* pending suggestion show as that suggestion, as tracked text does.
|
|
936
|
+
*/
|
|
937
|
+
const runPropertyChangeMark = (changes) => {
|
|
938
|
+
const suggestionIds = new Set(changes.map(({ info }) => info.suggestionId));
|
|
939
|
+
const [suggestionId] = suggestionIds;
|
|
940
|
+
return schema.mark("runPropertyChange", {
|
|
941
|
+
changes: [...changes],
|
|
942
|
+
...suggestionIds.size === 1 && suggestionId !== void 0 ? {
|
|
943
|
+
provenance: "suggested",
|
|
944
|
+
suggestionId
|
|
945
|
+
} : {}
|
|
946
|
+
});
|
|
947
|
+
};
|
|
745
948
|
function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runScope, runFormattingResolvers, styleResolver, moveKind, textBoxAnchors, wrappedBy, openCommentIds, options = {}) {
|
|
746
949
|
const nodes = [];
|
|
747
950
|
const preserveParentBoundaryOwnership = options.preserveParentBoundaryOwnership ?? true;
|
|
@@ -842,6 +1045,10 @@ function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runS
|
|
|
842
1045
|
date: change.info.date ?? null,
|
|
843
1046
|
utcDate: change.info.utcDate?.value ?? null,
|
|
844
1047
|
initials: change.info.initials ?? null,
|
|
1048
|
+
...change.info.suggestionId === void 0 ? {} : {
|
|
1049
|
+
provenance: "suggested",
|
|
1050
|
+
suggestionId: change.info.suggestionId
|
|
1051
|
+
},
|
|
845
1052
|
moveKind,
|
|
846
1053
|
_docxOuterWrapperCount: wrappedBy.length,
|
|
847
1054
|
_docxResolutionJoins: change.resolutionJoins ?? null,
|
|
@@ -878,7 +1085,11 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
878
1085
|
if (formatting?.numPrFromStyle) attrs.numPrFromStyle = paragraphNumberingAttr(formatting.numPrFromStyle);
|
|
879
1086
|
if (paragraph.listRendering && formatting?.numPr?.kind !== "none") Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS, listRenderingAttrPatch(paragraph.listRendering));
|
|
880
1087
|
if (formatting) attrs._originalFormatting = formatting;
|
|
881
|
-
if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = paragraph.propertyChanges.map(({ previousFormatting, ...
|
|
1088
|
+
if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = paragraph.propertyChanges.map(({ previousFormatting, ...modelChange }) => {
|
|
1089
|
+
const change = {
|
|
1090
|
+
...modelChange,
|
|
1091
|
+
info: suggestedRevisionInfo(modelChange.info)
|
|
1092
|
+
};
|
|
882
1093
|
if (previousFormatting === void 0) return change;
|
|
883
1094
|
const { numPr, numPrFromStyle, ...rest } = previousFormatting;
|
|
884
1095
|
return {
|
|
@@ -891,7 +1102,10 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
891
1102
|
};
|
|
892
1103
|
});
|
|
893
1104
|
if (paragraph.preservedAttributes && paragraph.preservedAttributes.length > 0) attrs._preservedAttributes = paragraph.preservedAttributes;
|
|
894
|
-
if (paragraph.pPrMark) attrs.pPrMark = paragraph.pPrMark
|
|
1105
|
+
if (paragraph.pPrMark) attrs.pPrMark = paragraph.pPrMark.info.suggestionId === void 0 ? paragraph.pPrMark : {
|
|
1106
|
+
...paragraph.pPrMark,
|
|
1107
|
+
info: suggestedRevisionInfo(paragraph.pPrMark.info)
|
|
1108
|
+
};
|
|
895
1109
|
const set = (key, val) => {
|
|
896
1110
|
if (val !== void 0) attrs[key] = val;
|
|
897
1111
|
};
|
|
@@ -1377,6 +1591,10 @@ function convertTableCell({ cell, styleResolver, context, isHeader, gridWidthPer
|
|
|
1377
1591
|
case "bookmarkEnd":
|
|
1378
1592
|
nodes.push(convertBlockBookmarkBoundary(block));
|
|
1379
1593
|
break;
|
|
1594
|
+
case "commentRangeStart":
|
|
1595
|
+
case "commentRangeEnd":
|
|
1596
|
+
nodes.push(convertBlockCommentRangeBoundary(block, context.openCommentIds));
|
|
1597
|
+
break;
|
|
1380
1598
|
case "moveFromRangeStart":
|
|
1381
1599
|
case "moveFromRangeEnd":
|
|
1382
1600
|
case "moveToRangeStart":
|
|
@@ -1535,7 +1753,7 @@ function convertField(field, { getInheritedRunFormatting, styleResolver, nextHyp
|
|
|
1535
1753
|
const displayText = getInlineDisplayText(schema.node("paragraph", null, inlineNodes));
|
|
1536
1754
|
const emptyResultRuns = displayText === "" && resultRuns.length > 0 && (field.type === "complexField" || field.content.length === resultRuns.length) && resultRuns.every((run) => run.content.every((item) => item.type === "text" && item.text === "")) ? resultRuns : void 0;
|
|
1537
1755
|
const resultPropertyChanges = emptyResultRuns ? emptyFieldRunPropertyChanges(emptyResultRuns) : fieldPropertyChanges;
|
|
1538
|
-
if (!createStructuredField && resultPropertyChanges && resultPropertyChanges.length > 0) marks.push(
|
|
1756
|
+
if (!createStructuredField && resultPropertyChanges && resultPropertyChanges.length > 0) marks.push(runPropertyChangeMark(resultPropertyChanges));
|
|
1539
1757
|
const fieldNode = schema.node(createStructuredField ? "structuredField" : "field", {
|
|
1540
1758
|
fieldType: field.fieldType,
|
|
1541
1759
|
instruction: field.instruction,
|
|
@@ -1735,7 +1953,7 @@ function convertRun(run, resolvedStyleFormatting, runScope, styleResolver, textB
|
|
|
1735
1953
|
styleResolver,
|
|
1736
1954
|
createMark: runScope.createMark
|
|
1737
1955
|
});
|
|
1738
|
-
if (run.propertyChanges && run.propertyChanges.length > 0) marks.push(
|
|
1956
|
+
if (run.propertyChanges && run.propertyChanges.length > 0) marks.push(runPropertyChangeMark(run.propertyChanges));
|
|
1739
1957
|
const identity = runIdentityMark(run, runScope.nextRunIdentityId);
|
|
1740
1958
|
if (identity) marks.push(identity);
|
|
1741
1959
|
for (const content of run.content) {
|
|
@@ -1969,7 +2187,7 @@ const RUN_FORMATTING_INFERENCE = {
|
|
|
1969
2187
|
italic: "ordinary-toggle",
|
|
1970
2188
|
italicCs: "structural",
|
|
1971
2189
|
underline: "underline",
|
|
1972
|
-
strike: "
|
|
2190
|
+
strike: "strike",
|
|
1973
2191
|
doubleStrike: "double-strike",
|
|
1974
2192
|
vertAlign: "visible-value",
|
|
1975
2193
|
smallCaps: "visible-boolean",
|
|
@@ -2042,6 +2260,10 @@ const canReconstructAuthoredRunFormatting = ({ directFormatting, effectiveFormat
|
|
|
2042
2260
|
case "underline":
|
|
2043
2261
|
if (typeof directValue === "object" && directValue !== null && Reflect.get(directValue, "style") !== "none" && Reflect.get(directValue, "color") === void 0 && sameFormattingValue(directValue, effectiveValue) && !sameFormattingValue(directValue, inheritedValue)) continue;
|
|
2044
2262
|
return false;
|
|
2263
|
+
case "strike":
|
|
2264
|
+
if (directValue === false) continue;
|
|
2265
|
+
if (directValue === true && inheritedFormatting?.strike !== true && inheritedFormatting?.doubleStrike !== true && effectiveFormatting?.doubleStrike !== true) continue;
|
|
2266
|
+
return false;
|
|
2045
2267
|
case "double-strike":
|
|
2046
2268
|
if (directValue === false) continue;
|
|
2047
2269
|
if (directValue === true && inheritedFormatting?.strike !== true && inheritedFormatting?.doubleStrike !== true) continue;
|
|
@@ -2456,7 +2678,7 @@ function convertHyperlink(hyperlink, { getInheritedRunFormatting, styleResolver,
|
|
|
2456
2678
|
styleResolver,
|
|
2457
2679
|
createMark: runScope.createMark
|
|
2458
2680
|
});
|
|
2459
|
-
if (child.propertyChanges && child.propertyChanges.length > 0) runMarks.push(
|
|
2681
|
+
if (child.propertyChanges && child.propertyChanges.length > 0) runMarks.push(runPropertyChangeMark(child.propertyChanges));
|
|
2460
2682
|
const identity = runIdentityMark(child, runScope.nextRunIdentityId);
|
|
2461
2683
|
if (identity) runMarks.push(identity);
|
|
2462
2684
|
const allMarks = [...runMarks, linkMark];
|
|
@@ -2471,6 +2693,19 @@ function convertHyperlink(hyperlink, { getInheritedRunFormatting, styleResolver,
|
|
|
2471
2693
|
}));
|
|
2472
2694
|
break;
|
|
2473
2695
|
}
|
|
2696
|
+
case "complexField": {
|
|
2697
|
+
const fieldNode = convertField(child, {
|
|
2698
|
+
getInheritedRunFormatting,
|
|
2699
|
+
styleResolver,
|
|
2700
|
+
nextHyperlinkInstanceIndex: () => panic("A complex field result holds no hyperlink."),
|
|
2701
|
+
runScope,
|
|
2702
|
+
textBoxAnchors,
|
|
2703
|
+
openCommentIds
|
|
2704
|
+
});
|
|
2705
|
+
if (fieldNode) childNodes.push(fieldNode.mark(linkMark.addToSet(fieldNode.marks)));
|
|
2706
|
+
commentsAlreadyApplied = true;
|
|
2707
|
+
break;
|
|
2708
|
+
}
|
|
2474
2709
|
}
|
|
2475
2710
|
const wrappedNodes = withInlineWrapperMark(childNodes, stack, {
|
|
2476
2711
|
hyperlinkIndex,
|
|
@@ -2803,17 +3038,46 @@ function convertTextBox(textBox, styleResolver, options) {
|
|
|
2803
3038
|
...options.context,
|
|
2804
3039
|
openCommentIds: /* @__PURE__ */ new Set()
|
|
2805
3040
|
};
|
|
2806
|
-
const
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
3041
|
+
const convertBoxBlocks = (blocks) => {
|
|
3042
|
+
const nodes = [];
|
|
3043
|
+
for (const block of blocks) switch (block.type) {
|
|
3044
|
+
case "paragraph":
|
|
3045
|
+
nodes.push(...convertParagraphWithTextBoxes(block, styleResolver, {
|
|
3046
|
+
textBoxGroupId: textBoxContext.nextTextBoxGroupId(),
|
|
3047
|
+
context: textBoxContext
|
|
3048
|
+
}));
|
|
3049
|
+
break;
|
|
3050
|
+
case "table":
|
|
3051
|
+
nodes.push(convertTable(block, styleResolver, textBoxContext));
|
|
3052
|
+
break;
|
|
3053
|
+
case "blockSdt":
|
|
3054
|
+
nodes.push(convertBlockSdt(block, convertBoxBlocks));
|
|
3055
|
+
break;
|
|
3056
|
+
case "blockCustomXml":
|
|
3057
|
+
nodes.push(convertBlockCustomXml(block, convertBoxBlocks));
|
|
3058
|
+
break;
|
|
3059
|
+
case "preservedBlock":
|
|
3060
|
+
nodes.push(convertPreservedBlock(block));
|
|
3061
|
+
break;
|
|
3062
|
+
case "bookmarkStart":
|
|
3063
|
+
case "bookmarkEnd":
|
|
3064
|
+
nodes.push(convertBlockBookmarkBoundary(block));
|
|
3065
|
+
break;
|
|
3066
|
+
case "commentRangeStart":
|
|
3067
|
+
case "commentRangeEnd":
|
|
3068
|
+
nodes.push(convertBlockCommentRangeBoundary(block, textBoxContext.openCommentIds));
|
|
3069
|
+
break;
|
|
3070
|
+
case "moveFromRangeStart":
|
|
3071
|
+
case "moveFromRangeEnd":
|
|
3072
|
+
case "moveToRangeStart":
|
|
3073
|
+
case "moveToRangeEnd":
|
|
3074
|
+
nodes.push(convertBlockMoveRangeBoundary(block));
|
|
3075
|
+
break;
|
|
3076
|
+
default: return block;
|
|
2814
3077
|
}
|
|
2815
|
-
|
|
2816
|
-
}
|
|
3078
|
+
return nodes;
|
|
3079
|
+
};
|
|
3080
|
+
const contentNodes = convertBoxBlocks(textBox.content);
|
|
2817
3081
|
if (contentNodes.length === 0) contentNodes.push(schema.node("paragraph", {}, []));
|
|
2818
3082
|
const wrapType = textBox.wrap?.type;
|
|
2819
3083
|
const wrapText = textBox.wrap?.wrapText;
|
|
@@ -2972,6 +3236,10 @@ function headerFooterToProseDoc(content, options) {
|
|
|
2972
3236
|
case "bookmarkEnd":
|
|
2973
3237
|
out.push(convertBlockBookmarkBoundary(block));
|
|
2974
3238
|
break;
|
|
3239
|
+
case "commentRangeStart":
|
|
3240
|
+
case "commentRangeEnd":
|
|
3241
|
+
out.push(convertBlockCommentRangeBoundary(block, conversionContext.openCommentIds));
|
|
3242
|
+
break;
|
|
2975
3243
|
case "moveFromRangeStart":
|
|
2976
3244
|
case "moveFromRangeEnd":
|
|
2977
3245
|
case "moveToRangeStart":
|
|
@@ -2997,4 +3265,4 @@ function footnoteToProseDoc(content, options) {
|
|
|
2997
3265
|
function createEmptyDoc() {
|
|
2998
3266
|
return schema.node("doc", null, [schema.node("paragraph", {}, [])]);
|
|
2999
3267
|
}
|
|
3000
|
-
export { collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, hostParagraphAttrs, standaloneTableCellToProseMirror, toProseDoc };
|
|
3268
|
+
export { ProjectionBlockCache, collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, hostParagraphAttrs, standaloneTableCellToProseMirror, toProseDoc };
|
|
@@ -20,6 +20,7 @@ import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtensio
|
|
|
20
20
|
import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
|
|
21
21
|
import { MARK_EXTENSIONS, MARK_NESTING_ORDER } from "./markRegistry.js";
|
|
22
22
|
import { BlockBookmarkBoundaryExtension } from "./nodes/BlockBookmarkBoundaryExtension.js";
|
|
23
|
+
import { BlockCommentRangeBoundaryExtension } from "./nodes/BlockCommentRangeBoundaryExtension.js";
|
|
23
24
|
import { BlockCustomXmlExtension } from "./nodes/BlockCustomXmlExtension.js";
|
|
24
25
|
import { BlockMoveRangeBoundaryExtension } from "./nodes/BlockMoveRangeBoundaryExtension.js";
|
|
25
26
|
import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
|
|
@@ -73,6 +74,7 @@ function createStarterKit(options = {}) {
|
|
|
73
74
|
add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
74
75
|
add("blockBookmarkBoundary", BlockBookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
75
76
|
add("blockMoveRangeBoundary", BlockMoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
77
|
+
add("blockCommentRangeBoundary", BlockCommentRangeBoundaryExtension());
|
|
76
78
|
add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
|
|
77
79
|
add("commentRangeBoundary", CommentRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
78
80
|
add("moveRangeBoundary", MoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
@@ -14,7 +14,7 @@ const DocExtension = createNodeExtension({
|
|
|
14
14
|
_adjustLineHeightInTable: { default: false },
|
|
15
15
|
_doNotUseIndentAsNumberingTabStop: { default: false }
|
|
16
16
|
},
|
|
17
|
-
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+"
|
|
17
|
+
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+"
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
export { DocExtension };
|
|
@@ -22,4 +22,4 @@ export declare const autoBidiDetectionKey: Readonly<{
|
|
|
22
22
|
* document already carried, is unaffected — it always round-trips.
|
|
23
23
|
*/
|
|
24
24
|
export declare const ensureBaseDirectionInState: (state: EditorState) => EditorState;
|
|
25
|
-
export declare const AutoBidiDetectionExtension: (options?: Partial<
|
|
25
|
+
export declare const AutoBidiDetectionExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Extension } from "../types.js";
|
|
2
2
|
export declare const JOINED_RUNS_RESTYLED_META = "joinedRunsRestyled";
|
|
3
|
-
export declare const JoinedRunStyleExtension: (options?: Partial<
|
|
3
|
+
export declare const JoinedRunStyleExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
|
|
@@ -52,5 +52,5 @@ export declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly
|
|
|
52
52
|
export declare const ensureParaIdsInDoc: (doc: Node) => Node;
|
|
53
53
|
/** {@link ensureParaIdsInDoc} for a state that already exists. */
|
|
54
54
|
export declare const ensureParaIdsInState: (state: EditorState) => EditorState;
|
|
55
|
-
export declare const ParaIdAllocatorExtension: (options?: Partial<
|
|
55
|
+
export declare const ParaIdAllocatorExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
|
|
56
56
|
export {};
|
|
@@ -104,5 +104,5 @@ type MarkChangedParagraphRangesOptions = {
|
|
|
104
104
|
};
|
|
105
105
|
/** Record mark-only paragraph changes whose replacement step has a granular map. */
|
|
106
106
|
export declare function markChangedParagraphRanges(tr: Transaction, batch: MarkChangedParagraphRangesOptions): Transaction;
|
|
107
|
-
export declare const ParagraphChangeTrackerExtension: (options?: Partial<
|
|
107
|
+
export declare const ParagraphChangeTrackerExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
|
|
108
108
|
export {};
|
|
@@ -17,18 +17,19 @@ const hasListHint = (node) => node?.type.name === "paragraph" && Boolean(expectP
|
|
|
17
17
|
*/
|
|
18
18
|
const flattenPastedHtmlLists = (html) => {
|
|
19
19
|
if (!/<(?:ul|ol)\b/iu.test(html)) return html;
|
|
20
|
-
const
|
|
20
|
+
const owner = document.implementation.createHTMLDocument("");
|
|
21
|
+
const host = owner.createElement("div");
|
|
21
22
|
host.innerHTML = html;
|
|
22
23
|
let nextGroup = 0;
|
|
23
24
|
const flatten = (list, level) => {
|
|
24
|
-
const fragment =
|
|
25
|
+
const fragment = owner.createDocumentFragment();
|
|
25
26
|
const group = ++nextGroup;
|
|
26
27
|
const kind = list.localName === "ul" ? "bullet" : "numbered";
|
|
27
28
|
const rawStart = Number(list.getAttribute("start"));
|
|
28
29
|
const start = Number.isSafeInteger(rawStart) && rawStart > 0 ? rawStart : void 0;
|
|
29
30
|
for (const item of Array.from(list.children)) {
|
|
30
31
|
if (item.localName !== "li") continue;
|
|
31
|
-
let paragraph =
|
|
32
|
+
let paragraph = owner.createElement("p");
|
|
32
33
|
let emitted = false;
|
|
33
34
|
const mark = (element) => {
|
|
34
35
|
element.setAttribute("data-folio-list-group", String(group));
|
|
@@ -40,7 +41,7 @@ const flattenPastedHtmlLists = (html) => {
|
|
|
40
41
|
if (!paragraph.hasChildNodes()) return;
|
|
41
42
|
mark(paragraph);
|
|
42
43
|
fragment.append(paragraph);
|
|
43
|
-
paragraph =
|
|
44
|
+
paragraph = owner.createElement("p");
|
|
44
45
|
emitted = true;
|
|
45
46
|
};
|
|
46
47
|
for (const child of Array.from(item.childNodes)) if (child instanceof Element && isList(child)) {
|