@stll/folio-core 0.11.0 → 0.13.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 +2 -1
- package/dist/ai-edits/apply.js +693 -63
- package/dist/ai-edits/block-identity.d.ts +4 -0
- package/dist/ai-edits/block-identity.js +9 -0
- package/dist/ai-edits/blockRange.d.ts +28 -1
- package/dist/ai-edits/blockRange.js +68 -2
- package/dist/ai-edits/clean-text.js +2 -1
- package/dist/ai-edits/headless.d.ts +4 -4
- package/dist/ai-edits/headless.js +9 -9
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/read.d.ts +7 -7
- package/dist/ai-edits/read.js +110 -3
- package/dist/ai-edits/snapshot.js +21 -3
- package/dist/ai-edits/table-cell-mutations.d.ts +48 -0
- package/dist/ai-edits/table-cell-mutations.js +238 -0
- package/dist/ai-edits/table-mutation-plan.d.ts +38 -0
- package/dist/ai-edits/table-mutation-plan.js +90 -0
- package/dist/ai-edits/table-row-column-mutations.d.ts +108 -0
- package/dist/ai-edits/table-row-column-mutations.js +300 -0
- package/dist/ai-edits/table-targets.d.ts +32 -0
- package/dist/ai-edits/table-targets.js +70 -0
- package/dist/ai-edits/types.d.ts +62 -1
- package/dist/ai-edits/word-diff.js +21 -0
- package/dist/compat/eigenpal.d.ts +3 -3
- package/dist/compat/eigenpal.js +3 -3
- package/dist/content-controls/mutateContentControls.js +1 -1
- package/dist/controller/activeEditorStory.d.ts +36 -0
- package/dist/controller/activeEditorStory.js +30 -0
- package/dist/controller/contentControlWidgetController.d.ts +55 -0
- package/dist/controller/contentControlWidgetController.js +141 -0
- package/dist/controller/fontReadiness.js +2 -0
- package/dist/controller/headerFooterEditorManager.js +2 -2
- package/dist/controller/hiddenEditorApi.js +2 -2
- package/dist/controller/hiddenEditorManager.d.ts +12 -1
- package/dist/controller/hiddenEditorManager.js +44 -12
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +17 -2
- package/dist/controller/noteEditorManager.d.ts +36 -0
- package/dist/controller/noteEditorManager.js +210 -0
- package/dist/document-operations.d.ts +43 -11
- package/dist/document-operations.js +186 -18
- package/dist/docx/blockContentParser.js +21 -7
- package/dist/docx/commentParser.js +6 -1
- package/dist/docx/commentRangeIntegrity.d.ts +6 -0
- package/dist/docx/commentRangeIntegrity.js +186 -0
- package/dist/docx/conformance.js +62 -1
- package/dist/docx/documentGrid.d.ts +8 -0
- package/dist/docx/documentGrid.js +8 -0
- package/dist/docx/drawingUtils.js +1 -1
- package/dist/docx/encryption/agileDecryption.js +12 -2
- package/dist/docx/encryption/compoundFile.js +6 -1
- package/dist/docx/encryption/encryptionInfo.d.ts +9 -1
- package/dist/docx/encryption/encryptionInfo.js +18 -2
- package/dist/docx/encryption/openEncryptedDocx.js +1 -1
- package/dist/docx/ensureParaIds.js +8 -7
- package/dist/docx/fieldParser.js +1 -1
- package/dist/docx/groupDrawingParser.js +10 -5
- package/dist/docx/hyperlinkParser.js +1 -1
- package/dist/docx/imageParser.js +10 -6
- package/dist/docx/metadataPrivacy.js +17 -3
- package/dist/docx/notePropertiesParser.js +1 -1
- package/dist/docx/numberingParser.js +1 -1
- package/dist/docx/paragraphParser.js +70 -61
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +67 -13
- package/dist/docx/paragraphTraversal.js +1 -1
- package/dist/docx/parser.js +3 -3
- package/dist/docx/rezip.js +20 -9
- package/dist/docx/runParser.js +17 -6
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sectionParser.js +18 -5
- package/dist/docx/selectiveSave.js +5 -1
- package/dist/docx/selectiveXmlPatch.d.ts +22 -1
- package/dist/docx/selectiveXmlPatch.js +61 -1
- package/dist/docx/serializer/blockSdtSerializer.js +3 -2
- package/dist/docx/serializer/commentSerializer.js +5 -6
- package/dist/docx/serializer/documentSerializer.js +2 -2
- package/dist/docx/serializer/headerFooterSerializer.js +2 -2
- package/dist/docx/serializer/noteSerializer.js +2 -2
- package/dist/docx/serializer/paragraphSerializer.js +23 -15
- package/dist/docx/serializer/runSerializer.js +25 -21
- package/dist/docx/serializer/sectionPropertiesSerializer.js +2 -1
- package/dist/docx/serializer/stylesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.d.ts +5 -4
- package/dist/docx/serializer/tableSerializer.js +26 -20
- package/dist/docx/serializer/xmlUtils.d.ts +13 -1
- package/dist/docx/serializer/xmlUtils.js +27 -1
- package/dist/docx/server/applyDocxXmlPatchProposal.d.ts +87 -0
- package/dist/docx/server/applyDocxXmlPatchProposal.js +204 -0
- package/dist/docx/server/boundedArchive.d.ts +14 -3
- package/dist/docx/server/boundedArchive.js +56 -11
- package/dist/docx/server/evaluateDocxXmlPatchProposal.d.ts +85 -0
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +361 -0
- package/dist/docx/server/extractDocxText.js +55 -8
- package/dist/docx/server/inspectDocxPackage.d.ts +70 -0
- package/dist/docx/server/inspectDocxPackage.js +217 -0
- package/dist/docx/server/validateDocxConformance.d.ts +41 -0
- package/dist/docx/server/validateDocxConformance.js +336 -0
- package/dist/docx/settingsParser.js +26 -3
- package/dist/docx/shapeParser.js +1 -1
- package/dist/docx/styleParser.js +4 -2
- package/dist/docx/tableParser.d.ts +8 -1
- package/dist/docx/tableParser.js +31 -10
- package/dist/docx/textBoxParser.d.ts +3 -3
- package/dist/docx/textBoxParser.js +16 -12
- package/dist/docx/unzip.js +1 -0
- package/dist/docx/vmlImageParser.js +11 -3
- package/dist/docx/xmlParser.js +11 -1
- package/dist/docx/xmlSafety.d.ts +5 -0
- package/dist/docx/xmlSafety.js +9 -0
- package/dist/fields/resolveFieldValues.js +1 -3
- package/dist/fonts/embeddedFonts.d.ts +33 -5
- package/dist/fonts/embeddedFonts.js +37 -8
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +47 -40
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +3 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.js +3 -3
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +151 -20
- package/dist/layout-bridge/dom/noteStoryDom.d.ts +6 -0
- package/dist/layout-bridge/dom/noteStoryDom.js +17 -0
- package/dist/layout-bridge/engine/clickToPosition.js +2 -2
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +58 -30
- package/dist/layout-engine/justificationCompatibility.d.ts +6 -0
- package/dist/layout-engine/justificationCompatibility.js +8 -0
- package/dist/layout-engine/keep-together.js +11 -1
- package/dist/layout-engine/measure/cache.js +23 -5
- package/dist/layout-engine/measure/effectiveLineBreakPolicy.js +8 -2
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +2 -2
- package/dist/layout-engine/measure/lineBreakProvider.js +56 -37
- package/dist/layout-engine/measure/measureBlocks.js +15 -4
- package/dist/layout-engine/measure/measureContainer.js +1 -1
- package/dist/layout-engine/measure/measureHelpers.d.ts +11 -2
- package/dist/layout-engine/measure/measureHelpers.js +15 -4
- package/dist/layout-engine/measure/measureParagraph.js +85 -25
- package/dist/layout-engine/measure/measureProvider.js +4 -3
- package/dist/layout-engine/measure/tableCellFlow.js +5 -2
- package/dist/layout-engine/measure/textBoxParagraphLayout.d.ts +9 -7
- package/dist/layout-engine/measure/textBoxParagraphLayout.js +22 -6
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +3 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.js +7 -1
- package/dist/layout-engine/paginator.js +5 -1
- package/dist/layout-engine/paragraphSpacing.d.ts +28 -4
- package/dist/layout-engine/paragraphSpacing.js +107 -13
- package/dist/layout-engine/renderedBreakReconciliation.js +1 -1
- package/dist/layout-engine/types.d.ts +48 -15
- package/dist/layout-painter/registry/modules/textBox.js +5 -1
- package/dist/layout-painter/renderImage.d.ts +12 -1
- package/dist/layout-painter/renderImage.js +21 -4
- package/dist/layout-painter/renderPage.d.ts +5 -2
- package/dist/layout-painter/renderPage.js +59 -14
- package/dist/layout-painter/renderParagraph.js +55 -15
- package/dist/layout-painter/renderTable.d.ts +5 -1
- package/dist/layout-painter/renderTable.js +7 -3
- package/dist/layout-painter/renderTextBox.d.ts +2 -1
- package/dist/layout-painter/renderTextBox.js +25 -14
- package/dist/layout-painter/renderWatermark.d.ts +1 -1
- package/dist/layout-painter/renderWatermark.js +2 -1
- package/dist/managers/DocumentLoaderManager.js +1 -1
- package/dist/markdown/fromMarkdown.js +1 -1
- package/dist/model.js +1 -1
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +175 -18
- package/dist/prosemirror/commands/comments.d.ts +79 -4
- package/dist/prosemirror/commands/comments.js +622 -13
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/hyperlink.js +15 -1
- package/dist/prosemirror/commands/image.js +7 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +2 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +3 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +9 -0
- package/dist/prosemirror/commands/tableCellMergeResolution.js +181 -0
- package/dist/prosemirror/commentIdAllocator.js +13 -3
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +404 -62
- package/dist/prosemirror/conversion/index.js +1 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +9 -0
- package/dist/prosemirror/conversion/sdtAttrs.js +49 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +2 -1
- package/dist/prosemirror/conversion/toProseDoc.js +364 -103
- package/dist/prosemirror/extensions/ExtensionManager.js +1 -1
- package/dist/prosemirror/extensions/StarterKit.js +6 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +6 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +10 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +10 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +93 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +2 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +6 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +15 -2
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +30 -4
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +9 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +70 -11
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +22 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +14 -6
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.js +41 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +5 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -1
- package/dist/prosemirror/index.d.ts +1 -1
- package/dist/prosemirror/index.js +1 -1
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +36 -10
- package/dist/prosemirror/plugins/contentControlWidgets.js +128 -94
- package/dist/prosemirror/plugins/revisionIds.d.ts +23 -0
- package/dist/prosemirror/plugins/revisionIds.js +57 -0
- package/dist/prosemirror/plugins/selectionTracker.js +1 -0
- package/dist/prosemirror/plugins/suggestionMode.js +5 -4
- package/dist/prosemirror/runFormattingMarkNames.d.ts +14 -0
- package/dist/prosemirror/runFormattingMarkNames.js +40 -0
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +30 -3
- package/dist/prosemirror/schema/marks.js +15 -0
- package/dist/prosemirror/schema/nodes.d.ts +111 -6
- package/dist/prosemirror/selectionState.js +1 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
- package/dist/prosemirror/tableCellMergeRevision.d.ts +9 -0
- package/dist/prosemirror/tableCellMergeRevision.js +22 -0
- package/dist/prosemirror/textBoxAnchorAttrs.d.ts +9 -0
- package/dist/prosemirror/textBoxAnchorAttrs.js +33 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +1 -1
- package/dist/prosemirror/utils/extractTrackedChanges.js +62 -14
- package/dist/prosemirror/validation.js +9 -1
- package/dist/render-dom/RemoteSelectionOverlay.js +2 -2
- package/dist/server.d.ts +7 -3
- package/dist/server.js +7 -3
- package/dist/utils/clipboard.d.ts +10 -1
- package/dist/utils/clipboard.js +33 -6
- package/dist/utils/colorResolver.d.ts +8 -1
- package/dist/utils/colorResolver.js +35 -5
- package/dist/utils/fontFamilyMerge.js +9 -11
- package/dist/utils/fontLoader.js +3 -2
- package/dist/utils/fontResolver.d.ts +2 -1
- package/dist/utils/fontResolver.js +31 -7
- package/dist/utils/fontWeights.d.ts +1 -1
- package/dist/utils/fontWeights.js +1 -1
- package/dist/utils/hexId.d.ts +11 -1
- package/dist/utils/hexId.js +11 -1
- package/dist/utils/paragraphFormattingMerge.js +1 -0
- package/dist/utils/sanitizeImageSrc.d.ts +21 -0
- package/dist/utils/sanitizeImageSrc.js +30 -0
- package/dist/utils/stripXmlDeclarations.d.ts +11 -0
- package/dist/utils/stripXmlDeclarations.js +35 -0
- package/dist/version-comparison.d.ts +22 -2
- package/dist/version-comparison.js +41 -12
- package/dist/watermark/index.d.ts +11 -1
- package/dist/watermark/index.js +22 -1
- package/package.json +3 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ContentControlWidgetEvent } from "../prosemirror/plugins/contentControlWidgets.js";
|
|
2
|
+
import { Subscribable } from "../managers/Subscribable.js";
|
|
3
|
+
import { EditorView } from "prosemirror-view";
|
|
4
|
+
|
|
5
|
+
//#region src/controller/contentControlWidgetController.d.ts
|
|
6
|
+
type ContentControlListItem = {
|
|
7
|
+
displayText: string;
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
type ContentControlPickerPosition = {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
type ContentControlWidgetSnapshot = {
|
|
15
|
+
status: "closed";
|
|
16
|
+
} | {
|
|
17
|
+
status: "dropdown";
|
|
18
|
+
items: readonly ContentControlListItem[];
|
|
19
|
+
pmPos: number;
|
|
20
|
+
position: ContentControlPickerPosition;
|
|
21
|
+
} | {
|
|
22
|
+
status: "date";
|
|
23
|
+
currentValue: string | null;
|
|
24
|
+
pmPos: number;
|
|
25
|
+
position: ContentControlPickerPosition;
|
|
26
|
+
};
|
|
27
|
+
type ContentControlWidgetControllerOptions = {
|
|
28
|
+
onRefused?: ((event: Extract<ContentControlWidgetEvent, {
|
|
29
|
+
kind: "refused";
|
|
30
|
+
}>) => void) | undefined;
|
|
31
|
+
};
|
|
32
|
+
declare const parseContentControlListItems: (raw: string | undefined) => ContentControlListItem[];
|
|
33
|
+
declare class ContentControlWidgetController extends Subscribable<ContentControlWidgetSnapshot> {
|
|
34
|
+
private readonly options;
|
|
35
|
+
private view;
|
|
36
|
+
private viewDom;
|
|
37
|
+
private eventRoot;
|
|
38
|
+
private ownerWindow;
|
|
39
|
+
constructor(options?: ContentControlWidgetControllerOptions);
|
|
40
|
+
bind(view: EditorView | null, eventRoot?: HTMLElement | null): void;
|
|
41
|
+
handleWidgetEvent(event: ContentControlWidgetEvent): void;
|
|
42
|
+
pickDropdown(value: string): boolean;
|
|
43
|
+
pickDate(value: string): boolean;
|
|
44
|
+
close(): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
private readonly onDomEvent;
|
|
47
|
+
private readonly onPaintedClick;
|
|
48
|
+
private readonly onKeyDown;
|
|
49
|
+
private readonly onScroll;
|
|
50
|
+
private open;
|
|
51
|
+
private removeDismissListeners;
|
|
52
|
+
private unbindView;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ContentControlListItem, ContentControlPickerPosition, ContentControlWidgetController, ContentControlWidgetControllerOptions, ContentControlWidgetSnapshot, parseContentControlListItems };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CONTENT_CONTROL_WIDGET_EVENT_NAME, dispatchDatePick, dispatchDropdownPick, handleContentControlWidgetClick } from "../prosemirror/plugins/contentControlWidgets.js";
|
|
2
|
+
import { Subscribable } from "../managers/Subscribable.js";
|
|
3
|
+
//#region src/controller/contentControlWidgetController.ts
|
|
4
|
+
const CLOSED_SNAPSHOT = { status: "closed" };
|
|
5
|
+
const PICKER_GAP_PX = 4;
|
|
6
|
+
const isListItem = (value) => {
|
|
7
|
+
if (typeof value !== "object" || value === null) return false;
|
|
8
|
+
if (!("displayText" in value) || !("value" in value)) return false;
|
|
9
|
+
return typeof value.displayText === "string" && typeof value.value === "string";
|
|
10
|
+
};
|
|
11
|
+
const parseContentControlListItems = (raw) => {
|
|
12
|
+
if (!raw) return [];
|
|
13
|
+
let parsed;
|
|
14
|
+
try {
|
|
15
|
+
parsed = JSON.parse(raw);
|
|
16
|
+
} catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
if (!Array.isArray(parsed)) return [];
|
|
20
|
+
return parsed.filter(isListItem);
|
|
21
|
+
};
|
|
22
|
+
const pickerPosition = (event) => {
|
|
23
|
+
const rect = event.anchor.getBoundingClientRect();
|
|
24
|
+
return {
|
|
25
|
+
x: rect.left,
|
|
26
|
+
y: rect.bottom + PICKER_GAP_PX
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const isContentControlWidgetEvent = (value) => {
|
|
30
|
+
if (typeof value !== "object" || value === null || !("kind" in value)) return false;
|
|
31
|
+
if (!("tag" in value) || typeof value.tag !== "string" || !("pmPos" in value) || typeof value.pmPos !== "number" || !("anchor" in value) || typeof value.anchor !== "object" || value.anchor === null || !("getBoundingClientRect" in value.anchor) || typeof value.anchor.getBoundingClientRect !== "function") return false;
|
|
32
|
+
if (value.kind === "dropdownOpen") return "sdtType" in value && (value.sdtType === "dropdown" || value.sdtType === "comboBox") && "listItemsJson" in value && (value.listItemsJson === void 0 || typeof value.listItemsJson === "string");
|
|
33
|
+
if (value.kind === "datePick") return "currentValue" in value && (value.currentValue === void 0 || typeof value.currentValue === "string");
|
|
34
|
+
return value.kind === "refused" && "sdtType" in value && "error" in value;
|
|
35
|
+
};
|
|
36
|
+
var ContentControlWidgetController = class extends Subscribable {
|
|
37
|
+
options;
|
|
38
|
+
view = null;
|
|
39
|
+
viewDom = null;
|
|
40
|
+
eventRoot = null;
|
|
41
|
+
ownerWindow = null;
|
|
42
|
+
constructor(options = {}) {
|
|
43
|
+
super(CLOSED_SNAPSHOT);
|
|
44
|
+
this.options = options;
|
|
45
|
+
}
|
|
46
|
+
bind(view, eventRoot = null) {
|
|
47
|
+
if (this.view === view && this.eventRoot === eventRoot) return;
|
|
48
|
+
this.unbindView();
|
|
49
|
+
this.view = view;
|
|
50
|
+
this.viewDom = view?.dom ?? null;
|
|
51
|
+
this.eventRoot = eventRoot;
|
|
52
|
+
this.viewDom?.addEventListener(CONTENT_CONTROL_WIDGET_EVENT_NAME, this.onDomEvent);
|
|
53
|
+
this.eventRoot?.addEventListener("click", this.onPaintedClick);
|
|
54
|
+
}
|
|
55
|
+
handleWidgetEvent(event) {
|
|
56
|
+
if (event.kind === "refused") {
|
|
57
|
+
this.close();
|
|
58
|
+
this.options.onRefused?.(event);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (event.kind === "dropdownOpen") {
|
|
62
|
+
this.open({
|
|
63
|
+
status: "dropdown",
|
|
64
|
+
items: parseContentControlListItems(event.listItemsJson),
|
|
65
|
+
pmPos: event.pmPos,
|
|
66
|
+
position: pickerPosition(event)
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.open({
|
|
71
|
+
status: "date",
|
|
72
|
+
currentValue: event.currentValue ?? null,
|
|
73
|
+
pmPos: event.pmPos,
|
|
74
|
+
position: pickerPosition(event)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
pickDropdown(value) {
|
|
78
|
+
const snapshot = this.getSnapshot();
|
|
79
|
+
if (snapshot.status !== "dropdown" || !this.view) return false;
|
|
80
|
+
const changed = dispatchDropdownPick(this.view, snapshot.pmPos, value);
|
|
81
|
+
this.close();
|
|
82
|
+
return changed;
|
|
83
|
+
}
|
|
84
|
+
pickDate(value) {
|
|
85
|
+
const snapshot = this.getSnapshot();
|
|
86
|
+
if (snapshot.status !== "date" || !this.view || value.length === 0) return false;
|
|
87
|
+
const changed = dispatchDatePick(this.view, snapshot.pmPos, value);
|
|
88
|
+
this.close();
|
|
89
|
+
return changed;
|
|
90
|
+
}
|
|
91
|
+
close() {
|
|
92
|
+
this.removeDismissListeners();
|
|
93
|
+
if (this.getSnapshot().status !== "closed") this.setSnapshot(CLOSED_SNAPSHOT);
|
|
94
|
+
}
|
|
95
|
+
destroy() {
|
|
96
|
+
this.unbindView();
|
|
97
|
+
this.view = null;
|
|
98
|
+
}
|
|
99
|
+
onDomEvent = (event) => {
|
|
100
|
+
if (!("detail" in event)) return;
|
|
101
|
+
const detail = event.detail;
|
|
102
|
+
if (isContentControlWidgetEvent(detail)) this.handleWidgetEvent(detail);
|
|
103
|
+
};
|
|
104
|
+
onPaintedClick = (event) => {
|
|
105
|
+
if (!this.view || !isPaintedBodyClick(event.target)) return;
|
|
106
|
+
handleContentControlWidgetClick({
|
|
107
|
+
view: this.view,
|
|
108
|
+
event,
|
|
109
|
+
onEvent: (widgetEvent) => this.handleWidgetEvent(widgetEvent)
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
onKeyDown = (event) => {
|
|
113
|
+
if (event.key === "Escape") this.close();
|
|
114
|
+
};
|
|
115
|
+
onScroll = () => this.close();
|
|
116
|
+
open(snapshot) {
|
|
117
|
+
this.removeDismissListeners();
|
|
118
|
+
this.ownerWindow = this.viewDom?.ownerDocument.defaultView ?? null;
|
|
119
|
+
this.ownerWindow?.addEventListener("keydown", this.onKeyDown);
|
|
120
|
+
this.ownerWindow?.addEventListener("scroll", this.onScroll, true);
|
|
121
|
+
this.setSnapshot(snapshot);
|
|
122
|
+
}
|
|
123
|
+
removeDismissListeners() {
|
|
124
|
+
this.ownerWindow?.removeEventListener("keydown", this.onKeyDown);
|
|
125
|
+
this.ownerWindow?.removeEventListener("scroll", this.onScroll, true);
|
|
126
|
+
this.ownerWindow = null;
|
|
127
|
+
}
|
|
128
|
+
unbindView() {
|
|
129
|
+
this.close();
|
|
130
|
+
this.viewDom?.removeEventListener(CONTENT_CONTROL_WIDGET_EVENT_NAME, this.onDomEvent);
|
|
131
|
+
this.eventRoot?.removeEventListener("click", this.onPaintedClick);
|
|
132
|
+
this.viewDom = null;
|
|
133
|
+
this.eventRoot = null;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const isPaintedBodyClick = (target) => {
|
|
137
|
+
if (typeof target !== "object" || target === null || !("closest" in target) || typeof target.closest !== "function") return false;
|
|
138
|
+
return target.closest(".layout-page-content") !== null;
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
export { ContentControlWidgetController, parseContentControlListItems };
|
|
@@ -11,6 +11,8 @@ function documentFontsAreLoaded() {
|
|
|
11
11
|
const INITIAL_LAYOUT_FONT_TIMEOUT_MS = 2e3;
|
|
12
12
|
const DEFAULT_LAYOUT_FONT_FAMILY = "Calibri";
|
|
13
13
|
const OFFICE_FONT_FAMILY_MAP = {
|
|
14
|
+
Aptos: "Lato",
|
|
15
|
+
"Aptos Display": "Lato",
|
|
14
16
|
Arial: "Arimo",
|
|
15
17
|
Calibri: "Carlito",
|
|
16
18
|
Cambria: "Caladea",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { clearHeaderFooterVerbatimXml } from "../docx/headerFooterVerbatim.js";
|
|
2
|
-
import { proseDocToBlocks } from "../prosemirror/conversion/fromProseDoc.js";
|
|
3
1
|
import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
|
|
4
2
|
import { ensureBaseDirectionInState } from "../prosemirror/extensions/features/AutoBidiDetectionExtension.js";
|
|
5
3
|
import { createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
@@ -7,6 +5,8 @@ import { ensureParaIdsInState } from "../prosemirror/extensions/features/ParaIdA
|
|
|
7
5
|
import { createStarterKit } from "../prosemirror/extensions/StarterKit.js";
|
|
8
6
|
import { schema } from "../prosemirror/schema/index.js";
|
|
9
7
|
import { headerFooterToProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
8
|
+
import { proseDocToBlocks } from "../prosemirror/conversion/fromProseDoc.js";
|
|
9
|
+
import { clearHeaderFooterVerbatimXml } from "../docx/headerFooterVerbatim.js";
|
|
10
10
|
import { EditorState } from "prosemirror-state";
|
|
11
11
|
import { EditorView } from "prosemirror-view";
|
|
12
12
|
//#region src/controller/headerFooterEditorManager.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fromProseDoc } from "../prosemirror/conversion/fromProseDoc.js";
|
|
2
|
-
import { NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
3
|
-
import { redo, undo } from "prosemirror-history";
|
|
4
2
|
import { CellSelection } from "prosemirror-tables";
|
|
3
|
+
import { redo, undo } from "prosemirror-history";
|
|
4
|
+
import { NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
5
5
|
//#region src/controller/hiddenEditorApi.ts
|
|
6
6
|
/**
|
|
7
7
|
* Hidden-editor imperative API
|
|
@@ -72,11 +72,22 @@ type HiddenEditorManagerDeps = {
|
|
|
72
72
|
onTransaction: (transaction: Transaction, newState: EditorState) => void;
|
|
73
73
|
onSelectionChange: (state: EditorState) => void;
|
|
74
74
|
onKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
75
|
+
onCopy?: () => void;
|
|
76
|
+
onCut?: () => void;
|
|
77
|
+
onPaste?: () => void;
|
|
75
78
|
onReadOnlyEditAttempt: () => void;
|
|
76
79
|
onEditorViewReady: (view: EditorView) => void;
|
|
77
80
|
onEditorViewDestroy: () => void;
|
|
78
81
|
onRemoteSelectionsChange: (selections: HiddenProseMirrorRemoteSelection[]) => void;
|
|
79
82
|
};
|
|
83
|
+
type PreventableDomEvent = {
|
|
84
|
+
preventDefault: () => void;
|
|
85
|
+
};
|
|
86
|
+
declare const createHiddenEditorClipboardHandlers: (deps: Pick<HiddenEditorManagerDeps, "getReadOnly" | "onCopy" | "onCut" | "onPaste" | "onReadOnlyEditAttempt">) => {
|
|
87
|
+
copy: () => boolean;
|
|
88
|
+
cut: (_view: unknown, event: PreventableDomEvent) => boolean;
|
|
89
|
+
paste: (_view: unknown, event: PreventableDomEvent) => boolean;
|
|
90
|
+
};
|
|
80
91
|
type HiddenEditorManager = {
|
|
81
92
|
/** Request the view (sets the requested flag, then attempts creation). */ensureView: () => void; /** Re-attempt a previously-requested-but-deferred creation (no-op otherwise). */
|
|
82
93
|
retryViewCreation: () => void;
|
|
@@ -90,4 +101,4 @@ type HiddenEditorManager = {
|
|
|
90
101
|
};
|
|
91
102
|
declare const createHiddenEditorManager: (deps: HiddenEditorManagerDeps) => HiddenEditorManager;
|
|
92
103
|
//#endregion
|
|
93
|
-
export { CollaborationModules, CreateHiddenEditorStateOptions, HiddenEditorManager, HiddenEditorManagerDeps, HiddenProseMirrorCollaboration, HiddenProseMirrorRemoteSelection, collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState };
|
|
104
|
+
export { CollaborationModules, CreateHiddenEditorStateOptions, HiddenEditorManager, HiddenEditorManagerDeps, HiddenProseMirrorCollaboration, HiddenProseMirrorRemoteSelection, collectRemoteSelections, createHiddenEditorClipboardHandlers, createHiddenEditorManager, createHiddenEditorState };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ensureBaseDirectionInState } from "../prosemirror/extensions/features/AutoBidiDetectionExtension.js";
|
|
2
2
|
import { createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
3
|
-
import { ensureParaIdsInState } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
|
|
3
|
+
import { ensureParaIdsInDoc, ensureParaIdsInState } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
|
|
4
4
|
import { schema } from "../prosemirror/schema/index.js";
|
|
5
5
|
import { createEmptyDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
6
6
|
import { createHiddenEditorApi } from "./hiddenEditorApi.js";
|
|
@@ -23,7 +23,18 @@ import { EditorView } from "prosemirror-view";
|
|
|
23
23
|
* *when* to act) and drives this manager through the methods below.
|
|
24
24
|
*/
|
|
25
25
|
const normalizeSeedState = (state) => ensureBaseDirectionInState(ensureParaIdsInState(state));
|
|
26
|
+
const normalizeLocalSeedState = (state) => ensureBaseDirectionInState(state);
|
|
26
27
|
const isObjectRecord = (value) => typeof value === "object" && value !== null;
|
|
28
|
+
/**
|
|
29
|
+
* A remote collaborator's awareness `user.color` is read from another
|
|
30
|
+
* peer's Yjs awareness state — effectively untrusted network input — and
|
|
31
|
+
* gets fed straight into `element.style.background`/`backgroundColor` (see
|
|
32
|
+
* `RemoteSelectionOverlay`). Restrict it to a plain 6-digit hex color before
|
|
33
|
+
* accepting it so a crafted value (e.g. a CSS `url(...)` payload) can't ride
|
|
34
|
+
* along as a CSS-injection / beacon vector; anything else falls back to the
|
|
35
|
+
* default selection color below.
|
|
36
|
+
*/
|
|
37
|
+
const AWARENESS_HEX_COLOR_PATTERN = /^#[0-9A-Fa-f]{6}$/u;
|
|
27
38
|
const isYSyncState = (value, yjs) => {
|
|
28
39
|
if (!isObjectRecord(value)) return false;
|
|
29
40
|
const binding = value["binding"];
|
|
@@ -47,8 +58,9 @@ const readAwarenessUser = (state, clientId) => {
|
|
|
47
58
|
name: `User ${clientId}`
|
|
48
59
|
};
|
|
49
60
|
const user = state["user"];
|
|
61
|
+
const rawColor = user["color"];
|
|
50
62
|
return {
|
|
51
|
-
color: typeof
|
|
63
|
+
color: typeof rawColor === "string" && AWARENESS_HEX_COLOR_PATTERN.test(rawColor) ? rawColor : "var(--doc-image-selection)",
|
|
52
64
|
name: typeof user["name"] === "string" ? user["name"] : `User ${clientId}`
|
|
53
65
|
};
|
|
54
66
|
};
|
|
@@ -92,8 +104,9 @@ function createHiddenEditorState(options) {
|
|
|
92
104
|
if (document) {
|
|
93
105
|
const startedAt = performance.now();
|
|
94
106
|
localDoc = styles === void 0 || styles === null ? toProseDoc(document) : toProseDoc(document, { styles });
|
|
107
|
+
localDoc = ensureParaIdsInDoc(localDoc);
|
|
95
108
|
recordHiddenEditorPhase(reason, "to-prose-doc", performance.now() - startedAt);
|
|
96
|
-
}
|
|
109
|
+
} else localDoc = ensureParaIdsInDoc(localDoc);
|
|
97
110
|
const styleResolverPlugin = createDocumentStylesPlugin(styles ?? document?.package.styles);
|
|
98
111
|
const plugins = [
|
|
99
112
|
...externalPlugins,
|
|
@@ -103,7 +116,7 @@ function createHiddenEditorState(options) {
|
|
|
103
116
|
if (collaboration) {
|
|
104
117
|
if (!collaborationModules) panic("Collaboration modules must be loaded before creating collaborative editor state.");
|
|
105
118
|
if (collaboration.shouldSeed && collaboration.yXmlFragment.length === 0) {
|
|
106
|
-
const seedState =
|
|
119
|
+
const seedState = normalizeLocalSeedState(EditorState.create({
|
|
107
120
|
doc: localDoc,
|
|
108
121
|
schema: activeSchema,
|
|
109
122
|
plugins
|
|
@@ -131,7 +144,7 @@ function createHiddenEditorState(options) {
|
|
|
131
144
|
return state;
|
|
132
145
|
}
|
|
133
146
|
const startedAt = performance.now();
|
|
134
|
-
const state =
|
|
147
|
+
const state = normalizeLocalSeedState(EditorState.create({
|
|
135
148
|
doc: localDoc,
|
|
136
149
|
schema: activeSchema,
|
|
137
150
|
plugins
|
|
@@ -149,6 +162,30 @@ function syncHiddenEditorAccessibility(view, readOnly) {
|
|
|
149
162
|
if (!dom.hasAttribute("tabindex")) dom.tabIndex = 0;
|
|
150
163
|
dom.setAttribute("aria-readonly", readOnly ? "true" : "false");
|
|
151
164
|
}
|
|
165
|
+
const createHiddenEditorClipboardHandlers = (deps) => ({
|
|
166
|
+
copy: () => {
|
|
167
|
+
deps.onCopy?.();
|
|
168
|
+
return false;
|
|
169
|
+
},
|
|
170
|
+
cut: (_view, event) => {
|
|
171
|
+
if (!deps.getReadOnly()) {
|
|
172
|
+
deps.onCut?.();
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
deps.onReadOnlyEditAttempt();
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
return true;
|
|
178
|
+
},
|
|
179
|
+
paste: (_view, event) => {
|
|
180
|
+
if (!deps.getReadOnly()) {
|
|
181
|
+
deps.onPaste?.();
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
deps.onReadOnlyEditAttempt();
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
152
189
|
const createHiddenEditorManager = (deps) => {
|
|
153
190
|
let view = null;
|
|
154
191
|
let isDestroying = false;
|
|
@@ -207,18 +244,13 @@ const createHiddenEditorManager = (deps) => {
|
|
|
207
244
|
handleDOMEvents: {
|
|
208
245
|
focus: () => false,
|
|
209
246
|
blur: () => false,
|
|
247
|
+
...createHiddenEditorClipboardHandlers(deps),
|
|
210
248
|
beforeinput: (_view, event) => {
|
|
211
249
|
if (!deps.getReadOnly()) return false;
|
|
212
250
|
deps.onReadOnlyEditAttempt();
|
|
213
251
|
event.preventDefault();
|
|
214
252
|
return true;
|
|
215
253
|
},
|
|
216
|
-
paste: (_view, event) => {
|
|
217
|
-
if (!deps.getReadOnly()) return false;
|
|
218
|
-
deps.onReadOnlyEditAttempt();
|
|
219
|
-
event.preventDefault();
|
|
220
|
-
return true;
|
|
221
|
-
},
|
|
222
254
|
drop: (_view, event) => {
|
|
223
255
|
if (!deps.getReadOnly()) return false;
|
|
224
256
|
deps.onReadOnlyEditAttempt();
|
|
@@ -305,4 +337,4 @@ const createHiddenEditorManager = (deps) => {
|
|
|
305
337
|
};
|
|
306
338
|
};
|
|
307
339
|
//#endregion
|
|
308
|
-
export { collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState };
|
|
340
|
+
export { collectRemoteSelections, createHiddenEditorClipboardHandlers, createHiddenEditorManager, createHiddenEditorState };
|
|
@@ -31,6 +31,8 @@ type LayoutPipelineDeps<THfPMs> = {
|
|
|
31
31
|
};
|
|
32
32
|
margins: PageMargins;
|
|
33
33
|
pageGap: number;
|
|
34
|
+
showMarginGuides: boolean;
|
|
35
|
+
marginGuideColor: string | undefined;
|
|
34
36
|
syncCoordinator: LayoutSelectionGate;
|
|
35
37
|
headerContent: document_d_exports.HeaderFooter | null | undefined;
|
|
36
38
|
footerContent: document_d_exports.HeaderFooter | null | undefined;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { getDocumentWatermark } from "../watermark/index.js";
|
|
1
2
|
import "../layout-engine/types.js";
|
|
3
|
+
import { resolveEffectiveParagraphSpacingTree } from "../layout-engine/paragraphSpacing.js";
|
|
2
4
|
import { renderPages } from "../layout-painter/renderPage.js";
|
|
3
5
|
import { templatePreviewValuesKey } from "../prosemirror/plugins/templatePreviewValues.js";
|
|
6
|
+
import { resolveDocumentGridLinePitch } from "../docx/documentGrid.js";
|
|
4
7
|
import { getMargins, getPageSize, twipsToPixels } from "../paged-layout/sectionGeometry.js";
|
|
5
8
|
import { getColumns } from "../layout-bridge/sectionColumns.js";
|
|
6
9
|
import { toFlowBlocks } from "../layout-bridge/convert/toFlowBlocks.js";
|
|
@@ -14,10 +17,10 @@ import { installCanvasMeasureProvider } from "../layout-engine/measure/measureCo
|
|
|
14
17
|
import { buildFootnoteContentMap, collectEndnoteRefs, collectFootnoteRefs, computeNoteDisplayNumbers, remapNoteMarkerText } from "../layout-bridge/convert/footnoteLayout.js";
|
|
15
18
|
import { applyTemplatePreviewToBlocks } from "../layout-bridge/convert/templatePreviewFlow.js";
|
|
16
19
|
import { layoutDocument } from "../layout-engine/index.js";
|
|
20
|
+
import { resolveJustificationCompatibility } from "../layout-engine/justificationCompatibility.js";
|
|
17
21
|
import { measureBlocks, measureSingleBlockWithoutFloatingZones } from "../layout-engine/measure/measureBlocks.js";
|
|
18
22
|
import { tryBuildIncrementalMeasures } from "../paged-layout/incrementalMeasure.js";
|
|
19
23
|
import { computePerBlockMeasureInputs } from "../paged-layout/sectionBlockWidths.js";
|
|
20
|
-
import { getDocumentWatermark } from "../watermark/index.js";
|
|
21
24
|
//#region src/controller/layoutPipeline.ts
|
|
22
25
|
function bodyMarginsClearHeaderFooter({ authoredMargins, preparedHeader, preparedFooter }) {
|
|
23
26
|
const headerBottom = preparedHeader ? (authoredMargins.header ?? 0) + (preparedHeader.marginPushBottom ?? preparedHeader.height) : authoredMargins.top;
|
|
@@ -56,7 +59,7 @@ function bodyBlocksClearSectionHeaderFooter(blocks, { authoredMargins, sectionHe
|
|
|
56
59
|
return changed ? nextBlocks : blocks;
|
|
57
60
|
}
|
|
58
61
|
function runLayoutPipeline(deps, state, options = {}) {
|
|
59
|
-
const { contentWidth, columns, pageSize, margins, pageGap, syncCoordinator, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, sectionHeaderFooterRefs, theme: _theme, sectionProperties, document, defaultTabStop, mirrorMargins, styles, layout, hfPMs, painter, pagesContainer, session, renderHfFromContentOrPm, renderHeaderFooterContentByRId, documentFontsAreLoaded, buildFootnoteRenderItems, describeInvalidHighlightMarks, emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES } = deps;
|
|
62
|
+
const { contentWidth, columns, pageSize, margins, pageGap, showMarginGuides, marginGuideColor, syncCoordinator, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, sectionHeaderFooterRefs, theme: _theme, sectionProperties, document, defaultTabStop, mirrorMargins, styles, layout, hfPMs, painter, pagesContainer, session, renderHfFromContentOrPm, renderHeaderFooterContentByRId, documentFontsAreLoaded, buildFootnoteRenderItems, describeInvalidHighlightMarks, emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES } = deps;
|
|
60
63
|
let outcome = {};
|
|
61
64
|
let pendingArtifacts;
|
|
62
65
|
let pendingTemplatePreview;
|
|
@@ -75,12 +78,16 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
75
78
|
if (defaultTabStop !== void 0) flowOpts.defaultTabStopTwips = defaultTabStop;
|
|
76
79
|
if (document?.package.settings?.lineBreakRules) flowOpts.lineBreakRules = document.package.settings.lineBreakRules;
|
|
77
80
|
const documentSettings = document?.package.settings;
|
|
81
|
+
const justificationCompatibility = resolveJustificationCompatibility(documentSettings?.compatibilityMode);
|
|
82
|
+
if (justificationCompatibility) flowOpts.justificationCompatibility = justificationCompatibility;
|
|
78
83
|
if (documentSettings?.autoHyphenation === true) flowOpts.automaticHyphenation = {
|
|
79
84
|
enabled: true,
|
|
80
85
|
...documentSettings.doNotHyphenateCaps !== void 0 ? { doNotHyphenateCaps: documentSettings.doNotHyphenateCaps } : {},
|
|
81
86
|
...documentSettings.consecutiveHyphenLimit !== void 0 ? { consecutiveLineLimit: documentSettings.consecutiveHyphenLimit } : {},
|
|
82
87
|
...documentSettings.hyphenationZoneTwips !== void 0 ? { hyphenationZoneTwips: documentSettings.hyphenationZoneTwips } : {}
|
|
83
88
|
};
|
|
89
|
+
const finalSectionDocumentGridLinePitchTwips = resolveDocumentGridLinePitch(document?.package.document.sections?.at(-1)?.properties.docGrid);
|
|
90
|
+
if (finalSectionDocumentGridLinePitchTwips !== void 0) flowOpts.finalSectionDocumentGridLinePitchTwips = finalSectionDocumentGridLinePitchTwips;
|
|
84
91
|
let newBlocks = toFlowBlocks(state.doc, flowOpts);
|
|
85
92
|
const previewState = templatePreviewValuesKey.getState(state);
|
|
86
93
|
const previewEntries = previewState?.entries ?? EMPTY_TEMPLATE_PREVIEW_ENTRIES;
|
|
@@ -127,6 +134,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
127
134
|
measureBlocks: hfMeasureBlocks,
|
|
128
135
|
...defaultTabStop !== void 0 ? { defaultTabStopTwips: defaultTabStop } : {},
|
|
129
136
|
...flowOpts.lineBreakRules ? { lineBreakRules: flowOpts.lineBreakRules } : {},
|
|
137
|
+
...flowOpts.justificationCompatibility ? { justificationCompatibility: flowOpts.justificationCompatibility } : {},
|
|
130
138
|
...flowOpts.automaticHyphenation ? { automaticHyphenation: flowOpts.automaticHyphenation } : {}
|
|
131
139
|
};
|
|
132
140
|
};
|
|
@@ -209,6 +217,8 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
209
217
|
marginRight: blockMeasureInputs.marginRights,
|
|
210
218
|
marginBottom: blockMeasureInputs.marginBottoms
|
|
211
219
|
});
|
|
220
|
+
newBlocks = resolveEffectiveParagraphSpacingTree(newBlocks);
|
|
221
|
+
outcome.blocks = newBlocks;
|
|
212
222
|
pendingArtifacts = {
|
|
213
223
|
blocks: newBlocks,
|
|
214
224
|
blockWidths,
|
|
@@ -256,6 +266,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
256
266
|
if (_theme !== void 0) footnoteOptions.theme = _theme;
|
|
257
267
|
if (defaultTabStop !== void 0) footnoteOptions.defaultTabStopTwips = defaultTabStop;
|
|
258
268
|
if (flowOpts.lineBreakRules) footnoteOptions.lineBreakRules = flowOpts.lineBreakRules;
|
|
269
|
+
if (flowOpts.justificationCompatibility) footnoteOptions.justificationCompatibility = flowOpts.justificationCompatibility;
|
|
259
270
|
if (flowOpts.automaticHyphenation) footnoteOptions.automaticHyphenation = flowOpts.automaticHyphenation;
|
|
260
271
|
return footnoteOptions;
|
|
261
272
|
})());
|
|
@@ -372,6 +383,10 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
372
383
|
blockLookup,
|
|
373
384
|
titlePg: hasTitlePg
|
|
374
385
|
};
|
|
386
|
+
if (showMarginGuides) {
|
|
387
|
+
renderOpts.showMarginGuides = true;
|
|
388
|
+
if (marginGuideColor !== void 0) renderOpts.marginGuideColor = marginGuideColor;
|
|
389
|
+
}
|
|
375
390
|
if (headerContentForRender) renderOpts.headerContent = headerContentForRender;
|
|
376
391
|
if (footerContentForRender) renderOpts.footerContent = footerContentForRender;
|
|
377
392
|
if (firstPageHeaderForRender) renderOpts.firstPageHeaderContent = firstPageHeaderForRender;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Plugin } from "prosemirror-state";
|
|
3
|
+
import { EditorView } from "prosemirror-view";
|
|
4
|
+
|
|
5
|
+
//#region src/controller/noteEditorManager.d.ts
|
|
6
|
+
type NoteStoryKind = "footnote" | "endnote";
|
|
7
|
+
type NoteStoryKey = {
|
|
8
|
+
kind: NoteStoryKind;
|
|
9
|
+
noteId: number;
|
|
10
|
+
};
|
|
11
|
+
type NoteEditorTransaction = NoteStoryKey & {
|
|
12
|
+
docChanged: boolean;
|
|
13
|
+
selectionChanged: boolean;
|
|
14
|
+
view: EditorView;
|
|
15
|
+
};
|
|
16
|
+
type NoteEditorManagerDeps = {
|
|
17
|
+
getDocument: () => document_d_exports.Document | null;
|
|
18
|
+
getHost: () => HTMLElement | null;
|
|
19
|
+
getPlugins?: (() => Plugin[]) | undefined;
|
|
20
|
+
getStyles: () => document_d_exports.StyleDefinitions | null | undefined;
|
|
21
|
+
getTheme: () => document_d_exports.Theme | null | undefined;
|
|
22
|
+
onTransaction?: ((transaction: NoteEditorTransaction) => void) | undefined;
|
|
23
|
+
};
|
|
24
|
+
type NoteEditorManager = {
|
|
25
|
+
activate: (story: NoteStoryKey | null) => EditorView | null;
|
|
26
|
+
destroy: () => void;
|
|
27
|
+
getActive: () => NoteStoryKey | null;
|
|
28
|
+
getView: (story: NoteStoryKey) => EditorView | null;
|
|
29
|
+
listStories: () => NoteStoryKey[];
|
|
30
|
+
snapshotDocument: (document: document_d_exports.Document) => document_d_exports.Document;
|
|
31
|
+
sync: () => void;
|
|
32
|
+
};
|
|
33
|
+
declare const enumerateDocumentNoteStories: (document: document_d_exports.Document | null) => NoteStoryKey[];
|
|
34
|
+
declare const createNoteEditorManager: (deps: NoteEditorManagerDeps) => NoteEditorManager;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { NoteEditorManager, NoteEditorManagerDeps, NoteEditorTransaction, NoteStoryKey, NoteStoryKind, createNoteEditorManager, enumerateDocumentNoteStories };
|