@stll/folio-core 0.28.1 → 0.30.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/controller/folioEditor.d.ts +28 -1
- package/dist/controller/folioEditor.js +37 -26
- package/dist/controller/fontReadiness.js +28 -24
- package/dist/controller/hiddenEditorManager.d.ts +2 -7
- package/dist/controller/layoutPipeline.js +33 -3
- package/dist/controller/noteEditorManager.d.ts +3 -6
- package/dist/docx/metafileSvg.d.ts +12 -0
- package/dist/docx/metafileSvg.js +462 -0
- package/dist/docx/paragraphTextBoxEnrichment.js +55 -4
- package/dist/docx/parser.d.ts +2 -2
- package/dist/docx/parser.js +26 -0
- package/dist/docx/runParser.js +2 -1
- package/dist/docx/serializer/runSerializer.js +14 -2
- package/dist/docx/styleParser.js +2 -1
- package/dist/docx/textBoxParser.js +14 -0
- package/dist/docx/vmlImageParser.js +72 -152
- package/dist/docx/vmlPreview.d.ts +31 -0
- package/dist/docx/vmlPreview.js +535 -0
- package/dist/docx/wrapTypes.d.ts +2 -36
- package/dist/docx/wrapTypes.js +1 -39
- package/dist/fonts/fontAlternates.d.ts +8 -0
- package/dist/fonts/fontAlternates.js +16 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +34 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +5 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +136 -120
- package/dist/layout-bridge/dom/noteStoryDom.d.ts +1 -1
- package/dist/layout-bridge/engine/selectionRects.js +3 -1
- package/dist/layout-engine/index.js +65 -32
- package/dist/layout-engine/justifiedLineFit.d.ts +7 -0
- package/dist/layout-engine/justifiedLineFit.js +6 -0
- package/dist/layout-engine/keep-together.js +15 -10
- package/dist/layout-engine/measure/complexScriptFormatting.d.ts +6 -1
- package/dist/layout-engine/measure/complexScriptFormatting.js +11 -2
- package/dist/layout-engine/measure/floatingTablePosition.d.ts +16 -1
- package/dist/layout-engine/measure/floatingTablePosition.js +29 -6
- package/dist/layout-engine/measure/lineBreakProvider.js +67 -8
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +23 -10
- package/dist/layout-engine/measure/measureBlocks.d.ts +15 -0
- package/dist/layout-engine/measure/measureBlocks.js +197 -30
- package/dist/layout-engine/measure/measureContainer.js +20 -24
- package/dist/layout-engine/measure/measureHelpers.d.ts +1 -1
- package/dist/layout-engine/measure/measureHelpers.js +14 -8
- package/dist/layout-engine/measure/measureParagraph.js +111 -37
- package/dist/layout-engine/measure/measureTypes.d.ts +3 -0
- package/dist/layout-engine/measure/tabCalculator.d.ts +123 -0
- package/dist/layout-engine/measure/tabCalculator.js +144 -0
- package/dist/layout-engine/measure/tableCellFlow.d.ts +21 -1
- package/dist/layout-engine/measure/tableCellFlow.js +45 -8
- package/dist/layout-engine/measure/tableInlinePlacement.d.ts +10 -2
- package/dist/layout-engine/measure/tableInlinePlacement.js +17 -15
- package/dist/layout-engine/paginator.d.ts +26 -2
- package/dist/layout-engine/paginator.js +76 -14
- package/dist/layout-engine/paragraphSpacing.d.ts +3 -1
- package/dist/layout-engine/paragraphSpacing.js +4 -3
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +14 -3
- package/dist/layout-engine/renderedBreakReconciliation.js +45 -14
- package/dist/layout-engine/section-breaks.d.ts +3 -1
- package/dist/layout-engine/section-breaks.js +6 -2
- package/dist/layout-engine/types.d.ts +18 -1
- package/dist/layout-engine/types.js +1 -1
- package/dist/layout-painter/imageLayout.d.ts +1 -1
- package/dist/layout-painter/renderPage.js +6 -1
- package/dist/layout-painter/renderParagraph.js +169 -82
- package/dist/layout-painter/renderTable.d.ts +1 -1
- package/dist/layout-painter/renderTable.js +18 -7
- package/dist/layout-painter/renderTextBox.d.ts +1 -1
- package/dist/layout-painter/renderTextBox.js +6 -1
- package/dist/markdown/renderParagraph.js +7 -2
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +14 -0
- package/dist/paged-layout/sectionBlockWidths.js +103 -14
- package/dist/prosemirror/attrs/index.js +14 -2
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +8 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +66 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +176 -54
- package/dist/prosemirror/conversion/toProseDoc.js +179 -64
- package/dist/prosemirror/extensions/StarterKit.js +11 -3
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +8 -4
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +9 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +10 -23
- package/dist/prosemirror/extensions/features/pasteCleanup.js +77 -22
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +9 -5
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +10 -4
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +77 -59
- package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -0
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +6 -2
- package/dist/prosemirror/listMarker.d.ts +58 -0
- package/dist/prosemirror/listMarker.js +185 -0
- package/dist/prosemirror/numberedRefFields.d.ts +24 -0
- package/dist/prosemirror/numberedRefFields.js +276 -0
- package/dist/prosemirror/paraText.js +56 -17
- package/dist/prosemirror/plugins/anonymizationDecorations.js +1 -1
- package/dist/prosemirror/plugins/pmTextScan.d.ts +3 -1
- package/dist/prosemirror/plugins/pmTextScan.js +28 -7
- package/dist/prosemirror/plugins/templateDirectives.js +2 -2
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/nodes.d.ts +17 -1
- package/dist/prosemirror/utils/tabCalculator.d.ts +2 -123
- package/dist/prosemirror/utils/tabCalculator.js +1 -140
- package/dist/prosemirror/validation.js +93 -0
- package/dist/render-dom/RemoteSelectionOverlay.d.ts +4 -4
- package/dist/types/documentEnumValues.d.ts +4 -1
- package/dist/types/documentEnumValues.js +12 -1
- package/dist/types/editor-story.d.ts +8 -0
- package/dist/types/editor-story.js +0 -0
- package/dist/types/remote-selection.d.ts +11 -0
- package/dist/types/remote-selection.js +0 -0
- package/dist/types/wrap.d.ts +36 -0
- package/dist/types/wrap.js +40 -0
- package/dist/utils/fontResolver.d.ts +1 -1
- package/dist/utils/fontResolver.js +42 -2
- package/dist/utils/formatToStyle.js +4 -2
- package/dist/utils/horizontalScale.d.ts +28 -0
- package/dist/utils/horizontalScale.js +42 -0
- package/package.json +2 -2
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { DocxInput } from "../utils/docxInput.js";
|
|
1
3
|
import { Layout } from "../layout-engine/types.js";
|
|
2
4
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
3
5
|
import { FolioEditorEmitter } from "./folioEditorEvents.js";
|
|
@@ -8,9 +10,34 @@ type FolioEditorDeps = {
|
|
|
8
10
|
getEditorApi: () => HiddenEditorApi | null;
|
|
9
11
|
getLayout: () => Layout | null;
|
|
10
12
|
runLayout: (state: EditorState, options: LayoutRunOptions) => void;
|
|
13
|
+
/** Required only when the document I/O methods are used. */
|
|
14
|
+
getDocumentIO?: () => FolioEditorDocumentIO;
|
|
11
15
|
emitter: FolioEditorEmitter;
|
|
12
16
|
};
|
|
17
|
+
declare const FOLIO_DOCX_SERIALIZATION_MODE: Readonly<{
|
|
18
|
+
readonly full: "full";
|
|
19
|
+
readonly preferSelective: "prefer-selective";
|
|
20
|
+
}>;
|
|
21
|
+
type FolioDocxSerializationMode = (typeof FOLIO_DOCX_SERIALIZATION_MODE)[keyof typeof FOLIO_DOCX_SERIALIZATION_MODE];
|
|
22
|
+
type FolioGetDocxOptions = {
|
|
23
|
+
mode?: FolioDocxSerializationMode;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Document lifecycle operations supplied by a host integration.
|
|
27
|
+
*
|
|
28
|
+
* The controller owns the stable contract while each adapter supplies its
|
|
29
|
+
* current persistence implementation. This lets document I/O migrate without
|
|
30
|
+
* coupling core to React, Vue, or host callbacks.
|
|
31
|
+
*/
|
|
32
|
+
type FolioEditorDocumentIO = {
|
|
33
|
+
getDocx: (options?: FolioGetDocxOptions) => Promise<ArrayBuffer | null>;
|
|
34
|
+
loadDocument: (document: document_d_exports.Document) => void;
|
|
35
|
+
loadDocx: (input: DocxInput) => Promise<void>;
|
|
36
|
+
};
|
|
13
37
|
type FolioEditor = HiddenEditorApi & {
|
|
38
|
+
getDocx: FolioEditorDocumentIO["getDocx"];
|
|
39
|
+
loadDocument: FolioEditorDocumentIO["loadDocument"];
|
|
40
|
+
loadDocx: FolioEditorDocumentIO["loadDocx"];
|
|
14
41
|
getLayout: () => Layout | null;
|
|
15
42
|
/** Re-run layout for the current editor state (no-op if there is no view). */
|
|
16
43
|
relayout: () => void;
|
|
@@ -18,4 +45,4 @@ type FolioEditor = HiddenEditorApi & {
|
|
|
18
45
|
};
|
|
19
46
|
declare const createFolioEditor: (deps: FolioEditorDeps) => FolioEditor;
|
|
20
47
|
//#endregion
|
|
21
|
-
export { FolioEditor, FolioEditorDeps, createFolioEditor };
|
|
48
|
+
export { FOLIO_DOCX_SERIALIZATION_MODE, FolioDocxSerializationMode, FolioEditor, FolioEditorDeps, FolioEditorDocumentIO, FolioGetDocxOptions, createFolioEditor };
|
|
@@ -1,29 +1,40 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
1
2
|
//#region src/controller/folioEditor.ts
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getState: () => deps.getEditorApi()?.getState() ?? null,
|
|
6
|
-
getView: () => deps.getEditorApi()?.getView() ?? null,
|
|
7
|
-
getDocument: () => deps.getEditorApi()?.getDocument() ?? null,
|
|
8
|
-
focus: () => deps.getEditorApi()?.focus(),
|
|
9
|
-
blur: () => deps.getEditorApi()?.blur(),
|
|
10
|
-
isFocused: () => deps.getEditorApi()?.isFocused() ?? false,
|
|
11
|
-
dispatch: (tr) => deps.getEditorApi()?.dispatch(tr),
|
|
12
|
-
executeCommand: (command) => deps.getEditorApi()?.executeCommand(command) ?? false,
|
|
13
|
-
undo: () => deps.getEditorApi()?.undo() ?? false,
|
|
14
|
-
redo: () => deps.getEditorApi()?.redo() ?? false,
|
|
15
|
-
canUndo: () => deps.getEditorApi()?.canUndo() ?? false,
|
|
16
|
-
canRedo: () => deps.getEditorApi()?.canRedo() ?? false,
|
|
17
|
-
setSelection: (anchor, head) => deps.getEditorApi()?.setSelection(anchor, head),
|
|
18
|
-
setNodeSelection: (pos) => deps.getEditorApi()?.setNodeSelection(pos),
|
|
19
|
-
setCellSelection: (anchorCellPos, headCellPos) => deps.getEditorApi()?.setCellSelection(anchorCellPos, headCellPos),
|
|
20
|
-
scrollToSelection: () => deps.getEditorApi()?.scrollToSelection(),
|
|
21
|
-
getLayout: () => deps.getLayout(),
|
|
22
|
-
relayout: () => {
|
|
23
|
-
const state = deps.getEditorApi()?.getState();
|
|
24
|
-
if (state) deps.runLayout(state, { reason: "manual" });
|
|
25
|
-
},
|
|
26
|
-
on: (event, listener) => deps.emitter.on(event, listener)
|
|
3
|
+
const FOLIO_DOCX_SERIALIZATION_MODE = Object.freeze({
|
|
4
|
+
full: "full",
|
|
5
|
+
preferSelective: "prefer-selective"
|
|
27
6
|
});
|
|
7
|
+
const createFolioEditor = (deps) => {
|
|
8
|
+
const getDocumentIO = () => deps.getDocumentIO?.() ?? panic("FolioEditor document I/O requires a getDocumentIO dependency");
|
|
9
|
+
return {
|
|
10
|
+
getDocx: (options) => getDocumentIO().getDocx(options),
|
|
11
|
+
loadDocument: (document) => getDocumentIO().loadDocument(document),
|
|
12
|
+
loadDocx: (input) => getDocumentIO().loadDocx(input),
|
|
13
|
+
ensureView: () => deps.getEditorApi()?.ensureView(),
|
|
14
|
+
isViewRequested: () => deps.getEditorApi()?.isViewRequested() ?? false,
|
|
15
|
+
getState: () => deps.getEditorApi()?.getState() ?? null,
|
|
16
|
+
getView: () => deps.getEditorApi()?.getView() ?? null,
|
|
17
|
+
getDocument: () => deps.getEditorApi()?.getDocument() ?? null,
|
|
18
|
+
focus: () => deps.getEditorApi()?.focus(),
|
|
19
|
+
blur: () => deps.getEditorApi()?.blur(),
|
|
20
|
+
isFocused: () => deps.getEditorApi()?.isFocused() ?? false,
|
|
21
|
+
dispatch: (tr) => deps.getEditorApi()?.dispatch(tr),
|
|
22
|
+
executeCommand: (command) => deps.getEditorApi()?.executeCommand(command) ?? false,
|
|
23
|
+
undo: () => deps.getEditorApi()?.undo() ?? false,
|
|
24
|
+
redo: () => deps.getEditorApi()?.redo() ?? false,
|
|
25
|
+
canUndo: () => deps.getEditorApi()?.canUndo() ?? false,
|
|
26
|
+
canRedo: () => deps.getEditorApi()?.canRedo() ?? false,
|
|
27
|
+
setSelection: (anchor, head) => deps.getEditorApi()?.setSelection(anchor, head),
|
|
28
|
+
setNodeSelection: (pos) => deps.getEditorApi()?.setNodeSelection(pos),
|
|
29
|
+
setCellSelection: (anchorCellPos, headCellPos) => deps.getEditorApi()?.setCellSelection(anchorCellPos, headCellPos),
|
|
30
|
+
scrollToSelection: () => deps.getEditorApi()?.scrollToSelection(),
|
|
31
|
+
getLayout: () => deps.getLayout(),
|
|
32
|
+
relayout: () => {
|
|
33
|
+
const state = deps.getEditorApi()?.getState();
|
|
34
|
+
if (state) deps.runLayout(state, { reason: "manual" });
|
|
35
|
+
},
|
|
36
|
+
on: (event, listener) => deps.emitter.on(event, listener)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
28
39
|
//#endregion
|
|
29
|
-
export { createFolioEditor };
|
|
40
|
+
export { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildFontAlternates, getFontAlternate } from "../fonts/fontAlternates.js";
|
|
1
2
|
import { expectFontFamilyMarkAttrs, expectParagraphAttrs } from "../prosemirror/attrs/index.js";
|
|
2
3
|
import { parseFontFamilyList, resolveFontFamily } from "../utils/fontResolver.js";
|
|
3
4
|
//#region src/controller/fontReadiness.ts
|
|
@@ -52,31 +53,32 @@ function collectInitialLayoutFontFamilies(documentModel, pmDoc) {
|
|
|
52
53
|
}
|
|
53
54
|
function collectInitialLayoutFontFaces(documentModel, pmDoc) {
|
|
54
55
|
const faces = /* @__PURE__ */ new Map();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
addLayoutFontFamilyFace(faces,
|
|
58
|
-
addLayoutFontFamilyFace(faces, documentModel?.package.theme?.fontScheme?.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const fontAlternates = buildFontAlternates(documentModel?.package.fontTable);
|
|
57
|
+
addLayoutFontFamilyFace(faces, DEFAULT_LAYOUT_FONT_FAMILY, REGULAR_LAYOUT_FONT_DESCRIPTOR, fontAlternates);
|
|
58
|
+
for (const family of documentModel?.requiredFonts ?? []) addLayoutFontFamilyFace(faces, family, REGULAR_LAYOUT_FONT_DESCRIPTOR, fontAlternates);
|
|
59
|
+
addLayoutFontFamilyFace(faces, documentModel?.package.theme?.fontScheme?.majorFont?.latin, REGULAR_LAYOUT_FONT_DESCRIPTOR, fontAlternates);
|
|
60
|
+
addLayoutFontFamilyFace(faces, documentModel?.package.theme?.fontScheme?.minorFont?.latin, REGULAR_LAYOUT_FONT_DESCRIPTOR, fontAlternates);
|
|
61
|
+
addTextFormattingFontFaces(faces, documentModel?.package.styles?.docDefaults?.rPr, fontAlternates);
|
|
62
|
+
for (const style of documentModel?.package.styles?.styles ?? []) addTextFormattingFontFaces(faces, style.rPr, fontAlternates);
|
|
63
|
+
collectProseMirrorFontFaces(faces, pmDoc, void 0, fontAlternates);
|
|
62
64
|
return Array.from(faces.values());
|
|
63
65
|
}
|
|
64
|
-
function addTextFormattingFontFaces(faces, formatting) {
|
|
66
|
+
function addTextFormattingFontFaces(faces, formatting, fontAlternates) {
|
|
65
67
|
const standardDescriptor = layoutDescriptorFromFormatting(formatting);
|
|
66
68
|
const complexScriptDescriptor = layoutDescriptorFromEmphasis(formatting?.boldCs ?? formatting?.bold, formatting?.italicCs ?? formatting?.italic);
|
|
67
|
-
addLayoutFontFamilyFace(faces, formatting?.fontFamily, standardDescriptor, complexScriptDescriptor);
|
|
69
|
+
addLayoutFontFamilyFace(faces, formatting?.fontFamily, standardDescriptor, fontAlternates, complexScriptDescriptor);
|
|
68
70
|
}
|
|
69
|
-
function collectProseMirrorFontFaces(faces, node, inheritedTextFormatting) {
|
|
71
|
+
function collectProseMirrorFontFaces(faces, node, inheritedTextFormatting, fontAlternates) {
|
|
70
72
|
const paragraphDefaults = readParagraphDefaultTextFormatting(node);
|
|
71
73
|
const textFormatting = paragraphDefaults ?? inheritedTextFormatting;
|
|
72
|
-
if (paragraphDefaults) addTextFormattingFontFaces(faces, paragraphDefaults);
|
|
73
|
-
if (node.type.name === "paragraph") addTextFormattingFontFaces(faces, expectParagraphAttrs(node).listMarkerFormatting);
|
|
74
|
+
if (paragraphDefaults) addTextFormattingFontFaces(faces, paragraphDefaults, fontAlternates);
|
|
75
|
+
if (node.type.name === "paragraph") addTextFormattingFontFaces(faces, expectParagraphAttrs(node).listMarkerFormatting, fontAlternates);
|
|
74
76
|
if (node.isText) {
|
|
75
77
|
const descriptor = layoutDescriptorFromFormattingAndMarks(textFormatting, node.marks);
|
|
76
|
-
addLayoutFontFamilyFace(faces, readFontFamilyMarkAttrs(node.marks) ?? textFormatting?.fontFamily ?? DEFAULT_LAYOUT_FONT_FAMILY, descriptor);
|
|
78
|
+
addLayoutFontFamilyFace(faces, readFontFamilyMarkAttrs(node.marks) ?? textFormatting?.fontFamily ?? DEFAULT_LAYOUT_FONT_FAMILY, descriptor, fontAlternates);
|
|
77
79
|
}
|
|
78
80
|
node.forEach((child) => {
|
|
79
|
-
collectProseMirrorFontFaces(faces, child, textFormatting);
|
|
81
|
+
collectProseMirrorFontFaces(faces, child, textFormatting, fontAlternates);
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
function readParagraphDefaultTextFormatting(node) {
|
|
@@ -108,23 +110,25 @@ function layoutDescriptorFromFormattingAndMarks(formatting, marks) {
|
|
|
108
110
|
weight: bold ? 700 : 400
|
|
109
111
|
};
|
|
110
112
|
}
|
|
111
|
-
function addLayoutFontFamilyFace(faces, value, descriptor, complexScriptDescriptor = descriptor) {
|
|
113
|
+
function addLayoutFontFamilyFace(faces, value, descriptor, fontAlternates, complexScriptDescriptor = descriptor) {
|
|
112
114
|
if (typeof value === "string") {
|
|
113
|
-
addLayoutFontFamilyNameFace(faces, value, descriptor);
|
|
115
|
+
addLayoutFontFamilyNameFace(faces, value, descriptor, fontAlternates);
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
116
118
|
if (!value || typeof value !== "object") return;
|
|
117
119
|
const fontFamily = value;
|
|
118
|
-
addLayoutFontFamilyFace(faces, fontFamily.ascii, descriptor);
|
|
119
|
-
addLayoutFontFamilyFace(faces, fontFamily.hAnsi, descriptor);
|
|
120
|
-
addLayoutFontFamilyFace(faces, fontFamily.cs, complexScriptDescriptor);
|
|
121
|
-
addLayoutFontFamilyFace(faces, fontFamily.eastAsia, descriptor);
|
|
120
|
+
addLayoutFontFamilyFace(faces, fontFamily.ascii, descriptor, fontAlternates);
|
|
121
|
+
addLayoutFontFamilyFace(faces, fontFamily.hAnsi, descriptor, fontAlternates);
|
|
122
|
+
addLayoutFontFamilyFace(faces, fontFamily.cs, complexScriptDescriptor, fontAlternates);
|
|
123
|
+
addLayoutFontFamilyFace(faces, fontFamily.eastAsia, descriptor, fontAlternates);
|
|
122
124
|
}
|
|
123
|
-
function addLayoutFontFamilyNameFace(faces, family, descriptor) {
|
|
125
|
+
function addLayoutFontFamilyNameFace(faces, family, descriptor, fontAlternates) {
|
|
124
126
|
const normalized = family.trim();
|
|
125
127
|
if (!normalized || CSS_GENERIC_FONT_FAMILIES.has(normalized)) return;
|
|
126
128
|
addLayoutFontFace(faces, normalized, descriptor);
|
|
127
|
-
|
|
129
|
+
const alternate = getFontAlternate(normalized, fontAlternates);
|
|
130
|
+
if (alternate) addLayoutFontFace(faces, alternate, descriptor);
|
|
131
|
+
for (const stackFamily of resolvedStackFamilies(normalized, alternate)) addLayoutFontFace(faces, stackFamily, descriptor);
|
|
128
132
|
}
|
|
129
133
|
/**
|
|
130
134
|
* The concrete families in a resolved CSS font stack, generics dropped.
|
|
@@ -132,8 +136,8 @@ function addLayoutFontFamilyNameFace(faces, family, descriptor) {
|
|
|
132
136
|
* Parsed from the stack rather than read from a map because the stack is what
|
|
133
137
|
* the painter and the measurer put in `ctx.font` and `style.fontFamily`.
|
|
134
138
|
*/
|
|
135
|
-
function resolvedStackFamilies(family) {
|
|
136
|
-
const { cssFallback } = resolveFontFamily(family);
|
|
139
|
+
function resolvedStackFamilies(family, alternate) {
|
|
140
|
+
const { cssFallback } = resolveFontFamily(family, alternate);
|
|
137
141
|
return parseFontFamilyList(cssFallback).filter((name) => !CSS_GENERIC_FONT_FAMILIES.has(name));
|
|
138
142
|
}
|
|
139
143
|
function addLayoutFontFace(faces, family, descriptor) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { HiddenEditorStateReason } from "../layout-engine/layoutInstrumentation.js";
|
|
3
3
|
import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
|
|
4
|
+
import { RemoteSelection } from "../types/remote-selection.js";
|
|
4
5
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
5
6
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
6
7
|
import { EditorView } from "prosemirror-view";
|
|
@@ -26,13 +27,7 @@ type HiddenProseMirrorCollaboration = {
|
|
|
26
27
|
shouldSeed?: boolean | undefined;
|
|
27
28
|
yXmlFragment: XmlFragment;
|
|
28
29
|
};
|
|
29
|
-
type HiddenProseMirrorRemoteSelection =
|
|
30
|
-
anchor: number;
|
|
31
|
-
clientId: number;
|
|
32
|
-
color: string;
|
|
33
|
-
head: number;
|
|
34
|
-
name: string;
|
|
35
|
-
};
|
|
30
|
+
type HiddenProseMirrorRemoteSelection = RemoteSelection;
|
|
36
31
|
declare const collectRemoteSelections: (state: EditorState, awareness: CollaborationAwareness, collaborationModules: CollaborationModules) => HiddenProseMirrorRemoteSelection[];
|
|
37
32
|
/**
|
|
38
33
|
* Create ProseMirror state from document
|
|
@@ -4,6 +4,7 @@ import { buildBookmarkText } from "../fields/bookmarkText.js";
|
|
|
4
4
|
import { buildHeaderFooterFieldValues, fieldValuesEqual, resolveFieldValues } from "../fields/resolveFieldValues.js";
|
|
5
5
|
import { buildSectionPageCounts } from "../fields/sectionPageCounts.js";
|
|
6
6
|
import { buildSeqValues } from "../fields/seqValues.js";
|
|
7
|
+
import { buildFontAlternates } from "../fonts/fontAlternates.js";
|
|
7
8
|
import { buildFootnoteContentMap, collectEndnoteRefs, collectFootnoteRefs, computeNoteDisplayNumbers, remapNoteMarkerText } from "../layout-bridge/convert/footnoteLayout.js";
|
|
8
9
|
import { applyTemplatePreviewToBlocks } from "../layout-bridge/convert/templatePreviewFlow.js";
|
|
9
10
|
import { toFlowBlocks } from "../layout-bridge/convert/toFlowBlocks.js";
|
|
@@ -97,7 +98,12 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
97
98
|
syncCoordinator.onLayoutStart();
|
|
98
99
|
try {
|
|
99
100
|
let phaseStartedAt = performance.now();
|
|
100
|
-
const
|
|
101
|
+
const pageContentHeight = pageSize.h - margins.top - margins.bottom;
|
|
102
|
+
const fontAlternates = buildFontAlternates(document?.package.fontTable);
|
|
103
|
+
const flowOpts = {
|
|
104
|
+
pageContentHeight,
|
|
105
|
+
fontAlternates
|
|
106
|
+
};
|
|
101
107
|
if (_theme !== void 0) flowOpts.theme = _theme;
|
|
102
108
|
if (defaultTabStop !== void 0) flowOpts.defaultTabStopTwips = defaultTabStop;
|
|
103
109
|
if (document?.package.settings?.lineBreakRules) flowOpts.lineBreakRules = document.package.settings.lineBreakRules;
|
|
@@ -155,6 +161,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
155
161
|
return {
|
|
156
162
|
...styles ? { styles } : {},
|
|
157
163
|
..._theme !== void 0 ? { theme: _theme } : {},
|
|
164
|
+
fontAlternates,
|
|
158
165
|
measureBlocks: hfMeasureBlocks,
|
|
159
166
|
...defaultTabStop !== void 0 ? { defaultTabStopTwips: defaultTabStop } : {},
|
|
160
167
|
...flowOpts.lineBreakRules ? { lineBreakRules: flowOpts.lineBreakRules } : {},
|
|
@@ -241,7 +248,18 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
241
248
|
pageHeight: blockMeasureInputs.pageHeights,
|
|
242
249
|
marginLeft: blockMeasureInputs.marginLefts,
|
|
243
250
|
marginRight: blockMeasureInputs.marginRights,
|
|
244
|
-
marginBottom: blockMeasureInputs.marginBottoms
|
|
251
|
+
marginBottom: blockMeasureInputs.marginBottoms,
|
|
252
|
+
contentLeft: blockMeasureInputs.contentLefts,
|
|
253
|
+
physicalPage: {
|
|
254
|
+
pageWidth: blockMeasureInputs.physicalPageGeometry.pageWidths,
|
|
255
|
+
pageHeight: blockMeasureInputs.physicalPageGeometry.pageHeights,
|
|
256
|
+
marginTop: blockMeasureInputs.physicalPageGeometry.marginTops,
|
|
257
|
+
marginLeft: blockMeasureInputs.physicalPageGeometry.marginLefts,
|
|
258
|
+
marginRight: blockMeasureInputs.physicalPageGeometry.marginRights,
|
|
259
|
+
marginBottom: blockMeasureInputs.physicalPageGeometry.marginBottoms
|
|
260
|
+
},
|
|
261
|
+
columnIndex: blockMeasureInputs.columnIndices,
|
|
262
|
+
columnCount: blockMeasureInputs.columnCounts
|
|
245
263
|
});
|
|
246
264
|
newBlocks = resolveEffectiveParagraphSpacingTree(newBlocks);
|
|
247
265
|
outcome.blocks = newBlocks;
|
|
@@ -290,6 +308,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
290
308
|
const footnoteOptions = { measureBlocks };
|
|
291
309
|
if (styles) footnoteOptions.styles = styles;
|
|
292
310
|
if (_theme !== void 0) footnoteOptions.theme = _theme;
|
|
311
|
+
footnoteOptions.fontAlternates = fontAlternates;
|
|
293
312
|
if (defaultTabStop !== void 0) footnoteOptions.defaultTabStopTwips = defaultTabStop;
|
|
294
313
|
if (flowOpts.lineBreakRules) footnoteOptions.lineBreakRules = flowOpts.lineBreakRules;
|
|
295
314
|
if (flowOpts.justificationCompatibility) footnoteOptions.justificationCompatibility = flowOpts.justificationCompatibility;
|
|
@@ -354,7 +373,18 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
354
373
|
pageHeight: blockMeasureInputs.pageHeights,
|
|
355
374
|
marginLeft: blockMeasureInputs.marginLefts,
|
|
356
375
|
marginRight: blockMeasureInputs.marginRights,
|
|
357
|
-
marginBottom: blockMeasureInputs.marginBottoms
|
|
376
|
+
marginBottom: blockMeasureInputs.marginBottoms,
|
|
377
|
+
contentLeft: blockMeasureInputs.contentLefts,
|
|
378
|
+
physicalPage: {
|
|
379
|
+
pageWidth: blockMeasureInputs.physicalPageGeometry.pageWidths,
|
|
380
|
+
pageHeight: blockMeasureInputs.physicalPageGeometry.pageHeights,
|
|
381
|
+
marginTop: blockMeasureInputs.physicalPageGeometry.marginTops,
|
|
382
|
+
marginLeft: blockMeasureInputs.physicalPageGeometry.marginLefts,
|
|
383
|
+
marginRight: blockMeasureInputs.physicalPageGeometry.marginRights,
|
|
384
|
+
marginBottom: blockMeasureInputs.physicalPageGeometry.marginBottoms
|
|
385
|
+
},
|
|
386
|
+
columnIndex: blockMeasureInputs.columnIndices,
|
|
387
|
+
columnCount: blockMeasureInputs.columnCounts
|
|
358
388
|
}, values);
|
|
359
389
|
relayoutWithCurrentMeasures(layoutOptsUsed);
|
|
360
390
|
pendingArtifacts = {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { NoteStoryKey } from "../types/editor-story.js";
|
|
2
3
|
import { Plugin } from "prosemirror-state";
|
|
3
4
|
import { EditorView } from "prosemirror-view";
|
|
4
5
|
//#region src/controller/noteEditorManager.d.ts
|
|
5
|
-
type NoteStoryKind = "
|
|
6
|
-
type NoteStoryKey = {
|
|
7
|
-
kind: NoteStoryKind;
|
|
8
|
-
noteId: number;
|
|
9
|
-
};
|
|
6
|
+
type NoteStoryKind = NoteStoryKey["kind"];
|
|
10
7
|
type NoteEditorTransaction = NoteStoryKey & {
|
|
11
8
|
docChanged: boolean;
|
|
12
9
|
selectionChanged: boolean;
|
|
@@ -32,4 +29,4 @@ type NoteEditorManager = {
|
|
|
32
29
|
declare const enumerateDocumentNoteStories: (document: document_d_exports.Document | null) => NoteStoryKey[];
|
|
33
30
|
declare const createNoteEditorManager: (deps: NoteEditorManagerDeps) => NoteEditorManager;
|
|
34
31
|
//#endregion
|
|
35
|
-
export { NoteEditorManager, NoteEditorManagerDeps, NoteEditorTransaction, NoteStoryKey, NoteStoryKind, createNoteEditorManager, enumerateDocumentNoteStories };
|
|
32
|
+
export { NoteEditorManager, NoteEditorManagerDeps, NoteEditorTransaction, type NoteStoryKey, NoteStoryKind, createNoteEditorManager, enumerateDocumentNoteStories };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/docx/metafileSvg.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Render a deliberately small, browser-safe EMF subset to generated SVG.
|
|
4
|
+
*
|
|
5
|
+
* This covers vector logos built from filled paths. Unsupported records fail
|
|
6
|
+
* closed: a partial metafile is more misleading than the existing placeholder.
|
|
7
|
+
* Original EMF bytes remain the source of truth for DOCX round-trip.
|
|
8
|
+
*/
|
|
9
|
+
/** Convert the supported filled-path EMF subset to inert generated SVG. */
|
|
10
|
+
declare function renderEmfSvg(data: ArrayBuffer | Uint8Array): string | null;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { renderEmfSvg };
|