@stll/folio-core 0.43.0 → 0.44.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 +6 -5
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/snapshot.js +13 -9
- package/dist/compare/content-alignment.js +16 -1
- package/dist/compare/inline-atoms.js +1 -1
- package/dist/compare/style-resources.js +6 -0
- package/dist/docx/appVersionNormalization.d.ts +0 -18
- package/dist/docx/blockContentParser.js +8 -0
- package/dist/docx/blockRangeMarkers.d.ts +36 -0
- package/dist/docx/blockRangeMarkers.js +59 -0
- package/dist/docx/bookmarkParser.d.ts +2 -20
- package/dist/docx/bookmarkParser.js +6 -30
- package/dist/docx/borderParser.d.ts +13 -0
- package/dist/docx/borderParser.js +71 -0
- package/dist/docx/builtInStyles.d.ts +165 -0
- package/dist/docx/builtInStyles.js +239 -0
- package/dist/docx/commentIdNormalization.d.ts +3 -1
- package/dist/docx/commentIdNormalization.js +18 -1
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +34 -7
- package/dist/docx/commentReferenceNormalization.d.ts +4 -1
- package/dist/docx/commentReferenceNormalization.js +23 -14
- package/dist/docx/danglingRelationshipReferences.d.ts +15 -0
- package/dist/docx/danglingRelationshipReferences.js +30 -0
- package/dist/docx/defaultParagraphStyle.d.ts +18 -1
- package/dist/docx/defaultParagraphStyle.js +23 -1
- package/dist/docx/documentParser.d.ts +2 -1
- package/dist/docx/documentParser.js +2 -2
- package/dist/docx/drawingUtils.d.ts +8 -1
- package/dist/docx/drawingUtils.js +12 -3
- package/dist/docx/fieldParser.js +3 -5
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +19 -4
- package/dist/docx/groupDrawingParser.js +1 -1
- package/dist/docx/headerFooterRefParser.d.ts +4 -3
- package/dist/docx/headerFooterRefParser.js +42 -12
- package/dist/docx/headerFooterReferenceNormalization.d.ts +4 -1
- package/dist/docx/headerFooterReferenceNormalization.js +5 -1
- package/dist/docx/hyperlinkParser.js +11 -15
- package/dist/docx/imageParser.d.ts +1 -1
- package/dist/docx/imageParser.js +22 -18
- package/dist/docx/imageRawXml.js +5 -5
- package/dist/docx/markupRangeMarker.d.ts +15 -0
- package/dist/docx/markupRangeMarker.js +44 -0
- package/dist/docx/noteReferenceStyles.d.ts +29 -0
- package/dist/docx/noteReferenceStyles.js +70 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -1
- package/dist/docx/numberingReferenceNormalization.js +20 -1
- package/dist/docx/paraIdRangeNormalization.d.ts +0 -19
- package/dist/docx/paragraphParser.js +66 -99
- package/dist/docx/paragraphPropertySource.js +1 -0
- package/dist/docx/paragraphTraversal.d.ts +37 -1
- package/dist/docx/paragraphTraversal.js +84 -1
- package/dist/docx/parseContext.d.ts +37 -0
- package/dist/docx/parseContext.js +67 -0
- package/dist/docx/parseWarningMessage.d.ts +6 -0
- package/dist/docx/parseWarningMessage.js +44 -0
- package/dist/docx/parser.js +81 -27
- package/dist/docx/relsParser.d.ts +28 -11
- package/dist/docx/relsParser.js +26 -13
- package/dist/docx/revisionIdNormalization.js +81 -7
- package/dist/docx/rezip.js +63 -22
- package/dist/docx/runConsolidator.js +1 -2
- package/dist/docx/runParser.d.ts +8 -1
- package/dist/docx/runParser.js +30 -48
- package/dist/docx/sectionParser.d.ts +2 -1
- package/dist/docx/sectionParser.js +21 -65
- package/dist/docx/serializer/borderSerializer.d.ts +1 -2
- package/dist/docx/serializer/commentSerializer.js +22 -9
- package/dist/docx/serializer/documentSerializer.d.ts +1 -5
- package/dist/docx/serializer/documentSerializer.js +6 -16
- package/dist/docx/serializer/headerFooterSerializer.js +5 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
- package/dist/docx/serializer/markupRangeAttributes.js +24 -0
- package/dist/docx/serializer/noteSerializer.js +5 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -5
- package/dist/docx/serializer/paragraphSerializer.js +29 -35
- package/dist/docx/serializer/runSerializer.js +13 -7
- package/dist/docx/serializer/tableSerializer.js +28 -13
- package/dist/docx/serializer/textFormattingSerializer.d.ts +2 -3
- package/dist/docx/server/build.js +8 -1
- package/dist/docx/server/createBilingualDocument.js +10 -18
- package/dist/docx/server/extractDocxText.js +3 -4
- package/dist/docx/shadingParser.d.ts +6 -0
- package/dist/docx/shadingParser.js +32 -0
- package/dist/docx/shapeParser.js +3 -3
- package/dist/docx/styleParser.js +13 -87
- package/dist/docx/styleReferenceResolution.d.ts +36 -0
- package/dist/docx/styleReferenceResolution.js +51 -0
- package/dist/docx/tableLook.d.ts +57 -0
- package/dist/docx/tableLook.js +63 -0
- package/dist/docx/tableParser.d.ts +7 -9
- package/dist/docx/tableParser.js +64 -110
- package/dist/docx/textBoxParser.js +4 -4
- package/dist/docx/trackedMoveRangeNormalization.d.ts +3 -1
- package/dist/docx/trackedMoveRangeNormalization.js +11 -21
- package/dist/docx/transitionalSpelling.d.ts +13 -2
- package/dist/docx/transitionalSpelling.js +23 -1
- package/dist/docx/verbatimCapture.js +4 -11
- package/dist/docx/vmlImageParser.js +2 -2
- package/dist/docx/watermarkParser.js +2 -2
- package/dist/docx/xmlParser.d.ts +22 -32
- package/dist/docx/xmlParser.js +36 -21
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +2 -3
- package/dist/internal/paragraphFormattingSerialization.js +26 -6
- package/dist/layout-bridge/convert/footnoteLayout.js +2 -7
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +2 -2
- package/dist/layout-engine/measure/measureBlocks.js +1 -6
- package/dist/layout-engine/types.d.ts +8 -2
- package/dist/layout-engine/types.js +35 -2
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/internals.d.ts +6 -1
- package/dist/markdown/internals.js +14 -1
- package/dist/markdown/renderBlock.js +35 -21
- package/dist/markdown/renderParagraph.js +14 -5
- package/dist/markdown/renderRuns.js +4 -3
- package/dist/markdown/renderTable.js +4 -3
- package/dist/markdown/trailers.js +41 -7
- package/dist/markdown/types.d.ts +3 -7
- package/dist/prosemirror/attrs/index.js +2 -5
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +11 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +18 -3
- package/dist/prosemirror/commands/index.d.ts +3 -3
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +3 -3
- package/dist/prosemirror/commands/paragraph.js +2 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -7
- package/dist/prosemirror/conversion/fromProseDoc.js +129 -40
- package/dist/prosemirror/conversion/toProseDoc.d.ts +1 -14
- package/dist/prosemirror/conversion/toProseDoc.js +375 -316
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +14 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +11 -6
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +6 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +7 -0
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +74 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +11 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +98 -19
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +7 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +15 -1
- package/dist/prosemirror/extensions/types.d.ts +2 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertOperations.d.ts +9 -2
- package/dist/prosemirror/insertOperations.js +9 -4
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +159 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +106 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +9 -1
- package/dist/prosemirror/plugins/documentStyles.js +11 -1
- package/dist/prosemirror/plugins/index.d.ts +2 -2
- package/dist/prosemirror/plugins/index.js +2 -2
- package/dist/prosemirror/plugins/revisionIds.d.ts +11 -2
- package/dist/prosemirror/plugins/revisionIds.js +21 -6
- package/dist/prosemirror/runFormattingReconciliation.js +3 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +31 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +9 -0
- package/dist/prosemirror/styles/styleResolver.js +12 -0
- package/dist/style-engine/styleEngine.d.ts +3 -0
- package/dist/style-engine/styleEngine.js +3 -0
- package/dist/style-sets/extract.js +1 -23
- package/dist/style-sets/stellaStyle.js +46 -39
- package/dist/style-sets/styleSetNormalization.d.ts +19 -0
- package/dist/style-sets/styleSetNormalization.js +99 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +145 -20
- package/dist/utils/headingCollector.d.ts +8 -5
- package/dist/utils/headingCollector.js +23 -25
- package/dist/utils/tableOfContentsStyle.js +9 -2
- package/package.json +2 -2
- package/dist/docx/textWhitespace.d.ts +0 -4
- package/dist/docx/textWhitespace.js +0 -4
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -6
- package/dist/layout-bridge/engine/tableWidthUtils.js +0 -25
- package/dist/markdown/headings.d.ts +0 -13
- package/dist/markdown/headings.js +0 -20
|
@@ -21,6 +21,19 @@ declare function getParagraphAlignment(state: EditorState): document_d_exports.P
|
|
|
21
21
|
declare function getParagraphTabs(state: EditorState): document_d_exports.TabStop[] | null;
|
|
22
22
|
declare function getStyleId(state: EditorState): string | null;
|
|
23
23
|
declare function getParagraphBidi(state: EditorState): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* What a generated table of contents needs from its caller.
|
|
26
|
+
*
|
|
27
|
+
* The title is the caller's because this layer has no locale: a command in
|
|
28
|
+
* `@stll/folio-core` cannot know whether the document should read "Table of
|
|
29
|
+
* Contents", "Obsah" or "Inhaltsverzeichnis", and a hardcoded English string
|
|
30
|
+
* is wrong in every document that is not in English. The host passes the
|
|
31
|
+
* string it already renders its own UI with.
|
|
32
|
+
*/
|
|
33
|
+
type GenerateTableOfContentsOptions = {
|
|
34
|
+
/** Heading text for the table, in the document's language. */
|
|
35
|
+
title: string;
|
|
36
|
+
};
|
|
24
37
|
declare const ParagraphExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
|
|
25
38
|
//#endregion
|
|
26
|
-
export { ParagraphExtension, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId };
|
|
39
|
+
export { GenerateTableOfContentsOptions, ParagraphExtension, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BUILT_IN_STYLE_NAME } from "../../../docx/builtInStyles.js";
|
|
1
2
|
import { PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR } from "../../../docx/paragraphPropertySource.js";
|
|
2
3
|
import { PARAGRAPH_ALIGNMENT_VALUES } from "../../../types/documentEnumValues.js";
|
|
3
4
|
import { paragraphToStyle } from "../../../utils/formatToStyle.js";
|
|
@@ -8,6 +9,7 @@ import { autospacingMatchesBase } from "../../autospacingBase.js";
|
|
|
8
9
|
import { directParagraphAlignment } from "../../paragraphAlignment.js";
|
|
9
10
|
import { directionIsRtl } from "../../paragraphDirection.js";
|
|
10
11
|
import { withDirectParagraphSpacing } from "../../paragraphSpacing.js";
|
|
12
|
+
import { getDocumentBuiltInStyles } from "../../plugins/documentStyles.js";
|
|
11
13
|
import { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
12
14
|
import { createNodeExtension } from "../create.js";
|
|
13
15
|
import { Fragment } from "prosemirror-model";
|
|
@@ -248,6 +250,7 @@ const paragraphNodeSpec = {
|
|
|
248
250
|
bookmarks: { default: null },
|
|
249
251
|
_emptyHyperlinks: { default: null },
|
|
250
252
|
_originalFormatting: { default: null },
|
|
253
|
+
_resolvedFormatting: { default: void 0 },
|
|
251
254
|
_autospacingBase: { default: null },
|
|
252
255
|
_sectionProperties: { default: null },
|
|
253
256
|
_propertyChanges: { default: null },
|
|
@@ -602,8 +605,9 @@ const ParagraphExtension = createNodeExtension({
|
|
|
602
605
|
}),
|
|
603
606
|
insertSectionBreak: (breakType) => setParagraphAttr("sectionBreakType", breakType),
|
|
604
607
|
removeSectionBreak: () => setParagraphAttr("sectionBreakType", null),
|
|
605
|
-
generateTOC: () => (state, dispatch) => {
|
|
606
|
-
const
|
|
608
|
+
generateTOC: ({ title }) => (state, dispatch) => {
|
|
609
|
+
const builtInStyles = getDocumentBuiltInStyles(state);
|
|
610
|
+
const headings = collectHeadings(state.doc, builtInStyles);
|
|
607
611
|
if (headings.length === 0) return false;
|
|
608
612
|
if (!dispatch) return true;
|
|
609
613
|
const { schema: s } = state;
|
|
@@ -630,10 +634,11 @@ const ParagraphExtension = createNodeExtension({
|
|
|
630
634
|
}
|
|
631
635
|
}
|
|
632
636
|
const tocNodes = [];
|
|
637
|
+
const tocHeadingStyleId = builtInStyles.styleIdForBuiltInName(BUILT_IN_STYLE_NAME.tocHeading);
|
|
633
638
|
tocNodes.push(s.node("paragraph", {
|
|
634
|
-
styleId:
|
|
639
|
+
...tocHeadingStyleId === void 0 ? {} : { styleId: tocHeadingStyleId },
|
|
635
640
|
alignment: "center"
|
|
636
|
-
}, [s.text(
|
|
641
|
+
}, [s.text(title, s.marks["bold"] ? [s.marks["bold"].create()] : [])]));
|
|
637
642
|
const DEFAULT_MARGIN_TWIPS = 1440;
|
|
638
643
|
let tocTabStopTwips = 12240 - 2 * DEFAULT_MARGIN_TWIPS;
|
|
639
644
|
let tabStopResolved = false;
|
|
@@ -650,7 +655,7 @@ const ParagraphExtension = createNodeExtension({
|
|
|
650
655
|
const canPageNumber = Boolean(s.nodes["field"] && s.nodes["tab"]);
|
|
651
656
|
for (const entry of bookmarkEntries) {
|
|
652
657
|
const indent = entry.level * 720;
|
|
653
|
-
const tocStyleId =
|
|
658
|
+
const tocStyleId = builtInStyles.styleIdForTableOfContentsLevel(entry.level + 1);
|
|
654
659
|
if (!s.marks["hyperlink"]) continue;
|
|
655
660
|
const linkMark = s.marks["hyperlink"].create({ href: `#${entry.name}` });
|
|
656
661
|
const content = [s.text(entry.text, [linkMark])];
|
|
@@ -663,7 +668,7 @@ const ParagraphExtension = createNodeExtension({
|
|
|
663
668
|
dirty: true
|
|
664
669
|
}));
|
|
665
670
|
tocNodes.push(s.node("paragraph", {
|
|
666
|
-
styleId: tocStyleId,
|
|
671
|
+
...tocStyleId === void 0 ? {} : { styleId: tocStyleId },
|
|
667
672
|
indentLeft: indent > 0 ? indent : null,
|
|
668
673
|
...canPageNumber ? { tabs: [{
|
|
669
674
|
position: tocTabStopTwips,
|
|
@@ -7,9 +7,9 @@ const emptyParagraphFormatKey = new PluginKey("emptyParagraphFormat");
|
|
|
7
7
|
* Run-formatting properties the painter does NOT reproduce from
|
|
8
8
|
* `defaultTextFormatting` on its own (it forwards only font family + size).
|
|
9
9
|
* When an empty paragraph's defaults carry any of these, typed text must
|
|
10
|
-
* acquire real marks or it would render unstyled.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* acquire real marks or it would render unstyled. Every property listed here
|
|
11
|
+
* must be one `textFormattingToMarks` can turn into a mark, or the gate would
|
|
12
|
+
* open for work that produces nothing.
|
|
13
13
|
*/
|
|
14
14
|
function hasNonFontDefaults(dtf) {
|
|
15
15
|
return !!(dtf.bold || dtf.italic || dtf.underline || dtf.strike || dtf.doubleStrike || dtf.color || dtf.highlight || dtf.vertAlign || dtf.rtl);
|
|
@@ -11,7 +11,10 @@ import { Extension } from "../types.js";
|
|
|
11
11
|
* default clipboard parser; ProseMirror chains every plugin's
|
|
12
12
|
* `transformPastedHTML`, so this cooperates with the inliner rather than
|
|
13
13
|
* replacing it, and `<style>` blocks are left intact for it to resolve.
|
|
14
|
-
* 2. `
|
|
14
|
+
* 2. `transformPasted` — drops unpaired bookmark boundaries, then points
|
|
15
|
+
* pasted headings at the open document's own heading style (see
|
|
16
|
+
* {@link retargetPastedHeadingStyles}).
|
|
17
|
+
* 3. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
|
|
15
18
|
* the source formatting stripped (see {@link pasteWithoutFormatting}).
|
|
16
19
|
*/
|
|
17
20
|
type PasteCleanupOptions = {
|
|
@@ -2,6 +2,7 @@ import { pasteWithoutFormatting } from "../../commands/pastePlainText.js";
|
|
|
2
2
|
import { createExtension } from "../create.js";
|
|
3
3
|
import { Priority } from "../types.js";
|
|
4
4
|
import { cleanPastedHtml, removeUnpairedBookmarkBoundaries } from "./pasteCleanup.js";
|
|
5
|
+
import { retargetPastedHeadingStyles } from "./pastedHeadingStyles.js";
|
|
5
6
|
import { Plugin } from "prosemirror-state";
|
|
6
7
|
//#region src/prosemirror/extensions/features/PasteCleanupExtension.ts
|
|
7
8
|
/**
|
|
@@ -15,7 +16,10 @@ import { Plugin } from "prosemirror-state";
|
|
|
15
16
|
* default clipboard parser; ProseMirror chains every plugin's
|
|
16
17
|
* `transformPastedHTML`, so this cooperates with the inliner rather than
|
|
17
18
|
* replacing it, and `<style>` blocks are left intact for it to resolve.
|
|
18
|
-
* 2. `
|
|
19
|
+
* 2. `transformPasted` — drops unpaired bookmark boundaries, then points
|
|
20
|
+
* pasted headings at the open document's own heading style (see
|
|
21
|
+
* {@link retargetPastedHeadingStyles}).
|
|
22
|
+
* 3. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
|
|
19
23
|
* the source formatting stripped (see {@link pasteWithoutFormatting}).
|
|
20
24
|
*/
|
|
21
25
|
const PasteCleanupExtension = createExtension({
|
|
@@ -28,7 +32,7 @@ const PasteCleanupExtension = createExtension({
|
|
|
28
32
|
const internalClipboardToken = options.getInternalClipboardToken?.();
|
|
29
33
|
return cleanPastedHtml(html, { ...internalClipboardToken ? { internalClipboardToken } : {} });
|
|
30
34
|
},
|
|
31
|
-
transformPasted: removeUnpairedBookmarkBoundaries
|
|
35
|
+
transformPasted: (slice, view) => retargetPastedHeadingStyles(removeUnpairedBookmarkBoundaries(slice), view)
|
|
32
36
|
} })],
|
|
33
37
|
keyboardShortcuts: { "Mod-Alt-v": pasteWithoutFormatting }
|
|
34
38
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Slice } from "prosemirror-model";
|
|
2
|
+
import { EditorView } from "prosemirror-view";
|
|
3
|
+
//#region src/prosemirror/extensions/features/pastedHeadingStyles.d.ts
|
|
4
|
+
/** A `transformPasted` hook; returns the slice unchanged when nothing matches. */
|
|
5
|
+
declare const retargetPastedHeadingStyles: (slice: Slice, view: EditorView) => Slice;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { retargetPastedHeadingStyles };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { isHeadingOutlineLevel } from "../../../docx/builtInStyles.js";
|
|
2
|
+
import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "../../plugins/documentStyles.js";
|
|
3
|
+
import { Fragment, Slice } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/extensions/features/pastedHeadingStyles.ts
|
|
5
|
+
/**
|
|
6
|
+
* Retarget pasted heading paragraphs at the open document's own heading style.
|
|
7
|
+
*
|
|
8
|
+
* The schema's `h1`–`h6` paste rule runs inside `parseDOM`, which sees no
|
|
9
|
+
* document, so it can only write the English built-in id `Heading1`…`Heading6`.
|
|
10
|
+
* In a document written by a localized Word the heading style is `Nadpis1` or
|
|
11
|
+
* `berschrift2`, and in one folio generated from a style set the deeper levels
|
|
12
|
+
* may not exist at all, so that id resolves to nothing and the pasted heading
|
|
13
|
+
* loses the document's heading formatting.
|
|
14
|
+
*
|
|
15
|
+
* The paragraph still classifies as a heading either way — `parseDOM` also sets
|
|
16
|
+
* `outlineLevel`, which is what `docx/builtInStyles.ts` reads first. This is
|
|
17
|
+
* about which style the text picks up.
|
|
18
|
+
*
|
|
19
|
+
* Deliberately narrow: a paragraph is retargeted only when the document defines
|
|
20
|
+
* no style under the id it carries. Pasting between two folio documents, or
|
|
21
|
+
* within one, never reaches it. Creating a style stays an explicit command —
|
|
22
|
+
* minting one here would edit `styles.xml` as a side effect of a clipboard
|
|
23
|
+
* action — so a level the document does not define falls back to the deepest
|
|
24
|
+
* heading it does. An `<h5>` pasted into a set that stops at `heading 4` lands
|
|
25
|
+
* on that one rather than keeping an id nothing resolves.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The document's style for this heading level, else its deepest shallower one.
|
|
29
|
+
* Never deeper: promoting an `<h5>` to `heading 1` would restructure the
|
|
30
|
+
* document's outline, while demoting it to the deepest level it has preserves
|
|
31
|
+
* the ordering of everything around it.
|
|
32
|
+
*/
|
|
33
|
+
const nearestHeadingStyleId = (outlineLevel, styles) => {
|
|
34
|
+
for (let level = outlineLevel; level >= 0; level -= 1) {
|
|
35
|
+
const styleId = styles.styleIdForHeadingLevel(level);
|
|
36
|
+
if (styleId !== void 0) return styleId;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const retargetedStyleId = (node, view) => {
|
|
40
|
+
const styleId = node.attrs["styleId"];
|
|
41
|
+
if (typeof styleId !== "string") return;
|
|
42
|
+
const outlineLevel = node.attrs["outlineLevel"];
|
|
43
|
+
if (typeof outlineLevel !== "number" || !isHeadingOutlineLevel(outlineLevel)) return;
|
|
44
|
+
const resolver = getDocumentStyleResolver(view.state);
|
|
45
|
+
if (resolver === null || resolver.getStyle(styleId) !== void 0) return;
|
|
46
|
+
const target = nearestHeadingStyleId(outlineLevel, getDocumentBuiltInStyles(view.state));
|
|
47
|
+
return target === styleId ? void 0 : target;
|
|
48
|
+
};
|
|
49
|
+
const retargetFragment = (fragment, view) => {
|
|
50
|
+
const children = [];
|
|
51
|
+
let changed = false;
|
|
52
|
+
fragment.forEach((node) => {
|
|
53
|
+
const content = retargetFragment(node.content, view);
|
|
54
|
+
const styleId = node.type.name === "paragraph" ? retargetedStyleId(node, view) : void 0;
|
|
55
|
+
if (styleId === void 0 && content === node.content) {
|
|
56
|
+
children.push(node);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
changed = true;
|
|
60
|
+
const retargeted = styleId === void 0 ? node : node.type.create({
|
|
61
|
+
...node.attrs,
|
|
62
|
+
styleId
|
|
63
|
+
}, content, node.marks);
|
|
64
|
+
children.push(styleId === void 0 ? node.copy(content) : retargeted);
|
|
65
|
+
});
|
|
66
|
+
return changed ? Fragment.fromArray(children) : fragment;
|
|
67
|
+
};
|
|
68
|
+
/** A `transformPasted` hook; returns the slice unchanged when nothing matches. */
|
|
69
|
+
const retargetPastedHeadingStyles = (slice, view) => {
|
|
70
|
+
const content = retargetFragment(slice.content, view);
|
|
71
|
+
return content === slice.content ? slice : new Slice(content, slice.openStart, slice.openEnd);
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { retargetPastedHeadingStyles };
|
|
@@ -21,10 +21,18 @@ declare function isMarkActive(state: EditorState, markType: MarkType, attrs?: Re
|
|
|
21
21
|
* Get the current value of a mark attribute
|
|
22
22
|
*/
|
|
23
23
|
declare function getMarkAttr(state: EditorState, markType: MarkType, attr: string): unknown;
|
|
24
|
+
type AuthoredRunFormattingCarrier = "preserve" | "reconstruct";
|
|
24
25
|
/**
|
|
25
|
-
* Convert TextFormatting to marks
|
|
26
|
+
* Convert TextFormatting to ProseMirror marks
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
type TextFormattingToMarksOptions = {
|
|
29
|
+
overrideFormatting: document_d_exports.TextFormatting | undefined;
|
|
30
|
+
/** Direct standard font properties whose authored provenance must survive. */
|
|
31
|
+
directFormatting?: document_d_exports.TextFormatting | undefined;
|
|
32
|
+
/** Whether direct authorship is reconstructible from structural marks and the style context. */
|
|
33
|
+
authoredCarrier?: AuthoredRunFormattingCarrier;
|
|
34
|
+
};
|
|
35
|
+
declare function textFormattingToMarks(formatting: document_d_exports.TextFormatting | undefined, schema: Schema, options?: TextFormattingToMarksOptions): Mark[];
|
|
28
36
|
/**
|
|
29
37
|
* Clear all text formatting (remove all marks)
|
|
30
38
|
*/
|
|
@@ -38,4 +46,4 @@ declare function createSetMarkCommand(markType: MarkType, attrs?: Record<string,
|
|
|
38
46
|
*/
|
|
39
47
|
declare function createRemoveMarkCommand(markType: MarkType): Command;
|
|
40
48
|
//#endregion
|
|
41
|
-
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
49
|
+
export { AuthoredRunFormattingCarrier, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { FONT_THEME_VALUES } from "../../../types/documentEnumValues.js";
|
|
2
2
|
import { mergeFontFamily } from "../../../utils/fontFamilyMerge.js";
|
|
3
|
+
import { normalizeHorizontalScalePercent } from "../../../utils/horizontalScale.js";
|
|
3
4
|
import { expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
5
|
+
import { shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
|
|
4
6
|
import { selectRunFormattingCarrierRepresentations } from "../../runFormattingInlineCarriers.js";
|
|
5
7
|
import { hasRunFormattingOverrideAttrs } from "../../runFormattingProvenance.js";
|
|
8
|
+
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS } from "../../schema/marks.js";
|
|
6
9
|
import { applyRunFormattingOverrideMark, buildRunFormattingOverrideAttrs } from "./RunFormattingOverrideExtension.js";
|
|
7
10
|
import { toggleMark } from "prosemirror-commands";
|
|
8
11
|
//#region src/prosemirror/extensions/marks/markUtils.ts
|
|
@@ -328,30 +331,85 @@ function getMarkAttr(state, markType, attr) {
|
|
|
328
331
|
});
|
|
329
332
|
return value;
|
|
330
333
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
334
|
+
const addDirectFontProvenance = (marks, schema, directFormatting) => {
|
|
335
|
+
const directFontProperties = [];
|
|
336
|
+
if (directFormatting?.fontFamily !== void 0) directFontProperties.push("fontFamily");
|
|
337
|
+
if (directFormatting?.fontSize !== void 0) directFontProperties.push("fontSize");
|
|
338
|
+
if (directFormatting?.color !== void 0) directFontProperties.push("color");
|
|
339
|
+
if (directFontProperties.length === 0) return;
|
|
340
|
+
const index = marks.findIndex(({ type }) => type.name === "runFormattingOverride");
|
|
341
|
+
const existing = index >= 0 ? marks.at(index) : void 0;
|
|
342
|
+
const override = schema.mark("runFormattingOverride", {
|
|
343
|
+
...existing?.attrs,
|
|
344
|
+
directFontProperties
|
|
345
|
+
});
|
|
346
|
+
if (index >= 0) {
|
|
347
|
+
marks[index] = override;
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
marks.push(override);
|
|
351
|
+
};
|
|
352
|
+
const COMPLEX_SCRIPT_MIRRORS = [
|
|
353
|
+
{
|
|
354
|
+
ordinary: "bold",
|
|
355
|
+
complex: "boldCs"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
ordinary: "italic",
|
|
359
|
+
complex: "italicCs"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
ordinary: "fontSize",
|
|
363
|
+
complex: "fontSizeCs"
|
|
364
|
+
}
|
|
365
|
+
];
|
|
366
|
+
const addComplexScriptAbsenceProvenance = (marks, schema, directFormatting) => {
|
|
367
|
+
const absent = COMPLEX_SCRIPT_MIRRORS.filter(({ ordinary, complex }) => directFormatting?.[ordinary] !== void 0 && directFormatting[complex] === void 0).map(({ complex }) => complex);
|
|
368
|
+
if (absent.length === 0) return;
|
|
369
|
+
const index = marks.findIndex(({ type }) => type.name === "runFormattingOverride");
|
|
370
|
+
const existing = index >= 0 ? marks.at(index) : void 0;
|
|
371
|
+
const existingAbsences = new Set(existing?.attrs["complexScriptPropertyAbsences"] ?? []);
|
|
372
|
+
for (const property of absent) existingAbsences.add(property);
|
|
373
|
+
const override = schema.mark("runFormattingOverride", {
|
|
374
|
+
...existing?.attrs,
|
|
375
|
+
complexScriptPropertyAbsences: COMPLEX_SCRIPT_RUN_PROPERTY_KEYS.filter((property) => existingAbsences.has(property))
|
|
376
|
+
});
|
|
377
|
+
if (index >= 0) {
|
|
378
|
+
marks[index] = override;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
marks.push(override);
|
|
382
|
+
};
|
|
383
|
+
function textFormattingToMarks(formatting, schema, options) {
|
|
384
|
+
if (!formatting) return [];
|
|
335
385
|
const marks = [];
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
if (
|
|
340
|
-
|
|
386
|
+
const overrideFormatting = options ? options.overrideFormatting : formatting;
|
|
387
|
+
let overrideAttrs;
|
|
388
|
+
if (options?.authoredCarrier === "reconstruct") overrideAttrs = buildRunFormattingOverrideAttrs(overrideFormatting, { type: "structural-only" });
|
|
389
|
+
else if (options) overrideAttrs = buildRunFormattingOverrideAttrs(overrideFormatting, {
|
|
390
|
+
type: "authored-baseline",
|
|
391
|
+
formatting: options.directFormatting
|
|
392
|
+
});
|
|
393
|
+
else overrideAttrs = buildRunFormattingOverrideAttrs(overrideFormatting);
|
|
394
|
+
if (overrideAttrs) marks.push(schema.mark("runFormattingOverride", overrideAttrs));
|
|
395
|
+
if (formatting.bold) marks.push(schema.mark("bold"));
|
|
396
|
+
if (formatting.italic) marks.push(schema.mark("italic"));
|
|
397
|
+
if (formatting.underline && formatting.underline.style !== "none") marks.push(schema.mark("underline", {
|
|
341
398
|
style: formatting.underline.style,
|
|
342
399
|
color: formatting.underline.color
|
|
343
400
|
}));
|
|
344
|
-
if (formatting.strike
|
|
345
|
-
if (formatting.
|
|
346
|
-
if (formatting.color && schema.marks["textColor"]) marks.push(schema.marks["textColor"].create({
|
|
401
|
+
if (formatting.strike || formatting.doubleStrike) marks.push(schema.mark("strike", { double: formatting.doubleStrike || false }));
|
|
402
|
+
if (formatting.color && !formatting.color.auto) marks.push(schema.mark("textColor", {
|
|
347
403
|
rgb: formatting.color.rgb,
|
|
348
404
|
themeColor: formatting.color.themeColor,
|
|
349
405
|
themeTint: formatting.color.themeTint,
|
|
350
406
|
themeShade: formatting.color.themeShade
|
|
351
407
|
}));
|
|
352
|
-
if (formatting.highlight &&
|
|
353
|
-
|
|
354
|
-
if (
|
|
408
|
+
if (formatting.highlight && formatting.highlight !== "none") marks.push(schema.mark("highlight", { color: formatting.highlight }));
|
|
409
|
+
const runShadingMarkAttrs = shadingToRunShadingAttrs(formatting.shading);
|
|
410
|
+
if (runShadingMarkAttrs) marks.push(schema.mark("runShading", runShadingMarkAttrs));
|
|
411
|
+
if (formatting.fontSize) marks.push(schema.mark("fontSize", { size: formatting.fontSize }));
|
|
412
|
+
if (formatting.fontFamily) marks.push(schema.mark("fontFamily", {
|
|
355
413
|
ascii: formatting.fontFamily.ascii,
|
|
356
414
|
hAnsi: formatting.fontFamily.hAnsi,
|
|
357
415
|
eastAsia: formatting.fontFamily.eastAsia,
|
|
@@ -362,10 +420,31 @@ function textFormattingToMarks(formatting, schema) {
|
|
|
362
420
|
eastAsiaTheme: formatting.fontFamily.eastAsiaTheme,
|
|
363
421
|
csTheme: formatting.fontFamily.csTheme
|
|
364
422
|
}));
|
|
365
|
-
if (formatting.language
|
|
366
|
-
if (formatting.vertAlign === "superscript"
|
|
367
|
-
if (formatting.vertAlign === "subscript"
|
|
368
|
-
if (formatting.
|
|
423
|
+
if (formatting.language) marks.push(schema.mark("language", formatting.language));
|
|
424
|
+
if (formatting.vertAlign === "superscript") marks.push(schema.mark("superscript"));
|
|
425
|
+
else if (formatting.vertAlign === "subscript") marks.push(schema.mark("subscript"));
|
|
426
|
+
if (formatting.allCaps) marks.push(schema.mark("allCaps"));
|
|
427
|
+
if (formatting.smallCaps) marks.push(schema.mark("smallCaps"));
|
|
428
|
+
const spacing = typeof formatting.spacing === "number" ? formatting.spacing : null;
|
|
429
|
+
const position = typeof formatting.position === "number" ? formatting.position : null;
|
|
430
|
+
const scale = normalizeHorizontalScalePercent(formatting.scale) ?? null;
|
|
431
|
+
const kerning = typeof formatting.kerning === "number" ? formatting.kerning : null;
|
|
432
|
+
if (spacing !== null || position !== null || scale !== null || kerning !== null) marks.push(schema.mark("characterSpacing", {
|
|
433
|
+
spacing,
|
|
434
|
+
position,
|
|
435
|
+
scale,
|
|
436
|
+
kerning
|
|
437
|
+
}));
|
|
438
|
+
if (formatting.hidden === true) marks.push(schema.mark("hidden"));
|
|
439
|
+
if (formatting.emboss) marks.push(schema.mark("emboss"));
|
|
440
|
+
if (formatting.imprint) marks.push(schema.mark("imprint"));
|
|
441
|
+
if (formatting.shadow) marks.push(schema.mark("textShadow"));
|
|
442
|
+
if (formatting.emphasisMark && formatting.emphasisMark !== "none") marks.push(schema.mark("emphasisMark", { type: formatting.emphasisMark }));
|
|
443
|
+
if (formatting.outline) marks.push(schema.mark("textOutline"));
|
|
444
|
+
if (formatting.rtl) marks.push(schema.mark("rtl"));
|
|
445
|
+
if (formatting.effect && formatting.effect !== "none") marks.push(schema.mark("textEffect", { effect: formatting.effect }));
|
|
446
|
+
addDirectFontProvenance(marks, schema, options?.directFormatting);
|
|
447
|
+
if (options?.authoredCarrier === "preserve") addComplexScriptAbsenceProvenance(marks, schema, options.directFormatting);
|
|
369
448
|
return marks;
|
|
370
449
|
}
|
|
371
450
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readParagraphAttrs } from "../../attrs/index.js";
|
|
2
|
-
import { expectBookmarkBoundaryAttrs, readBookmarkBoundaryAttrs } from "../../bookmarkBoundaryAttrs.js";
|
|
2
|
+
import { expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs } from "../../bookmarkBoundaryAttrs.js";
|
|
3
3
|
import { findInvalidBookmarkBoundaryIds } from "../../bookmarkBoundaryIntegrity.js";
|
|
4
4
|
import { createNodeExtension } from "../create.js";
|
|
5
5
|
import { Plugin } from "prosemirror-state";
|
|
@@ -60,7 +60,8 @@ const BookmarkBoundaryExtension = createNodeExtension({
|
|
|
60
60
|
id: {},
|
|
61
61
|
name: { default: null },
|
|
62
62
|
colFirst: { default: null },
|
|
63
|
-
colLast: { default: null }
|
|
63
|
+
colLast: { default: null },
|
|
64
|
+
displacedByCustomXml: { default: null }
|
|
64
65
|
},
|
|
65
66
|
parseDOM: [{
|
|
66
67
|
tag: "span[data-docx-bookmark-boundary]",
|
|
@@ -73,12 +74,14 @@ const BookmarkBoundaryExtension = createNodeExtension({
|
|
|
73
74
|
const colFirst = readOptionalColumn(dom, "data-docx-bookmark-col-first");
|
|
74
75
|
const colLast = readOptionalColumn(dom, "data-docx-bookmark-col-last");
|
|
75
76
|
if (colFirst === false || colLast === false) return false;
|
|
77
|
+
const displaced = dom.getAttribute("data-docx-bookmark-displaced");
|
|
76
78
|
return {
|
|
77
79
|
type,
|
|
78
80
|
id,
|
|
79
81
|
...name ? { name } : {},
|
|
80
82
|
...colFirst !== void 0 ? { colFirst } : {},
|
|
81
|
-
...colLast !== void 0 ? { colLast } : {}
|
|
83
|
+
...colLast !== void 0 ? { colLast } : {},
|
|
84
|
+
...isDisplacedByCustomXml(displaced) ? { displacedByCustomXml: displaced } : {}
|
|
82
85
|
};
|
|
83
86
|
}
|
|
84
87
|
}],
|
|
@@ -90,6 +93,7 @@ const BookmarkBoundaryExtension = createNodeExtension({
|
|
|
90
93
|
...attrs.type === "start" ? { "data-docx-bookmark-name": attrs.name } : {},
|
|
91
94
|
...attrs.type === "start" && attrs.colFirst !== void 0 ? { "data-docx-bookmark-col-first": String(attrs.colFirst) } : {},
|
|
92
95
|
...attrs.type === "start" && attrs.colLast !== void 0 ? { "data-docx-bookmark-col-last": String(attrs.colLast) } : {},
|
|
96
|
+
...attrs.displacedByCustomXml !== void 0 ? { "data-docx-bookmark-displaced": attrs.displacedByCustomXml } : {},
|
|
93
97
|
"aria-hidden": "true",
|
|
94
98
|
contenteditable: "false",
|
|
95
99
|
style: "display: none;",
|
|
@@ -49,7 +49,8 @@ const ImageExtension = createNodeExtension({
|
|
|
49
49
|
_docxRawXml: { default: null },
|
|
50
50
|
_docxRawXmlMode: { default: null },
|
|
51
51
|
_docxRawImageFingerprint: { default: null },
|
|
52
|
-
_docxObjectPreview: { default: null }
|
|
52
|
+
_docxObjectPreview: { default: null },
|
|
53
|
+
_docxRunFormatting: { default: null }
|
|
53
54
|
},
|
|
54
55
|
parseDOM: [{
|
|
55
56
|
tag: "img[src]",
|
|
@@ -369,6 +369,7 @@ const ShapeExtension = createNodeExtension({
|
|
|
369
369
|
attrs: {
|
|
370
370
|
shapeType: { default: "rect" },
|
|
371
371
|
geometryAdjustments: { default: null },
|
|
372
|
+
_docxRunFormatting: { default: null },
|
|
372
373
|
shapeId: { default: null },
|
|
373
374
|
width: { default: 100 },
|
|
374
375
|
height: { default: 80 },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setTableLookFlags } from "../../../docx/tableLook.js";
|
|
1
2
|
import { TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_WIDTH_TYPE_VALUES } from "../../../types/documentEnumValues.js";
|
|
2
3
|
import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
|
|
3
4
|
import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
|
|
@@ -1618,7 +1619,20 @@ const TablePluginExtension = createExtension({
|
|
|
1618
1619
|
};
|
|
1619
1620
|
const conditionals = styleData.conditionals ?? {};
|
|
1620
1621
|
const tableBorders = styleData.tableBorders;
|
|
1621
|
-
tr = tr.setNodeMarkup(tablePos, void 0, mergeTableAttrs(table, {
|
|
1622
|
+
tr = tr.setNodeMarkup(tablePos, void 0, mergeTableAttrs(table, {
|
|
1623
|
+
styleId: styleData.styleId,
|
|
1624
|
+
look: setTableLookFlags({
|
|
1625
|
+
look: expectTableAttrs(table).look,
|
|
1626
|
+
flags: {
|
|
1627
|
+
firstRow: look.firstRow === true,
|
|
1628
|
+
lastRow: look.lastRow === true,
|
|
1629
|
+
firstColumn: look.firstCol === true,
|
|
1630
|
+
lastColumn: look.lastCol === true,
|
|
1631
|
+
noHBand: look.noHBand === true,
|
|
1632
|
+
noVBand: look.noVBand === true
|
|
1633
|
+
}
|
|
1634
|
+
})
|
|
1635
|
+
}));
|
|
1622
1636
|
let dataRowIndex = 0;
|
|
1623
1637
|
let rowOffset = tablePos + 1;
|
|
1624
1638
|
for (let rowIdx = 0; rowIdx < totalRows; rowIdx++) {
|
|
@@ -2,7 +2,7 @@ import { document_d_exports } from "../../types/document.js";
|
|
|
2
2
|
import { TextColorAttrs } from "../schema/marks.js";
|
|
3
3
|
import "../schema/index.js";
|
|
4
4
|
import { TablePropertiesCommand } from "../../utils/tableOperations.js";
|
|
5
|
-
import { ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
|
|
5
|
+
import { GenerateTableOfContentsOptions, ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
|
|
6
6
|
import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
|
|
7
7
|
import { Command, Plugin } from "prosemirror-state";
|
|
8
8
|
import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
|
|
@@ -106,7 +106,7 @@ type FolioCommandArguments = {
|
|
|
106
106
|
setRtl: [];
|
|
107
107
|
setLtr: [];
|
|
108
108
|
setTabs: [tabs: document_d_exports.TabStop[]];
|
|
109
|
-
generateTOC: [];
|
|
109
|
+
generateTOC: [options: GenerateTableOfContentsOptions];
|
|
110
110
|
insertTable: [rows: number, cols: number];
|
|
111
111
|
addRowAbove: [];
|
|
112
112
|
addRowBelow: [];
|
|
@@ -10,7 +10,7 @@ import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensi
|
|
|
10
10
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
11
11
|
import { insertImageFromFile } from "./commands/image.js";
|
|
12
12
|
import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
|
|
13
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel,
|
|
13
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
14
14
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
15
15
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
16
16
|
import "./commands/index.js";
|
|
@@ -22,8 +22,8 @@ import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin
|
|
|
22
22
|
import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
|
|
23
23
|
import "./styles/index.js";
|
|
24
24
|
import { SelectionState, extractSelectionState } from "./selectionState.js";
|
|
25
|
-
import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
25
|
+
import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
26
26
|
import "./plugins/index.js";
|
|
27
27
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
28
28
|
import { TextSelection } from "prosemirror-state";
|
|
29
|
-
export { type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type HyperlinkAttrs, type ImageAttrs, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderPreset, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc,
|
|
29
|
+
export { type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type HyperlinkAttrs, type ImageAttrs, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderPreset, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -2,7 +2,7 @@ import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./co
|
|
|
2
2
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
3
3
|
import { insertImageFromFile } from "./commands/image.js";
|
|
4
4
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
5
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel,
|
|
5
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
6
6
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
7
7
|
import { fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
|
|
8
8
|
import { createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
@@ -13,11 +13,11 @@ import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensi
|
|
|
13
13
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
14
14
|
import { getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
15
15
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
16
|
-
import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
16
|
+
import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
17
17
|
import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
|
|
18
18
|
import { schema, singletonManager } from "./schema/index.js";
|
|
19
19
|
import { extractSelectionState } from "./selectionState.js";
|
|
20
20
|
import { StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
21
21
|
import { assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
22
22
|
import { TextSelection } from "prosemirror-state";
|
|
23
|
-
export { PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc,
|
|
23
|
+
export { PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { GenerateTableOfContentsOptions } from "./extensions/core/ParagraphExtension.js";
|
|
1
2
|
import { insertImageFromFile } from "./commands/image.js";
|
|
3
|
+
import "./commands/index.js";
|
|
2
4
|
import { EditorView } from "prosemirror-view";
|
|
3
5
|
//#region src/prosemirror/insertOperations.d.ts
|
|
4
6
|
/** Insert a `rows × columns` table at the current selection. */
|
|
5
7
|
declare function insertTableInView(view: EditorView, rows: number, columns: number): boolean;
|
|
6
8
|
/** Insert a page break at the current selection. */
|
|
7
9
|
declare function insertPageBreakInView(view: EditorView): boolean;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Generate (or refresh) a table of contents from the document's headings.
|
|
12
|
+
*
|
|
13
|
+
* `title` is the caller's because this layer has no locale — see
|
|
14
|
+
* {@link GenerateTableOfContentsOptions}.
|
|
15
|
+
*/
|
|
16
|
+
declare function insertTableOfContentsInView(view: EditorView, options: GenerateTableOfContentsOptions): boolean;
|
|
10
17
|
//#endregion
|
|
11
18
|
export { insertImageFromFile, insertPageBreakInView, insertTableInView, insertTableOfContentsInView };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { insertImageFromFile } from "./commands/image.js";
|
|
2
2
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
3
|
-
import {
|
|
3
|
+
import { generateTableOfContents } from "./commands/paragraph.js";
|
|
4
4
|
import { insertTable } from "./commands/table.js";
|
|
5
5
|
//#region src/prosemirror/insertOperations.ts
|
|
6
6
|
/** Insert a `rows × columns` table at the current selection. */
|
|
@@ -11,9 +11,14 @@ function insertTableInView(view, rows, columns) {
|
|
|
11
11
|
function insertPageBreakInView(view) {
|
|
12
12
|
return insertPageBreak(view.state, view.dispatch);
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Generate (or refresh) a table of contents from the document's headings.
|
|
16
|
+
*
|
|
17
|
+
* `title` is the caller's because this layer has no locale — see
|
|
18
|
+
* {@link GenerateTableOfContentsOptions}.
|
|
19
|
+
*/
|
|
20
|
+
function insertTableOfContentsInView(view, options) {
|
|
21
|
+
return generateTableOfContents(options)(view.state, view.dispatch);
|
|
17
22
|
}
|
|
18
23
|
//#endregion
|
|
19
24
|
export { insertImageFromFile, insertPageBreakInView, insertTableInView, insertTableOfContentsInView };
|