@stll/folio-core 0.66.1 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.d.ts +13 -1
- package/dist/ai-edits/apply.js +572 -140
- package/dist/ai-edits/batch-claims.d.ts +26 -0
- package/dist/ai-edits/batch-claims.js +32 -5
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +6 -0
- package/dist/ai-edits/headless.js +25 -3
- package/dist/ai-edits/newListNumbering.d.ts +4 -1
- package/dist/ai-edits/newListNumbering.js +4 -2
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.js +24 -14
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- package/dist/ai-edits/types.d.ts +1 -1
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +76 -18
- package/dist/controller/canonicalInput.d.ts +0 -1
- package/dist/controller/canonicalInput.js +19 -1
- package/dist/controller/canonicalSession.js +1 -2
- package/dist/controller/hiddenEditorManager.d.ts +6 -0
- package/dist/controller/hiddenEditorManager.js +3 -1
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +7 -3
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +29 -13
- package/dist/document-operations.d.ts +13 -1
- package/dist/document-operations.js +11 -4
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/listNumberingInstances.d.ts +6 -4
- package/dist/docx/listNumberingInstances.js +12 -11
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- package/dist/docx/numberingIds.d.ts +10 -0
- package/dist/docx/numberingIds.js +5 -1
- package/dist/docx/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +16 -3
- package/dist/docx/paragraphProperties.js +2 -1
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -1
- package/dist/docx/rezip.js +4 -4
- package/dist/docx/serializer/paragraphSerializer.js +86 -66
- package/dist/docx/shapeAlternateContent.js +19 -0
- package/dist/docx/unzip.js +2 -0
- package/dist/i18n/messages/ar.gen.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +1 -1
- package/dist/internal/wholeStoryRevisionResolution.js +81 -21
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/runMarkFormatting.js +1 -0
- package/dist/layout-bridge/convert/tableConversion.js +6 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +7 -4
- package/dist/layout-engine/tableRowBreak.d.ts +10 -0
- package/dist/layout-engine/tableRowBreak.js +151 -36
- package/dist/layout-engine/types.d.ts +7 -2
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +6 -3
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +33 -19
- package/dist/markdown/renderRuns.js +68 -12
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/commands/comments.js +22 -7
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- package/dist/prosemirror/commands/resolveParagraphProperties.js +15 -2
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +19 -4
- package/dist/prosemirror/conversion/fromProseDoc.js +94 -22
- package/dist/prosemirror/conversion/hyphenTextCarriers.d.ts +23 -1
- package/dist/prosemirror/conversion/hyphenTextCarriers.js +46 -1
- package/dist/prosemirror/conversion/toProseDoc.js +21 -13
- package/dist/prosemirror/extensions/StarterKit.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +6 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +2 -1
- package/dist/prosemirror/extensions/markRegistry.d.ts +3 -1
- package/dist/prosemirror/extensions/markRegistry.js +3 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.js +54 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +87 -7
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/fieldRepresentation.js +2 -1
- package/dist/prosemirror/hyphenElementAttrs.d.ts +10 -0
- package/dist/prosemirror/hyphenElementAttrs.js +32 -0
- package/dist/prosemirror/keptRangeBoundaries.d.ts +2 -0
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.js +3 -2
- package/dist/prosemirror/paragraphIndentation.js +2 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -14
- package/dist/prosemirror/paragraphPropertyCarry.js +4 -28
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +194 -27
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -0
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -0
- package/dist/prosemirror/sectionCarrier.d.ts +8 -0
- package/dist/prosemirror/sectionCarrier.js +29 -1
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +10 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +12 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/tableRunIn.d.ts +24 -9
- package/dist/prosemirror/tableRunIn.js +107 -21
- package/dist/prosemirror/textInput.js +3 -1
- package/dist/prosemirror/validation.js +7 -1
- package/dist/utils/createDocument.js +11 -8
- package/dist/utils/formatToStyle.js +2 -2
- package/dist/utils/units.d.ts +5 -0
- package/dist/utils/units.js +6 -1
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mintListInstance } from "../../../docx/listNumberingInstances.js";
|
|
2
|
+
import { NO_NUMBERING_IDS_IN_USE } from "../../../docx/numberingIds.js";
|
|
2
3
|
import { createNumberingMap } from "../../../docx/numberingParser.js";
|
|
3
4
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
4
5
|
import { completeNumberingForDoc } from "../../listInstanceReferences.js";
|
|
@@ -93,7 +94,7 @@ const numberPastedHtmlLists = (slice, view) => {
|
|
|
93
94
|
const minted = mintListInstance(definitions, {
|
|
94
95
|
kind: hint.kind,
|
|
95
96
|
...hint.start === void 0 ? {} : { start: hint.start }
|
|
96
|
-
});
|
|
97
|
+
}, NO_NUMBERING_IDS_IN_USE);
|
|
97
98
|
definitions = minted.definitions;
|
|
98
99
|
numbering = createNumberingMap(definitions);
|
|
99
100
|
group = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MarkExtension } from "./types.js";
|
|
2
|
+
import { HyphenElementExtension } from "./marks/HyphenElementExtension.js";
|
|
2
3
|
export declare const MARK_EXTENSIONS: {
|
|
3
4
|
readonly bold: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
4
5
|
readonly italic: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
@@ -27,6 +28,7 @@ export declare const MARK_EXTENSIONS: {
|
|
|
27
28
|
readonly textEffect: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
28
29
|
readonly runFormattingOverride: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
29
30
|
readonly characterStyle: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
31
|
+
readonly hyphenElement: typeof HyphenElementExtension;
|
|
30
32
|
readonly runIdentity: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
31
33
|
readonly comment: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
32
34
|
readonly insertion: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
@@ -56,4 +58,4 @@ export type SchemaMarkName = keyof typeof MARK_EXTENSIONS;
|
|
|
56
58
|
* own in OOXML, so the save leg ranks it against nothing and its place here is
|
|
57
59
|
* a presentation decision.
|
|
58
60
|
*/
|
|
59
|
-
export declare const MARK_NESTING_ORDER: readonly ["bold", "italic", "underline", "strike", "textColor", "runShading", "highlight", "fontSize", "fontFamily", "language", "superscript", "subscript", "allCaps", "smallCaps", "footnoteRef", "characterSpacing", "emboss", "imprint", "hidden", "textShadow", "emphasisMark", "textOutline", "rtl", "textEffect", "runFormattingOverride", "characterStyle", "comment", "inlineWrapper", "insertion", "deletion", "hyperlink", "runPropertyChange", "runIdentity"];
|
|
61
|
+
export declare const MARK_NESTING_ORDER: readonly ["bold", "italic", "underline", "strike", "textColor", "runShading", "highlight", "fontSize", "fontFamily", "language", "superscript", "subscript", "allCaps", "smallCaps", "footnoteRef", "characterSpacing", "emboss", "imprint", "hidden", "textShadow", "emphasisMark", "textOutline", "rtl", "textEffect", "runFormattingOverride", "characterStyle", "hyphenElement", "comment", "inlineWrapper", "insertion", "deletion", "hyperlink", "runPropertyChange", "runIdentity"];
|
|
@@ -9,6 +9,7 @@ import { FootnoteRefExtension } from "./marks/FootnoteRefExtension.js";
|
|
|
9
9
|
import { HiddenTextExtension } from "./marks/HiddenTextExtension.js";
|
|
10
10
|
import { HighlightExtension } from "./marks/HighlightExtension.js";
|
|
11
11
|
import { HyperlinkExtension } from "./marks/HyperlinkExtension.js";
|
|
12
|
+
import { HyphenElementExtension } from "./marks/HyphenElementExtension.js";
|
|
12
13
|
import { InlineWrapperExtension } from "./marks/InlineWrapperExtension.js";
|
|
13
14
|
import { ItalicExtension } from "./marks/ItalicExtension.js";
|
|
14
15
|
import { LanguageExtension } from "./marks/LanguageExtension.js";
|
|
@@ -67,6 +68,7 @@ const MARK_EXTENSIONS = {
|
|
|
67
68
|
textEffect: TextEffectExtension,
|
|
68
69
|
runFormattingOverride: RunFormattingOverrideExtension,
|
|
69
70
|
characterStyle: CharacterStyleExtension,
|
|
71
|
+
hyphenElement: HyphenElementExtension,
|
|
70
72
|
runIdentity: RunIdentityExtension,
|
|
71
73
|
comment: CommentExtension,
|
|
72
74
|
insertion: InsertionExtension,
|
|
@@ -123,6 +125,7 @@ const MARK_NESTING_ORDER = markNestingOrder([
|
|
|
123
125
|
"textEffect",
|
|
124
126
|
"runFormattingOverride",
|
|
125
127
|
"characterStyle",
|
|
128
|
+
"hyphenElement",
|
|
126
129
|
"comment",
|
|
127
130
|
"inlineWrapper",
|
|
128
131
|
"insertion",
|
|
@@ -140,6 +140,11 @@ const HyperlinkExtension = createMarkExtension({
|
|
|
140
140
|
tooltip: tooltip || null
|
|
141
141
|
});
|
|
142
142
|
let tr = state.tr.addMark(from, to, mark);
|
|
143
|
+
state.doc.nodesBetween(from, to, (node, position) => {
|
|
144
|
+
if (node.type.name !== "field" && node.type.name !== "structuredField") return true;
|
|
145
|
+
tr = tr.removeMark(position, position + node.nodeSize, hlType);
|
|
146
|
+
return false;
|
|
147
|
+
});
|
|
143
148
|
const textColorType = state.schema.marks["textColor"];
|
|
144
149
|
if (textColorType) tr = tr.removeMark(from, to, textColorType);
|
|
145
150
|
dispatch(tr.scrollIntoView());
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { HYPHEN_ELEMENT_MARK_NAME } from "../../conversion/hyphenTextCarriers.js";
|
|
2
|
+
import { expectHyphenElementMarkAttrs } from "../../hyphenElementAttrs.js";
|
|
3
|
+
import { createMarkExtension } from "../create.js";
|
|
4
|
+
// src/prosemirror/extensions/marks/HyphenElementExtension.ts
|
|
5
|
+
/**
|
|
6
|
+
* Marks the native text that stands for a `w:softHyphen` or `w:noBreakHyphen`
|
|
7
|
+
* run child (ECMA-376 Part 1, 17.3.3.29 and 17.3.3.18).
|
|
8
|
+
*
|
|
9
|
+
* The editor renders both elements as their Unicode characters so line
|
|
10
|
+
* breaking and measurement treat them as text. The same characters may also be
|
|
11
|
+
* authored inside `w:t`, so without this mark the save leg could not tell
|
|
12
|
+
* which of the two the source held. Nothing is painted for it.
|
|
13
|
+
*
|
|
14
|
+
* Not inclusive, and each carrier in a paragraph has its own `id`: ProseMirror
|
|
15
|
+
* keeps a non-inclusive mark only where both neighbours hold an equal mark, so
|
|
16
|
+
* distinct ids mean a character typed beside or between carriers is text. The
|
|
17
|
+
* ids only tell neighbours apart. They can repeat after a paste beside the
|
|
18
|
+
* source or a paragraph join, which `hyphenElementRunContent` describes.
|
|
19
|
+
*
|
|
20
|
+
* External HTML must not be able to claim the element: `cleanPastedHtml` strips
|
|
21
|
+
* the attribute unless the slice carries the internal clipboard capability, so
|
|
22
|
+
* `toDOM` stamps that capability on every carrier it writes.
|
|
23
|
+
*/
|
|
24
|
+
const HYPHEN_ELEMENT_ATTRIBUTE = "data-docx-hyphen-element";
|
|
25
|
+
const CANONICAL_HYPHEN_ELEMENT_ID = /^(?:0|[1-9]\d*)$/u;
|
|
26
|
+
const HyphenElementExtension = createMarkExtension({
|
|
27
|
+
name: HYPHEN_ELEMENT_MARK_NAME,
|
|
28
|
+
schemaMarkName: HYPHEN_ELEMENT_MARK_NAME,
|
|
29
|
+
markSpec: (options) => ({
|
|
30
|
+
attrs: { id: {} },
|
|
31
|
+
inclusive: false,
|
|
32
|
+
parseDOM: [{
|
|
33
|
+
tag: `span[${HYPHEN_ELEMENT_ATTRIBUTE}]`,
|
|
34
|
+
getAttrs(dom) {
|
|
35
|
+
const rawId = dom.getAttribute(HYPHEN_ELEMENT_ATTRIBUTE);
|
|
36
|
+
if (rawId === null || !CANONICAL_HYPHEN_ELEMENT_ID.test(rawId)) return false;
|
|
37
|
+
const id = Number(rawId);
|
|
38
|
+
return Number.isSafeInteger(id) ? { id } : false;
|
|
39
|
+
}
|
|
40
|
+
}],
|
|
41
|
+
toDOM(mark) {
|
|
42
|
+
const { id } = expectHyphenElementMarkAttrs(mark);
|
|
43
|
+
return [
|
|
44
|
+
"span",
|
|
45
|
+
{
|
|
46
|
+
[HYPHEN_ELEMENT_ATTRIBUTE]: String(id),
|
|
47
|
+
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
48
|
+
},
|
|
49
|
+
0
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
export { HyphenElementExtension };
|
|
@@ -22,7 +22,7 @@ const TextColorExtension = createMarkExtension({
|
|
|
22
22
|
parseDOM: [{
|
|
23
23
|
style: "color",
|
|
24
24
|
getAttrs: (value) => {
|
|
25
|
-
const hexMatch =
|
|
25
|
+
const hexMatch = /^#(?<hex>[0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/u.exec(value);
|
|
26
26
|
if (hexMatch) return { rgb: (hexMatch.groups?.["hex"] ?? "").toUpperCase() };
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
@@ -16,9 +16,13 @@ import { authorFromClipboardRevision } from "../features/clipboardTrackedRevisio
|
|
|
16
16
|
* ProseMirror toDOM runs before the layout painter, so we set the
|
|
17
17
|
* decoration here for correct rendering in both the layout-painter
|
|
18
18
|
* path and the ProseMirror DOM path.
|
|
19
|
+
*
|
|
20
|
+
* The line is a longhand because the underline and strike parse rules read the
|
|
21
|
+
* `text-decoration` shorthand. A review mark's presentation is not run
|
|
22
|
+
* formatting, and ProseMirror reads this DOM back on every native edit.
|
|
19
23
|
*/
|
|
20
|
-
const insertionStyle = (color) => `color: ${color}; text-decoration: underline; text-decoration-color: ${color};`;
|
|
21
|
-
const deletionStyle = (color) => `color: ${color}; text-decoration: line-through; text-decoration-color: ${color};`;
|
|
24
|
+
const insertionStyle = (color) => `color: ${color}; text-decoration-line: underline; text-decoration-color: ${color};`;
|
|
25
|
+
const deletionStyle = (color) => `color: ${color}; text-decoration-line: line-through; text-decoration-color: ${color};`;
|
|
22
26
|
/**
|
|
23
27
|
* Suggested (AI-proposed) tracked changes reuse the insertion/deletion visual
|
|
24
28
|
* grammar but with a DOTTED stroke and a dedicated suggestion hue, kept
|
|
@@ -31,8 +35,8 @@ const deletionStyle = (color) => `color: ${color}; text-decoration: line-through
|
|
|
31
35
|
const SUGGESTION_COLOR = "var(--suggestion-color, #6d3bd6)";
|
|
32
36
|
const SUGGESTION_TINT = "var(--suggestion-bg, color-mix(in oklch, #6d3bd6 12%, transparent))";
|
|
33
37
|
const SUGGESTION_TINT_LAYER = `linear-gradient(${SUGGESTION_TINT}, ${SUGGESTION_TINT})`;
|
|
34
|
-
const suggestedInsertionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration: underline; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
|
|
35
|
-
const suggestedDeletionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration: line-through; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
|
|
38
|
+
const suggestedInsertionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
|
|
39
|
+
const suggestedDeletionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration-line: line-through; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
|
|
36
40
|
const revisionAncestorsFromDom = (serialized) => {
|
|
37
41
|
if (serialized === void 0) return null;
|
|
38
42
|
try {
|
|
@@ -4,6 +4,7 @@ import { findInvalidBookmarkBoundaryIds } from "../../bookmarkBoundaryIntegrity.
|
|
|
4
4
|
import { createNodeExtension } from "../create.js";
|
|
5
5
|
import { BLOCK_BOOKMARK_BOUNDARY_NODE_NAME } from "./BlockBookmarkBoundaryExtension.js";
|
|
6
6
|
import { bookmarkBoundaryAttrSpec, bookmarkBoundaryDomAttributes, parseBookmarkBoundaryDom } from "./bookmarkBoundaryDom.js";
|
|
7
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
7
8
|
import { Plugin } from "prosemirror-state";
|
|
8
9
|
// src/prosemirror/extensions/nodes/BookmarkBoundaryExtension.ts
|
|
9
10
|
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
@@ -73,7 +74,10 @@ const BookmarkBoundaryExtension = createNodeExtension({
|
|
|
73
74
|
getAttrs: (dom) => parseBookmarkBoundaryDom(dom, options.getInternalClipboardToken?.())
|
|
74
75
|
}],
|
|
75
76
|
toDOM(node) {
|
|
76
|
-
return ["span",
|
|
77
|
+
return ["span", {
|
|
78
|
+
...bookmarkBoundaryDomAttributes(node, options.getInternalClipboardToken?.()),
|
|
79
|
+
style: INLINE_ANCHOR_DOM_STYLE
|
|
80
|
+
}];
|
|
77
81
|
}
|
|
78
82
|
}),
|
|
79
83
|
onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, _oldState, newState) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { expectCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker } from "../../commentRangeBoundaryAttrs.js";
|
|
2
2
|
import { createNodeExtension } from "../create.js";
|
|
3
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
3
4
|
// src/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.ts
|
|
4
5
|
const COMMENT_RANGE_BOUNDARY_NODE_NAME = "commentRangeBoundary";
|
|
5
6
|
const COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE = "data-docx-comment-range-boundary";
|
|
@@ -33,7 +34,7 @@ const CommentRangeBoundaryExtension = createNodeExtension({
|
|
|
33
34
|
[COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE]: JSON.stringify(marker),
|
|
34
35
|
"aria-hidden": "true",
|
|
35
36
|
contenteditable: "false",
|
|
36
|
-
style:
|
|
37
|
+
style: INLINE_ANCHOR_DOM_STYLE,
|
|
37
38
|
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
38
39
|
}];
|
|
39
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readCommentReferenceAttrs } from "../../commentReferenceAttrs.js";
|
|
2
2
|
import { COMMENT_REFERENCE_NODE_NAME, resolveCommentReferences } from "../../commentReferenceIntegrity.js";
|
|
3
3
|
import { createNodeExtension } from "../create.js";
|
|
4
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
4
5
|
import { Plugin } from "prosemirror-state";
|
|
5
6
|
// src/prosemirror/extensions/nodes/CommentReferenceExtension.ts
|
|
6
7
|
/** Zero-width `w:commentReference`: where a comment's visible mark is painted. */
|
|
@@ -29,14 +30,14 @@ const CommentReferenceExtension = createNodeExtension({
|
|
|
29
30
|
"data-docx-comment-reference": String(attrs.ok ? attrs.value.commentId : ""),
|
|
30
31
|
"aria-hidden": "true",
|
|
31
32
|
contenteditable: "false",
|
|
32
|
-
style:
|
|
33
|
+
style: INLINE_ANCHOR_DOM_STYLE,
|
|
33
34
|
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
34
35
|
}];
|
|
35
36
|
}
|
|
36
37
|
}),
|
|
37
|
-
onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions,
|
|
38
|
+
onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, oldState, newState) {
|
|
38
39
|
if (!transactions.some(({ docChanged }) => docChanged)) return null;
|
|
39
|
-
const resolution = resolveCommentReferences(newState.doc);
|
|
40
|
+
const resolution = resolveCommentReferences(newState.doc, oldState.doc);
|
|
40
41
|
if (!resolution) return null;
|
|
41
42
|
const transaction = newState.tr;
|
|
42
43
|
for (const step of resolution.steps) transaction.step(step);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE, isInternalClipboardDom } from "../../copyOriginDom.js";
|
|
2
2
|
import { expectMoveRangeBoundaryAttrs, moveRangeMarkerForDom, readMoveRangeMarker, withoutUntrustedCopyOrigin } from "../../moveRangeBoundaryAttrs.js";
|
|
3
3
|
import { createNodeExtension } from "../create.js";
|
|
4
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
4
5
|
// src/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.ts
|
|
5
6
|
/** Hidden boundary for one non-empty tracked-move range. */
|
|
6
7
|
const MOVE_RANGE_BOUNDARY_NODE_NAME = "moveRangeBoundary";
|
|
@@ -37,7 +38,7 @@ const MoveRangeBoundaryExtension = createNodeExtension({
|
|
|
37
38
|
[MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE]: JSON.stringify(marker),
|
|
38
39
|
"aria-hidden": "true",
|
|
39
40
|
contenteditable: "false",
|
|
40
|
-
style:
|
|
41
|
+
style: INLINE_ANCHOR_DOM_STYLE,
|
|
41
42
|
...internalClipboardToken ? { [INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE]: internalClipboardToken } : {}
|
|
42
43
|
}];
|
|
43
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { expectNoteMarkerAttrs } from "../../../internal/noteMarkerAttrs.js";
|
|
2
2
|
import { createNodeExtension } from "../create.js";
|
|
3
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
3
4
|
// src/prosemirror/extensions/nodes/NoteMarkerExtension.ts
|
|
4
5
|
/** An authored automatic note mark: invisible, but retained through PM JSON and edits. */
|
|
5
6
|
const NOTE_MARKER_NODE_NAME = "noteMarker";
|
|
@@ -27,7 +28,7 @@ const NoteMarkerExtension = createNodeExtension({
|
|
|
27
28
|
"data-docx-note-marker": kind,
|
|
28
29
|
"aria-hidden": "true",
|
|
29
30
|
contenteditable: "false",
|
|
30
|
-
style:
|
|
31
|
+
style: INLINE_ANCHOR_DOM_STYLE
|
|
31
32
|
}];
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -3,6 +3,7 @@ import { INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE, isInternalClipboardDom } from "../.
|
|
|
3
3
|
import { withoutUntrustedCopyOrigin } from "../../moveRangeBoundaryAttrs.js";
|
|
4
4
|
import { readRangeAnchorAttrs, readRangeAnchorValues } from "../../rangeAnchorAttrs.js";
|
|
5
5
|
import { createNodeExtension } from "../create.js";
|
|
6
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
6
7
|
// src/prosemirror/extensions/nodes/RangeAnchorExtension.ts
|
|
7
8
|
/** Zero-width comment or tracked-move range that spans no content. */
|
|
8
9
|
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
@@ -52,7 +53,7 @@ const RangeAnchorExtension = createNodeExtension({
|
|
|
52
53
|
[RANGE_ANCHOR_DOM_ATTRIBUTE]: serializedMarkers,
|
|
53
54
|
"aria-hidden": "true",
|
|
54
55
|
contenteditable: "false",
|
|
55
|
-
style:
|
|
56
|
+
style: INLINE_ANCHOR_DOM_STYLE,
|
|
56
57
|
...internalClipboardToken ? { [INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE]: internalClipboardToken } : {}
|
|
57
58
|
}];
|
|
58
59
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createNodeExtension } from "../create.js";
|
|
2
|
+
import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
|
|
2
3
|
// src/prosemirror/extensions/nodes/RenderedPageBreakExtension.ts
|
|
3
4
|
/** Zero-width cached pagination boundary preserved from DOCX. */
|
|
4
5
|
/**
|
|
@@ -19,7 +20,7 @@ const RenderedPageBreakExtension = createNodeExtension({
|
|
|
19
20
|
toDOM() {
|
|
20
21
|
return ["span", {
|
|
21
22
|
"data-docx-rendered-page-break": "true",
|
|
22
|
-
style:
|
|
23
|
+
style: INLINE_ANCHOR_DOM_STYLE
|
|
23
24
|
}];
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion } from "../../../ai-edits/table-row-column-mutations.js";
|
|
1
2
|
import { setTableLookFlags } from "../../../docx/tableLook.js";
|
|
2
3
|
import { TABLE_JUSTIFICATION_VALUES, TABLE_WIDTH_TYPE_VALUES, TEXT_DIRECTION_VALUES } from "../../../types/documentEnumValues.js";
|
|
3
4
|
import { cssBorderStyle } from "../../../utils/borderCss.js";
|
|
@@ -5,9 +6,11 @@ import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
|
|
|
5
6
|
import { resolveTablePlacementAlignment } from "../../../utils/tablePlacement.js";
|
|
6
7
|
import { textFlowCss } from "../../../utils/textDirectionFlow.js";
|
|
7
8
|
import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
|
|
9
|
+
import { mintRevisionId } from "../../plugins/revisionIds.js";
|
|
8
10
|
import { makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
9
11
|
import { pasteTableCells, pastedSliceWithNewTableCells } from "../../tableCellPaste.js";
|
|
10
12
|
import { insertTableColumn, removeTableColumns, removeTableRow } from "../../tableGridMutation.js";
|
|
13
|
+
import { tablePositionedBookmarksPlugin } from "../../tablePositionedBookmarks.js";
|
|
11
14
|
import { createExtension, createNodeExtension } from "../create.js";
|
|
12
15
|
import { panic } from "better-result";
|
|
13
16
|
import { statesNoBorder } from "@stll/docx-core/model";
|
|
@@ -37,9 +40,31 @@ const hasOmittedGridSlots = (table) => {
|
|
|
37
40
|
});
|
|
38
41
|
return found;
|
|
39
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* With Track Changes on, a revision for a structural table edit touching `count`
|
|
45
|
+
* cells or rows. Each takes the next id of a run reserved here, as the document
|
|
46
|
+
* operations do.
|
|
47
|
+
*/
|
|
48
|
+
const trackedTableRevision = (state, count) => {
|
|
49
|
+
const info = makeRevisionInfo(state);
|
|
50
|
+
if (!info) return null;
|
|
51
|
+
for (let reserved = 1; reserved < count; reserved += 1) mintRevisionId();
|
|
52
|
+
return {
|
|
53
|
+
revisionId: info.id,
|
|
54
|
+
author: info.author,
|
|
55
|
+
date: info.date
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A merged cell cannot run through a position a row omits, nor is that position
|
|
60
|
+
* a cell to split: the file has nothing there to hold either.
|
|
61
|
+
*/
|
|
40
62
|
const preserveOmittedGridSlots = (command) => (state, dispatch, view) => {
|
|
41
63
|
const { table } = getTableContext(state);
|
|
42
|
-
if (table && hasOmittedGridSlots(table))
|
|
64
|
+
if (table && hasOmittedGridSlots(table)) {
|
|
65
|
+
const rect = selectedRect(state);
|
|
66
|
+
if (rect.map.cellsInRect(rect).some((position) => isOmittedGridSlot(expectTableCellAttrs(rect.table.nodeAt(position) ?? table)._omittedGridSlot))) return false;
|
|
67
|
+
}
|
|
43
68
|
return command(state, dispatch, view);
|
|
44
69
|
};
|
|
45
70
|
const preserveSourceCellIdentity = (command) => (state, dispatch, view) => {
|
|
@@ -827,7 +852,7 @@ const TablePluginExtension = createExtension({
|
|
|
827
852
|
*/
|
|
828
853
|
function insertTableRow(state, dispatch, boundaryOffset) {
|
|
829
854
|
const context = getTableContext(state);
|
|
830
|
-
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0
|
|
855
|
+
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
|
|
831
856
|
if (!dispatch) return true;
|
|
832
857
|
const { table, tablePos } = context;
|
|
833
858
|
const rect = selectedRect(state);
|
|
@@ -854,9 +879,11 @@ const TablePluginExtension = createExtension({
|
|
|
854
879
|
continue;
|
|
855
880
|
}
|
|
856
881
|
const templatePos = below ?? above;
|
|
857
|
-
|
|
882
|
+
const templateCell = templatePos === void 0 ? null : table.nodeAt(templatePos);
|
|
883
|
+
const omitted = templateCell?.attrs["_omittedGridSlot"] != null;
|
|
884
|
+
if (templatePos === void 0 || !omitted && templatePos === lastTemplatePos) continue;
|
|
858
885
|
lastTemplatePos = templatePos;
|
|
859
|
-
const template =
|
|
886
|
+
const template = omitted ? null : templateCell;
|
|
860
887
|
cells.push((template?.type ?? tableNodeTypes(state.schema).cell).create(buildCellAttrsFromTemplate(template), paragraphType?.create() ?? null));
|
|
861
888
|
}
|
|
862
889
|
const rowNode = table.child(boundaryOffset === 0 ? rect.top : rect.bottom - 1);
|
|
@@ -879,7 +906,6 @@ const TablePluginExtension = createExtension({
|
|
|
879
906
|
function deleteRow(state, dispatch) {
|
|
880
907
|
const context = getTableContext(state);
|
|
881
908
|
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
|
|
882
|
-
if (hasOmittedGridSlots(context.table)) return false;
|
|
883
909
|
const tablePos = context.tablePos;
|
|
884
910
|
const table = context.table;
|
|
885
911
|
const rowCount = context.rowCount ?? 0;
|
|
@@ -897,6 +923,30 @@ const TablePluginExtension = createExtension({
|
|
|
897
923
|
const coversAllRows = firstRow === 0 && lastRow >= rowCount - 1;
|
|
898
924
|
if (dispatch) {
|
|
899
925
|
const tr = state.tr;
|
|
926
|
+
const revision = trackedTableRevision(state, lastRow - firstRow + 1);
|
|
927
|
+
if (revision) {
|
|
928
|
+
const rows = [];
|
|
929
|
+
table.forEach((_row, offset, rowIndex) => {
|
|
930
|
+
if (rowIndex >= firstRow && rowIndex <= lastRow) rows.push({
|
|
931
|
+
rowIndex,
|
|
932
|
+
rowPosition: tablePos + 1 + offset
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
for (const [index, row] of rows.entries()) applyTableRowDeletion({
|
|
936
|
+
tr,
|
|
937
|
+
deletion: {
|
|
938
|
+
...row,
|
|
939
|
+
tablePosition: tablePos,
|
|
940
|
+
tableStart: tablePos + 1
|
|
941
|
+
},
|
|
942
|
+
revision: {
|
|
943
|
+
...revision,
|
|
944
|
+
revisionId: revision.revisionId + index
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
dispatch(tr.scrollIntoView());
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
900
950
|
if (coversAllRows) {
|
|
901
951
|
const tableEnd = tablePos + table.nodeSize;
|
|
902
952
|
const emptyParagraph = state.doc.resolve(tablePos).parent.childCount === 1 ? state.schema.nodes["paragraph"]?.createAndFill() : null;
|
|
@@ -931,7 +981,22 @@ const TablePluginExtension = createExtension({
|
|
|
931
981
|
*/
|
|
932
982
|
function insertColumnBeside(state, dispatch, side) {
|
|
933
983
|
const context = getTableContext(state);
|
|
934
|
-
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0
|
|
984
|
+
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0) return false;
|
|
985
|
+
if (makeRevisionInfo(state) !== null) {
|
|
986
|
+
const rect = selectedRect(state);
|
|
987
|
+
const tr = state.tr;
|
|
988
|
+
if (applyTableColumnInsertion({
|
|
989
|
+
tr,
|
|
990
|
+
insertion: {
|
|
991
|
+
tablePosition: rect.tableStart - 1,
|
|
992
|
+
columnIndex: side === "left" ? rect.left : rect.right
|
|
993
|
+
},
|
|
994
|
+
cellTexts: void 0,
|
|
995
|
+
revision: trackedTableRevision(state, rect.map.height)
|
|
996
|
+
}).type !== "applied") return false;
|
|
997
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
998
|
+
return true;
|
|
999
|
+
}
|
|
935
1000
|
if (dispatch) {
|
|
936
1001
|
const rect = selectedRect(state);
|
|
937
1002
|
const tr = state.tr;
|
|
@@ -968,9 +1033,23 @@ const TablePluginExtension = createExtension({
|
|
|
968
1033
|
*/
|
|
969
1034
|
function deleteColumn(state, dispatch) {
|
|
970
1035
|
const context = getTableContext(state);
|
|
971
|
-
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1
|
|
1036
|
+
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1) return false;
|
|
972
1037
|
const rect = selectedRect(state);
|
|
973
1038
|
if (rect.right - rect.left >= rect.map.width) return false;
|
|
1039
|
+
if (makeRevisionInfo(state) !== null) {
|
|
1040
|
+
const tr = state.tr;
|
|
1041
|
+
for (let column = rect.left; column < rect.right; column += 1) if (applyTableColumnDeletion({
|
|
1042
|
+
tr,
|
|
1043
|
+
deletion: {
|
|
1044
|
+
tablePosition: rect.tableStart - 1,
|
|
1045
|
+
columnIndex: column
|
|
1046
|
+
},
|
|
1047
|
+
insertedColumnCount: 0,
|
|
1048
|
+
revision: trackedTableRevision(state, rect.map.height)
|
|
1049
|
+
}).type !== "applied") return false;
|
|
1050
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
974
1053
|
if (dispatch) {
|
|
975
1054
|
const tr = state.tr;
|
|
976
1055
|
removeTableColumns(tr, rect.tableStart - 1, rect.left, rect.right);
|
|
@@ -1917,6 +1996,7 @@ const TablePluginExtension = createExtension({
|
|
|
1917
1996
|
}),
|
|
1918
1997
|
tableCellPastePlugin,
|
|
1919
1998
|
tableEditing(),
|
|
1999
|
+
tablePositionedBookmarksPlugin(),
|
|
1920
2000
|
activeCellPlugin
|
|
1921
2001
|
],
|
|
1922
2002
|
keyboardShortcuts: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
/**
|
|
3
|
+
* How an inline node with no visible content sits in the editor's DOM.
|
|
4
|
+
*
|
|
5
|
+
* It takes no space, but it keeps a box. A browser's editing commands skip what
|
|
6
|
+
* has no box, so replacing the composition text beside a `display: none` element
|
|
7
|
+
* also removed the element, and the next DOM read lost the node it stood for.
|
|
8
|
+
*/
|
|
9
|
+
export declare const INLINE_ANCHOR_DOM_STYLE = "display: inline-block; width: 0; height: 0; overflow: hidden;";
|
|
10
|
+
/** Whether a node is one of those, which the caret passes without stopping. */
|
|
11
|
+
export declare const isInlineAnchor: (node: Node) => boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/prosemirror/extensions/nodes/inlineAnchorDom.ts
|
|
2
|
+
/**
|
|
3
|
+
* How an inline node with no visible content sits in the editor's DOM.
|
|
4
|
+
*
|
|
5
|
+
* It takes no space, but it keeps a box. A browser's editing commands skip what
|
|
6
|
+
* has no box, so replacing the composition text beside a `display: none` element
|
|
7
|
+
* also removed the element, and the next DOM read lost the node it stood for.
|
|
8
|
+
*/
|
|
9
|
+
const INLINE_ANCHOR_DOM_STYLE = "display: inline-block; width: 0; height: 0; overflow: hidden;";
|
|
10
|
+
const INLINE_ANCHOR_NODE_NAMES = /* @__PURE__ */ new Set([
|
|
11
|
+
"bookmarkBoundary",
|
|
12
|
+
"commentRangeBoundary",
|
|
13
|
+
"commentReference",
|
|
14
|
+
"moveRangeBoundary",
|
|
15
|
+
"noteMarker",
|
|
16
|
+
"rangeAnchor",
|
|
17
|
+
"renderedPageBreak"
|
|
18
|
+
]);
|
|
19
|
+
/** Whether a node is one of those, which the caret passes without stopping. */
|
|
20
|
+
const isInlineAnchor = (node) => INLINE_ANCHOR_NODE_NAMES.has(node.type.name);
|
|
21
|
+
export { INLINE_ANCHOR_DOM_STYLE, isInlineAnchor };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./conversion/hyphenTextCarriers.js";
|
|
1
2
|
import "./extensions/marks/InlineWrapperExtension.js";
|
|
2
3
|
import { getInlineDisplayText } from "./inlineDisplayText.js";
|
|
3
4
|
import "./runIdentity.js";
|
|
@@ -11,7 +12,7 @@ const fieldCommentCoverage = (fieldKind) => FIELD_COMMENT_COVERAGE[fieldKind];
|
|
|
11
12
|
/** Current children alone decide whether a field needs editable structural content. */
|
|
12
13
|
const fieldRequiresStructuredContent = (children) => {
|
|
13
14
|
const first = children.at(0);
|
|
14
|
-
return children.some((child) => !child.isText || first !== void 0 && !Mark.sameSet(first.marks, child.marks) || child.marks.some((mark) => mark.type.name === "runIdentity" || mark.type.name === "footnoteRef" || mark.type.name === "hyperlink" || mark.type.name === "inlineWrapper" || mark.type.name === "insertion" || mark.type.name === "deletion"));
|
|
15
|
+
return children.some((child) => !child.isText || first !== void 0 && !Mark.sameSet(first.marks, child.marks) || child.marks.some((mark) => mark.type.name === "runIdentity" || mark.type.name === "hyphenElement" || mark.type.name === "footnoteRef" || mark.type.name === "hyperlink" || mark.type.name === "inlineWrapper" || mark.type.name === "insertion" || mark.type.name === "deletion"));
|
|
15
16
|
};
|
|
16
17
|
/** Resolution collapses a field only when the atom can retain its result. */
|
|
17
18
|
const canonicalFieldNode = (node) => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReadProseMirrorAttrsResult } from "../internal/prosemirrorAttrBoundary.js";
|
|
2
|
+
import "./attrs/index.js";
|
|
3
|
+
import { Mark } from "prosemirror-model";
|
|
4
|
+
type HyphenElementMarkAttrs = {
|
|
5
|
+
/** Tells this carrier from its neighbours. Monotonic within one paragraph. */
|
|
6
|
+
id: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const readHyphenElementMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<HyphenElementMarkAttrs>;
|
|
9
|
+
export declare const expectHyphenElementMarkAttrs: (mark: Mark) => HyphenElementMarkAttrs;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
// src/prosemirror/hyphenElementAttrs.ts
|
|
3
|
+
const readHyphenElementMarkAttrs = (mark) => {
|
|
4
|
+
const id = mark.attrs["id"];
|
|
5
|
+
if (mark.type.name !== "hyphenElement") return {
|
|
6
|
+
ok: false,
|
|
7
|
+
issues: [{
|
|
8
|
+
path: "mark.type.name",
|
|
9
|
+
message: `Expected hyphenElement, got ${mark.type.name}.`
|
|
10
|
+
}]
|
|
11
|
+
};
|
|
12
|
+
if (typeof id !== "number" || !Number.isSafeInteger(id) || id < 0) return {
|
|
13
|
+
ok: false,
|
|
14
|
+
issues: [{
|
|
15
|
+
path: "hyphenElement.attrs.id",
|
|
16
|
+
message: "Expected a non-negative safe integer."
|
|
17
|
+
}]
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
ok: true,
|
|
21
|
+
value: { id }
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const expectHyphenElementMarkAttrs = (mark) => {
|
|
25
|
+
const result = readHyphenElementMarkAttrs(mark);
|
|
26
|
+
if (!result.ok) {
|
|
27
|
+
const details = result.issues.map((issue) => `${issue.path}: ${issue.message}`).join("\n");
|
|
28
|
+
panic(`Invalid ProseMirror hyphen element attrs:\n${details}`);
|
|
29
|
+
}
|
|
30
|
+
return result.value;
|
|
31
|
+
};
|
|
32
|
+
export { expectHyphenElementMarkAttrs, readHyphenElementMarkAttrs };
|
|
@@ -6,6 +6,8 @@ import { Transaction } from "prosemirror-state";
|
|
|
6
6
|
type BoundaryItem = Extract<document_d_exports.ParagraphContent, {
|
|
7
7
|
type: "bookmarkStart" | "bookmarkEnd" | "commentRangeStart" | "commentRangeEnd" | "moveFromRangeStart" | "moveFromRangeEnd" | "moveToRangeStart" | "moveToRangeEnd";
|
|
8
8
|
}>;
|
|
9
|
+
/** The marks that say a node is in a revision: its wrappers, in the engine. */
|
|
10
|
+
export declare const REVISION_MARK_NAMES: ReadonlySet<string>;
|
|
9
11
|
/** The range boundaries `node` carries; none for any other node. */
|
|
10
12
|
export declare const rangeBoundaryItemsOf: (node: Node) => readonly BoundaryItem[];
|
|
11
13
|
/** Range boundary nodes, as the nodes that stand for them between blocks. */
|
|
@@ -377,4 +377,4 @@ const removeResolvedSubtree = (node, selection) => {
|
|
|
377
377
|
if (selection.mode === "reject") visit(node);
|
|
378
378
|
return { kept };
|
|
379
379
|
};
|
|
380
|
-
export { blockBoundariesOf, carriesCommentAnchor, inlineBoundariesOf, isBlockBoundaryNode, normalizeKeptRangeBoundaries, paragraphRemainsOf, rangeBoundaryItemsOf, removeResolvedSubtree, revisionLayerRemovesContent };
|
|
380
|
+
export { REVISION_MARK_NAMES, blockBoundariesOf, carriesCommentAnchor, inlineBoundariesOf, isBlockBoundaryNode, normalizeKeptRangeBoundaries, paragraphRemainsOf, rangeBoundaryItemsOf, removeResolvedSubtree, revisionLayerRemovesContent };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mintListInstance, restartListInstance } from "../docx/listNumberingInstances.js";
|
|
2
|
+
import { NO_NUMBERING_IDS_IN_USE } from "../docx/numberingIds.js";
|
|
2
3
|
import { createNumberingMap, isBulletLevel } from "../docx/numberingParser.js";
|
|
3
4
|
import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
4
5
|
import { expectParagraphAttrs } from "./attrs/index.js";
|
|
@@ -179,7 +180,7 @@ const resolveListTarget = ({ numbering, $from, $to, requests }) => {
|
|
|
179
180
|
ilvl: 0,
|
|
180
181
|
numbering
|
|
181
182
|
};
|
|
182
|
-
const minted = mintListInstance(numbering?.definitions, first);
|
|
183
|
+
const minted = mintListInstance(numbering?.definitions, first, NO_NUMBERING_IDS_IN_USE);
|
|
183
184
|
return {
|
|
184
185
|
numId: minted.numId,
|
|
185
186
|
ilvl: 0,
|
|
@@ -289,7 +290,7 @@ const setNumberingValue = (value) => withCanonicalCommand((state, dispatch) => {
|
|
|
289
290
|
abstractNumId,
|
|
290
291
|
ilvl: selected.membership.ilvl,
|
|
291
292
|
start: value
|
|
292
|
-
});
|
|
293
|
+
}, NO_NUMBERING_IDS_IN_USE);
|
|
293
294
|
dispatch(moveItems({
|
|
294
295
|
state,
|
|
295
296
|
items: itemsFrom(state, selected.membership.numId, selected.pos),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hangingFirstLineIndent } from "../utils/units.js";
|
|
1
2
|
import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "./numberingAttr.js";
|
|
2
3
|
import { panic } from "better-result";
|
|
3
4
|
// src/prosemirror/paragraphIndentation.ts
|
|
@@ -70,7 +71,7 @@ const directParagraphIndentation = (attrs) => {
|
|
|
70
71
|
if (indentation.indentFirstLine !== void 0) {
|
|
71
72
|
const hanging = attrs.hangingIndent === true;
|
|
72
73
|
indentation.hangingIndent = hanging;
|
|
73
|
-
if (hanging) indentation.indentFirstLine =
|
|
74
|
+
if (hanging) indentation.indentFirstLine = hangingFirstLineIndent(indentation.indentFirstLine);
|
|
74
75
|
} else if (original?.hangingIndent !== void 0 && original.indentFirstLine === void 0 && typeof attrs.hangingIndent === "boolean") indentation.hangingIndent = attrs.hangingIndent;
|
|
75
76
|
return Object.keys(indentation).length > 0 ? indentation : void 0;
|
|
76
77
|
};
|