@stll/folio-core 0.59.0 → 0.61.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/README.md +23 -1
- package/dist/ai-edits/apply.js +139 -32
- package/dist/ai-edits/headless.d.ts +3 -0
- package/dist/ai-edits/headless.js +57 -63
- package/dist/ai-edits/note-story-inventory.d.ts +7 -0
- package/dist/ai-edits/note-story-inventory.js +11 -0
- package/dist/ai-edits/read.js +16 -9
- package/dist/ai-edits/revisionStretches.js +52 -1
- package/dist/ai-edits/table-row-column-mutations.js +6 -1
- package/dist/compare/reproducible-package.js +2 -1
- package/dist/compare/verification.js +1 -0
- package/dist/compat/eigenpal.d.ts +4 -2
- package/dist/compat/eigenpal.js +2 -2
- package/dist/controller/canonicalClipboard.js +2 -1
- package/dist/controller/canonicalListRendering.d.ts +4 -6
- package/dist/controller/canonicalListRendering.js +3 -157
- package/dist/controller/canonicalSession.js +3 -2
- package/dist/controller/canonicalStructure.js +10 -7
- package/dist/controller/fontReadiness.js +1 -1
- package/dist/controller/headerFooterEditorManager.d.ts +1 -0
- package/dist/controller/headerFooterEditorManager.js +11 -0
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +3 -1
- package/dist/controller/layoutPipeline.d.ts +3 -1
- package/dist/controller/layoutPipeline.js +19 -4
- package/dist/controller/layoutSession.d.ts +4 -1
- package/dist/display-list/build/fontTable.js +7 -5
- package/dist/display-list/build/furniture.d.ts +1 -0
- package/dist/display-list/build/furniture.js +1 -0
- package/dist/display-list/build/imagePrimitives.js +3 -6
- package/dist/display-list/build/watermarkPrimitives.d.ts +2 -1
- package/dist/display-list/build/watermarkPrimitives.js +9 -3
- package/dist/display-list/editor/pageRenderer.js +1 -0
- package/dist/docx/bookmarkIdNormalization.d.ts +10 -0
- package/dist/docx/bookmarkIdNormalization.js +100 -0
- package/dist/docx/bookmarkParser.js +4 -2
- package/dist/docx/canonicalStoryRepack.js +3 -2
- package/dist/docx/commentTextParagraph.d.ts +6 -0
- package/dist/docx/commentTextParagraph.js +15 -0
- package/dist/docx/conformance.js +6 -1
- package/dist/docx/diagramPreview.js +2 -1
- package/dist/docx/documentParser.d.ts +13 -1
- package/dist/docx/documentParser.js +1 -1
- package/dist/docx/encryption/compoundFile.d.ts +0 -8
- package/dist/docx/encryption/compoundFile.js +2 -1
- package/dist/docx/encryption/cryptoBytes.d.ts +2 -2
- package/dist/docx/encryption/cryptoBytes.js +3 -18
- package/dist/docx/encryption/encryptionInfo.d.ts +0 -5
- package/dist/docx/encryption/encryptionInfo.js +2 -1
- package/dist/docx/ensureParaIds.js +2 -1
- package/dist/docx/groupDrawingParser.js +6 -1
- package/dist/docx/importedIdCollisions.d.ts +136 -0
- package/dist/docx/importedIdCollisions.js +215 -0
- package/dist/docx/listModelNormalization.d.ts +10 -0
- package/dist/docx/listModelNormalization.js +166 -0
- package/dist/docx/metadataPrivacy.js +3 -2
- package/dist/docx/metafileRaster.js +2 -1
- package/dist/docx/numberingParser.js +2 -2
- package/dist/docx/packageParts.js +6 -5
- package/dist/docx/paragraphParser.js +6 -4
- package/dist/docx/paragraphPropertySource.js +1 -2
- package/dist/docx/parseContext.d.ts +2 -1
- package/dist/docx/parseContext.js +1 -0
- package/dist/docx/parseWarningMessage.js +1 -0
- package/dist/docx/parser.js +10 -5
- package/dist/docx/preservedRunContent.js +11 -2
- package/dist/docx/relsParser.js +1 -1
- package/dist/docx/removeHeaderFooterParts.js +8 -7
- package/dist/docx/replyToComment.js +3 -13
- package/dist/docx/rezip.js +90 -90
- package/dist/docx/runParser.js +12 -6
- package/dist/docx/runPropertyPresence.d.ts +11 -0
- package/dist/docx/runPropertyPresence.js +14 -0
- package/dist/docx/selectedXmlIdentityScan.d.ts +10 -0
- package/dist/docx/selectedXmlIdentityScan.js +36 -0
- package/dist/docx/selectiveSave.js +19 -17
- package/dist/docx/selectiveXmlPatch.js +44 -52
- package/dist/docx/serializer/commentSerializer.d.ts +3 -1
- package/dist/docx/serializer/commentSerializer.js +11 -2
- package/dist/docx/serializer/runSerializer.js +5 -4
- package/dist/docx/serializer/tableSerializer.js +2 -1
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +1 -3
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -11
- package/dist/docx/server/applyDocxXmlPatchProposal.js +2 -2
- package/dist/docx/server/boundedArchive.js +2 -1
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +2 -1
- package/dist/docx/server/inspectDocxPackage.js +5 -1
- package/dist/docx/server/validateDocxConformance.js +2 -1
- package/dist/docx/tableParser.js +7 -4
- package/dist/docx/tableRowPropertyPresence.d.ts +9 -0
- package/dist/docx/tableRowPropertyPresence.js +15 -0
- package/dist/docx/unzip.js +2 -1
- package/dist/docx/xmlEncoding.js +6 -5
- package/dist/fonts/embeddedFontFingerprint.d.ts +5 -0
- package/dist/fonts/embeddedFontFingerprint.js +18 -0
- package/dist/fonts/embeddedFonts.d.ts +1 -1
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/fonts/fontsourceFaces.js +2 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/fonts/sfnt/parse.js +6 -9
- package/dist/fonts/sfnt/subset.js +2 -1
- package/dist/fonts/sfnt/tables.js +2 -3
- package/dist/fonts/sfnt/woff.js +2 -1
- package/dist/headless-layout.js +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -2
- package/dist/internal/revisionResolutionInline.d.ts +2 -1
- package/dist/internal/revisionResolutionInline.js +22 -1
- package/dist/internal/wholeStoryRevisionResolution.js +24 -7
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +4 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +5 -1
- package/dist/layout-bridge/convert/footnoteLayout.js +16 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +6 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +13 -14
- package/dist/layout-bridge/convert/paragraphConversion.js +8 -1
- package/dist/layout-bridge/convert/paragraphRuns.js +2 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +25 -1
- package/dist/layout-engine/measure/cache.js +39 -7
- package/dist/layout-engine/measure/crossRunWords.js +12 -2
- package/dist/layout-engine/measure/lineTypography.js +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +1 -0
- package/dist/layout-engine/measure/measureContainer.js +3 -4
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -9
- package/dist/layout-engine/measure/measureHelpers.js +21 -18
- package/dist/layout-engine/measure/measureParagraph.js +2 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -0
- package/dist/layout-engine/types.d.ts +4 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +11 -3
- package/dist/layout-painter/renderParagraph.js +13 -3
- package/dist/layout-painter/renderWatermark.d.ts +1 -0
- package/dist/layout-painter/renderWatermark.js +7 -3
- package/dist/managers/AutoSaveManager.js +2 -1
- package/dist/managers/EditorModeManager.d.ts +10 -1
- package/dist/managers/EditorModeManager.js +15 -1
- package/dist/managers/TableSelectionManager.d.ts +1 -1
- package/dist/managers/autoSaveCodec.js +2 -6
- package/dist/managers/editorShortcuts.d.ts +2 -1
- package/dist/managers/editorShortcuts.js +2 -1
- package/dist/managers/reviewDisplayMode.d.ts +8 -0
- package/dist/managers/reviewDisplayMode.js +15 -0
- package/dist/paged-layout/pageText.d.ts +11 -2
- package/dist/paged-layout/pageText.js +8 -3
- package/dist/pdf/fonts.js +5 -14
- package/dist/pdf/images.js +3 -2
- package/dist/pdf/objects.d.ts +0 -11
- package/dist/pdf/objects.js +7 -9
- package/dist/pdf/writePdf.js +2 -1
- package/dist/prosemirror/canonicalSelectionRange.d.ts +4 -1
- package/dist/prosemirror/canonicalSelectionRange.js +9 -3
- package/dist/prosemirror/commands/comments.js +51 -13
- package/dist/prosemirror/containerFinalParagraph.d.ts +8 -8
- package/dist/prosemirror/containerFinalParagraph.js +8 -8
- package/dist/prosemirror/conversion/fromProseDoc.js +9 -4
- package/dist/prosemirror/conversion/toProseDoc.js +4 -4
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +39 -3
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +4 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +6 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +11 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +1 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +16 -2
- package/dist/prosemirror/findReplaceSelection.d.ts +11 -1
- package/dist/prosemirror/findReplaceSelection.js +15 -1
- package/dist/prosemirror/markupViewProjection.d.ts +10 -1
- package/dist/prosemirror/markupViewProjection.js +21 -3
- package/dist/prosemirror/pluginKeyOwner.d.ts +13 -0
- package/dist/prosemirror/pluginKeyOwner.js +35 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiCitationDecorations.js +16 -3
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +18 -3
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +11 -11
- package/dist/prosemirror/plugins/anonymizationDecorations.js +23 -13
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +8 -2
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +27 -5
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +8 -2
- package/dist/prosemirror/plugins/contentControlWidgets.js +4 -3
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +6 -5
- package/dist/prosemirror/plugins/createDocScanPlugin.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +5 -3
- package/dist/prosemirror/plugins/documentStyleState.d.ts +8 -2
- package/dist/prosemirror/plugins/documentStyleState.js +2 -2
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +8 -2
- package/dist/prosemirror/plugins/selectionTracker.js +4 -3
- package/dist/prosemirror/plugins/suggestionMode.d.ts +8 -2
- package/dist/prosemirror/plugins/suggestionMode.js +4 -3
- package/dist/prosemirror/plugins/templateDirectives.d.ts +8 -2
- package/dist/prosemirror/plugins/templateDirectives.js +19 -4
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +8 -2
- package/dist/prosemirror/plugins/templatePreviewValues.js +27 -5
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +8 -2
- package/dist/prosemirror/plugins/templateSlashMenu.js +23 -5
- package/dist/prosemirror/plugins/transactionInvariants.js +29 -4
- package/dist/prosemirror/replacedAnnotations.d.ts +15 -1
- package/dist/prosemirror/replacedAnnotations.js +71 -12
- package/dist/prosemirror/runFormattingReconciliation.d.ts +3 -1
- package/dist/prosemirror/runFormattingReconciliation.js +10 -2
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +5 -7
- package/dist/prosemirror/runIdentityAcrossRevisions.js +66 -38
- package/dist/prosemirror/runPropertyChangeResolution.js +13 -1
- package/dist/utils/base64.d.ts +1 -31
- package/dist/utils/base64.js +19 -33
- package/dist/utils/clipboard.js +5 -4
- package/dist/utils/colorResolver.js +11 -2
- package/dist/utils/findReplace.d.ts +5 -0
- package/dist/utils/fontLoader.d.ts +2 -2
- package/dist/utils/fontLoader.js +2 -7
- package/dist/utils/fontResolver.d.ts +7 -3
- package/dist/utils/fontResolver.js +6 -8
- package/dist/utils/replaceText.js +21 -4
- package/dist/utils/sliceText.d.ts +2 -0
- package/dist/utils/sliceText.js +2 -0
- package/dist/utils/textEncoding.d.ts +2 -0
- package/dist/utils/textEncoding.js +2 -0
- package/dist/utils/tiffConverter.d.ts +0 -9
- package/dist/utils/tiffConverter.js +2 -4
- package/package.json +73 -31
|
@@ -18,6 +18,20 @@ const DISPLAY_MODES = [
|
|
|
18
18
|
"no-markup",
|
|
19
19
|
"original"
|
|
20
20
|
];
|
|
21
|
+
const REVIEW_VIEW_ACCESS = {
|
|
22
|
+
"all-markup": "editable",
|
|
23
|
+
"simple-markup": "read-only",
|
|
24
|
+
"no-markup": "read-only",
|
|
25
|
+
original: "read-only"
|
|
26
|
+
};
|
|
27
|
+
const getReviewViewReadOnlyReason = (displayMode) => REVIEW_VIEW_ACCESS[displayMode] === "read-only" ? "review-display-mode" : null;
|
|
28
|
+
const getEditorReadOnlyReason = ({ editingMode, readOnlyProp, displayMode }) => {
|
|
29
|
+
const viewReason = getReviewViewReadOnlyReason(displayMode);
|
|
30
|
+
if (viewReason) return viewReason;
|
|
31
|
+
if (readOnlyProp) return "host-read-only";
|
|
32
|
+
if (editingMode === "viewing") return "viewing-mode";
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
21
35
|
/** True when the host opts into read-only OR the mode is `"viewing"`. */
|
|
22
36
|
const isReadOnlyMode = (editingMode, readOnlyProp) => readOnlyProp || editingMode === "viewing";
|
|
23
37
|
/** True when the mode is `"suggesting"`. */
|
|
@@ -47,4 +61,4 @@ var EditorModeManager = class extends Subscribable {
|
|
|
47
61
|
}
|
|
48
62
|
};
|
|
49
63
|
//#endregion
|
|
50
|
-
export { DISPLAY_MODES, EditorModeManager, isReadOnlyMode, isTrackChangesMode, toggledTrackChangesMode };
|
|
64
|
+
export { DISPLAY_MODES, EditorModeManager, getEditorReadOnlyReason, getReviewViewReadOnlyReason, isReadOnlyMode, isTrackChangesMode, toggledTrackChangesMode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import { TableAction, TableContext } from "../utils/tableOperations.js";
|
|
3
2
|
import { Subscribable } from "./Subscribable.js";
|
|
3
|
+
import { TableAction, TableContext } from "../utils/tableOperations.js";
|
|
4
4
|
import { CellCoordinates } from "./types.js";
|
|
5
5
|
//#region src/managers/TableSelectionManager.d.ts
|
|
6
6
|
/** Data attributes for table elements in the rendered DOM */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateFolioDocumentModel } from "../docx/modelValidation.js";
|
|
2
2
|
import { bytesToBase64 } from "../utils/base64.js";
|
|
3
|
+
import { base64ToBytes } from "../utils/textEncoding.js";
|
|
3
4
|
//#region src/managers/autoSaveCodec.ts
|
|
4
5
|
/**
|
|
5
6
|
* Version 3 renamed the model's `bidiWrapper` to `inlineWrapper` and gave it a
|
|
@@ -10,12 +11,7 @@ import { bytesToBase64 } from "../utils/base64.js";
|
|
|
10
11
|
* re-taken rather than migrated.
|
|
11
12
|
*/
|
|
12
13
|
const AUTOSAVE_FORMAT_VERSION = 3;
|
|
13
|
-
const decodeBase64 = (value) =>
|
|
14
|
-
const binary = atob(value);
|
|
15
|
-
const bytes = new Uint8Array(binary.length);
|
|
16
|
-
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
17
|
-
return bytes.buffer;
|
|
18
|
-
};
|
|
14
|
+
const decodeBase64 = (value) => base64ToBytes(value).buffer;
|
|
19
15
|
const encodeValue = (value) => {
|
|
20
16
|
if (value === void 0) return { type: "undefined" };
|
|
21
17
|
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HistoryShortcutOwner } from "../prosemirror/extensions/core/HistoryExtension.js";
|
|
2
2
|
import { EditorState, Transaction } from "prosemirror-state";
|
|
3
3
|
//#region src/managers/editorShortcuts.d.ts
|
|
4
|
+
declare const DEFAULT_KEYBOARD_SHORTCUT_SCOPE = "editor";
|
|
4
5
|
declare function isMacPlatform(): boolean;
|
|
5
6
|
/**
|
|
6
7
|
* `target` is an input-like element that the user is typing into. We must
|
|
@@ -82,4 +83,4 @@ declare function isKeydownInShortcutScope(event: {
|
|
|
82
83
|
*/
|
|
83
84
|
declare function deleteSelectedTable(state: EditorState, dispatch: (tr: Transaction) => void): boolean;
|
|
84
85
|
//#endregion
|
|
85
|
-
export { ClassifyEditorKeydownOptions, EditorKeydownIntent, HostShortcut, IsKeydownInShortcutScopeOptions, KeyboardShortcutScope, ShortcutScopeRoot, classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform };
|
|
86
|
+
export { ClassifyEditorKeydownOptions, DEFAULT_KEYBOARD_SHORTCUT_SCOPE, EditorKeydownIntent, HostShortcut, IsKeydownInShortcutScopeOptions, KeyboardShortcutScope, ShortcutScopeRoot, classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { deleteTable } from "../prosemirror/commands/table.js";
|
|
2
2
|
import { getTableContext } from "../prosemirror/extensions/nodes/TableExtension.js";
|
|
3
3
|
//#region src/managers/editorShortcuts.ts
|
|
4
|
+
const DEFAULT_KEYBOARD_SHORTCUT_SCOPE = "editor";
|
|
4
5
|
function isMacPlatform() {
|
|
5
6
|
if (typeof navigator === "undefined") return false;
|
|
6
7
|
return /Mac|iPod|iPhone|iPad/u.test(navigator.platform);
|
|
@@ -78,4 +79,4 @@ function deleteSelectedTable(state, dispatch) {
|
|
|
78
79
|
return false;
|
|
79
80
|
}
|
|
80
81
|
//#endregion
|
|
81
|
-
export { classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform };
|
|
82
|
+
export { DEFAULT_KEYBOARD_SHORTCUT_SCOPE, classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DisplayMode } from "./EditorModeManager.js";
|
|
2
|
+
//#region src/managers/reviewDisplayMode.d.ts
|
|
3
|
+
/** The host's reading of pending revisions; it never changes the saved document. */
|
|
4
|
+
declare const REVIEW_DISPLAY_MODES: readonly ["all-markup", "final", "original"];
|
|
5
|
+
type ReviewDisplayMode = (typeof REVIEW_DISPLAY_MODES)[number];
|
|
6
|
+
declare const reviewDisplayModeToDisplayMode: (mode: ReviewDisplayMode) => DisplayMode;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { REVIEW_DISPLAY_MODES, ReviewDisplayMode, reviewDisplayModeToDisplayMode };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/managers/reviewDisplayMode.ts
|
|
2
|
+
/** The host's reading of pending revisions; it never changes the saved document. */
|
|
3
|
+
const REVIEW_DISPLAY_MODES = [
|
|
4
|
+
"all-markup",
|
|
5
|
+
"final",
|
|
6
|
+
"original"
|
|
7
|
+
];
|
|
8
|
+
const REVIEW_DISPLAY_MODE_VIEWS = {
|
|
9
|
+
"all-markup": "all-markup",
|
|
10
|
+
final: "no-markup",
|
|
11
|
+
original: "original"
|
|
12
|
+
};
|
|
13
|
+
const reviewDisplayModeToDisplayMode = (mode) => REVIEW_DISPLAY_MODE_VIEWS[mode];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { REVIEW_DISPLAY_MODES, reviewDisplayModeToDisplayMode };
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { Layout } from "../layout-engine/types.js";
|
|
2
2
|
import "../layout-engine/index.js";
|
|
3
|
+
import { MarkupViewProjection } from "../prosemirror/markupViewProjection.js";
|
|
3
4
|
import { Node } from "prosemirror-model";
|
|
4
5
|
//#region src/paged-layout/pageText.d.ts
|
|
6
|
+
type PageTextOptions = {
|
|
7
|
+
layout: Layout | null;
|
|
8
|
+
doc: Node;
|
|
9
|
+
page: number;
|
|
10
|
+
projection?: MarkupViewProjection;
|
|
11
|
+
};
|
|
5
12
|
/**
|
|
6
13
|
* The plain text of a single rendered page (1-based), read by joining each of
|
|
7
14
|
* the page's layout fragments' `[pmStart, pmEnd)` document text with a
|
|
8
|
-
* newline.
|
|
15
|
+
* newline. A review projection maps those authored ranges to the displayed
|
|
16
|
+
* document, excluding text the view hides. Fragments with no `pmStart`/`pmEnd`
|
|
17
|
+
* (e.g. a page-shell placeholder)
|
|
9
18
|
* are skipped. Returns `null` when the layout hasn't been computed yet or the
|
|
10
19
|
* page number is out of range.
|
|
11
20
|
*/
|
|
12
|
-
declare const getPageTextFromLayout: (layout
|
|
21
|
+
declare const getPageTextFromLayout: ({ layout, doc, page, projection }: PageTextOptions) => string | null;
|
|
13
22
|
//#endregion
|
|
14
23
|
export { getPageTextFromLayout };
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* The plain text of a single rendered page (1-based), read by joining each of
|
|
4
4
|
* the page's layout fragments' `[pmStart, pmEnd)` document text with a
|
|
5
|
-
* newline.
|
|
5
|
+
* newline. A review projection maps those authored ranges to the displayed
|
|
6
|
+
* document, excluding text the view hides. Fragments with no `pmStart`/`pmEnd`
|
|
7
|
+
* (e.g. a page-shell placeholder)
|
|
6
8
|
* are skipped. Returns `null` when the layout hasn't been computed yet or the
|
|
7
9
|
* page number is out of range.
|
|
8
10
|
*/
|
|
9
|
-
const getPageTextFromLayout = (layout, doc, page) => {
|
|
11
|
+
const getPageTextFromLayout = ({ layout, doc, page, projection }) => {
|
|
10
12
|
if (!layout || !Number.isInteger(page) || page < 1) return null;
|
|
11
13
|
const layoutPage = layout.pages[page - 1];
|
|
12
14
|
if (!layoutPage) return null;
|
|
15
|
+
const viewDoc = projection?.type === "resolved" ? projection.doc : doc;
|
|
13
16
|
const fragmentTexts = [];
|
|
14
17
|
for (const fragment of layoutPage.fragments) {
|
|
15
18
|
if (typeof fragment.pmStart !== "number" || typeof fragment.pmEnd !== "number") continue;
|
|
16
|
-
|
|
19
|
+
const from = projection?.type === "resolved" ? projection.toView(fragment.pmStart, 1) : fragment.pmStart;
|
|
20
|
+
const to = projection?.type === "resolved" ? projection.toView(fragment.pmEnd, -1) : fragment.pmEnd;
|
|
21
|
+
fragmentTexts.push(viewDoc.textBetween(from, to, "\n"));
|
|
17
22
|
}
|
|
18
23
|
return fragmentTexts.join("\n");
|
|
19
24
|
};
|
package/dist/pdf/fonts.js
CHANGED
|
@@ -2,6 +2,7 @@ import { parseSfnt } from "../fonts/sfnt/parse.js";
|
|
|
2
2
|
import { subsetTrueType } from "../fonts/sfnt/subset.js";
|
|
3
3
|
import { toSfntBytes } from "../fonts/sfnt/woff.js";
|
|
4
4
|
import { needsShaping, placeRun } from "../shaping/placeRun.js";
|
|
5
|
+
import { bytesToHex, decodeText, encodeUtf16BE, encodeUtf8 } from "../utils/textEncoding.js";
|
|
5
6
|
import { pdfArray, pdfAsciiString, pdfDict, pdfFlateStream, pdfName, pdfNumber, pdfNumberArray } from "./objects.js";
|
|
6
7
|
import { Result, TaggedError, panic } from "better-result";
|
|
7
8
|
//#region src/pdf/fonts.ts
|
|
@@ -46,7 +47,7 @@ const SUBSET_TAG_LENGTH = 6;
|
|
|
46
47
|
const ALPHABET_LENGTH = 26;
|
|
47
48
|
const UPPERCASE_A = 65;
|
|
48
49
|
const WOFF_SIGNATURES = ["wOFF", "wOF2"];
|
|
49
|
-
const readTag = (bytes) =>
|
|
50
|
+
const readTag = (bytes) => decodeText(Uint8Array.of(bytes[0] ?? 0, bytes[1] ?? 0, bytes[2] ?? 0, bytes[3] ?? 0), { encoding: "binary" });
|
|
50
51
|
/**
|
|
51
52
|
* Six uppercase letters derived from the face and the exact glyph set, so the
|
|
52
53
|
* tag is stable across runs and two different subsets of one family do not
|
|
@@ -148,18 +149,8 @@ const buildWinAnsiTable = () => {
|
|
|
148
149
|
return table;
|
|
149
150
|
};
|
|
150
151
|
const WIN_ANSI_BY_CODE_POINT = buildWinAnsiTable();
|
|
151
|
-
const utf16BeHexOf = (text) =>
|
|
152
|
-
const utf16BeHex = (codePoint) =>
|
|
153
|
-
const SUPPLEMENTARY_START = 65536;
|
|
154
|
-
const SURROGATE_HALF_BITS = 10;
|
|
155
|
-
const LOW_SURROGATE_MASK = 1023;
|
|
156
|
-
const HIGH_SURROGATE_BASE = 55296;
|
|
157
|
-
const LOW_SURROGATE_BASE = 56320;
|
|
158
|
-
const hex = (unit) => unit.toString(16).padStart(4, "0").toUpperCase();
|
|
159
|
-
if (codePoint < SUPPLEMENTARY_START) return hex(codePoint);
|
|
160
|
-
const offset = codePoint - SUPPLEMENTARY_START;
|
|
161
|
-
return hex(HIGH_SURROGATE_BASE + (offset >> SURROGATE_HALF_BITS)) + hex(LOW_SURROGATE_BASE + (offset & LOW_SURROGATE_MASK));
|
|
162
|
-
};
|
|
152
|
+
const utf16BeHexOf = (text) => bytesToHex(encodeUtf16BE(text)).toUpperCase();
|
|
153
|
+
const utf16BeHex = (codePoint) => utf16BeHexOf(String.fromCodePoint(codePoint));
|
|
163
154
|
/** Entries per `beginbfchar` block; the CMap syntax caps this at 100. */
|
|
164
155
|
const BFCHAR_BLOCK_SIZE = 100;
|
|
165
156
|
const toUnicodeCMap = (glyphToText) => {
|
|
@@ -290,7 +281,7 @@ const emitFont = (document, plan) => {
|
|
|
290
281
|
fontFileKey: font.isCff ? "FontFile3" : "FontFile2",
|
|
291
282
|
fontFileRef
|
|
292
283
|
}));
|
|
293
|
-
const toUnicodeRef = document.add(pdfFlateStream([],
|
|
284
|
+
const toUnicodeRef = document.add(pdfFlateStream([], encodeUtf8(toUnicodeCMap(plan.glyphToText))));
|
|
294
285
|
const descendantRef = document.add(pdfDict([
|
|
295
286
|
["Type", pdfName("Font")],
|
|
296
287
|
["Subtype", pdfName(font.isCff ? "CIDFontType0" : "CIDFontType2")],
|
package/dist/pdf/images.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeText } from "../utils/textEncoding.js";
|
|
1
2
|
import { pdfArray, pdfHexString, pdfName, pdfNumber } from "./objects.js";
|
|
2
3
|
import { Result, TaggedError } from "better-result";
|
|
3
4
|
import { inflateSync } from "node:zlib";
|
|
@@ -63,7 +64,7 @@ const readPngChunks = (bytes) => {
|
|
|
63
64
|
const CHUNK_CRC_BYTES = 4;
|
|
64
65
|
while (cursor + CHUNK_HEADER_BYTES <= bytes.length) {
|
|
65
66
|
const length = view.getUint32(cursor);
|
|
66
|
-
const type =
|
|
67
|
+
const type = decodeText(bytes.subarray(cursor + 4, cursor + 8), { encoding: "binary" });
|
|
67
68
|
const dataStart = cursor + CHUNK_HEADER_BYTES;
|
|
68
69
|
const dataEnd = dataStart + length;
|
|
69
70
|
if (dataEnd > bytes.length) return Result.err(new PdfImageError({ message: `PNG chunk ${type} runs past the end` }));
|
|
@@ -538,7 +539,7 @@ const decodeJpeg = (bytes) => {
|
|
|
538
539
|
const length = view.getUint16(cursor + 2);
|
|
539
540
|
const segment = cursor + 4;
|
|
540
541
|
const frame = JPEG_FRAME_MODES[marker];
|
|
541
|
-
if (marker === APP14 && length >= 12) adobe =
|
|
542
|
+
if (marker === APP14 && length >= 12) adobe = decodeText(bytes.subarray(segment, segment + 5), { encoding: "binary" }) === "Adobe";
|
|
542
543
|
if (frame !== void 0) {
|
|
543
544
|
if (!frame.dctDecodable) return Result.err(new PdfImageError({ message: `JPEG ${frame.name} frame (marker 0xff${marker.toString(16)}) has no /DCTDecode equivalent` }));
|
|
544
545
|
const height = view.getUint16(segment + 1);
|
package/dist/pdf/objects.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
//#region src/pdf/objects.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The PDF object model: values, serialization, the cross-reference table and
|
|
4
|
-
* the trailer.
|
|
5
|
-
*
|
|
6
|
-
* Everything a backend writes into a PDF file passes through here, which is
|
|
7
|
-
* what makes byte-for-byte determinism enforceable rather than aspirational:
|
|
8
|
-
* numbers go through one formatter, dictionaries carry their entries as an
|
|
9
|
-
* ordered list (never an object or a `Map` whose iteration order depends on
|
|
10
|
-
* how it was built), and object numbers come from one allocator in call
|
|
11
|
-
* order.
|
|
12
|
-
*/
|
|
13
2
|
/** The one number formatter. Every number in the file is emitted through it. */
|
|
14
3
|
declare const formatNumber: (value: number) => string;
|
|
15
4
|
type PdfRef = {
|
package/dist/pdf/objects.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bytesToHex, encodeBinaryString, encodeUtf16BE, encodeUtf8 } from "../utils/textEncoding.js";
|
|
1
2
|
import { panic } from "better-result";
|
|
2
3
|
import { deflateSync } from "node:zlib";
|
|
3
4
|
//#region src/pdf/objects.ts
|
|
@@ -94,7 +95,10 @@ const pdfFlateStream = (entries, data) => pdfStream(pdfDict([...entries, ["Filte
|
|
|
94
95
|
const NAME_REGULAR = /^[A-Za-z0-9._\-+]$/u;
|
|
95
96
|
const encodeName = (value) => {
|
|
96
97
|
let out = "/";
|
|
97
|
-
for (const
|
|
98
|
+
for (const byte of encodeUtf8(value)) {
|
|
99
|
+
const char = String.fromCharCode(byte);
|
|
100
|
+
out += NAME_REGULAR.test(char) ? char : `#${byte.toString(16).padStart(2, "0").toUpperCase()}`;
|
|
101
|
+
}
|
|
98
102
|
return out;
|
|
99
103
|
};
|
|
100
104
|
const encodeAsciiString = (value) => {
|
|
@@ -108,11 +112,7 @@ const encodeAsciiString = (value) => {
|
|
|
108
112
|
}
|
|
109
113
|
return `${out})`;
|
|
110
114
|
};
|
|
111
|
-
const encodeTextString = (value) => {
|
|
112
|
-
let hex = "FEFF";
|
|
113
|
-
for (let index = 0; index < value.length; index += 1) hex += value.charCodeAt(index).toString(16).padStart(4, "0").toUpperCase();
|
|
114
|
-
return `<${hex}>`;
|
|
115
|
-
};
|
|
115
|
+
const encodeTextString = (value) => `<FEFF${bytesToHex(encodeUtf16BE(value)).toUpperCase()}>`;
|
|
116
116
|
const createByteSink = () => {
|
|
117
117
|
const chunks = [];
|
|
118
118
|
let length = 0;
|
|
@@ -122,9 +122,7 @@ const createByteSink = () => {
|
|
|
122
122
|
};
|
|
123
123
|
return {
|
|
124
124
|
writeAscii: (text) => {
|
|
125
|
-
|
|
126
|
-
for (let index = 0; index < text.length; index += 1) bytes[index] = text.charCodeAt(index) & 255;
|
|
127
|
-
writeBytes(bytes);
|
|
125
|
+
writeBytes(encodeBinaryString(text));
|
|
128
126
|
},
|
|
129
127
|
writeBytes,
|
|
130
128
|
offset: () => length,
|
package/dist/pdf/writePdf.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getShaper } from "../shaping/shaper.js";
|
|
2
|
+
import { encodeUtf8 } from "../utils/textEncoding.js";
|
|
2
3
|
import { collectResources, renderContentStream } from "./contentStream.js";
|
|
3
4
|
import { prepareFonts } from "./fonts.js";
|
|
4
5
|
import { decodeImage } from "./images.js";
|
|
@@ -288,7 +289,7 @@ const writePdf = async (list, options) => {
|
|
|
288
289
|
fonts: byFontIndex
|
|
289
290
|
});
|
|
290
291
|
const resources = collectResources(parts);
|
|
291
|
-
const contentRef = document.add(pdfFlateStream([],
|
|
292
|
+
const contentRef = document.add(pdfFlateStream([], encodeUtf8(renderContentStream(parts, resources))));
|
|
292
293
|
const annotationRefs = [];
|
|
293
294
|
for (const link of page.links) {
|
|
294
295
|
const annotation = buildLinkAnnotation({
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
1
2
|
import { EditorState } from "prosemirror-state";
|
|
2
3
|
//#region src/prosemirror/canonicalSelectionRange.d.ts
|
|
4
|
+
/** Document edges denote the first and last editable content gaps. */
|
|
5
|
+
declare const canonicalContentPosition: (doc: Node, position: number) => number;
|
|
3
6
|
/** Whole-document selection addresses paragraph content rather than document edges. */
|
|
4
7
|
declare const canonicalSelectionRange: ({ doc, selection }: EditorState) => {
|
|
5
8
|
from: number;
|
|
6
9
|
to: number;
|
|
7
10
|
};
|
|
8
11
|
//#endregion
|
|
9
|
-
export { canonicalSelectionRange };
|
|
12
|
+
export { canonicalContentPosition, canonicalSelectionRange };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { AllSelection, Selection } from "prosemirror-state";
|
|
2
2
|
//#region src/prosemirror/canonicalSelectionRange.ts
|
|
3
|
+
/** Document edges denote the first and last editable content gaps. */
|
|
4
|
+
const canonicalContentPosition = (doc, position) => {
|
|
5
|
+
if (position === 0) return Selection.atStart(doc).from;
|
|
6
|
+
if (position === doc.content.size) return Selection.atEnd(doc).to;
|
|
7
|
+
return position;
|
|
8
|
+
};
|
|
3
9
|
/** Whole-document selection addresses paragraph content rather than document edges. */
|
|
4
10
|
const canonicalSelectionRange = ({ doc, selection }) => {
|
|
5
11
|
if (selection instanceof AllSelection) return {
|
|
6
|
-
from:
|
|
7
|
-
to:
|
|
12
|
+
from: canonicalContentPosition(doc, selection.from),
|
|
13
|
+
to: canonicalContentPosition(doc, selection.to)
|
|
8
14
|
};
|
|
9
15
|
return {
|
|
10
16
|
from: selection.from,
|
|
@@ -12,4 +18,4 @@ const canonicalSelectionRange = ({ doc, selection }) => {
|
|
|
12
18
|
};
|
|
13
19
|
};
|
|
14
20
|
//#endregion
|
|
15
|
-
export { canonicalSelectionRange };
|
|
21
|
+
export { canonicalContentPosition, canonicalSelectionRange };
|
|
@@ -13,11 +13,13 @@ import "../extensions/nodes/SdtExtension.js";
|
|
|
13
13
|
import { canonicalFieldNode } from "../fieldRepresentation.js";
|
|
14
14
|
import { resolveStateStory } from "../markupViewProjection.js";
|
|
15
15
|
import { joinAtParagraphMark } from "../paragraphMarkJoin.js";
|
|
16
|
+
import { carryParagraphProperties, paragraphLeftAfter } from "../paragraphPropertyCarry.js";
|
|
16
17
|
import { getDocumentNumbering } from "../plugins/documentNumbering.js";
|
|
17
18
|
import { getDocumentStyleResolver } from "../plugins/documentStyleState.js";
|
|
18
19
|
import { resolvedPreservedXmlAttrs } from "../preservedXmlReview.js";
|
|
19
20
|
import { setParagraphAttrsWithRebasedRunFormatting } from "../rebaseParagraphRunFormatting.js";
|
|
20
21
|
import { rejoinRunsAt } from "../rejoinRunCarriers.js";
|
|
22
|
+
import { commentPoint, resolvedCommentPoints } from "../replacedAnnotations.js";
|
|
21
23
|
import { getFolioNodeRevisionCarriers, nodePropertyRevisionSites } from "../revisionCarriers.js";
|
|
22
24
|
import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
|
|
23
25
|
import { reconstructRejectedRunFormattingMarks, restoreHistoricalRunFormatting } from "../runPropertyChangeResolution.js";
|
|
@@ -100,6 +102,16 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
100
102
|
const removeKeptMarksInBulk = revisionSet === null && keepType !== void 0;
|
|
101
103
|
const matchesRevision = (mark) => revisionSet === null || typeof mark.attrs["revisionId"] === "number" && revisionSet.has(mark.attrs["revisionId"]);
|
|
102
104
|
if (dispatch) {
|
|
105
|
+
const points = mode === "accept" ? resolvedCommentPoints({
|
|
106
|
+
doc: state.doc,
|
|
107
|
+
retiresStructure: (node, position) => {
|
|
108
|
+
if (node.type.name === "paragraph") return collectPPrMarkOp(node, position, from, to, mode, revisionSet)?.action === "join";
|
|
109
|
+
if (!rangeCoversNode(from, to, position, node)) return false;
|
|
110
|
+
if (node.type.name === "tableRow") return collectTableRowStructuralOp(node, position, mode, revisionSet)?.action === "remove";
|
|
111
|
+
return collectTableCellStructuralOps(node, position, mode, revisionSet).some((op) => op.type === "membership" && op.action === "remove");
|
|
112
|
+
},
|
|
113
|
+
removes: (node, position) => position >= from && position + node.nodeSize <= to && node.marks.some((mark) => mark.type === removeType && matchesRevision(mark))
|
|
114
|
+
}) : /* @__PURE__ */ new Map();
|
|
103
115
|
const tr = state.tr;
|
|
104
116
|
tr.setMeta(JOINED_RUNS_RESTYLED_META, true);
|
|
105
117
|
const deleteRanges = [];
|
|
@@ -110,6 +122,25 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
110
122
|
const tableCellStructuralOps = [];
|
|
111
123
|
let removedSectionEndpointCount = 0;
|
|
112
124
|
const removedSectionReferences = [];
|
|
125
|
+
const carryRestoredProperties = (position) => {
|
|
126
|
+
if (mode !== "reject" || revisionSet === null) return;
|
|
127
|
+
const source = tr.doc.nodeAt(position);
|
|
128
|
+
const mark = source ? expectParagraphAttrs(source).pPrMark : null;
|
|
129
|
+
if (!source || mark?.kind !== "del" && mark?.kind !== "moveFrom" || revisionSet.has(mark.info.id)) return;
|
|
130
|
+
const survivor = paragraphLeftAfter({
|
|
131
|
+
doc: tr.doc,
|
|
132
|
+
paragraphPos: position
|
|
133
|
+
});
|
|
134
|
+
if (survivor === null) return;
|
|
135
|
+
carryParagraphProperties({
|
|
136
|
+
tr,
|
|
137
|
+
position: survivor,
|
|
138
|
+
source,
|
|
139
|
+
styleResolver,
|
|
140
|
+
numbering,
|
|
141
|
+
revision: mark.info
|
|
142
|
+
});
|
|
143
|
+
};
|
|
113
144
|
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
114
145
|
if (node.type.name === "paragraph") {
|
|
115
146
|
const op = collectPPrMarkOp(node, pos, from, to, mode, revisionSet);
|
|
@@ -122,18 +153,21 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
122
153
|
styleResolver,
|
|
123
154
|
numbering
|
|
124
155
|
});
|
|
125
|
-
if (nextAttrs)
|
|
126
|
-
nextAttrs
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
if (nextAttrs) {
|
|
157
|
+
if (nextAttrs["styleId"] !== node.attrs["styleId"] && styleResolver) setParagraphAttrsWithRebasedRunFormatting({
|
|
158
|
+
nextAttrs,
|
|
159
|
+
paragraphPosition: pos,
|
|
160
|
+
styleResolver,
|
|
161
|
+
tr,
|
|
162
|
+
...mode === "reject" && { shouldRebase: (inline) => {
|
|
163
|
+
const deleted = inline.marks.some(({ type }) => type.name === "deletion");
|
|
164
|
+
const direct = inline.marks.some(({ type }) => type.name === "runFormattingOverride");
|
|
165
|
+
return !deleted || !direct;
|
|
166
|
+
} }
|
|
167
|
+
});
|
|
168
|
+
else tr.setNodeMarkup(pos, void 0, nextAttrs);
|
|
169
|
+
carryRestoredProperties(pos);
|
|
170
|
+
}
|
|
137
171
|
return true;
|
|
138
172
|
}
|
|
139
173
|
if (node.type.name === "tableRow" && rangeCoversNode(from, to, pos, node)) {
|
|
@@ -388,7 +422,10 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
388
422
|
removedSectionEndpointCount++;
|
|
389
423
|
removedSectionReferences.push(...sectionReferencesOf(paragraph));
|
|
390
424
|
}
|
|
391
|
-
} catch {
|
|
425
|
+
} catch {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (op.markWasAdded) carryRestoredProperties(mappedPos);
|
|
392
429
|
}
|
|
393
430
|
if (removedSectionEndpointCount > 0) markTrackedSectionEndpointRemoval(tr, {
|
|
394
431
|
sourceDoc: state.doc,
|
|
@@ -416,6 +453,7 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
416
453
|
if (field.type === node.type) tr.setNodeMarkup(position, void 0, node.attrs, node.marks);
|
|
417
454
|
else tr.replaceWith(position, position + field.nodeSize, node);
|
|
418
455
|
}
|
|
456
|
+
for (const [id, position] of [...points].toReversed()) tr.insert(tr.mapping.map(position, -1), commentPoint(tr.doc.type.schema, id));
|
|
419
457
|
if (tr.steps.length > 0) dispatch(tr);
|
|
420
458
|
}
|
|
421
459
|
return true;
|
|
@@ -2,15 +2,15 @@ import { Node, ResolvedPos } from "prosemirror-model";
|
|
|
2
2
|
//#region src/prosemirror/containerFinalParagraph.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Whether the paragraph starting at `at` is the one its container ENDS with,
|
|
5
|
-
*
|
|
5
|
+
* where a paragraph break cannot join into a following paragraph.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
7
|
+
* Added boundaries normally rotate onto a preceding paragraph, so rejecting
|
|
8
|
+
* them joins back into this one. If an occupied boundary or a table prevents
|
|
9
|
+
* rotation, the final inserted paragraph must retain its own revision: the
|
|
10
|
+
* resolver removes the whole paragraph after rejecting its inserted content.
|
|
11
|
+
* A terminal deletion, by contrast, clears without removing the container's
|
|
12
|
+
* required ending. Bodies, table cells, headers, footers, notes and text boxes
|
|
13
|
+
* share these rules.
|
|
14
14
|
*
|
|
15
15
|
* A paragraph before a TABLE is not one of those: the table is a following
|
|
16
16
|
* sibling, so the paragraph does not end anything and carries its own mark
|
|
@@ -14,15 +14,15 @@ const nothingFollowsIn = (parent, fromIndex, paragraphTypeName) => {
|
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Whether the paragraph starting at `at` is the one its container ENDS with,
|
|
17
|
-
*
|
|
17
|
+
* where a paragraph break cannot join into a following paragraph.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
19
|
+
* Added boundaries normally rotate onto a preceding paragraph, so rejecting
|
|
20
|
+
* them joins back into this one. If an occupied boundary or a table prevents
|
|
21
|
+
* rotation, the final inserted paragraph must retain its own revision: the
|
|
22
|
+
* resolver removes the whole paragraph after rejecting its inserted content.
|
|
23
|
+
* A terminal deletion, by contrast, clears without removing the container's
|
|
24
|
+
* required ending. Bodies, table cells, headers, footers, notes and text boxes
|
|
25
|
+
* share these rules.
|
|
26
26
|
*
|
|
27
27
|
* A paragraph before a TABLE is not one of those: the table is a following
|
|
28
28
|
* sibling, so the paragraph does not end anything and carries its own mark
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { joinCommentRangesAcrossParagraphs } from "../../docx/commentRangeJoin.js";
|
|
2
2
|
import { completeCommentReferences } from "../../docx/commentReferenceCompletion.js";
|
|
3
|
+
import { buildSections } from "../../docx/documentParser.js";
|
|
3
4
|
import { normalizeFoldedListNumbers } from "../../docx/foldedListNumberFields.js";
|
|
4
5
|
import { getDocumentSourceStyles } from "../../docx/headerFooterVerbatim.js";
|
|
5
6
|
import { EDITED_PREVIEW_FINGERPRINT, imageRawXmlFingerprint } from "../../docx/imageRawXml.js";
|
|
@@ -397,7 +398,7 @@ function fromProseDoc(pmDoc, baseDocument, { stylesheetSource, reuse = "none" })
|
|
|
397
398
|
const documentBody = { content: blocks };
|
|
398
399
|
if (baseDocument?.package.document.background) documentBody.background = baseDocument.package.document.background;
|
|
399
400
|
if (baseDocument?.package.document.finalSectionProperties) documentBody.finalSectionProperties = baseDocument.package.document.finalSectionProperties;
|
|
400
|
-
if (baseDocument?.package.document.sections) documentBody.sections =
|
|
401
|
+
if (baseDocument?.package.document.sections) documentBody.sections = buildSections(blocks, documentBody.finalSectionProperties);
|
|
401
402
|
if (baseDocument?.package.document.comments) documentBody.comments = baseDocument.package.document.comments;
|
|
402
403
|
const numbering = completeNumberingForDoc(baseDocument?.package.numbering, pmDoc);
|
|
403
404
|
if (baseDocument) {
|
|
@@ -1582,12 +1583,16 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
|
|
|
1582
1583
|
};
|
|
1583
1584
|
const appendDirectRun = (node, run, coalescePlainText = false) => {
|
|
1584
1585
|
if (currentHyperlink) flushCurrentInline();
|
|
1585
|
-
const marksKey = getMarksKey(node.marks)
|
|
1586
|
+
const marksKey = getMarksKey(node.marks.filter((mark) => {
|
|
1587
|
+
if (mark.type.name !== "runIdentity") return true;
|
|
1588
|
+
const { emptyFormatting, preservedAttributes, preserved } = expectRunIdentityMarkAttrs(mark);
|
|
1589
|
+
return emptyFormatting !== true || (preservedAttributes?.length ?? 0) > 0 || (preserved?.children?.length ?? 0) > 0;
|
|
1590
|
+
}));
|
|
1586
1591
|
const ownerId = runIdentityId(node);
|
|
1587
1592
|
const currentOwnerId = currentRun ? sourceRunOwners.get(currentRun) : void 0;
|
|
1588
1593
|
const currentRunIsPlainText = currentRun?.content.every((runContent) => runContent.type === "text");
|
|
1589
1594
|
const joinsOwnedSourceRun = ownerId !== void 0 && ownerId === currentOwnerId && currentRun !== null && runsShareProperties(currentRun, run);
|
|
1590
|
-
const joinsOrdinaryText = coalescePlainText &&
|
|
1595
|
+
const joinsOrdinaryText = coalescePlainText && currentRun !== null && runsShareProperties(currentRun, run) && currentRunIsPlainText === true && currentMarksKey === marksKey;
|
|
1591
1596
|
if (currentRun && (joinsOwnedSourceRun || joinsOrdinaryText)) {
|
|
1592
1597
|
if (joinsOrdinaryText) {
|
|
1593
1598
|
for (const runContent of run.content) if (runContent.type === "text") appendTextToRun(currentRun, runContent.text);
|
|
@@ -3319,7 +3324,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
3319
3324
|
if (attrs.margins && !sameResolvedValue(attrs.margins, attrs._resolvedMargins)) result.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
3320
3325
|
if (attrs.textDirection !== (orig.textDirection ?? void 0)) if (attrs.textDirection) result.textDirection = attrs.textDirection;
|
|
3321
3326
|
else delete result.textDirection;
|
|
3322
|
-
return result;
|
|
3327
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
3323
3328
|
}
|
|
3324
3329
|
const authoredWidth = attrs._authoredWidth;
|
|
3325
3330
|
if (!(attrs.colspan > 1 || attrs.rowspan > 1 || authoredWidth !== void 0 || attrs.verticalAlign || backgroundChanged || attrs.borders || attrs.margins || attrs.textDirection)) return;
|
|
@@ -42,7 +42,7 @@ import { directionFromBidi } from "../paragraphDirection.js";
|
|
|
42
42
|
import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
|
|
43
43
|
import { lineSpacingProvenanceFromSpacing } from "../paragraphSpacing.js";
|
|
44
44
|
import { RUN_IDENTITY_MARK_NAME, hasRunIdentityPayload, runIdentityAttrs } from "../runIdentity.js";
|
|
45
|
-
import {
|
|
45
|
+
import { continueSourceCarrierIdentitiesAcrossRevisions } from "../runIdentityAcrossRevisions.js";
|
|
46
46
|
import { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, isParagraphMarkSuppressionEligible, resolveParagraphInheritedRunFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting } from "../runStyleFormatting.js";
|
|
47
47
|
import { schema } from "../schema/index.js";
|
|
48
48
|
import { PRESERVED_XML_LEVELS } from "../schema/nodes.js";
|
|
@@ -112,7 +112,7 @@ const runIdentityMark = (run, nextRunIdentityId) => {
|
|
|
112
112
|
const payload = {
|
|
113
113
|
preservedAttributes: run.preservedAttributes,
|
|
114
114
|
preserved: run.formatting?.preserved,
|
|
115
|
-
emptyFormatting: run.formatting !== void 0 && Object.keys(run.formatting).length === 0
|
|
115
|
+
emptyFormatting: run.formatting !== void 0 && Object.keys(run.formatting).length === 0 ? true : void 0
|
|
116
116
|
};
|
|
117
117
|
if (!runHasPageBreakContent(run) && !runHasMixedContent(run) && !hasRunIdentityPayload(payload)) return null;
|
|
118
118
|
return schema.mark(RUN_IDENTITY_MARK_NAME, runIdentityAttrs(nextRunIdentityId(), payload));
|
|
@@ -676,7 +676,7 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
|
|
|
676
676
|
if (emptyHyperlinks) attrs._emptyHyperlinks = emptyHyperlinks;
|
|
677
677
|
return createProseParagraphWithPropertySource(schema.nodes["paragraph"], paragraph, {
|
|
678
678
|
attrs,
|
|
679
|
-
content:
|
|
679
|
+
content: continueSourceCarrierIdentitiesAcrossRevisions(inlineNodes)
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
/**
|
|
@@ -1256,7 +1256,7 @@ function convertTableCell({ cell, styleResolver, context, isHeader, gridWidthPer
|
|
|
1256
1256
|
attrs.margins = effectiveFormatting.margins;
|
|
1257
1257
|
attrs._resolvedMargins = effectiveFormatting.margins;
|
|
1258
1258
|
}
|
|
1259
|
-
|
|
1259
|
+
attrs._originalFormatting = formatting ?? {};
|
|
1260
1260
|
if (cell.propertyChanges && cell.propertyChanges.length > 0) attrs.tcPrChange = [...cell.propertyChanges];
|
|
1261
1261
|
if (cell.contentControls && cell.contentControls.length > 0) attrs.contentControls = cell.contentControls;
|
|
1262
1262
|
if (cell.carrierStack?.length) attrs.carrierStack = cell.carrierStack;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Extension } from "../types.js";
|
|
2
|
-
import { EditorState,
|
|
2
|
+
import { EditorState, Plugin } from "prosemirror-state";
|
|
3
3
|
//#region src/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts
|
|
4
|
-
declare const autoBidiDetectionKey:
|
|
4
|
+
declare const autoBidiDetectionKey: Readonly<{
|
|
5
|
+
key: string;
|
|
6
|
+
createKey: () => import("prosemirror-state").PluginKey<unknown>;
|
|
7
|
+
owns: (plugin: Plugin<unknown>) => boolean;
|
|
8
|
+
get: (state: EditorState) => Plugin<unknown> | undefined;
|
|
9
|
+
getState: (state: EditorState) => unknown;
|
|
10
|
+
}>;
|
|
5
11
|
/**
|
|
6
12
|
* Imperatively apply auto-bidi detection to a freshly built state (initial
|
|
7
13
|
* load: Markdown import, DOCX import, template). `appendTransaction` does not
|