@stll/folio-core 0.68.0 → 0.69.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/headless.js +2 -2
- package/dist/ai-edits/newListNumbering.d.ts +14 -1
- package/dist/ai-edits/newListNumbering.js +24 -1
- package/dist/ai-edits/pending-suggestions.js +2 -2
- package/dist/controller/canonicalClipboard.js +2 -2
- package/dist/controller/canonicalComposition.js +34 -5
- package/dist/controller/canonicalInput.js +4 -6
- package/dist/controller/canonicalLockGuard.d.ts +17 -2
- package/dist/controller/canonicalLockGuard.js +46 -1
- package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
- package/dist/controller/canonicalProjectionBlocks.js +75 -0
- package/dist/controller/canonicalPublicOperations.js +476 -100
- package/dist/controller/canonicalSeedContent.d.ts +12 -0
- package/dist/controller/canonicalSeedContent.js +131 -0
- package/dist/controller/canonicalSession.d.ts +53 -21
- package/dist/controller/canonicalSession.js +489 -210
- package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
- package/dist/controller/canonicalSourceNormalization.js +148 -0
- package/dist/controller/canonicalStoryEditor.d.ts +1 -1
- package/dist/controller/canonicalStoryEditor.js +16 -12
- package/dist/controller/folioEditor.js +3 -0
- package/dist/controller/headerFooterEditorManager.d.ts +5 -0
- package/dist/controller/headerFooterEditorManager.js +7 -2
- package/dist/controller/hiddenEditorApi.d.ts +11 -2
- package/dist/controller/hiddenEditorApi.js +3 -0
- package/dist/controller/hiddenEditorManager.d.ts +7 -0
- package/dist/controller/hiddenEditorManager.js +66 -11
- package/dist/controller/layoutPipeline.js +2 -1
- package/dist/controller/layoutSession.d.ts +3 -0
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/noteEditorManager.d.ts +5 -0
- package/dist/controller/noteEditorManager.js +7 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +9 -7
- package/dist/document-operations.d.ts +1 -1
- package/dist/docx/canonicalSave.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +19 -0
- package/dist/docx/commentAnchorIndex.js +55 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/contentTypeRegistry.js +1 -1
- package/dist/docx/hostCommentThreads.d.ts +11 -1
- package/dist/docx/hostCommentThreads.js +25 -2
- package/dist/docx/listModelNormalization.js +4 -5
- package/dist/docx/listNumberingInstances.d.ts +1 -1
- package/dist/docx/listNumberingInstances.js +2 -2
- package/dist/docx/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- package/dist/docx/paragraphPropertySource.d.ts +22 -0
- package/dist/docx/paragraphPropertySource.js +85 -16
- package/dist/docx/parser.js +2 -0
- package/dist/docx/removeHeaderFooterParts.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +72 -19
- package/dist/docx/serializer/documentSerializer.js +2 -1
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +1 -1
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/storyBlockReplay.js +15 -2
- package/dist/docx/structuralXmlPatch.js +25 -4
- package/dist/docx/xmlParser.d.ts +1 -1
- package/dist/docx/xmlParser.js +2 -3
- package/dist/i18n/messages/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
- package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
- package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
- package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
- package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
- package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
- package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
- package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
- package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
- package/dist/layout-bridge/dom/textStreamDom.js +3 -2
- package/dist/layout-bridge/headerFooterLayout.js +12 -11
- package/dist/layout-bridge/tableInsertHover.js +2 -1
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/cache.js +6 -1
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/imageLayout.js +2 -1
- package/dist/layout-painter/pageShellStyles.d.ts +10 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +117 -0
- package/dist/layout-painter/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.js +8 -29
- package/dist/layout-painter/renderParagraph.js +3 -3
- package/dist/layout-painter/renderTable.js +9 -12
- package/dist/layout-painter/renderTextBox.js +2 -2
- package/dist/layout-painter/sdtBoundary.js +3 -2
- package/dist/paged-layout/blockGeometry.js +3 -2
- package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
- package/dist/paged-layout/editorScrollRoot.js +10 -1
- package/dist/paged-layout/rangeProjection.js +5 -4
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/commands/comments.d.ts +5 -2
- package/dist/prosemirror/commands/comments.js +88 -8
- package/dist/prosemirror/commentRecords.d.ts +137 -0
- package/dist/prosemirror/commentRecords.js +400 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +9 -3
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +13 -4
- package/dist/prosemirror/conversion/toProseDoc.js +126 -38
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
- package/dist/prosemirror/extensions/marks/CommentExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
- package/dist/prosemirror/index.d.ts +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +33 -0
- package/dist/prosemirror/nativeSelection.js +74 -0
- package/dist/prosemirror/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -5
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
- package/dist/prosemirror/paragraphMarkJoin.js +155 -16
- package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +33 -14
- package/dist/prosemirror/plugins/suggestionMode.js +13 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- package/dist/prosemirror/schema/marks.d.ts +7 -1
- package/dist/prosemirror/storyListNumbering.js +7 -2
- package/dist/prosemirror/tableResize.d.ts +10 -9
- package/dist/prosemirror/tableResize.js +60 -49
- package/dist/prosemirror/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +78 -5
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RenderedDomContext.js +7 -6
- package/dist/types/canonicalCapabilities.d.ts +12 -11
- package/dist/types/canonicalCapabilities.js +12 -13
- package/dist/utils/findMatchView.js +4 -3
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/mergeDocumentContent.js +2 -2
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- package/package.json +2 -3
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Cette session de modification a été reprise ailleurs.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Éditeur de documents",
|
|
340
|
+
"changeUnavailable": "Cette modification n'est pas encore possible ici.",
|
|
340
341
|
"contentLocked": "Cette partie du document est verrouillée.",
|
|
341
342
|
"editing": "Modification",
|
|
342
343
|
"editingDescription": "Modifier directement le document",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "כרטיסייה, חלון או מכשיר אחר פתחו מסמך זה לעריכה, ולכן הפעלה זו שוחררה. שינויים מקומיים שלא נשמרו נשמרו — פתח מחדש את המסמך כדי להמשיך.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "עורך מסמכים",
|
|
340
|
+
"changeUnavailable": "עדיין לא ניתן לבצע את השינוי הזה כאן.",
|
|
340
341
|
"contentLocked": "חלק זה של המסמך נעול.",
|
|
341
342
|
"editing": "עריכה",
|
|
342
343
|
"editingDescription": "ערוך את המסמך ישירות",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "किसी अन्य टैब, विंडो या डिवाइस ने इस दस्तावेज़ को संपादन के लिए खोला, इसलिए यह सत्र बंद कर दिया गया। सहेजे नहीं गए स्थानीय परिवर्तन सुरक्षित हैं — जारी रखने के लिए दस्तावेज़ फिर से खोलें।",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "दस्तावेज़ संपादक",
|
|
340
|
+
"changeUnavailable": "यह बदलाव अभी यहाँ नहीं किया जा सकता।",
|
|
340
341
|
"contentLocked": "दस्तावेज़ का यह हिस्सा लॉक है।",
|
|
341
342
|
"editing": "संपादन",
|
|
342
343
|
"editingDescription": "दस्तावेज़ को सीधे संपादित करें",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Ezt a szerkesztési munkamenetet máshol vették át.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Dokumentumszerkesztő",
|
|
340
|
+
"changeUnavailable": "Ez a módosítás itt még nem hajtható végre.",
|
|
340
341
|
"contentLocked": "A dokumentum ezen része zárolva van.",
|
|
341
342
|
"editing": "Szerkesztés",
|
|
342
343
|
"editingDescription": "A dokumentum közvetlen szerkesztése",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Ši redagavimo sesija buvo perimta kitur.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Dokumentų redaktorius",
|
|
340
|
+
"changeUnavailable": "Šio pakeitimo čia dar negalima atlikti.",
|
|
340
341
|
"contentLocked": "Ši dokumento dalis užrakinta.",
|
|
341
342
|
"editing": "Redagavimas",
|
|
342
343
|
"editingDescription": "Redaguokite dokumentą tiesiogiai",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Šo rediģēšanas sesiju pārņēma citur.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Dokumentu redaktors",
|
|
340
|
+
"changeUnavailable": "Šīs izmaiņas šeit vēl nevar veikt.",
|
|
340
341
|
"contentLocked": "Šī dokumenta daļa ir bloķēta.",
|
|
341
342
|
"editing": "Rediģēšana",
|
|
342
343
|
"editingDescription": "Rediģējiet dokumentu tieši",
|
|
@@ -337,6 +337,7 @@ type Messages = {
|
|
|
337
337
|
"editSessionTakenOver": "Another tab, window, or device opened this document for editing, so this session was released. Unsaved local changes are preserved — reopen the doc to continue.";
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Document editor";
|
|
340
|
+
"changeUnavailable": "This change can't be made here yet.";
|
|
340
341
|
"contentLocked": "This part of the document is locked.";
|
|
341
342
|
"editing": "Editing";
|
|
342
343
|
"editingDescription": "Edit the document directly";
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Ta sesja edycji została przejęta gdzie indziej.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Edytor dokumentów",
|
|
340
|
+
"changeUnavailable": "Tej zmiany nie można jeszcze tu wprowadzić.",
|
|
340
341
|
"contentLocked": "Ta część dokumentu jest zablokowana.",
|
|
341
342
|
"editing": "Edytowanie",
|
|
342
343
|
"editingDescription": "Edytuj dokument bezpośrednio",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Esta sessão de edição foi assumida em outro lugar.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Editor de documentos",
|
|
340
|
+
"changeUnavailable": "Ainda não é possível fazer esta alteração aqui.",
|
|
340
341
|
"contentLocked": "Esta parte do documento está bloqueada.",
|
|
341
342
|
"editing": "Editando",
|
|
342
343
|
"editingDescription": "Edite o documento diretamente",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Túto reláciu úprav prevzalo iné okno.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Editor dokumentov",
|
|
340
|
+
"changeUnavailable": "Túto zmenu tu zatiaľ nemožno vykonať.",
|
|
340
341
|
"contentLocked": "Táto časť dokumentu je uzamknutá.",
|
|
341
342
|
"editing": "Úpravy",
|
|
342
343
|
"editingDescription": "Upravujte dokument priamo",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "Başka bir sekme, pencere veya cihaz bu belgeyi düzenlemek için açtığından bu oturum sonlandırıldı. Kaydedilmemiş yerel değişiklikler korunur; devam etmek için belgeyi yeniden açın.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "Belge düzenleyici",
|
|
340
|
+
"changeUnavailable": "Bu değişiklik henüz burada yapılamıyor.",
|
|
340
341
|
"contentLocked": "Belgenin bu bölümü kilitli.",
|
|
341
342
|
"editing": "Düzenleme",
|
|
342
343
|
"editingDescription": "Belgeyi doğrudan düzenleyin",
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "另一个标签页、窗口或设备已打开此文档进行编辑,因此本会话已释放。未保存的本地更改会保留,请重新打开文档以继续。",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "文档编辑器",
|
|
340
|
+
"changeUnavailable": "暂时无法在此处进行此更改。",
|
|
340
341
|
"contentLocked": "文档的这一部分已锁定。",
|
|
341
342
|
"editing": "编辑",
|
|
342
343
|
"editingDescription": "直接编辑文档",
|
|
@@ -2,5 +2,10 @@ import { Node } from "prosemirror-model";
|
|
|
2
2
|
export type PageBreakRunDescendantIndex = {
|
|
3
3
|
firstPageBreakRunPosition: (node: Node) => number | undefined;
|
|
4
4
|
};
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Build one identity-scoped index for a single layout conversion. Subtrees
|
|
7
|
+
* without a page break run hold no answer, so the walk skips them.
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildPageBreakRunDescendantIndex: (doc: Node) => PageBreakRunDescendantIndex;
|
|
10
|
+
/** The index built visiting every node, skipping none: the reference for the skip. */
|
|
11
|
+
export declare const buildPageBreakRunDescendantIndexVisitingEveryNode: (doc: Node) => PageBreakRunDescendantIndex;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { subtreeHolds } from "./subtreeHolds.js";
|
|
1
2
|
// src/internal/pageBreakRunDescendantIndex.ts
|
|
2
3
|
const indexesPageBreakDescendants = (node) => {
|
|
3
4
|
switch (node.type.name) {
|
|
@@ -8,12 +9,13 @@ const indexesPageBreakDescendants = (node) => {
|
|
|
8
9
|
default: return false;
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
const
|
|
12
|
+
const holdsPageBreakRun = subtreeHolds((node) => node.type.name === "pageBreakRun");
|
|
13
|
+
const buildIndex = (doc, skip) => {
|
|
13
14
|
const positions = /* @__PURE__ */ new WeakMap();
|
|
14
15
|
const visitNode = (node, startPos) => {
|
|
15
16
|
let firstPosition = node.type.name === "pageBreakRun" ? startPos : void 0;
|
|
16
17
|
node.forEach((child, offset) => {
|
|
18
|
+
if (skip(child)) return;
|
|
17
19
|
const descendantPosition = visitNode(child, startPos + 1 + offset);
|
|
18
20
|
firstPosition ??= descendantPosition;
|
|
19
21
|
});
|
|
@@ -23,4 +25,11 @@ const buildPageBreakRunDescendantIndex = (doc) => {
|
|
|
23
25
|
visitNode(doc, -1);
|
|
24
26
|
return { firstPageBreakRunPosition: (node) => positions.get(node) };
|
|
25
27
|
};
|
|
26
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Build one identity-scoped index for a single layout conversion. Subtrees
|
|
30
|
+
* without a page break run hold no answer, so the walk skips them.
|
|
31
|
+
*/
|
|
32
|
+
const buildPageBreakRunDescendantIndex = (doc) => buildIndex(doc, (node) => !holdsPageBreakRun(node));
|
|
33
|
+
/** The index built visiting every node, skipping none: the reference for the skip. */
|
|
34
|
+
const buildPageBreakRunDescendantIndexVisitingEveryNode = (doc) => buildIndex(doc, () => false);
|
|
35
|
+
export { buildPageBreakRunDescendantIndex, buildPageBreakRunDescendantIndexVisitingEveryNode };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a node, or any node under it, is one `carries` names, decided once
|
|
4
|
+
* per node.
|
|
5
|
+
*
|
|
6
|
+
* ProseMirror nodes are immutable and an edit shares every subtree it does
|
|
7
|
+
* not touch, so a walk that only needs the nodes `carries` names can skip
|
|
8
|
+
* every child this answers `false` for: an edit then costs the path it
|
|
9
|
+
* changed, not every node of the document. Leaves are answered directly
|
|
10
|
+
* rather than kept.
|
|
11
|
+
*/
|
|
12
|
+
export declare const subtreeHolds: (carries: (node: Node) => boolean) => ((node: Node) => boolean);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/internal/subtreeHolds.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether a node, or any node under it, is one `carries` names, decided once
|
|
4
|
+
* per node.
|
|
5
|
+
*
|
|
6
|
+
* ProseMirror nodes are immutable and an edit shares every subtree it does
|
|
7
|
+
* not touch, so a walk that only needs the nodes `carries` names can skip
|
|
8
|
+
* every child this answers `false` for: an edit then costs the path it
|
|
9
|
+
* changed, not every node of the document. Leaves are answered directly
|
|
10
|
+
* rather than kept.
|
|
11
|
+
*/
|
|
12
|
+
const subtreeHolds = (carries) => {
|
|
13
|
+
const known = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const holds = (node) => {
|
|
15
|
+
if (node.childCount === 0) return carries(node);
|
|
16
|
+
const kept = known.get(node);
|
|
17
|
+
if (kept !== void 0) return kept;
|
|
18
|
+
let held = carries(node);
|
|
19
|
+
for (let index = 0; !held && index < node.childCount; index += 1) held = holds(node.child(index));
|
|
20
|
+
known.set(node, held);
|
|
21
|
+
return held;
|
|
22
|
+
};
|
|
23
|
+
return holds;
|
|
24
|
+
};
|
|
25
|
+
export { subtreeHolds };
|
|
@@ -431,7 +431,7 @@ const resolveStructure = ({ node, position, context }) => {
|
|
|
431
431
|
});
|
|
432
432
|
pendingBookmarks = [];
|
|
433
433
|
}
|
|
434
|
-
const joinedAttrs = joinedParagraphAttrs(paragraph, chain.node);
|
|
434
|
+
const joinedAttrs = joinedParagraphAttrs(paragraph, chain.node, bookmarks.size);
|
|
435
435
|
if (joinedAttrs !== chain.node.attrs) chain.node = recreateProseNodeWithParagraphPropertySource(chain.node, { attrs: joinedAttrs });
|
|
436
436
|
const displacedToken = getProseParagraphPropertySourceToken(paragraph);
|
|
437
437
|
const selectedToken = getProseParagraphPropertySourceToken(chain.node);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readPaintedStart } from "../utils/paintedPositions.js";
|
|
1
2
|
// src/layout-bridge/cellSelectionHighlight.ts
|
|
2
3
|
/**
|
|
3
4
|
* Apply the `.layout-table-cell-selected` class to painted layout cells
|
|
@@ -23,9 +24,8 @@ function applyCellSelectionHighlight(pagesContainer, state, options = {}) {
|
|
|
23
24
|
});
|
|
24
25
|
const allCells = pagesContainer.querySelectorAll(scopeSelector);
|
|
25
26
|
for (const cellEl of Array.from(allCells)) {
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const pmPos = Number(pmStartAttr);
|
|
27
|
+
const pmPos = readPaintedStart(cellEl);
|
|
28
|
+
if (pmPos === void 0) continue;
|
|
29
29
|
for (const [start, end] of selectedRanges) if (pmPos >= start && pmPos < end) {
|
|
30
30
|
cellEl.classList.add("layout-table-cell-selected");
|
|
31
31
|
break;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getParagraphFrame, setParagraphFrame } from "../../utils/paragraphFrame.js";
|
|
1
2
|
import { headingLevelOf } from "@stll/docx-core/model";
|
|
2
3
|
// src/layout-bridge/convert/flowBlockPostprocessing.ts
|
|
3
4
|
/**
|
|
@@ -6,6 +7,22 @@ import { headingLevelOf } from "@stll/docx-core/model";
|
|
|
6
7
|
* merging.
|
|
7
8
|
*/
|
|
8
9
|
/**
|
|
10
|
+
* `block` with `attrs` added, as a new block in its place: the list's blocks
|
|
11
|
+
* may be kept from an earlier conversion, so they are never written.
|
|
12
|
+
*/
|
|
13
|
+
function replaceParagraphAttrs(blocks, index, block, attrs) {
|
|
14
|
+
const replaced = {
|
|
15
|
+
...block,
|
|
16
|
+
attrs: {
|
|
17
|
+
...block.attrs,
|
|
18
|
+
...attrs
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const frame = getParagraphFrame(block);
|
|
22
|
+
if (frame !== void 0) setParagraphFrame(replaced, frame);
|
|
23
|
+
blocks[index] = replaced;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
9
26
|
* Word keeps a final empty body paragraph after a table as an editable anchor,
|
|
10
27
|
* but that final anchor does not create a page of its own. Earlier authored
|
|
11
28
|
* empty paragraphs retain their height and may carry the document onto a blank
|
|
@@ -22,28 +39,19 @@ function suppressFinalEmptyParagraphAfterTable(blocks) {
|
|
|
22
39
|
while (suffixStart > 0 && isPaintlessTerminalParagraph(blocks[suffixStart - 1])) suffixStart -= 1;
|
|
23
40
|
if (suffixStart === blocks.length || suffixStart === 0 || blocks[suffixStart - 1]?.kind !== "table") return;
|
|
24
41
|
const finalBlock = blocks.at(-1);
|
|
25
|
-
if (isPaintlessTerminalParagraph(finalBlock))
|
|
26
|
-
...finalBlock.attrs,
|
|
27
|
-
suppressEmptyParagraphHeight: true
|
|
28
|
-
};
|
|
42
|
+
if (isPaintlessTerminalParagraph(finalBlock)) replaceParagraphAttrs(blocks, blocks.length - 1, finalBlock, { suppressEmptyParagraphHeight: true });
|
|
29
43
|
}
|
|
30
44
|
function suppressFinalParagraphInRepeatedEmptySuffix(blocks) {
|
|
31
45
|
let suffixStart = blocks.length;
|
|
32
46
|
while (suffixStart > 0 && isPaintlessTerminalParagraph(blocks[suffixStart - 1])) suffixStart -= 1;
|
|
33
47
|
if (suffixStart === 0 || blocks.length - suffixStart < 2 || blocks[suffixStart - 1]?.kind === "table") return;
|
|
34
48
|
const finalBlock = blocks.at(-1);
|
|
35
|
-
if (isPaintlessTerminalParagraph(finalBlock))
|
|
36
|
-
...finalBlock.attrs,
|
|
37
|
-
suppressEmptyParagraphHeight: true
|
|
38
|
-
};
|
|
49
|
+
if (isPaintlessTerminalParagraph(finalBlock)) replaceParagraphAttrs(blocks, blocks.length - 1, finalBlock, { suppressEmptyParagraphHeight: true });
|
|
39
50
|
}
|
|
40
51
|
function reserveLeadingEmptyOutlineHeight(blocks) {
|
|
41
52
|
const firstBlock = blocks.at(0);
|
|
42
53
|
if (firstBlock?.kind !== "paragraph" || firstBlock.runs.length !== 0 || headingLevelOf(firstBlock.attrs?.outlineLevel) !== 0) return;
|
|
43
|
-
firstBlock
|
|
44
|
-
...firstBlock.attrs,
|
|
45
|
-
reserveEmptyOutlineHeight: true
|
|
46
|
-
};
|
|
54
|
+
replaceParagraphAttrs(blocks, 0, firstBlock, { reserveEmptyOutlineHeight: true });
|
|
47
55
|
}
|
|
48
56
|
/**
|
|
49
57
|
* Merge consecutive paragraph blocks where the first carries
|
|
@@ -4,6 +4,7 @@ import { ListCounterStreams } from "../../prosemirror/listMarker.js";
|
|
|
4
4
|
import { DocumentFontFacts } from "../../fonts/documentFontFacts.js";
|
|
5
5
|
import { ParagraphAttrs, ParagraphBlock, TableBlock } from "../../layout-engine/types.js";
|
|
6
6
|
import { FontAlternates } from "../../fonts/fontAlternates.js";
|
|
7
|
+
import { ParagraphBlockCache } from "./paragraphBlockCache.js";
|
|
7
8
|
import { Node } from "prosemirror-model";
|
|
8
9
|
/**
|
|
9
10
|
* Options for the conversion.
|
|
@@ -103,6 +104,11 @@ export type ToFlowBlocksOptions = {
|
|
|
103
104
|
* longer the document's last and keeps its height.
|
|
104
105
|
*/
|
|
105
106
|
trailingEndnoteIds?: ReadonlySet<number>;
|
|
107
|
+
/**
|
|
108
|
+
* Paragraph blocks kept from earlier conversions of the same editor's
|
|
109
|
+
* document. Conversion gives the same blocks with or without it.
|
|
110
|
+
*/
|
|
111
|
+
paragraphBlocks?: ParagraphBlockCache;
|
|
106
112
|
};
|
|
107
113
|
export type FlowConversionOptions = ToFlowBlocksOptions & {
|
|
108
114
|
firstPageBreakRunPosition: (node: Node) => number | undefined;
|
|
@@ -113,6 +119,10 @@ export type FlowConversionOptions = ToFlowBlocksOptions & {
|
|
|
113
119
|
textBoxAnchorBlockIds: Map<string, ParagraphBlock["id"]>;
|
|
114
120
|
styleResolver: RunStyleResolver;
|
|
115
121
|
};
|
|
122
|
+
/** The options holding list counter state, which each paragraph advances in story order. */
|
|
123
|
+
export type ListCounterOptionKey = "listCounters" | "listAbstractCounters" | "listSeenNumIds" | "originalListCounters" | "originalListAbstractCounters" | "originalListSeenNumIds" | "listCounterStreams";
|
|
124
|
+
/** The conversion options without list counter state: what converting one paragraph at a known list marker reads. */
|
|
125
|
+
export type CounterFreeFlowConversionOptions = Omit<FlowConversionOptions, ListCounterOptionKey>;
|
|
116
126
|
/**
|
|
117
127
|
* Convert twips to pixels (1 twip = 1/1440 inch, 1 inch = 96 CSS px).
|
|
118
128
|
* No rounding — precision prevents cumulative layout drift across paragraphs.
|
|
@@ -122,4 +132,8 @@ export declare function nextBlockId(): string;
|
|
|
122
132
|
/**
|
|
123
133
|
* Reset the block ID counter (useful for testing).
|
|
124
134
|
*/
|
|
125
|
-
export declare function resetBlockIdCounter(): void;
|
|
135
|
+
export declare function resetBlockIdCounter(): void;
|
|
136
|
+
/** How many block ids the current conversion has handed out. */
|
|
137
|
+
export declare function blockIdsHandedOut(): number;
|
|
138
|
+
/** Hand out `count` ids without making blocks: blocks kept from before hold them. */
|
|
139
|
+
export declare function skipBlockIds(count: number): void;
|
|
@@ -29,4 +29,12 @@ function nextBlockId() {
|
|
|
29
29
|
function resetBlockIdCounter() {
|
|
30
30
|
blockIdCounter = 0;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
/** How many block ids the current conversion has handed out. */
|
|
33
|
+
function blockIdsHandedOut() {
|
|
34
|
+
return blockIdCounter;
|
|
35
|
+
}
|
|
36
|
+
/** Hand out `count` ids without making blocks: blocks kept from before hold them. */
|
|
37
|
+
function skipBlockIds(count) {
|
|
38
|
+
blockIdCounter += count;
|
|
39
|
+
}
|
|
40
|
+
export { ALT_CHUNK_CONTENT, blockIdsHandedOut, nextBlockId, resetBlockIdCounter, skipBlockIds, twipsToPixels };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
import { ParagraphAttrs } from "../../prosemirror/schema/nodes.js";
|
|
3
|
-
import { ListCounterStreams } from "../../prosemirror/listMarker.js";
|
|
3
|
+
import { ListCounterStreams, VisibleListMarker } from "../../prosemirror/listMarker.js";
|
|
4
4
|
import { ParagraphAttrs as ParagraphAttrs$1 } from "../../layout-engine/types.js";
|
|
5
5
|
import { FontAlternates } from "../../fonts/fontAlternates.js";
|
|
6
|
-
|
|
6
|
+
/** The marker the list counters give a paragraph where it sits in its story. */
|
|
7
|
+
export type ParagraphListMarker = VisibleListMarker["marker"];
|
|
8
|
+
/** What a paragraph's layout attributes read besides its own attributes and list marker. */
|
|
9
|
+
type ParagraphAttrsInputs = {
|
|
7
10
|
theme: document_d_exports.Theme | null | undefined;
|
|
8
11
|
fontAlternates: FontAlternates | undefined;
|
|
9
|
-
listCounterStreams: ListCounterStreams;
|
|
10
12
|
defaultTabStopTwips: number | undefined;
|
|
11
13
|
/**
|
|
12
14
|
* Resolved paragraph-mark run properties, the base of the list marker's
|
|
@@ -14,5 +16,14 @@ type ConvertParagraphAttrsOptions = {
|
|
|
14
16
|
*/
|
|
15
17
|
paragraphMarkFormatting: () => document_d_exports.TextFormatting | undefined;
|
|
16
18
|
};
|
|
17
|
-
|
|
19
|
+
type ConvertParagraphAttrsOptions = ParagraphAttrsInputs & {
|
|
20
|
+
listCounterStreams: ListCounterStreams;
|
|
21
|
+
};
|
|
22
|
+
/** A paragraph's layout attributes, advancing the list counters past it. */
|
|
23
|
+
export declare function convertParagraphAttrs(pmAttrs: ParagraphAttrs, { listCounterStreams, ...inputs }: ConvertParagraphAttrsOptions): ParagraphAttrs$1;
|
|
24
|
+
/**
|
|
25
|
+
* A paragraph's layout attributes given the marker the list counters give it.
|
|
26
|
+
* The marker is the only input that depends on the paragraphs before it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function paragraphAttrsWithListMarker(pmAttrs: ParagraphAttrs, listMarker: ParagraphListMarker, { theme, fontAlternates, defaultTabStopTwips, paragraphMarkFormatting }: ParagraphAttrsInputs): ParagraphAttrs$1;
|
|
18
29
|
export {};
|
|
@@ -48,7 +48,15 @@ const resolveFlowAlignment = (alignment, rightToLeft) => {
|
|
|
48
48
|
default: return flow;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
/** A paragraph's layout attributes, advancing the list counters past it. */
|
|
52
|
+
function convertParagraphAttrs(pmAttrs, { listCounterStreams, ...inputs }) {
|
|
53
|
+
return paragraphAttrsWithListMarker(pmAttrs, advanceVisibleListMarker(pmAttrs, listCounterStreams).marker, inputs);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A paragraph's layout attributes given the marker the list counters give it.
|
|
57
|
+
* The marker is the only input that depends on the paragraphs before it.
|
|
58
|
+
*/
|
|
59
|
+
function paragraphAttrsWithListMarker(pmAttrs, listMarker, { theme, fontAlternates, defaultTabStopTwips, paragraphMarkFormatting }) {
|
|
52
60
|
const attrs = {};
|
|
53
61
|
if (pmAttrs.alignment) attrs.alignment = resolveFlowAlignment(pmAttrs.alignment, directionIsRtl(pmAttrs.direction));
|
|
54
62
|
if (pmAttrs.outlineLevel !== void 0) attrs.outlineLevel = pmAttrs.outlineLevel;
|
|
@@ -172,8 +180,7 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
172
180
|
if (numberingInsertionChange) attrs.listMarkerRevision = toListMarkerRevision("ins", numberingInsertionChange.info);
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
|
-
const
|
|
176
|
-
const resolvedMarker = applyMarkerAllCaps(visibleMarker.marker, pmAttrs.listMarkerAllCaps);
|
|
183
|
+
const resolvedMarker = applyMarkerAllCaps(listMarker, pmAttrs.listMarkerAllCaps);
|
|
177
184
|
if (resolvedMarker !== null) attrs.listMarker = resolvedMarker;
|
|
178
185
|
else if (pmAttrs.listMarker) attrs.listMarker = pmAttrs.listIsBullet ? convertBulletToUnicode(pmAttrs.listMarker, bulletMarkerFontName(pmAttrs.listMarkerFormatting)) : pmAttrs.listMarker;
|
|
179
186
|
if (pmAttrs.listIsBullet !== void 0) attrs.listIsBullet = pmAttrs.listIsBullet;
|
|
@@ -241,4 +248,4 @@ const resolveTabAlignment = (alignment, rightToLeft) => {
|
|
|
241
248
|
default: return mapped;
|
|
242
249
|
}
|
|
243
250
|
};
|
|
244
|
-
export { convertParagraphAttrs };
|
|
251
|
+
export { convertParagraphAttrs, paragraphAttrsWithListMarker };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ParagraphBlock } from "../../layout-engine/types.js";
|
|
2
|
+
import { FlowConversionOptions } from "./flowConversionShared.js";
|
|
3
|
+
import { ParagraphListMarker } from "./paragraphAttrs.js";
|
|
4
|
+
import { RecordedConversion } from "./topLevelConversion.js";
|
|
5
|
+
import { Node } from "prosemirror-model";
|
|
6
|
+
export declare class ParagraphBlockCache {
|
|
7
|
+
private constants;
|
|
8
|
+
private paragraphs;
|
|
9
|
+
private conversion;
|
|
10
|
+
/** Start over unless every conversion constant converts as the one the kept blocks were converted with. */
|
|
11
|
+
use(options: FlowConversionOptions): void;
|
|
12
|
+
/**
|
|
13
|
+
* The last conversion, when it converted a document with the same document
|
|
14
|
+
* attributes under the constants `use` was last given.
|
|
15
|
+
*/
|
|
16
|
+
lastConversion(doc: Node): RecordedConversion | undefined;
|
|
17
|
+
/** Keep what converting each top-level node gave, for the next conversion. */
|
|
18
|
+
recordConversion(conversion: RecordedConversion | undefined): void;
|
|
19
|
+
/** The block converting `node` at `pmStart` with `listMarker` gives, under `id`. */
|
|
20
|
+
take(node: Node, pmStart: number, listMarker: ParagraphListMarker, id: () => ParagraphBlock["id"]): ParagraphBlock | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Keep the block converting `node` at `pmStart` gave, unless converting it
|
|
23
|
+
* read other blocks. Call before anything else writes to `block`.
|
|
24
|
+
*/
|
|
25
|
+
keep(node: Node, pmStart: number, listMarker: ParagraphListMarker, block: ParagraphBlock): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { documentFontFactsCacheIdentity } from "../../fonts/documentFontFacts.js";
|
|
2
|
+
import { noteParagraphOrigin } from "../../layout-engine/measure/paragraphKeyMemo.js";
|
|
3
|
+
import { getParagraphFrame, setParagraphFrame } from "../../utils/paragraphFrame.js";
|
|
4
|
+
// src/layout-bridge/convert/paragraphBlockCache.ts
|
|
5
|
+
/** Maps holding the same values under the same keys. */
|
|
6
|
+
const sameEntries = (left, right) => left === right || left !== void 0 && right !== void 0 && left.size === right.size && [...left].every(([key, value]) => right.has(key) && right.get(key) === value);
|
|
7
|
+
const sameMembers = (left, right) => left === right || left !== void 0 && right !== void 0 && left.size === right.size && [...left].every((member) => right.has(member));
|
|
8
|
+
/** Objects holding the same values under the same keys, one level deep. */
|
|
9
|
+
const sameFields = (left, right) => {
|
|
10
|
+
if (left === right) return true;
|
|
11
|
+
if (left === void 0 || right === void 0) return false;
|
|
12
|
+
const keys = Object.keys(left);
|
|
13
|
+
return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && Reflect.get(left, key) === Reflect.get(right, key));
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Every conversion option a paragraph's block can depend on, and how two
|
|
17
|
+
* of its values are compared. Counter state is the one order-dependent input
|
|
18
|
+
* and enters only as the list marker; the cache itself is not an input. A
|
|
19
|
+
* layout run builds some of these afresh from the same document, so they
|
|
20
|
+
* compare by content.
|
|
21
|
+
*/
|
|
22
|
+
const CONVERSION_CONSTANTS = {
|
|
23
|
+
altChunkMarkerText: (left, right) => left.altChunkMarkerText === right.altChunkMarkerText,
|
|
24
|
+
altChunkContent: (left, right) => left.altChunkContent === right.altChunkContent,
|
|
25
|
+
showCommentHighlights: (left, right) => left.showCommentHighlights === right.showCommentHighlights,
|
|
26
|
+
embeddedFontFamilyMap: (left, right) => left.embeddedFontFamilyMap === right.embeddedFontFamilyMap,
|
|
27
|
+
documentFontFacts: (left, right) => documentFontFactsCacheIdentity(left.documentFontFacts) === documentFontFactsCacheIdentity(right.documentFontFacts),
|
|
28
|
+
defaultFont: (left, right) => left.defaultFont === right.defaultFont,
|
|
29
|
+
defaultSize: (left, right) => left.defaultSize === right.defaultSize,
|
|
30
|
+
theme: (left, right) => left.theme === right.theme,
|
|
31
|
+
styles: (left, right) => left.styles === right.styles,
|
|
32
|
+
fontAlternates: (left, right) => sameEntries(left.fontAlternates, right.fontAlternates),
|
|
33
|
+
pageContentHeight: (left, right) => left.pageContentHeight === right.pageContentHeight,
|
|
34
|
+
splitPageBreakAndParagraphMark: (left, right) => left.splitPageBreakAndParagraphMark === right.splitPageBreakAndParagraphMark,
|
|
35
|
+
defaultTabStopTwips: (left, right) => left.defaultTabStopTwips === right.defaultTabStopTwips,
|
|
36
|
+
lineBreakRules: (left, right) => sameFields(left.lineBreakRules, right.lineBreakRules),
|
|
37
|
+
justificationCompatibility: (left, right) => sameFields(left.justificationCompatibility, right.justificationCompatibility),
|
|
38
|
+
tableIndentCompatibility: (left, right) => sameFields(left.tableIndentCompatibility, right.tableIndentCompatibility),
|
|
39
|
+
forceAnchorLayoutInCell: (left, right) => left.forceAnchorLayoutInCell === right.forceAnchorLayoutInCell,
|
|
40
|
+
automaticHyphenation: (left, right) => sameFields(left.automaticHyphenation, right.automaticHyphenation),
|
|
41
|
+
finalSectionDocumentGridLinePitchTwips: (left, right) => left.finalSectionDocumentGridLinePitchTwips === right.finalSectionDocumentGridLinePitchTwips,
|
|
42
|
+
noteReferenceMarkText: (left, right) => left.noteReferenceMarkText === right.noteReferenceMarkText,
|
|
43
|
+
trailingEndnoteIds: (left, right) => sameMembers(left.trailingEndnoteIds, right.trailingEndnoteIds)
|
|
44
|
+
};
|
|
45
|
+
const CONSTANT_KEYS = Object.keys(CONVERSION_CONSTANTS);
|
|
46
|
+
const movedRun = (run, delta) => ({
|
|
47
|
+
...run,
|
|
48
|
+
...run.pmStart === void 0 ? {} : { pmStart: run.pmStart + delta },
|
|
49
|
+
...run.pmEnd === void 0 ? {} : { pmEnd: run.pmEnd + delta }
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* A copy of `block` moved by `delta`, under `id`. The copy owns its top-level
|
|
53
|
+
* fields, attributes and runs, which conversion stamps after a paragraph is
|
|
54
|
+
* converted; the nested values it shares are never written after conversion.
|
|
55
|
+
*/
|
|
56
|
+
const movedBlock = (block, delta, id) => {
|
|
57
|
+
const moved = {
|
|
58
|
+
...block,
|
|
59
|
+
id,
|
|
60
|
+
runs: block.runs.map((run) => movedRun(run, delta)),
|
|
61
|
+
attrs: { ...block.attrs },
|
|
62
|
+
...block.pmStart === void 0 ? {} : { pmStart: block.pmStart + delta },
|
|
63
|
+
...block.pmEnd === void 0 ? {} : { pmEnd: block.pmEnd + delta }
|
|
64
|
+
};
|
|
65
|
+
const frame = getParagraphFrame(block);
|
|
66
|
+
if (frame !== void 0) setParagraphFrame(moved, frame);
|
|
67
|
+
return moved;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Whether converting `node` reads anything besides itself, the constants and
|
|
71
|
+
* its list marker: a field may show another paragraph's number, and a text box
|
|
72
|
+
* anchor records which block holds it.
|
|
73
|
+
*/
|
|
74
|
+
const readsOtherBlocks = (node) => {
|
|
75
|
+
let reads = false;
|
|
76
|
+
node.descendants((child) => {
|
|
77
|
+
if (reads) return false;
|
|
78
|
+
if (child.type.name === "field" || child.type.name === "structuredField" || child.type.name === "textBoxAnchor") {
|
|
79
|
+
reads = true;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
});
|
|
84
|
+
return reads;
|
|
85
|
+
};
|
|
86
|
+
var ParagraphBlockCache = class {
|
|
87
|
+
constants;
|
|
88
|
+
paragraphs = /* @__PURE__ */ new WeakMap();
|
|
89
|
+
conversion;
|
|
90
|
+
/** Start over unless every conversion constant converts as the one the kept blocks were converted with. */
|
|
91
|
+
use(options) {
|
|
92
|
+
const kept = this.constants;
|
|
93
|
+
this.constants = options;
|
|
94
|
+
if (kept !== void 0 && kept.numberingTabIgnoresIndent === options.numberingTabIgnoresIndent && CONSTANT_KEYS.every((key) => CONVERSION_CONSTANTS[key](kept, options))) return;
|
|
95
|
+
this.paragraphs = /* @__PURE__ */ new WeakMap();
|
|
96
|
+
this.conversion = void 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The last conversion, when it converted a document with the same document
|
|
100
|
+
* attributes under the constants `use` was last given.
|
|
101
|
+
*/
|
|
102
|
+
lastConversion(doc) {
|
|
103
|
+
const conversion = this.conversion;
|
|
104
|
+
return conversion !== void 0 && conversion.doc.sameMarkup(doc) ? conversion : void 0;
|
|
105
|
+
}
|
|
106
|
+
/** Keep what converting each top-level node gave, for the next conversion. */
|
|
107
|
+
recordConversion(conversion) {
|
|
108
|
+
this.conversion = conversion;
|
|
109
|
+
}
|
|
110
|
+
/** The block converting `node` at `pmStart` with `listMarker` gives, under `id`. */
|
|
111
|
+
take(node, pmStart, listMarker, id) {
|
|
112
|
+
const kept = this.paragraphs.get(node);
|
|
113
|
+
if (!kept || kept.listMarker !== listMarker) return void 0;
|
|
114
|
+
const moved = movedBlock(kept.block, pmStart - kept.pmStart, id());
|
|
115
|
+
noteParagraphOrigin(moved, kept.block);
|
|
116
|
+
return moved;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Keep the block converting `node` at `pmStart` gave, unless converting it
|
|
120
|
+
* read other blocks. Call before anything else writes to `block`.
|
|
121
|
+
*/
|
|
122
|
+
keep(node, pmStart, listMarker, block) {
|
|
123
|
+
if (this.paragraphs.get(node) === null) return;
|
|
124
|
+
if (readsOtherBlocks(node)) {
|
|
125
|
+
this.paragraphs.set(node, null);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const kept = movedBlock(block, 0, block.id);
|
|
129
|
+
noteParagraphOrigin(block, kept);
|
|
130
|
+
this.paragraphs.set(node, {
|
|
131
|
+
listMarker,
|
|
132
|
+
pmStart,
|
|
133
|
+
block: kept
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
export { ParagraphBlockCache };
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { ParagraphAttrs } from "../../prosemirror/schema/nodes.js";
|
|
2
2
|
import { ParagraphAttrs as ParagraphAttrs$1, ParagraphBlock } from "../../layout-engine/types.js";
|
|
3
|
-
import { FlowConversionOptions } from "./flowConversionShared.js";
|
|
3
|
+
import { CounterFreeFlowConversionOptions, FlowConversionOptions } from "./flowConversionShared.js";
|
|
4
|
+
import { ParagraphListMarker } from "./paragraphAttrs.js";
|
|
4
5
|
import { PageBreakRunProjection } from "./paragraphRuns.js";
|
|
5
6
|
import { Node } from "prosemirror-model";
|
|
6
7
|
export declare function hasVisibleParagraphPayload(attrs: ParagraphAttrs$1): boolean;
|
|
7
8
|
/** Whether any `w:pBdr` side draws a rule (`none`/`nil` sides draw nothing). */
|
|
8
9
|
export declare function drawsParagraphBorder(borders: ParagraphAttrs["borders"]): boolean;
|
|
9
|
-
|
|
10
|
+
/** Convert a paragraph node, advancing the list counters past it. */
|
|
11
|
+
export declare function convertParagraph(node: Node, startPos: number, options: FlowConversionOptions, pageBreaks?: PageBreakRunProjection[]): ParagraphBlock;
|
|
12
|
+
/** Advance the list counters past a paragraph and return the marker they give it. */
|
|
13
|
+
export declare function paragraphListMarker(node: Node, options: Pick<FlowConversionOptions, "listCounterStreams">): ParagraphListMarker;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a paragraph node given the marker the list counters give it. The
|
|
16
|
+
* options carry no counter state, so the marker is the only input that
|
|
17
|
+
* depends on the paragraphs before it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertParagraphWithListMarker(node: Node, startPos: number, options: CounterFreeFlowConversionOptions, listMarker: ParagraphListMarker, pageBreaks?: PageBreakRunProjection[]): ParagraphBlock;
|