@superdoc-dev/cli 0.5.0-next.42 → 0.5.0-next.43
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/index.js +1436 -1001
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -173461,7 +173461,7 @@ var init_remark_gfm_DCND_V_3_es = __esm(() => {
|
|
|
173461
173461
|
init_remark_gfm_BUJjZJLy_es();
|
|
173462
173462
|
});
|
|
173463
173463
|
|
|
173464
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
173464
|
+
// ../../packages/superdoc/dist/chunks/src-DIxjKbQ9.es.js
|
|
173465
173465
|
function deleteProps(obj, propOrProps) {
|
|
173466
173466
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
173467
173467
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -182066,10 +182066,11 @@ function replaceCommand(wrap5, moveForward) {
|
|
|
182066
182066
|
return true;
|
|
182067
182067
|
};
|
|
182068
182068
|
}
|
|
182069
|
-
function
|
|
182070
|
-
|
|
182071
|
-
|
|
182072
|
-
|
|
182069
|
+
function buildSdtBlockSelector(escapedSdtId) {
|
|
182070
|
+
return `.${DOM_CLASS_NAMES.BLOCK_SDT}[${DATA_ATTRS.SDT_ID}="${escapedSdtId}"]`;
|
|
182071
|
+
}
|
|
182072
|
+
function buildAnnotationSelector() {
|
|
182073
|
+
return `.${DOM_CLASS_NAMES.ANNOTATION}[${DATA_ATTRS.PM_START}]`;
|
|
182073
182074
|
}
|
|
182074
182075
|
function isPresenting(editor) {
|
|
182075
182076
|
const presentationCtx = editor?.presentationEditor;
|
|
@@ -211889,289 +211890,22 @@ function preferFullRestoredWhenPartial(current, previousRanges, doc$12, docSize)
|
|
|
211889
211890
|
return current;
|
|
211890
211891
|
return currentSpan.from >= restoredSpan.from && currentSpan.to <= restoredSpan.to && restoredSpan.to - restoredSpan.from > currentSpan.to - currentSpan.from ? restored : current;
|
|
211891
211892
|
}
|
|
211892
|
-
function
|
|
211893
|
-
|
|
211894
|
-
|
|
211895
|
-
|
|
211896
|
-
|
|
211897
|
-
|
|
211898
|
-
|
|
211899
|
-
|
|
211900
|
-
|
|
211901
|
-
|
|
211902
|
-
const runLanguage = findFirstRunLanguage(paraNode);
|
|
211903
|
-
if (runLanguage)
|
|
211904
|
-
return runLanguage;
|
|
211905
|
-
const paraLang = extractParagraphLanguage(paraNode);
|
|
211906
|
-
if (paraLang)
|
|
211907
|
-
return paraLang;
|
|
211908
|
-
return defaultLanguage;
|
|
211909
|
-
}
|
|
211910
|
-
function findFirstRunLanguage(paraNode) {
|
|
211911
|
-
let lang = null;
|
|
211912
|
-
paraNode.descendants((node3) => {
|
|
211913
|
-
if (lang)
|
|
211914
|
-
return false;
|
|
211915
|
-
if (node3.type.name === "run") {
|
|
211916
|
-
const runProps = node3.attrs.runProperties;
|
|
211917
|
-
if (runProps?.lang?.val) {
|
|
211918
|
-
lang = runProps.lang.val;
|
|
211919
|
-
return false;
|
|
211920
|
-
}
|
|
211921
|
-
}
|
|
211922
|
-
return true;
|
|
211923
|
-
});
|
|
211924
|
-
return lang;
|
|
211925
|
-
}
|
|
211926
|
-
function extractParagraphLanguage(paraNode) {
|
|
211927
|
-
return paraNode.attrs.paragraphProperties?.lang?.val ?? null;
|
|
211928
|
-
}
|
|
211929
|
-
function extractSegmentsWithMaps(doc$12, defaultLanguage, pageResolver) {
|
|
211930
|
-
const segments = [];
|
|
211931
|
-
const offsetMaps = /* @__PURE__ */ new Map;
|
|
211932
|
-
const segmentPositions = /* @__PURE__ */ new Map;
|
|
211933
|
-
walkParagraphs(doc$12, (paraNode, paraPos, surface) => {
|
|
211934
|
-
const { text: text5, slices } = extractParagraphText(paraNode, paraPos);
|
|
211935
|
-
if (text5.length === 0)
|
|
211936
|
-
return;
|
|
211937
|
-
const segmentId = buildSegmentId(paraNode, paraPos);
|
|
211938
|
-
const language = resolveSegmentLanguage(paraNode, defaultLanguage ?? null);
|
|
211939
|
-
const pageIndex = pageResolver?.(paraPos);
|
|
211940
|
-
segments.push({
|
|
211941
|
-
id: segmentId,
|
|
211942
|
-
text: text5,
|
|
211943
|
-
language,
|
|
211944
|
-
metadata: {
|
|
211945
|
-
blockId: paraNode.attrs.sdBlockId,
|
|
211946
|
-
pageIndex,
|
|
211947
|
-
surface
|
|
211948
|
-
}
|
|
211949
|
-
});
|
|
211950
|
-
offsetMaps.set(segmentId, {
|
|
211951
|
-
segmentId,
|
|
211952
|
-
slices
|
|
211953
|
-
});
|
|
211954
|
-
segmentPositions.set(segmentId, paraPos);
|
|
211955
|
-
});
|
|
211956
|
-
return {
|
|
211957
|
-
segments,
|
|
211958
|
-
offsetMaps,
|
|
211959
|
-
segmentPositions
|
|
211960
|
-
};
|
|
211961
|
-
}
|
|
211962
|
-
function walkParagraphs(doc$12, visitor) {
|
|
211963
|
-
doc$12.descendants((node3, pos) => {
|
|
211964
|
-
const typeName = node3.type.name;
|
|
211965
|
-
if (typeName === "header" || typeName === "footer")
|
|
211966
|
-
return false;
|
|
211967
|
-
if (typeName === "paragraph") {
|
|
211968
|
-
visitor(node3, pos, isInsideTableCell(doc$12, pos) ? "table-cell" : "body");
|
|
211969
|
-
return false;
|
|
211970
|
-
}
|
|
211971
|
-
return true;
|
|
211972
|
-
});
|
|
211973
|
-
}
|
|
211974
|
-
function isInsideTableCell(doc$12, pos) {
|
|
211975
|
-
const resolved = doc$12.resolve(pos);
|
|
211976
|
-
for (let depth = resolved.depth;depth > 0; depth--) {
|
|
211977
|
-
const ancestor = resolved.node(depth);
|
|
211978
|
-
if (ancestor.type.name === "tableCell" || ancestor.type.name === "tableHeader")
|
|
211979
|
-
return true;
|
|
211980
|
-
}
|
|
211981
|
-
return false;
|
|
211982
|
-
}
|
|
211983
|
-
function extractParagraphText(paraNode, paraPos) {
|
|
211984
|
-
const parts = [];
|
|
211985
|
-
const slices = [];
|
|
211986
|
-
let textOffset = 0;
|
|
211987
|
-
const contentStart = paraPos + 1;
|
|
211988
|
-
paraNode.forEach((child, offset$1) => {
|
|
211989
|
-
processNode(child, contentStart + offset$1);
|
|
211990
|
-
});
|
|
211991
|
-
return {
|
|
211992
|
-
text: parts.join(""),
|
|
211993
|
-
slices
|
|
211994
|
-
};
|
|
211995
|
-
function processNode(node3, pos) {
|
|
211996
|
-
const typeName = node3.type.name;
|
|
211997
|
-
if (typeName === "run") {
|
|
211998
|
-
const runProps = node3.attrs.runProperties;
|
|
211999
|
-
if (runProps?.vanish === true) {
|
|
212000
|
-
emitBoundary();
|
|
212001
|
-
return;
|
|
212002
|
-
}
|
|
212003
|
-
if (runProps?.noProof === true) {
|
|
212004
|
-
emitBoundary();
|
|
212005
|
-
return;
|
|
212006
|
-
}
|
|
212007
|
-
const runContentStart = pos + 1;
|
|
212008
|
-
node3.forEach((child, childOff) => {
|
|
212009
|
-
processNode(child, runContentStart + childOff);
|
|
212010
|
-
});
|
|
212011
|
-
return;
|
|
212012
|
-
}
|
|
212013
|
-
if (node3.isText && node3.text) {
|
|
212014
|
-
if (hasTrackDeleteMark(node3))
|
|
212015
|
-
return;
|
|
212016
|
-
const text5 = node3.text;
|
|
212017
|
-
const pmFrom = pos;
|
|
212018
|
-
const pmTo = pos + text5.length;
|
|
212019
|
-
slices.push({
|
|
212020
|
-
textStart: textOffset,
|
|
212021
|
-
textEnd: textOffset + text5.length,
|
|
212022
|
-
pmFrom,
|
|
212023
|
-
pmTo
|
|
212024
|
-
});
|
|
212025
|
-
parts.push(text5);
|
|
212026
|
-
textOffset += text5.length;
|
|
212027
|
-
return;
|
|
212028
|
-
}
|
|
212029
|
-
if (isNonTextInlineNode(typeName)) {
|
|
212030
|
-
emitBoundary();
|
|
212031
|
-
return;
|
|
212032
|
-
}
|
|
212033
|
-
if (node3.childCount > 0) {
|
|
212034
|
-
const contentStart$1 = pos + 1;
|
|
212035
|
-
node3.forEach((child, childOff) => {
|
|
212036
|
-
processNode(child, contentStart$1 + childOff);
|
|
212037
|
-
});
|
|
212038
|
-
}
|
|
212039
|
-
}
|
|
212040
|
-
function emitBoundary() {
|
|
212041
|
-
if (parts.length > 0 && !parts[parts.length - 1].endsWith(" ")) {
|
|
212042
|
-
parts.push(" ");
|
|
212043
|
-
textOffset += 1;
|
|
212044
|
-
}
|
|
212045
|
-
}
|
|
212046
|
-
}
|
|
212047
|
-
function hasTrackDeleteMark(node3) {
|
|
212048
|
-
return node3.marks?.some((m$1) => m$1.type.name === "trackDelete") ?? false;
|
|
212049
|
-
}
|
|
212050
|
-
function isNonTextInlineNode(typeName) {
|
|
212051
|
-
return NON_TEXT_INLINE_NODES.has(typeName);
|
|
212052
|
-
}
|
|
212053
|
-
function buildSegmentId(paraNode, paraPos) {
|
|
212054
|
-
const blockId = paraNode.attrs.sdBlockId;
|
|
212055
|
-
return blockId ? `blk-${blockId}` : `pos-${paraPos}`;
|
|
212056
|
-
}
|
|
212057
|
-
function resolveIssuePmRangeFromSlices(issue, slices) {
|
|
212058
|
-
const pmFrom = textOffsetToPmPos(issue.start, slices);
|
|
212059
|
-
const pmTo = textOffsetToPmPos(issue.end, slices);
|
|
212060
|
-
if (pmFrom === null || pmTo === null || pmFrom >= pmTo)
|
|
211893
|
+
function resolveAnnotationDisplayLabel(annotation, contentEl) {
|
|
211894
|
+
const existingLabel = annotation.dataset[DATASET_KEYS.DISPLAY_LABEL];
|
|
211895
|
+
const existingLabelSource = annotation.dataset[DISPLAY_LABEL_SOURCE_KEY];
|
|
211896
|
+
if (existingLabel !== undefined && existingLabelSource !== DISPLAY_LABEL_SOURCE.DERIVED)
|
|
211897
|
+
return {
|
|
211898
|
+
source: DISPLAY_LABEL_SOURCE.CANONICAL,
|
|
211899
|
+
value: existingLabel
|
|
211900
|
+
};
|
|
211901
|
+
const derivedLabel = contentEl?.textContent?.trim() ?? "";
|
|
211902
|
+
if (derivedLabel.length === 0)
|
|
212061
211903
|
return null;
|
|
212062
211904
|
return {
|
|
212063
|
-
|
|
212064
|
-
|
|
212065
|
-
pmTo
|
|
211905
|
+
source: DISPLAY_LABEL_SOURCE.DERIVED,
|
|
211906
|
+
value: derivedLabel
|
|
212066
211907
|
};
|
|
212067
211908
|
}
|
|
212068
|
-
function textOffsetToPmPos(textOffset, slices) {
|
|
212069
|
-
for (const slice2 of slices)
|
|
212070
|
-
if (textOffset >= slice2.textStart && textOffset <= slice2.textEnd) {
|
|
212071
|
-
const delta = textOffset - slice2.textStart;
|
|
212072
|
-
return slice2.pmFrom + delta;
|
|
212073
|
-
}
|
|
212074
|
-
for (const slice2 of slices)
|
|
212075
|
-
if (slice2.textStart >= textOffset)
|
|
212076
|
-
return slice2.pmFrom;
|
|
212077
|
-
if (slices.length > 0) {
|
|
212078
|
-
const last2 = slices[slices.length - 1];
|
|
212079
|
-
if (textOffset >= last2.textEnd)
|
|
212080
|
-
return last2.pmTo;
|
|
212081
|
-
}
|
|
212082
|
-
return null;
|
|
212083
|
-
}
|
|
212084
|
-
function computeDirtySegmentIds(segments, segmentPositions, changedRanges) {
|
|
212085
|
-
if (changedRanges.length === 0)
|
|
212086
|
-
return /* @__PURE__ */ new Set;
|
|
212087
|
-
const dirty = /* @__PURE__ */ new Set;
|
|
212088
|
-
const sorted = segments.map((seg) => ({
|
|
212089
|
-
id: seg.id,
|
|
212090
|
-
pos: segmentPositions.get(seg.id) ?? -1
|
|
212091
|
-
})).filter((s2) => s2.pos >= 0).sort((a2, b$1) => a2.pos - b$1.pos);
|
|
212092
|
-
for (const range of changedRanges)
|
|
212093
|
-
for (let i4 = 0;i4 < sorted.length; i4++) {
|
|
212094
|
-
const seg = sorted[i4];
|
|
212095
|
-
const segEnd = sorted[i4 + 1]?.pos ?? Infinity;
|
|
212096
|
-
if (seg.pos < range.to && segEnd > range.from)
|
|
212097
|
-
dirty.add(seg.id);
|
|
212098
|
-
if (seg.pos <= range.from && segEnd >= range.from && i4 > 0)
|
|
212099
|
-
dirty.add(sorted[i4 - 1].id);
|
|
212100
|
-
}
|
|
212101
|
-
return dirty;
|
|
212102
|
-
}
|
|
212103
|
-
function hashSegmentText(text5) {
|
|
212104
|
-
let hash$3 = 2166136261;
|
|
212105
|
-
for (let i4 = 0;i4 < text5.length; i4++) {
|
|
212106
|
-
hash$3 ^= text5.charCodeAt(i4);
|
|
212107
|
-
hash$3 = Math.imul(hash$3, 16777619);
|
|
212108
|
-
}
|
|
212109
|
-
return (hash$3 >>> 0).toString(16);
|
|
212110
|
-
}
|
|
212111
|
-
function prioritizeByVisibility(segments, visibilitySource) {
|
|
212112
|
-
const visiblePages = visibilitySource.getVisiblePageIndices();
|
|
212113
|
-
if (!visiblePages || visiblePages.length === 0)
|
|
212114
|
-
return segments;
|
|
212115
|
-
const visibleSet = new Set(visiblePages);
|
|
212116
|
-
const visible = [];
|
|
212117
|
-
const rest = [];
|
|
212118
|
-
for (const seg of segments) {
|
|
212119
|
-
const pageIndex = seg.metadata.pageIndex;
|
|
212120
|
-
if (pageIndex !== undefined && visibleSet.has(pageIndex))
|
|
212121
|
-
visible.push(seg);
|
|
212122
|
-
else
|
|
212123
|
-
rest.push(seg);
|
|
212124
|
-
}
|
|
212125
|
-
return [...visible, ...rest];
|
|
212126
|
-
}
|
|
212127
|
-
function buildPaintSlices(issues) {
|
|
212128
|
-
const spellingIssues = issues.filter((i4) => i4.kind === "spelling");
|
|
212129
|
-
if (spellingIssues.length === 0)
|
|
212130
|
-
return [];
|
|
212131
|
-
const sorted = [...spellingIssues].sort((a2, b$1) => a2.pmFrom - b$1.pmFrom || a2.pmTo - b$1.pmTo);
|
|
212132
|
-
const slices = [];
|
|
212133
|
-
let current = null;
|
|
212134
|
-
for (const issue of sorted) {
|
|
212135
|
-
if (!current) {
|
|
212136
|
-
current = {
|
|
212137
|
-
pmFrom: issue.pmFrom,
|
|
212138
|
-
pmTo: issue.pmTo,
|
|
212139
|
-
kind: "spelling",
|
|
212140
|
-
issue
|
|
212141
|
-
};
|
|
212142
|
-
continue;
|
|
212143
|
-
}
|
|
212144
|
-
if (issue.pmFrom <= current.pmTo)
|
|
212145
|
-
current.pmTo = Math.max(current.pmTo, issue.pmTo);
|
|
212146
|
-
else {
|
|
212147
|
-
slices.push(current);
|
|
212148
|
-
current = {
|
|
212149
|
-
pmFrom: issue.pmFrom,
|
|
212150
|
-
pmTo: issue.pmTo,
|
|
212151
|
-
kind: "spelling",
|
|
212152
|
-
issue
|
|
212153
|
-
};
|
|
212154
|
-
}
|
|
212155
|
-
}
|
|
212156
|
-
if (current)
|
|
212157
|
-
slices.push(current);
|
|
212158
|
-
return slices;
|
|
212159
|
-
}
|
|
212160
|
-
function findSliceAtPosition(slices, pmPos) {
|
|
212161
|
-
let lo = 0;
|
|
212162
|
-
let hi = slices.length - 1;
|
|
212163
|
-
while (lo <= hi) {
|
|
212164
|
-
const mid = lo + hi >>> 1;
|
|
212165
|
-
const slice2 = slices[mid];
|
|
212166
|
-
if (pmPos < slice2.pmFrom)
|
|
212167
|
-
hi = mid - 1;
|
|
212168
|
-
else if (pmPos >= slice2.pmTo)
|
|
212169
|
-
lo = mid + 1;
|
|
212170
|
-
else
|
|
212171
|
-
return slice2;
|
|
212172
|
-
}
|
|
212173
|
-
return null;
|
|
212174
|
-
}
|
|
212175
211909
|
function mapWordFamilyFallback(wordFamily) {
|
|
212176
211910
|
if (!wordFamily)
|
|
212177
211911
|
return DEFAULT_GENERIC_FALLBACK2;
|
|
@@ -214075,9 +213809,6 @@ function applyParagraphBordersAndShading(paraWrapper, block) {
|
|
|
214075
213809
|
if (shadingFill)
|
|
214076
213810
|
paraWrapper.style.backgroundColor = shadingFill;
|
|
214077
213811
|
}
|
|
214078
|
-
function sdtElementsById(root3, sdtId) {
|
|
214079
|
-
return root3.querySelectorAll(`.${DOM_CLASS_NAMES.BLOCK_SDT}[data-sdt-id="${sdtId}"]`);
|
|
214080
|
-
}
|
|
214081
213812
|
function classifyMathText(text5) {
|
|
214082
213813
|
if (/^\d*\.?\d+$/.test(text5))
|
|
214083
213814
|
return "mn";
|
|
@@ -214182,6 +213913,26 @@ function readSnapshotStyleValue(styleValue2) {
|
|
|
214182
213913
|
return null;
|
|
214183
213914
|
return styleValue2;
|
|
214184
213915
|
}
|
|
213916
|
+
function createEmptyPaintSnapshotEntities() {
|
|
213917
|
+
return {
|
|
213918
|
+
annotations: [],
|
|
213919
|
+
structuredContentBlocks: [],
|
|
213920
|
+
structuredContentInlines: [],
|
|
213921
|
+
images: []
|
|
213922
|
+
};
|
|
213923
|
+
}
|
|
213924
|
+
function readSnapshotDatasetNumber(value) {
|
|
213925
|
+
if (typeof value !== "string" || value.length === 0)
|
|
213926
|
+
return null;
|
|
213927
|
+
const parsed = Number(value);
|
|
213928
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
213929
|
+
}
|
|
213930
|
+
function resolveSnapshotPageIndex(element3) {
|
|
213931
|
+
const pageEl = element3.closest(`.${DOM_CLASS_NAMES.PAGE}`);
|
|
213932
|
+
if (!pageEl)
|
|
213933
|
+
return null;
|
|
213934
|
+
return readSnapshotDatasetNumber(pageEl.dataset.pageIndex);
|
|
213935
|
+
}
|
|
214185
213936
|
function compactSnapshotObject(input2) {
|
|
214186
213937
|
const out = {};
|
|
214187
213938
|
for (const [key$1, value] of Object.entries(input2)) {
|
|
@@ -214193,6 +213944,89 @@ function compactSnapshotObject(input2) {
|
|
|
214193
213944
|
}
|
|
214194
213945
|
return out;
|
|
214195
213946
|
}
|
|
213947
|
+
function shouldIncludeInlineImageSnapshotElement(element3) {
|
|
213948
|
+
if (element3.classList.contains(DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER))
|
|
213949
|
+
return true;
|
|
213950
|
+
if (!element3.classList.contains(DOM_CLASS_NAMES.INLINE_IMAGE))
|
|
213951
|
+
return false;
|
|
213952
|
+
return !element3.closest(`.${DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER}`);
|
|
213953
|
+
}
|
|
213954
|
+
function collectPaintSnapshotEntitiesFromDomRoot(rootEl) {
|
|
213955
|
+
const entities = createEmptyPaintSnapshotEntities();
|
|
213956
|
+
const annotationElements = Array.from(rootEl.querySelectorAll(`.${DOM_CLASS_NAMES.ANNOTATION}[data-pm-start]`));
|
|
213957
|
+
for (const element3 of annotationElements) {
|
|
213958
|
+
const pageIndex = resolveSnapshotPageIndex(element3);
|
|
213959
|
+
if (pageIndex == null)
|
|
213960
|
+
continue;
|
|
213961
|
+
entities.annotations.push(compactSnapshotObject({
|
|
213962
|
+
element: element3,
|
|
213963
|
+
pageIndex,
|
|
213964
|
+
pmStart: readSnapshotDatasetNumber(element3.dataset.pmStart),
|
|
213965
|
+
pmEnd: readSnapshotDatasetNumber(element3.dataset.pmEnd),
|
|
213966
|
+
fieldId: element3.dataset.fieldId || null,
|
|
213967
|
+
fieldType: element3.dataset.fieldType || null,
|
|
213968
|
+
type: element3.dataset.type || null
|
|
213969
|
+
}));
|
|
213970
|
+
}
|
|
213971
|
+
const blockSdtElements = Array.from(rootEl.querySelectorAll(`.${DOM_CLASS_NAMES.BLOCK_SDT}[data-sdt-id]`));
|
|
213972
|
+
for (const element3 of blockSdtElements) {
|
|
213973
|
+
const pageIndex = resolveSnapshotPageIndex(element3);
|
|
213974
|
+
const sdtId = element3.dataset.sdtId;
|
|
213975
|
+
if (pageIndex == null || !sdtId)
|
|
213976
|
+
continue;
|
|
213977
|
+
entities.structuredContentBlocks.push(compactSnapshotObject({
|
|
213978
|
+
element: element3,
|
|
213979
|
+
pageIndex,
|
|
213980
|
+
sdtId,
|
|
213981
|
+
pmStart: readSnapshotDatasetNumber(element3.dataset.pmStart),
|
|
213982
|
+
pmEnd: readSnapshotDatasetNumber(element3.dataset.pmEnd)
|
|
213983
|
+
}));
|
|
213984
|
+
}
|
|
213985
|
+
const inlineSdtElements = Array.from(rootEl.querySelectorAll(`.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}[data-sdt-id]`));
|
|
213986
|
+
for (const element3 of inlineSdtElements) {
|
|
213987
|
+
const pageIndex = resolveSnapshotPageIndex(element3);
|
|
213988
|
+
const sdtId = element3.dataset.sdtId;
|
|
213989
|
+
if (pageIndex == null || !sdtId)
|
|
213990
|
+
continue;
|
|
213991
|
+
entities.structuredContentInlines.push(compactSnapshotObject({
|
|
213992
|
+
element: element3,
|
|
213993
|
+
pageIndex,
|
|
213994
|
+
sdtId,
|
|
213995
|
+
pmStart: readSnapshotDatasetNumber(element3.dataset.pmStart),
|
|
213996
|
+
pmEnd: readSnapshotDatasetNumber(element3.dataset.pmEnd)
|
|
213997
|
+
}));
|
|
213998
|
+
}
|
|
213999
|
+
const inlineImageElements = Array.from(rootEl.querySelectorAll(`.${DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER}[data-pm-start], .${DOM_CLASS_NAMES.INLINE_IMAGE}[data-pm-start]`));
|
|
214000
|
+
for (const element3 of inlineImageElements) {
|
|
214001
|
+
if (!shouldIncludeInlineImageSnapshotElement(element3))
|
|
214002
|
+
continue;
|
|
214003
|
+
const pageIndex = resolveSnapshotPageIndex(element3);
|
|
214004
|
+
if (pageIndex == null)
|
|
214005
|
+
continue;
|
|
214006
|
+
entities.images.push(compactSnapshotObject({
|
|
214007
|
+
element: element3,
|
|
214008
|
+
pageIndex,
|
|
214009
|
+
kind: "inline",
|
|
214010
|
+
pmStart: readSnapshotDatasetNumber(element3.dataset.pmStart),
|
|
214011
|
+
pmEnd: readSnapshotDatasetNumber(element3.dataset.pmEnd)
|
|
214012
|
+
}));
|
|
214013
|
+
}
|
|
214014
|
+
const fragmentImageElements = Array.from(rootEl.querySelectorAll(`.${DOM_CLASS_NAMES.IMAGE_FRAGMENT}[data-pm-start]`));
|
|
214015
|
+
for (const element3 of fragmentImageElements) {
|
|
214016
|
+
const pageIndex = resolveSnapshotPageIndex(element3);
|
|
214017
|
+
if (pageIndex == null)
|
|
214018
|
+
continue;
|
|
214019
|
+
entities.images.push(compactSnapshotObject({
|
|
214020
|
+
element: element3,
|
|
214021
|
+
pageIndex,
|
|
214022
|
+
kind: "fragment",
|
|
214023
|
+
pmStart: readSnapshotDatasetNumber(element3.dataset.pmStart),
|
|
214024
|
+
pmEnd: readSnapshotDatasetNumber(element3.dataset.pmEnd),
|
|
214025
|
+
blockId: element3.getAttribute("data-sd-block-id")
|
|
214026
|
+
}));
|
|
214027
|
+
}
|
|
214028
|
+
return entities;
|
|
214029
|
+
}
|
|
214196
214030
|
function snapshotLineStyleFromElement(lineEl) {
|
|
214197
214031
|
const style2 = lineEl?.style;
|
|
214198
214032
|
if (!style2)
|
|
@@ -214534,6 +214368,323 @@ function buildLegacyPaintInput(layout, legacyState, flowMode, pageGap) {
|
|
|
214534
214368
|
footerMeasures: legacyState.footerMeasures
|
|
214535
214369
|
};
|
|
214536
214370
|
}
|
|
214371
|
+
function isSuppressed(issue, normalizedIgnored) {
|
|
214372
|
+
if (normalizedIgnored.size === 0)
|
|
214373
|
+
return false;
|
|
214374
|
+
const raw = issue.word ?? issue.message;
|
|
214375
|
+
if (!raw)
|
|
214376
|
+
return false;
|
|
214377
|
+
const normalized = raw.normalize("NFC").toLowerCase();
|
|
214378
|
+
return normalizedIgnored.has(normalized);
|
|
214379
|
+
}
|
|
214380
|
+
function resolveSegmentLanguage(paraNode, defaultLanguage) {
|
|
214381
|
+
const runLanguage = findFirstRunLanguage(paraNode);
|
|
214382
|
+
if (runLanguage)
|
|
214383
|
+
return runLanguage;
|
|
214384
|
+
const paraLang = extractParagraphLanguage(paraNode);
|
|
214385
|
+
if (paraLang)
|
|
214386
|
+
return paraLang;
|
|
214387
|
+
return defaultLanguage;
|
|
214388
|
+
}
|
|
214389
|
+
function findFirstRunLanguage(paraNode) {
|
|
214390
|
+
let lang = null;
|
|
214391
|
+
paraNode.descendants((node3) => {
|
|
214392
|
+
if (lang)
|
|
214393
|
+
return false;
|
|
214394
|
+
if (node3.type.name === "run") {
|
|
214395
|
+
const runProps = node3.attrs.runProperties;
|
|
214396
|
+
if (runProps?.lang?.val) {
|
|
214397
|
+
lang = runProps.lang.val;
|
|
214398
|
+
return false;
|
|
214399
|
+
}
|
|
214400
|
+
}
|
|
214401
|
+
return true;
|
|
214402
|
+
});
|
|
214403
|
+
return lang;
|
|
214404
|
+
}
|
|
214405
|
+
function extractParagraphLanguage(paraNode) {
|
|
214406
|
+
return paraNode.attrs.paragraphProperties?.lang?.val ?? null;
|
|
214407
|
+
}
|
|
214408
|
+
function extractSegmentsWithMaps(doc$12, defaultLanguage, pageResolver) {
|
|
214409
|
+
const segments = [];
|
|
214410
|
+
const offsetMaps = /* @__PURE__ */ new Map;
|
|
214411
|
+
const segmentPositions = /* @__PURE__ */ new Map;
|
|
214412
|
+
walkParagraphs(doc$12, (paraNode, paraPos, surface) => {
|
|
214413
|
+
const { text: text5, slices } = extractParagraphText(paraNode, paraPos);
|
|
214414
|
+
if (text5.length === 0)
|
|
214415
|
+
return;
|
|
214416
|
+
const segmentId = buildSegmentId(paraNode, paraPos);
|
|
214417
|
+
const language = resolveSegmentLanguage(paraNode, defaultLanguage ?? null);
|
|
214418
|
+
const pageIndex = pageResolver?.(paraPos);
|
|
214419
|
+
segments.push({
|
|
214420
|
+
id: segmentId,
|
|
214421
|
+
text: text5,
|
|
214422
|
+
language,
|
|
214423
|
+
metadata: {
|
|
214424
|
+
blockId: paraNode.attrs.sdBlockId,
|
|
214425
|
+
pageIndex,
|
|
214426
|
+
surface
|
|
214427
|
+
}
|
|
214428
|
+
});
|
|
214429
|
+
offsetMaps.set(segmentId, {
|
|
214430
|
+
segmentId,
|
|
214431
|
+
slices
|
|
214432
|
+
});
|
|
214433
|
+
segmentPositions.set(segmentId, paraPos);
|
|
214434
|
+
});
|
|
214435
|
+
return {
|
|
214436
|
+
segments,
|
|
214437
|
+
offsetMaps,
|
|
214438
|
+
segmentPositions
|
|
214439
|
+
};
|
|
214440
|
+
}
|
|
214441
|
+
function walkParagraphs(doc$12, visitor) {
|
|
214442
|
+
doc$12.descendants((node3, pos) => {
|
|
214443
|
+
const typeName = node3.type.name;
|
|
214444
|
+
if (typeName === "header" || typeName === "footer")
|
|
214445
|
+
return false;
|
|
214446
|
+
if (typeName === "paragraph") {
|
|
214447
|
+
visitor(node3, pos, isInsideTableCell(doc$12, pos) ? "table-cell" : "body");
|
|
214448
|
+
return false;
|
|
214449
|
+
}
|
|
214450
|
+
return true;
|
|
214451
|
+
});
|
|
214452
|
+
}
|
|
214453
|
+
function isInsideTableCell(doc$12, pos) {
|
|
214454
|
+
const resolved = doc$12.resolve(pos);
|
|
214455
|
+
for (let depth = resolved.depth;depth > 0; depth--) {
|
|
214456
|
+
const ancestor = resolved.node(depth);
|
|
214457
|
+
if (ancestor.type.name === "tableCell" || ancestor.type.name === "tableHeader")
|
|
214458
|
+
return true;
|
|
214459
|
+
}
|
|
214460
|
+
return false;
|
|
214461
|
+
}
|
|
214462
|
+
function extractParagraphText(paraNode, paraPos) {
|
|
214463
|
+
const parts = [];
|
|
214464
|
+
const slices = [];
|
|
214465
|
+
let textOffset = 0;
|
|
214466
|
+
const contentStart = paraPos + 1;
|
|
214467
|
+
paraNode.forEach((child, offset$1) => {
|
|
214468
|
+
processNode(child, contentStart + offset$1);
|
|
214469
|
+
});
|
|
214470
|
+
return {
|
|
214471
|
+
text: parts.join(""),
|
|
214472
|
+
slices
|
|
214473
|
+
};
|
|
214474
|
+
function processNode(node3, pos) {
|
|
214475
|
+
const typeName = node3.type.name;
|
|
214476
|
+
if (typeName === "run") {
|
|
214477
|
+
const runProps = node3.attrs.runProperties;
|
|
214478
|
+
if (runProps?.vanish === true) {
|
|
214479
|
+
emitBoundary();
|
|
214480
|
+
return;
|
|
214481
|
+
}
|
|
214482
|
+
if (runProps?.noProof === true) {
|
|
214483
|
+
emitBoundary();
|
|
214484
|
+
return;
|
|
214485
|
+
}
|
|
214486
|
+
const runContentStart = pos + 1;
|
|
214487
|
+
node3.forEach((child, childOff) => {
|
|
214488
|
+
processNode(child, runContentStart + childOff);
|
|
214489
|
+
});
|
|
214490
|
+
return;
|
|
214491
|
+
}
|
|
214492
|
+
if (node3.isText && node3.text) {
|
|
214493
|
+
if (hasTrackDeleteMark(node3))
|
|
214494
|
+
return;
|
|
214495
|
+
const text5 = node3.text;
|
|
214496
|
+
const pmFrom = pos;
|
|
214497
|
+
const pmTo = pos + text5.length;
|
|
214498
|
+
slices.push({
|
|
214499
|
+
textStart: textOffset,
|
|
214500
|
+
textEnd: textOffset + text5.length,
|
|
214501
|
+
pmFrom,
|
|
214502
|
+
pmTo
|
|
214503
|
+
});
|
|
214504
|
+
parts.push(text5);
|
|
214505
|
+
textOffset += text5.length;
|
|
214506
|
+
return;
|
|
214507
|
+
}
|
|
214508
|
+
if (isNonTextInlineNode(typeName)) {
|
|
214509
|
+
emitBoundary();
|
|
214510
|
+
return;
|
|
214511
|
+
}
|
|
214512
|
+
if (node3.childCount > 0) {
|
|
214513
|
+
const contentStart$1 = pos + 1;
|
|
214514
|
+
node3.forEach((child, childOff) => {
|
|
214515
|
+
processNode(child, contentStart$1 + childOff);
|
|
214516
|
+
});
|
|
214517
|
+
}
|
|
214518
|
+
}
|
|
214519
|
+
function emitBoundary() {
|
|
214520
|
+
if (parts.length > 0 && !parts[parts.length - 1].endsWith(" ")) {
|
|
214521
|
+
parts.push(" ");
|
|
214522
|
+
textOffset += 1;
|
|
214523
|
+
}
|
|
214524
|
+
}
|
|
214525
|
+
}
|
|
214526
|
+
function hasTrackDeleteMark(node3) {
|
|
214527
|
+
return node3.marks?.some((m$1) => m$1.type.name === "trackDelete") ?? false;
|
|
214528
|
+
}
|
|
214529
|
+
function isNonTextInlineNode(typeName) {
|
|
214530
|
+
return NON_TEXT_INLINE_NODES.has(typeName);
|
|
214531
|
+
}
|
|
214532
|
+
function buildSegmentId(paraNode, paraPos) {
|
|
214533
|
+
const blockId = paraNode.attrs.sdBlockId;
|
|
214534
|
+
return blockId ? `blk-${blockId}` : `pos-${paraPos}`;
|
|
214535
|
+
}
|
|
214536
|
+
function resolveIssuePmRangeFromSlices(issue, slices) {
|
|
214537
|
+
const pmFrom = textOffsetToPmPos(issue.start, slices);
|
|
214538
|
+
const pmTo = textOffsetToPmPos(issue.end, slices);
|
|
214539
|
+
if (pmFrom === null || pmTo === null || pmFrom >= pmTo)
|
|
214540
|
+
return null;
|
|
214541
|
+
return {
|
|
214542
|
+
...issue,
|
|
214543
|
+
pmFrom,
|
|
214544
|
+
pmTo
|
|
214545
|
+
};
|
|
214546
|
+
}
|
|
214547
|
+
function textOffsetToPmPos(textOffset, slices) {
|
|
214548
|
+
for (const slice2 of slices)
|
|
214549
|
+
if (textOffset >= slice2.textStart && textOffset <= slice2.textEnd) {
|
|
214550
|
+
const delta = textOffset - slice2.textStart;
|
|
214551
|
+
return slice2.pmFrom + delta;
|
|
214552
|
+
}
|
|
214553
|
+
for (const slice2 of slices)
|
|
214554
|
+
if (slice2.textStart >= textOffset)
|
|
214555
|
+
return slice2.pmFrom;
|
|
214556
|
+
if (slices.length > 0) {
|
|
214557
|
+
const last2 = slices[slices.length - 1];
|
|
214558
|
+
if (textOffset >= last2.textEnd)
|
|
214559
|
+
return last2.pmTo;
|
|
214560
|
+
}
|
|
214561
|
+
return null;
|
|
214562
|
+
}
|
|
214563
|
+
function computeDirtySegmentIds(segments, segmentPositions, changedRanges) {
|
|
214564
|
+
if (changedRanges.length === 0)
|
|
214565
|
+
return /* @__PURE__ */ new Set;
|
|
214566
|
+
const dirty = /* @__PURE__ */ new Set;
|
|
214567
|
+
const sorted = segments.map((seg) => ({
|
|
214568
|
+
id: seg.id,
|
|
214569
|
+
pos: segmentPositions.get(seg.id) ?? -1
|
|
214570
|
+
})).filter((s2) => s2.pos >= 0).sort((a2, b$1) => a2.pos - b$1.pos);
|
|
214571
|
+
for (const range of changedRanges)
|
|
214572
|
+
for (let i4 = 0;i4 < sorted.length; i4++) {
|
|
214573
|
+
const seg = sorted[i4];
|
|
214574
|
+
const segEnd = sorted[i4 + 1]?.pos ?? Infinity;
|
|
214575
|
+
if (seg.pos < range.to && segEnd > range.from)
|
|
214576
|
+
dirty.add(seg.id);
|
|
214577
|
+
if (seg.pos <= range.from && segEnd >= range.from && i4 > 0)
|
|
214578
|
+
dirty.add(sorted[i4 - 1].id);
|
|
214579
|
+
}
|
|
214580
|
+
return dirty;
|
|
214581
|
+
}
|
|
214582
|
+
function hashSegmentText(text5) {
|
|
214583
|
+
let hash$3 = 2166136261;
|
|
214584
|
+
for (let i4 = 0;i4 < text5.length; i4++) {
|
|
214585
|
+
hash$3 ^= text5.charCodeAt(i4);
|
|
214586
|
+
hash$3 = Math.imul(hash$3, 16777619);
|
|
214587
|
+
}
|
|
214588
|
+
return (hash$3 >>> 0).toString(16);
|
|
214589
|
+
}
|
|
214590
|
+
function prioritizeByVisibility(segments, visibilitySource) {
|
|
214591
|
+
const visiblePages = visibilitySource.getVisiblePageIndices();
|
|
214592
|
+
if (!visiblePages || visiblePages.length === 0)
|
|
214593
|
+
return segments;
|
|
214594
|
+
const visibleSet = new Set(visiblePages);
|
|
214595
|
+
const visible = [];
|
|
214596
|
+
const rest = [];
|
|
214597
|
+
for (const seg of segments) {
|
|
214598
|
+
const pageIndex = seg.metadata.pageIndex;
|
|
214599
|
+
if (pageIndex !== undefined && visibleSet.has(pageIndex))
|
|
214600
|
+
visible.push(seg);
|
|
214601
|
+
else
|
|
214602
|
+
rest.push(seg);
|
|
214603
|
+
}
|
|
214604
|
+
return [...visible, ...rest];
|
|
214605
|
+
}
|
|
214606
|
+
function buildPaintSlices(issues) {
|
|
214607
|
+
const spellingIssues = issues.filter((i4) => i4.kind === "spelling");
|
|
214608
|
+
if (spellingIssues.length === 0)
|
|
214609
|
+
return [];
|
|
214610
|
+
const sorted = [...spellingIssues].sort((a2, b$1) => a2.pmFrom - b$1.pmFrom || a2.pmTo - b$1.pmTo);
|
|
214611
|
+
const slices = [];
|
|
214612
|
+
let current = null;
|
|
214613
|
+
for (const issue of sorted) {
|
|
214614
|
+
if (!current) {
|
|
214615
|
+
current = {
|
|
214616
|
+
pmFrom: issue.pmFrom,
|
|
214617
|
+
pmTo: issue.pmTo,
|
|
214618
|
+
kind: "spelling",
|
|
214619
|
+
issue
|
|
214620
|
+
};
|
|
214621
|
+
continue;
|
|
214622
|
+
}
|
|
214623
|
+
if (issue.pmFrom <= current.pmTo)
|
|
214624
|
+
current.pmTo = Math.max(current.pmTo, issue.pmTo);
|
|
214625
|
+
else {
|
|
214626
|
+
slices.push(current);
|
|
214627
|
+
current = {
|
|
214628
|
+
pmFrom: issue.pmFrom,
|
|
214629
|
+
pmTo: issue.pmTo,
|
|
214630
|
+
kind: "spelling",
|
|
214631
|
+
issue
|
|
214632
|
+
};
|
|
214633
|
+
}
|
|
214634
|
+
}
|
|
214635
|
+
if (current)
|
|
214636
|
+
slices.push(current);
|
|
214637
|
+
return slices;
|
|
214638
|
+
}
|
|
214639
|
+
function findSliceAtPosition(slices, pmPos) {
|
|
214640
|
+
let lo = 0;
|
|
214641
|
+
let hi = slices.length - 1;
|
|
214642
|
+
while (lo <= hi) {
|
|
214643
|
+
const mid = lo + hi >>> 1;
|
|
214644
|
+
const slice2 = slices[mid];
|
|
214645
|
+
if (pmPos < slice2.pmFrom)
|
|
214646
|
+
hi = mid - 1;
|
|
214647
|
+
else if (pmPos >= slice2.pmTo)
|
|
214648
|
+
lo = mid + 1;
|
|
214649
|
+
else
|
|
214650
|
+
return slice2;
|
|
214651
|
+
}
|
|
214652
|
+
return null;
|
|
214653
|
+
}
|
|
214654
|
+
function appendToArrayMap(map$12, key$1, value) {
|
|
214655
|
+
const existing = map$12.get(key$1);
|
|
214656
|
+
if (existing) {
|
|
214657
|
+
existing.push(value);
|
|
214658
|
+
return;
|
|
214659
|
+
}
|
|
214660
|
+
map$12.set(key$1, [value]);
|
|
214661
|
+
}
|
|
214662
|
+
function isMountedElement(element3) {
|
|
214663
|
+
return element3 instanceof HTMLElement && element3.isConnected;
|
|
214664
|
+
}
|
|
214665
|
+
function isInlineImageWrapperElement(element3) {
|
|
214666
|
+
return element3.classList.contains(DOM_CLASS_NAMES.INLINE_IMAGE_CLIP_WRAPPER);
|
|
214667
|
+
}
|
|
214668
|
+
function shouldReplaceInlineImageEntity(existing, candidate) {
|
|
214669
|
+
if (!existing)
|
|
214670
|
+
return true;
|
|
214671
|
+
const existingIsWrapper = isInlineImageWrapperElement(existing.element);
|
|
214672
|
+
const candidateIsWrapper = isInlineImageWrapperElement(candidate.element);
|
|
214673
|
+
if (existingIsWrapper && !candidateIsWrapper)
|
|
214674
|
+
return false;
|
|
214675
|
+
return true;
|
|
214676
|
+
}
|
|
214677
|
+
function normalizePinnedPageIndices(pageIndices) {
|
|
214678
|
+
return Array.from(new Set((pageIndices ?? []).filter((pageIndex) => Number.isInteger(pageIndex)))).sort((a2, b$1) => a2 - b$1);
|
|
214679
|
+
}
|
|
214680
|
+
function areNumberListsEqual(left$1, right$1) {
|
|
214681
|
+
if (left$1.length !== right$1.length)
|
|
214682
|
+
return false;
|
|
214683
|
+
for (let index2 = 0;index2 < left$1.length; index2 += 1)
|
|
214684
|
+
if (left$1[index2] !== right$1[index2])
|
|
214685
|
+
return false;
|
|
214686
|
+
return true;
|
|
214687
|
+
}
|
|
214537
214688
|
function resolveMarkerTextWidth(markerTextWidthPx, marker) {
|
|
214538
214689
|
const val = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : undefined;
|
|
214539
214690
|
return val(markerTextWidthPx) ?? val(marker.glyphWidthPx) ?? val(marker.markerBoxWidthPx) ?? 0;
|
|
@@ -229438,6 +229589,24 @@ function splitRunsAtDecorationBoundaries(blocks2, ranges) {
|
|
|
229438
229589
|
const boundaries = getBoundaries(ranges);
|
|
229439
229590
|
return blocks2.map((block) => splitRunsInBlock(block, boundaries));
|
|
229440
229591
|
}
|
|
229592
|
+
function ensureEditorNativeSelectionStyles(doc$12) {
|
|
229593
|
+
if (nativeSelectionStylesInjected || !doc$12)
|
|
229594
|
+
return;
|
|
229595
|
+
const styleEl = doc$12.createElement("style");
|
|
229596
|
+
styleEl.setAttribute("data-superdoc-editor-native-selection-styles", "true");
|
|
229597
|
+
styleEl.textContent = NATIVE_SELECTION_STYLES;
|
|
229598
|
+
doc$12.head?.appendChild(styleEl);
|
|
229599
|
+
nativeSelectionStylesInjected = true;
|
|
229600
|
+
}
|
|
229601
|
+
function ensureEditorFieldAnnotationInteractionStyles(doc$12) {
|
|
229602
|
+
if (fieldAnnotationInteractionStylesInjected || !doc$12)
|
|
229603
|
+
return;
|
|
229604
|
+
const styleEl = doc$12.createElement("style");
|
|
229605
|
+
styleEl.setAttribute("data-superdoc-editor-field-annotation-interaction-styles", "true");
|
|
229606
|
+
styleEl.textContent = FIELD_ANNOTATION_INTERACTION_STYLES;
|
|
229607
|
+
doc$12.head?.appendChild(styleEl);
|
|
229608
|
+
fieldAnnotationInteractionStylesInjected = true;
|
|
229609
|
+
}
|
|
229441
229610
|
var Node$13 = class Node$14 {
|
|
229442
229611
|
constructor(config2) {
|
|
229443
229612
|
this.type = "node";
|
|
@@ -240837,7 +241006,7 @@ var Node$13 = class Node$14 {
|
|
|
240837
241006
|
if (!allowedRanges?.length)
|
|
240838
241007
|
return false;
|
|
240839
241008
|
return allowedRanges.some((allowed) => range.from >= allowed.from && range.to <= allowed.to);
|
|
240840
|
-
}, PermissionRanges, Protection, DOM_CLASS_NAMES, DATA_ATTRS, VerticalNavigationPluginKey, createDefaultState = () => ({ goalX: null }), VerticalNavigation, createPermissionBlockMarkerNode = ({ name, attributes }) => Node$13.create({
|
|
241009
|
+
}, PermissionRanges, Protection, DOM_CLASS_NAMES, DATA_ATTRS, DATASET_KEYS, DRAGGABLE_SELECTOR, VerticalNavigationPluginKey, createDefaultState = () => ({ goalX: null }), VerticalNavigation, createPermissionBlockMarkerNode = ({ name, attributes }) => Node$13.create({
|
|
240841
241010
|
name,
|
|
240842
241011
|
group: "block",
|
|
240843
241012
|
inline: false,
|
|
@@ -244052,480 +244221,77 @@ var Node$13 = class Node$14 {
|
|
|
244052
244221
|
}
|
|
244053
244222
|
this.#applied.delete(el);
|
|
244054
244223
|
}
|
|
244055
|
-
},
|
|
244056
|
-
#
|
|
244057
|
-
|
|
244058
|
-
|
|
244059
|
-
if (list5)
|
|
244060
|
-
list5.push(issue);
|
|
244061
|
-
else
|
|
244062
|
-
this.#issuesBySegment.set(issue.segmentId, [issue]);
|
|
244224
|
+
}, INTERACTION_EPOCH_KEY = "interactionEpoch", DISPLAY_LABEL_SOURCE_KEY = "displayLabelSource", DISPLAY_LABEL_SOURCE, FieldAnnotationInteractionLayer = class {
|
|
244225
|
+
#container = null;
|
|
244226
|
+
setContainer(container) {
|
|
244227
|
+
this.#container = container;
|
|
244063
244228
|
}
|
|
244064
|
-
|
|
244065
|
-
|
|
244066
|
-
|
|
244067
|
-
|
|
244229
|
+
apply(layoutEpoch) {
|
|
244230
|
+
if (!this.#container)
|
|
244231
|
+
return;
|
|
244232
|
+
const epochStr = String(layoutEpoch);
|
|
244233
|
+
const annotations = this.#container.querySelectorAll(buildAnnotationSelector());
|
|
244234
|
+
for (let index2 = 0;index2 < annotations.length; index2 += 1) {
|
|
244235
|
+
const annotation = annotations[index2];
|
|
244236
|
+
if (annotation.dataset[INTERACTION_EPOCH_KEY] === epochStr)
|
|
244068
244237
|
continue;
|
|
244069
|
-
|
|
244070
|
-
|
|
244071
|
-
|
|
244072
|
-
|
|
244073
|
-
|
|
244074
|
-
|
|
244075
|
-
|
|
244076
|
-
continue;
|
|
244077
|
-
issue.pmFrom = fromResult.pos;
|
|
244078
|
-
issue.pmTo = toResult2.pos;
|
|
244079
|
-
issue.state = "mapped";
|
|
244080
|
-
issue.recheckId = recheckId;
|
|
244081
|
-
surviving.push(issue);
|
|
244238
|
+
annotation.dataset[INTERACTION_EPOCH_KEY] = epochStr;
|
|
244239
|
+
annotation.draggable = true;
|
|
244240
|
+
annotation.dataset[DATASET_KEYS.DRAGGABLE] = "true";
|
|
244241
|
+
const displayLabel = resolveAnnotationDisplayLabel(annotation, annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CONTENT}`));
|
|
244242
|
+
if (displayLabel !== null) {
|
|
244243
|
+
annotation.dataset[DATASET_KEYS.DISPLAY_LABEL] = displayLabel.value;
|
|
244244
|
+
annotation.dataset[DISPLAY_LABEL_SOURCE_KEY] = displayLabel.source;
|
|
244082
244245
|
}
|
|
244083
|
-
|
|
244084
|
-
|
|
244085
|
-
|
|
244086
|
-
|
|
244087
|
-
}
|
|
244088
|
-
}
|
|
244089
|
-
replaceBatchResults(recheckIds, coveredSegmentIds, freshIssues) {
|
|
244090
|
-
for (const segId of coveredSegmentIds) {
|
|
244091
|
-
const list5 = this.#issuesBySegment.get(segId);
|
|
244092
|
-
if (!list5)
|
|
244093
|
-
continue;
|
|
244094
|
-
const filtered = list5.filter((issue) => issue.recheckId === null || !recheckIds.has(issue.recheckId));
|
|
244095
|
-
if (filtered.length > 0)
|
|
244096
|
-
this.#issuesBySegment.set(segId, filtered);
|
|
244097
|
-
else
|
|
244098
|
-
this.#issuesBySegment.delete(segId);
|
|
244246
|
+
const variantType = annotation.dataset[DATASET_KEYS.TYPE];
|
|
244247
|
+
if (variantType)
|
|
244248
|
+
annotation.dataset[DATASET_KEYS.VARIANT] = variantType;
|
|
244249
|
+
this.#ensureCaretAnchor(annotation);
|
|
244099
244250
|
}
|
|
244100
|
-
for (const issue of freshIssues)
|
|
244101
|
-
this.addIssue(issue);
|
|
244102
|
-
}
|
|
244103
|
-
removeBySegmentIds(ids) {
|
|
244104
|
-
for (const id2 of ids)
|
|
244105
|
-
this.#issuesBySegment.delete(id2);
|
|
244106
|
-
}
|
|
244107
|
-
removeOrphanedSegments(currentSegmentIds) {
|
|
244108
|
-
for (const segId of this.#issuesBySegment.keys())
|
|
244109
|
-
if (!currentSegmentIds.has(segId))
|
|
244110
|
-
this.#issuesBySegment.delete(segId);
|
|
244111
244251
|
}
|
|
244112
244252
|
clear() {
|
|
244113
|
-
this.#
|
|
244114
|
-
}
|
|
244115
|
-
getAllIssues() {
|
|
244116
|
-
const result = [];
|
|
244117
|
-
for (const list5 of this.#issuesBySegment.values())
|
|
244118
|
-
result.push(...list5);
|
|
244119
|
-
return result;
|
|
244120
|
-
}
|
|
244121
|
-
getDisplayIssues(ignoredWords) {
|
|
244122
|
-
const normalizedIgnored = new Set(ignoredWords.map((w) => w.normalize("NFC").toLowerCase()));
|
|
244123
|
-
const result = [];
|
|
244124
|
-
for (const list5 of this.#issuesBySegment.values())
|
|
244125
|
-
for (const issue of list5) {
|
|
244126
|
-
if (issue.kind !== "spelling")
|
|
244127
|
-
continue;
|
|
244128
|
-
if (isSuppressed(issue, normalizedIgnored))
|
|
244129
|
-
continue;
|
|
244130
|
-
result.push(issue);
|
|
244131
|
-
}
|
|
244132
|
-
return result;
|
|
244133
|
-
}
|
|
244134
|
-
getActiveRecheckIds() {
|
|
244135
|
-
const ids = /* @__PURE__ */ new Set;
|
|
244136
|
-
for (const list5 of this.#issuesBySegment.values())
|
|
244137
|
-
for (const issue of list5)
|
|
244138
|
-
if (issue.state === "mapped" && issue.recheckId !== null)
|
|
244139
|
-
ids.add(issue.recheckId);
|
|
244140
|
-
return ids;
|
|
244141
|
-
}
|
|
244142
|
-
get isEmpty() {
|
|
244143
|
-
return this.#issuesBySegment.size === 0;
|
|
244144
|
-
}
|
|
244145
|
-
get size() {
|
|
244146
|
-
let count2 = 0;
|
|
244147
|
-
for (const list5 of this.#issuesBySegment.values())
|
|
244148
|
-
count2 += list5.length;
|
|
244149
|
-
return count2;
|
|
244150
|
-
}
|
|
244151
|
-
}, NON_TEXT_INLINE_NODES, DEFAULT_DEBOUNCE_MS = 500, DEFAULT_MAX_WAIT_MS = 2000, DEFAULT_TIMEOUT_MS = 1e4, DEFAULT_MAX_CONCURRENT = 2, DEFAULT_MAX_SEGMENTS_PER_BATCH = 20, DEFAULT_MAX_SUGGESTIONS = 5, ProofingSessionManager = class {
|
|
244152
|
-
#config;
|
|
244153
|
-
#provider = null;
|
|
244154
|
-
#capabilities = null;
|
|
244155
|
-
#status = "disabled";
|
|
244156
|
-
#store = new ProofingStore;
|
|
244157
|
-
#offsetMaps = /* @__PURE__ */ new Map;
|
|
244158
|
-
#segmentHashes = /* @__PURE__ */ new Map;
|
|
244159
|
-
#debounceTimer = null;
|
|
244160
|
-
#pendingAbortControllers = /* @__PURE__ */ new Set;
|
|
244161
|
-
#inFlightCount = 0;
|
|
244162
|
-
#documentEpoch = 0;
|
|
244163
|
-
#disposed = false;
|
|
244164
|
-
#pendingSegments = [];
|
|
244165
|
-
#nextRecheckId = 0;
|
|
244166
|
-
#isComposing = false;
|
|
244167
|
-
#lastCheckFiredAt = 0;
|
|
244168
|
-
#visibilitySource = null;
|
|
244169
|
-
#documentId = null;
|
|
244170
|
-
#pageResolver = null;
|
|
244171
|
-
#lastDoc = null;
|
|
244172
|
-
#lastSegments = [];
|
|
244173
|
-
constructor(config2 = {}) {
|
|
244174
|
-
this.onResultsChanged = null;
|
|
244175
|
-
this.#config = {
|
|
244176
|
-
enabled: config2.enabled ?? false,
|
|
244177
|
-
debounceMs: config2.debounceMs ?? DEFAULT_DEBOUNCE_MS,
|
|
244178
|
-
maxSuggestions: config2.maxSuggestions ?? DEFAULT_MAX_SUGGESTIONS,
|
|
244179
|
-
visibleFirst: config2.visibleFirst ?? true,
|
|
244180
|
-
allowIgnoreWord: config2.allowIgnoreWord ?? true,
|
|
244181
|
-
defaultLanguage: config2.defaultLanguage ?? null,
|
|
244182
|
-
ignoredWords: config2.ignoredWords ?? [],
|
|
244183
|
-
timeoutMs: config2.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
244184
|
-
maxConcurrentRequests: config2.maxConcurrentRequests ?? DEFAULT_MAX_CONCURRENT,
|
|
244185
|
-
maxSegmentsPerBatch: config2.maxSegmentsPerBatch ?? DEFAULT_MAX_SEGMENTS_PER_BATCH,
|
|
244186
|
-
onProofingError: config2.onProofingError ?? null,
|
|
244187
|
-
onStatusChange: config2.onStatusChange ?? null
|
|
244188
|
-
};
|
|
244189
|
-
if (config2.provider)
|
|
244190
|
-
this.#provider = config2.provider;
|
|
244191
|
-
if (this.#config.enabled && this.#provider)
|
|
244192
|
-
this.#setStatus("idle");
|
|
244193
|
-
}
|
|
244194
|
-
get status() {
|
|
244195
|
-
return this.#status;
|
|
244196
|
-
}
|
|
244197
|
-
get isEnabled() {
|
|
244198
|
-
return this.#config.enabled && this.#provider !== null;
|
|
244199
|
-
}
|
|
244200
|
-
get config() {
|
|
244201
|
-
return this.#config;
|
|
244202
|
-
}
|
|
244203
|
-
setVisibilitySource(source) {
|
|
244204
|
-
this.#visibilitySource = source;
|
|
244205
|
-
}
|
|
244206
|
-
setDocumentId(id2) {
|
|
244207
|
-
this.#documentId = id2;
|
|
244208
|
-
}
|
|
244209
|
-
setPageResolver(resolver2) {
|
|
244210
|
-
this.#pageResolver = resolver2;
|
|
244211
|
-
}
|
|
244212
|
-
setComposing(composing) {
|
|
244213
|
-
this.#isComposing = composing;
|
|
244214
|
-
if (!composing && this.#lastSegments.length > 0 && this.isEnabled)
|
|
244215
|
-
this.#scheduleDebouncedCheck(this.#lastSegments);
|
|
244216
|
-
}
|
|
244217
|
-
getPaintSlices(activeWordRange) {
|
|
244218
|
-
if (!this.isEnabled)
|
|
244219
|
-
return [];
|
|
244220
|
-
const slices = buildPaintSlices(this.#store.getDisplayIssues(this.#config.ignoredWords));
|
|
244221
|
-
if (!activeWordRange)
|
|
244222
|
-
return slices;
|
|
244223
|
-
return slices.filter((s2) => s2.pmTo <= activeWordRange.from || s2.pmFrom >= activeWordRange.to);
|
|
244224
|
-
}
|
|
244225
|
-
getIssueAtPosition(pmPos, activeWordRange) {
|
|
244226
|
-
return findSliceAtPosition(this.getPaintSlices(activeWordRange), pmPos)?.issue ?? null;
|
|
244227
|
-
}
|
|
244228
|
-
updateConfig(patch3, doc$12) {
|
|
244229
|
-
const prevEnabled = this.#config.enabled;
|
|
244230
|
-
const prevProvider = this.#provider;
|
|
244231
|
-
const needsRecheck = patch3.provider !== undefined || patch3.defaultLanguage !== undefined;
|
|
244232
|
-
if (patch3.debounceMs !== undefined)
|
|
244233
|
-
this.#config.debounceMs = patch3.debounceMs;
|
|
244234
|
-
if (patch3.maxSuggestions !== undefined)
|
|
244235
|
-
this.#config.maxSuggestions = patch3.maxSuggestions;
|
|
244236
|
-
if (patch3.visibleFirst !== undefined)
|
|
244237
|
-
this.#config.visibleFirst = patch3.visibleFirst;
|
|
244238
|
-
if (patch3.allowIgnoreWord !== undefined)
|
|
244239
|
-
this.#config.allowIgnoreWord = patch3.allowIgnoreWord;
|
|
244240
|
-
if (patch3.timeoutMs !== undefined)
|
|
244241
|
-
this.#config.timeoutMs = patch3.timeoutMs;
|
|
244242
|
-
if (patch3.maxConcurrentRequests !== undefined)
|
|
244243
|
-
this.#config.maxConcurrentRequests = patch3.maxConcurrentRequests;
|
|
244244
|
-
if (patch3.maxSegmentsPerBatch !== undefined)
|
|
244245
|
-
this.#config.maxSegmentsPerBatch = patch3.maxSegmentsPerBatch;
|
|
244246
|
-
if (patch3.onProofingError !== undefined)
|
|
244247
|
-
this.#config.onProofingError = patch3.onProofingError ?? null;
|
|
244248
|
-
if (patch3.onStatusChange !== undefined)
|
|
244249
|
-
this.#config.onStatusChange = patch3.onStatusChange ?? null;
|
|
244250
|
-
if (patch3.defaultLanguage !== undefined)
|
|
244251
|
-
this.#config.defaultLanguage = patch3.defaultLanguage ?? null;
|
|
244252
|
-
if (patch3.ignoredWords !== undefined) {
|
|
244253
|
-
this.#config.ignoredWords = patch3.ignoredWords ?? [];
|
|
244254
|
-
this.onResultsChanged?.();
|
|
244255
|
-
}
|
|
244256
|
-
if (patch3.provider !== undefined) {
|
|
244257
|
-
if (prevProvider && prevProvider !== patch3.provider)
|
|
244258
|
-
prevProvider.dispose?.();
|
|
244259
|
-
this.#provider = patch3.provider ?? null;
|
|
244260
|
-
this.#capabilities = null;
|
|
244261
|
-
}
|
|
244262
|
-
if (patch3.enabled !== undefined) {
|
|
244263
|
-
this.#config.enabled = patch3.enabled;
|
|
244264
|
-
if (!patch3.enabled) {
|
|
244265
|
-
this.#cancelAll();
|
|
244266
|
-
this.#store.clear();
|
|
244267
|
-
this.#segmentHashes.clear();
|
|
244268
|
-
this.#offsetMaps.clear();
|
|
244269
|
-
this.#setStatus("disabled");
|
|
244270
|
-
this.onResultsChanged?.();
|
|
244271
|
-
return;
|
|
244272
|
-
}
|
|
244273
|
-
if (patch3.enabled && !prevEnabled && doc$12) {
|
|
244274
|
-
this.#setStatus("idle");
|
|
244275
|
-
this.#scheduleFullCheck(doc$12);
|
|
244276
|
-
return;
|
|
244277
|
-
}
|
|
244278
|
-
}
|
|
244279
|
-
if (needsRecheck && this.isEnabled && doc$12) {
|
|
244280
|
-
this.#cancelAll();
|
|
244281
|
-
this.#documentEpoch++;
|
|
244282
|
-
this.#store.clear();
|
|
244283
|
-
this.#segmentHashes.clear();
|
|
244284
|
-
this.onResultsChanged?.();
|
|
244285
|
-
this.#scheduleFullCheck(doc$12);
|
|
244286
|
-
}
|
|
244287
|
-
}
|
|
244288
|
-
onDocumentChanged(doc$12, changedRanges, mapping) {
|
|
244289
|
-
if (!this.isEnabled)
|
|
244290
|
-
return;
|
|
244291
|
-
this.#documentEpoch++;
|
|
244292
|
-
this.#lastDoc = doc$12;
|
|
244293
|
-
const { segments, offsetMaps, segmentPositions } = extractSegmentsWithMaps(doc$12, this.#config.defaultLanguage, this.#pageResolver ?? undefined);
|
|
244294
|
-
this.#lastSegments = segments;
|
|
244295
|
-
this.#offsetMaps = offsetMaps;
|
|
244296
|
-
const dirtyIds = computeDirtySegmentIds(segments, segmentPositions, changedRanges);
|
|
244297
|
-
for (const id2 of dirtyIds)
|
|
244298
|
-
this.#segmentHashes.delete(id2);
|
|
244299
|
-
if (dirtyIds.size > 0) {
|
|
244300
|
-
const recheckId = this.#nextRecheckId++;
|
|
244301
|
-
this.#store.remapIssues(dirtyIds, mapping, recheckId);
|
|
244302
|
-
this.#store.removeOrphanedSegments(new Set(segments.map((s2) => s2.id)));
|
|
244303
|
-
}
|
|
244304
|
-
this.#scheduleDebouncedCheck(segments);
|
|
244305
|
-
}
|
|
244306
|
-
runInitialCheck(doc$12) {
|
|
244307
|
-
if (!this.isEnabled)
|
|
244308
|
-
return;
|
|
244309
|
-
this.#scheduleFullCheck(doc$12);
|
|
244310
|
-
}
|
|
244311
|
-
ignoreWord(word$1) {
|
|
244312
|
-
const normalized = word$1.normalize("NFC").toLowerCase();
|
|
244313
|
-
if (!this.#config.ignoredWords.includes(normalized)) {
|
|
244314
|
-
this.#config.ignoredWords = [...this.#config.ignoredWords, normalized];
|
|
244315
|
-
this.onResultsChanged?.();
|
|
244316
|
-
}
|
|
244317
|
-
}
|
|
244318
|
-
removeIgnoredWord(word$1) {
|
|
244319
|
-
const normalized = word$1.normalize("NFC").toLowerCase();
|
|
244320
|
-
this.#config.ignoredWords = this.#config.ignoredWords.filter((w) => w !== normalized);
|
|
244321
|
-
this.onResultsChanged?.();
|
|
244322
|
-
}
|
|
244323
|
-
dispose() {
|
|
244324
|
-
this.#disposed = true;
|
|
244325
|
-
this.#cancelAll();
|
|
244326
|
-
this.#store.clear();
|
|
244327
|
-
this.#offsetMaps.clear();
|
|
244328
|
-
this.#segmentHashes.clear();
|
|
244329
|
-
this.#lastDoc = null;
|
|
244330
|
-
this.#lastSegments = [];
|
|
244331
|
-
this.#pendingSegments = [];
|
|
244332
|
-
this.#provider?.dispose?.();
|
|
244333
|
-
this.#provider = null;
|
|
244334
|
-
this.#setStatus("disabled");
|
|
244335
|
-
}
|
|
244336
|
-
#scheduleFullCheck(doc$12) {
|
|
244337
|
-
this.#lastDoc = doc$12;
|
|
244338
|
-
const { segments, offsetMaps } = extractSegmentsWithMaps(doc$12, this.#config.defaultLanguage, this.#pageResolver ?? undefined);
|
|
244339
|
-
this.#lastSegments = segments;
|
|
244340
|
-
this.#offsetMaps = offsetMaps;
|
|
244341
|
-
this.#segmentHashes.clear();
|
|
244342
|
-
this.#store.clear();
|
|
244343
|
-
this.#scheduleDebouncedCheck(segments);
|
|
244344
|
-
}
|
|
244345
|
-
#scheduleDebouncedCheck(segments) {
|
|
244346
|
-
if (this.#isComposing)
|
|
244347
|
-
return;
|
|
244348
|
-
if (this.#debounceTimer !== null)
|
|
244349
|
-
clearTimeout(this.#debounceTimer);
|
|
244350
|
-
const msSinceLastCheck = Date.now() - this.#lastCheckFiredAt;
|
|
244351
|
-
if (this.#lastCheckFiredAt > 0 && msSinceLastCheck >= DEFAULT_MAX_WAIT_MS)
|
|
244352
|
-
this.#fireCheck(segments);
|
|
244353
|
-
else
|
|
244354
|
-
this.#debounceTimer = setTimeout(() => {
|
|
244355
|
-
this.#debounceTimer = null;
|
|
244356
|
-
this.#fireCheck(segments);
|
|
244357
|
-
}, this.#config.debounceMs);
|
|
244358
|
-
}
|
|
244359
|
-
#fireCheck(segments) {
|
|
244360
|
-
this.#lastCheckFiredAt = Date.now();
|
|
244361
|
-
this.#runCheck(segments);
|
|
244362
|
-
}
|
|
244363
|
-
async#runCheck(segments) {
|
|
244364
|
-
if (this.#disposed || !this.#provider)
|
|
244365
|
-
return;
|
|
244366
|
-
if (!this.#capabilities && this.#provider.getCapabilities)
|
|
244367
|
-
try {
|
|
244368
|
-
this.#capabilities = await this.#provider.getCapabilities();
|
|
244369
|
-
} catch {}
|
|
244370
|
-
const unchecked = segments.filter((seg) => {
|
|
244371
|
-
const hash$3 = hashSegmentText(seg.text);
|
|
244372
|
-
return this.#segmentHashes.get(seg.id) !== hash$3;
|
|
244373
|
-
});
|
|
244374
|
-
if (unchecked.length === 0) {
|
|
244375
|
-
this.#setStatus("idle");
|
|
244376
|
-
return;
|
|
244377
|
-
}
|
|
244378
|
-
const activeRecheckIds = this.#store.getActiveRecheckIds();
|
|
244379
|
-
const ordered = this.#config.visibleFirst && this.#visibilitySource ? prioritizeByVisibility(unchecked, this.#visibilitySource) : unchecked;
|
|
244380
|
-
const batches = this.#batchSegments(ordered);
|
|
244381
|
-
const epoch = this.#documentEpoch;
|
|
244382
|
-
this.#pendingSegments = [];
|
|
244383
|
-
for (let i4 = 0;i4 < batches.length; i4++) {
|
|
244384
|
-
if (this.#disposed || epoch !== this.#documentEpoch)
|
|
244385
|
-
return;
|
|
244386
|
-
if (this.#inFlightCount >= this.#config.maxConcurrentRequests) {
|
|
244387
|
-
for (let j = i4;j < batches.length; j++)
|
|
244388
|
-
this.#pendingSegments.push(...batches[j]);
|
|
244389
|
-
break;
|
|
244390
|
-
}
|
|
244391
|
-
this.#sendBatch(batches[i4], epoch, activeRecheckIds);
|
|
244392
|
-
}
|
|
244393
|
-
}
|
|
244394
|
-
async#sendBatch(segments, epoch, recheckIds) {
|
|
244395
|
-
if (!this.#provider || this.#disposed)
|
|
244396
|
-
return;
|
|
244397
|
-
const controller = new AbortController;
|
|
244398
|
-
this.#pendingAbortControllers.add(controller);
|
|
244399
|
-
this.#inFlightCount++;
|
|
244400
|
-
this.#setStatus("checking");
|
|
244401
|
-
const timeoutId = setTimeout(() => controller.abort(), this.#config.timeoutMs);
|
|
244402
|
-
const request = {
|
|
244403
|
-
documentId: this.#documentId,
|
|
244404
|
-
defaultLanguage: this.#config.defaultLanguage,
|
|
244405
|
-
maxSuggestions: this.#config.maxSuggestions,
|
|
244406
|
-
segments,
|
|
244407
|
-
signal: controller.signal
|
|
244408
|
-
};
|
|
244409
|
-
try {
|
|
244410
|
-
const result = await this.#provider.check(request);
|
|
244411
|
-
clearTimeout(timeoutId);
|
|
244412
|
-
if (!this.#pendingAbortControllers.delete(controller))
|
|
244413
|
-
return;
|
|
244414
|
-
this.#inFlightCount--;
|
|
244415
|
-
if (epoch !== this.#documentEpoch || this.#disposed) {
|
|
244416
|
-
this.#drainPendingSegments();
|
|
244417
|
-
return;
|
|
244418
|
-
}
|
|
244419
|
-
const validSegmentIds = new Set(segments.map((s2) => s2.id));
|
|
244420
|
-
const segmentTextMap = new Map(segments.map((s2) => [s2.id, s2]));
|
|
244421
|
-
const freshIssues = [];
|
|
244422
|
-
for (const issue of result.issues) {
|
|
244423
|
-
if (!this.#validateIssue(issue, validSegmentIds, segmentTextMap))
|
|
244424
|
-
continue;
|
|
244425
|
-
const offsetMap = this.#offsetMaps.get(issue.segmentId);
|
|
244426
|
-
if (!offsetMap)
|
|
244427
|
-
continue;
|
|
244428
|
-
const resolved = resolveIssuePmRangeFromSlices(issue, offsetMap.slices);
|
|
244429
|
-
if (!resolved)
|
|
244430
|
-
continue;
|
|
244431
|
-
const segment = segmentTextMap.get(issue.segmentId);
|
|
244432
|
-
const storedIssue = {
|
|
244433
|
-
...resolved,
|
|
244434
|
-
state: "confirmed",
|
|
244435
|
-
recheckId: null
|
|
244436
|
-
};
|
|
244437
|
-
if (segment)
|
|
244438
|
-
storedIssue.word = segment.text.slice(issue.start, issue.end);
|
|
244439
|
-
freshIssues.push(storedIssue);
|
|
244440
|
-
}
|
|
244441
|
-
this.#store.replaceBatchResults(recheckIds, validSegmentIds, freshIssues);
|
|
244442
|
-
for (const seg of segments)
|
|
244443
|
-
this.#segmentHashes.set(seg.id, hashSegmentText(seg.text));
|
|
244444
|
-
this.#setStatus(this.#inFlightCount > 0 ? "checking" : "idle");
|
|
244445
|
-
this.onResultsChanged?.();
|
|
244446
|
-
this.#schedulePendingSegments(epoch, recheckIds);
|
|
244447
|
-
} catch (err) {
|
|
244448
|
-
clearTimeout(timeoutId);
|
|
244449
|
-
if (!this.#pendingAbortControllers.delete(controller))
|
|
244450
|
-
return;
|
|
244451
|
-
this.#inFlightCount--;
|
|
244452
|
-
if (this.#disposed)
|
|
244453
|
-
return;
|
|
244454
|
-
if (epoch !== this.#documentEpoch) {
|
|
244455
|
-
this.#drainPendingSegments();
|
|
244456
|
-
return;
|
|
244457
|
-
}
|
|
244458
|
-
const isTimeout = controller.signal.aborted;
|
|
244459
|
-
const proofingError = {
|
|
244460
|
-
kind: isTimeout ? "timeout" : "provider-error",
|
|
244461
|
-
message: isTimeout ? "Provider request timed out" : String(err),
|
|
244462
|
-
segmentIds: segments.map((s2) => s2.id),
|
|
244463
|
-
cause: err
|
|
244464
|
-
};
|
|
244465
|
-
this.#config.onProofingError?.(proofingError);
|
|
244466
|
-
this.#setStatus(this.#inFlightCount > 0 ? "checking" : "degraded");
|
|
244467
|
-
this.#schedulePendingSegments(epoch, recheckIds);
|
|
244468
|
-
}
|
|
244469
|
-
}
|
|
244470
|
-
#schedulePendingSegments(epoch, recheckIds) {
|
|
244471
|
-
if (this.#disposed || epoch !== this.#documentEpoch)
|
|
244253
|
+
if (!this.#container)
|
|
244472
244254
|
return;
|
|
244473
|
-
|
|
244255
|
+
const annotations = this.#container.querySelectorAll(buildAnnotationSelector());
|
|
244256
|
+
for (let index2 = 0;index2 < annotations.length; index2 += 1) {
|
|
244257
|
+
const annotation = annotations[index2];
|
|
244258
|
+
annotation.removeAttribute("draggable");
|
|
244259
|
+
delete annotation.dataset[DATASET_KEYS.DRAGGABLE];
|
|
244260
|
+
delete annotation.dataset[DATASET_KEYS.DISPLAY_LABEL];
|
|
244261
|
+
delete annotation.dataset[DATASET_KEYS.VARIANT];
|
|
244262
|
+
delete annotation.dataset[INTERACTION_EPOCH_KEY];
|
|
244263
|
+
delete annotation.dataset[DISPLAY_LABEL_SOURCE_KEY];
|
|
244264
|
+
annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CARET_ANCHOR}`)?.remove();
|
|
244265
|
+
}
|
|
244266
|
+
}
|
|
244267
|
+
#ensureCaretAnchor(annotation) {
|
|
244268
|
+
if (annotation.querySelector(`.${DOM_CLASS_NAMES.ANNOTATION_CARET_ANCHOR}`))
|
|
244474
244269
|
return;
|
|
244475
|
-
|
|
244270
|
+
const pmEnd = annotation.dataset[DATASET_KEYS.PM_END];
|
|
244271
|
+
const layoutEpoch = annotation.dataset[DATASET_KEYS.LAYOUT_EPOCH];
|
|
244272
|
+
if (pmEnd == null)
|
|
244476
244273
|
return;
|
|
244477
|
-
const
|
|
244478
|
-
if (
|
|
244479
|
-
this.#sendBatch(nextBatch, epoch, recheckIds);
|
|
244480
|
-
}
|
|
244481
|
-
#drainPendingSegments() {
|
|
244482
|
-
if (this.#disposed || this.#pendingSegments.length === 0)
|
|
244274
|
+
const doc$12 = this.#container?.ownerDocument;
|
|
244275
|
+
if (!doc$12)
|
|
244483
244276
|
return;
|
|
244484
|
-
|
|
244485
|
-
|
|
244486
|
-
|
|
244487
|
-
|
|
244488
|
-
|
|
244489
|
-
|
|
244490
|
-
|
|
244491
|
-
|
|
244492
|
-
|
|
244493
|
-
|
|
244494
|
-
|
|
244495
|
-
|
|
244496
|
-
|
|
244497
|
-
|
|
244498
|
-
|
|
244499
|
-
|
|
244500
|
-
|
|
244501
|
-
|
|
244502
|
-
kind: "validation-error",
|
|
244503
|
-
message,
|
|
244504
|
-
segmentIds
|
|
244505
|
-
});
|
|
244506
|
-
}
|
|
244507
|
-
#batchSegments(segments) {
|
|
244508
|
-
const batches = [];
|
|
244509
|
-
for (let i4 = 0;i4 < segments.length; i4 += this.#config.maxSegmentsPerBatch)
|
|
244510
|
-
batches.push(segments.slice(i4, i4 + this.#config.maxSegmentsPerBatch));
|
|
244511
|
-
return batches;
|
|
244512
|
-
}
|
|
244513
|
-
#cancelAll() {
|
|
244514
|
-
if (this.#debounceTimer !== null) {
|
|
244515
|
-
clearTimeout(this.#debounceTimer);
|
|
244516
|
-
this.#debounceTimer = null;
|
|
244517
|
-
}
|
|
244518
|
-
for (const controller of this.#pendingAbortControllers)
|
|
244519
|
-
controller.abort();
|
|
244520
|
-
this.#pendingAbortControllers.clear();
|
|
244521
|
-
this.#inFlightCount = 0;
|
|
244522
|
-
this.#pendingSegments = [];
|
|
244523
|
-
}
|
|
244524
|
-
#setStatus(status) {
|
|
244525
|
-
if (this.#status !== status) {
|
|
244526
|
-
this.#status = status;
|
|
244527
|
-
this.#config.onStatusChange?.(status);
|
|
244528
|
-
}
|
|
244277
|
+
const caretAnchor = doc$12.createElement("span");
|
|
244278
|
+
caretAnchor.dataset[DATASET_KEYS.PM_START] = pmEnd;
|
|
244279
|
+
caretAnchor.dataset[DATASET_KEYS.PM_END] = pmEnd;
|
|
244280
|
+
caretAnchor.dataset[DATASET_KEYS.LAYOUT_EPOCH] = layoutEpoch ?? "";
|
|
244281
|
+
caretAnchor.classList.add(DOM_CLASS_NAMES.ANNOTATION_CARET_ANCHOR);
|
|
244282
|
+
caretAnchor.style.position = "absolute";
|
|
244283
|
+
caretAnchor.style.left = "100%";
|
|
244284
|
+
caretAnchor.style.top = "0";
|
|
244285
|
+
caretAnchor.style.width = "0";
|
|
244286
|
+
caretAnchor.style.height = "1em";
|
|
244287
|
+
caretAnchor.style.overflow = "hidden";
|
|
244288
|
+
caretAnchor.style.pointerEvents = "none";
|
|
244289
|
+
caretAnchor.style.userSelect = "none";
|
|
244290
|
+
caretAnchor.style.opacity = "0";
|
|
244291
|
+
caretAnchor.textContent = "";
|
|
244292
|
+
if (!annotation.style.position)
|
|
244293
|
+
annotation.style.position = "relative";
|
|
244294
|
+
annotation.appendChild(caretAnchor);
|
|
244529
244295
|
}
|
|
244530
244296
|
}, FONT_FAMILY_FALLBACKS2, DEFAULT_GENERIC_FALLBACK2 = "sans-serif", normalizeParts = (value) => (value || "").split(",").map((part) => part.trim()).filter(Boolean), splitOutsideQuotes = (str, delimiter) => {
|
|
244531
244297
|
if (!str.includes('"') && !str.includes("'"))
|
|
@@ -244983,9 +244749,8 @@ var Node$13 = class Node$14 {
|
|
|
244983
244749
|
border-color: transparent;
|
|
244984
244750
|
}
|
|
244985
244751
|
|
|
244986
|
-
/* Group hover (JavaScript-coordinated) */
|
|
244987
|
-
.superdoc-structured-content-block.sdt-group-hover:not(.ProseMirror-selectednode)
|
|
244988
|
-
.superdoc-structured-content-block.sdt-hover:not(.ProseMirror-selectednode) {
|
|
244752
|
+
/* Group hover (JavaScript-coordinated via PresentationEditor) */
|
|
244753
|
+
.superdoc-structured-content-block.sdt-group-hover:not(.ProseMirror-selectednode) {
|
|
244989
244754
|
background-color: var(--sd-content-controls-block-hover-bg, #f2f2f2);
|
|
244990
244755
|
border-color: transparent;
|
|
244991
244756
|
}
|
|
@@ -245029,7 +244794,7 @@ var Node$13 = class Node$14 {
|
|
|
245029
244794
|
}
|
|
245030
244795
|
|
|
245031
244796
|
.superdoc-structured-content-block.ProseMirror-selectednode .superdoc-structured-content__label,
|
|
245032
|
-
.superdoc-structured-content-block.sdt-hover:not(.ProseMirror-selectednode) .superdoc-structured-content__label {
|
|
244797
|
+
.superdoc-structured-content-block.sdt-group-hover:not(.ProseMirror-selectednode) .superdoc-structured-content__label {
|
|
245033
244798
|
display: inline-flex;
|
|
245034
244799
|
}
|
|
245035
244800
|
|
|
@@ -245117,10 +244882,10 @@ var Node$13 = class Node$14 {
|
|
|
245117
244882
|
|
|
245118
244883
|
/* Hover highlight for SDT containers.
|
|
245119
244884
|
* Hover adds background highlight and z-index boost.
|
|
245120
|
-
* Block SDTs use .sdt-hover class (event delegation for multi-fragment coordination).
|
|
244885
|
+
* Block SDTs use .sdt-group-hover class (event delegation for multi-fragment coordination).
|
|
245121
244886
|
* Inline SDTs use :hover (single element, no coordination needed).
|
|
245122
244887
|
* Hover is suppressed when the node is selected (SD-1584). */
|
|
245123
|
-
.superdoc-structured-content-block[data-lock-mode].sdt-hover:not(.ProseMirror-selectednode),
|
|
244888
|
+
.superdoc-structured-content-block[data-lock-mode].sdt-group-hover:not(.ProseMirror-selectednode),
|
|
245124
244889
|
.superdoc-structured-content-inline[data-lock-mode]:hover:not(.ProseMirror-selectednode) {
|
|
245125
244890
|
background-color: var(--sd-content-controls-lock-hover-bg, rgba(98, 155, 231, 0.08));
|
|
245126
244891
|
z-index: 9999999;
|
|
@@ -245140,8 +244905,7 @@ var Node$13 = class Node$14 {
|
|
|
245140
244905
|
}
|
|
245141
244906
|
|
|
245142
244907
|
.presentation-editor--viewing .superdoc-structured-content-block.sdt-group-hover,
|
|
245143
|
-
.presentation-editor--viewing .superdoc-structured-content-block.sdt-hover
|
|
245144
|
-
.presentation-editor--viewing .superdoc-structured-content-block[data-lock-mode].sdt-hover {
|
|
244908
|
+
.presentation-editor--viewing .superdoc-structured-content-block[data-lock-mode].sdt-group-hover {
|
|
245145
244909
|
background: none;
|
|
245146
244910
|
border: none;
|
|
245147
244911
|
}
|
|
@@ -245178,11 +244942,8 @@ var Node$13 = class Node$14 {
|
|
|
245178
244942
|
}
|
|
245179
244943
|
}
|
|
245180
244944
|
`, FIELD_ANNOTATION_STYLES = `
|
|
245181
|
-
/* Field annotation
|
|
245182
|
-
|
|
245183
|
-
user-select: text;
|
|
245184
|
-
}
|
|
245185
|
-
|
|
244945
|
+
/* Field annotation visual styles — suppress native selection artifacts.
|
|
244946
|
+
* Annotations are atomic inline nodes; native selection and caret look broken. */
|
|
245186
244947
|
.superdoc-layout .annotation::selection,
|
|
245187
244948
|
.superdoc-layout .annotation *::selection {
|
|
245188
244949
|
background: transparent;
|
|
@@ -245197,41 +244958,7 @@ var Node$13 = class Node$14 {
|
|
|
245197
244958
|
.superdoc-layout .annotation * {
|
|
245198
244959
|
caret-color: transparent;
|
|
245199
244960
|
}
|
|
245200
|
-
|
|
245201
|
-
.superdoc-layout .annotation[data-draggable="true"]:hover {
|
|
245202
|
-
opacity: 0.9;
|
|
245203
|
-
}
|
|
245204
|
-
|
|
245205
|
-
.superdoc-layout .annotation[data-draggable="true"]:active {
|
|
245206
|
-
cursor: grabbing;
|
|
245207
|
-
}
|
|
245208
|
-
|
|
245209
|
-
/* Drag over indicator for drop targets */
|
|
245210
|
-
.superdoc-layout.drag-over {
|
|
245211
|
-
outline: 2px dashed #b015b3;
|
|
245212
|
-
outline-offset: -2px;
|
|
245213
|
-
}
|
|
245214
|
-
|
|
245215
|
-
/* Drop zone indicator */
|
|
245216
|
-
.superdoc-layout .superdoc-drop-indicator {
|
|
245217
|
-
position: absolute;
|
|
245218
|
-
width: 2px;
|
|
245219
|
-
background-color: #b015b3;
|
|
245220
|
-
pointer-events: none;
|
|
245221
|
-
z-index: 1000;
|
|
245222
|
-
}
|
|
245223
|
-
`, IMAGE_SELECTION_STYLES, NATIVE_SELECTION_STYLES = `
|
|
245224
|
-
/* Hide native browser selection on layout engine content.
|
|
245225
|
-
* We render our own selection overlay via PresentationEditor's #localSelectionLayer
|
|
245226
|
-
* for precise control over selection geometry across pages and zoom levels. */
|
|
245227
|
-
.superdoc-layout *::selection {
|
|
245228
|
-
background: transparent;
|
|
245229
|
-
}
|
|
245230
|
-
|
|
245231
|
-
.superdoc-layout *::-moz-selection {
|
|
245232
|
-
background: transparent;
|
|
245233
|
-
}
|
|
245234
|
-
`, printStylesInjected = false, linkStylesInjected = false, trackChangeStylesInjected = false, sdtContainerStylesInjected = false, fieldAnnotationStylesInjected = false, imageSelectionStylesInjected = false, nativeSelectionStylesInjected = false, ensurePrintStyles = (doc$12) => {
|
|
244961
|
+
`, IMAGE_SELECTION_STYLES, printStylesInjected = false, linkStylesInjected = false, trackChangeStylesInjected = false, sdtContainerStylesInjected = false, fieldAnnotationStylesInjected = false, imageSelectionStylesInjected = false, ensurePrintStyles = (doc$12) => {
|
|
245235
244962
|
if (printStylesInjected || !doc$12)
|
|
245236
244963
|
return;
|
|
245237
244964
|
const styleEl = doc$12.createElement("style");
|
|
@@ -245279,14 +245006,6 @@ var Node$13 = class Node$14 {
|
|
|
245279
245006
|
styleEl.textContent = IMAGE_SELECTION_STYLES;
|
|
245280
245007
|
doc$12.head?.appendChild(styleEl);
|
|
245281
245008
|
imageSelectionStylesInjected = true;
|
|
245282
|
-
}, ensureNativeSelectionStyles = (doc$12) => {
|
|
245283
|
-
if (nativeSelectionStylesInjected || !doc$12)
|
|
245284
|
-
return;
|
|
245285
|
-
const styleEl = doc$12.createElement("style");
|
|
245286
|
-
styleEl.setAttribute("data-superdoc-native-selection-styles", "true");
|
|
245287
|
-
styleEl.textContent = NATIVE_SELECTION_STYLES;
|
|
245288
|
-
doc$12.head?.appendChild(styleEl);
|
|
245289
|
-
nativeSelectionStylesInjected = true;
|
|
245290
245009
|
}, gradientIdCounter = 0, getFragmentParagraphBorders = (fragment2, blockLookup) => {
|
|
245291
245010
|
const lookup3 = blockLookup.get(fragment2.blockId);
|
|
245292
245011
|
if (!lookup3)
|
|
@@ -246673,57 +246392,6 @@ var Node$13 = class Node$14 {
|
|
|
246673
246392
|
y$1 += actualRowHeight + cellSpacingPx;
|
|
246674
246393
|
}
|
|
246675
246394
|
return container;
|
|
246676
|
-
}, SDT_BLOCK_SELECTOR, HOVER_CLASS, SdtGroupedHover = class {
|
|
246677
|
-
constructor() {
|
|
246678
|
-
this.hoveredSdtId = null;
|
|
246679
|
-
this.mount = null;
|
|
246680
|
-
this.onMouseOver = null;
|
|
246681
|
-
this.onMouseLeave = null;
|
|
246682
|
-
}
|
|
246683
|
-
bind(mount) {
|
|
246684
|
-
this.destroy();
|
|
246685
|
-
this.mount = mount;
|
|
246686
|
-
this.onMouseOver = (e) => {
|
|
246687
|
-
const sdtId = e.target.closest?.(SDT_BLOCK_SELECTOR)?.dataset.sdtId ?? null;
|
|
246688
|
-
if (sdtId === this.hoveredSdtId)
|
|
246689
|
-
return;
|
|
246690
|
-
if (this.hoveredSdtId)
|
|
246691
|
-
sdtElementsById(mount, this.hoveredSdtId).forEach((el) => el.classList.remove(HOVER_CLASS));
|
|
246692
|
-
this.hoveredSdtId = sdtId;
|
|
246693
|
-
if (sdtId)
|
|
246694
|
-
sdtElementsById(mount, sdtId).forEach((el) => {
|
|
246695
|
-
if (!el.classList.contains("ProseMirror-selectednode"))
|
|
246696
|
-
el.classList.add(HOVER_CLASS);
|
|
246697
|
-
});
|
|
246698
|
-
};
|
|
246699
|
-
this.onMouseLeave = () => {
|
|
246700
|
-
if (this.hoveredSdtId) {
|
|
246701
|
-
sdtElementsById(mount, this.hoveredSdtId).forEach((el) => el.classList.remove(HOVER_CLASS));
|
|
246702
|
-
this.hoveredSdtId = null;
|
|
246703
|
-
}
|
|
246704
|
-
};
|
|
246705
|
-
mount.addEventListener("mouseover", this.onMouseOver);
|
|
246706
|
-
mount.addEventListener("mouseleave", this.onMouseLeave);
|
|
246707
|
-
}
|
|
246708
|
-
reapply() {
|
|
246709
|
-
if (this.hoveredSdtId && this.mount)
|
|
246710
|
-
sdtElementsById(this.mount, this.hoveredSdtId).forEach((el) => {
|
|
246711
|
-
if (!el.classList.contains("ProseMirror-selectednode"))
|
|
246712
|
-
el.classList.add(HOVER_CLASS);
|
|
246713
|
-
});
|
|
246714
|
-
}
|
|
246715
|
-
destroy() {
|
|
246716
|
-
if (this.mount) {
|
|
246717
|
-
if (this.onMouseOver)
|
|
246718
|
-
this.mount.removeEventListener("mouseover", this.onMouseOver);
|
|
246719
|
-
if (this.onMouseLeave)
|
|
246720
|
-
this.mount.removeEventListener("mouseleave", this.onMouseLeave);
|
|
246721
|
-
}
|
|
246722
|
-
this.mount = null;
|
|
246723
|
-
this.onMouseOver = null;
|
|
246724
|
-
this.onMouseLeave = null;
|
|
246725
|
-
this.hoveredSdtId = null;
|
|
246726
|
-
}
|
|
246727
246395
|
}, isRtlParagraph = (attrs) => attrs?.direction === "rtl" || attrs?.rtl === true, resolveTextAlign = (alignment$1, isRtl) => {
|
|
246728
246396
|
switch (alignment$1) {
|
|
246729
246397
|
case "center":
|
|
@@ -247597,6 +247265,9 @@ var Node$13 = class Node$14 {
|
|
|
247597
247265
|
setVirtualizationPins(pageIndices) {
|
|
247598
247266
|
painter.setVirtualizationPins(pageIndices);
|
|
247599
247267
|
},
|
|
247268
|
+
getMountedPageIndices() {
|
|
247269
|
+
return painter.getMountedPageIndices();
|
|
247270
|
+
},
|
|
247600
247271
|
onScroll() {
|
|
247601
247272
|
painter.onScroll();
|
|
247602
247273
|
},
|
|
@@ -247607,46 +247278,737 @@ var Node$13 = class Node$14 {
|
|
|
247607
247278
|
painter.setScrollContainer(el);
|
|
247608
247279
|
}
|
|
247609
247280
|
};
|
|
247281
|
+
}, PresentationProofingDecorator = class {
|
|
247282
|
+
#container = null;
|
|
247283
|
+
setContainer(container) {
|
|
247284
|
+
this.#container = container;
|
|
247285
|
+
}
|
|
247286
|
+
applyAnnotations(annotations) {
|
|
247287
|
+
const container = this.#container;
|
|
247288
|
+
if (!container)
|
|
247289
|
+
return false;
|
|
247290
|
+
if (!annotations || annotations.length === 0)
|
|
247291
|
+
return clearProofingDecorations(container);
|
|
247292
|
+
return applyProofingDecorations(container, annotations);
|
|
247293
|
+
}
|
|
247294
|
+
clear() {
|
|
247295
|
+
const container = this.#container;
|
|
247296
|
+
if (!container)
|
|
247297
|
+
return false;
|
|
247298
|
+
return clearProofingDecorations(container);
|
|
247299
|
+
}
|
|
247300
|
+
}, PresentationPostPaintPipeline = class {
|
|
247301
|
+
#fieldAnnotationLayer;
|
|
247302
|
+
#commentHighlightDecorator;
|
|
247303
|
+
#decorationBridge;
|
|
247304
|
+
#proofingDecorator;
|
|
247305
|
+
constructor(deps = {}) {
|
|
247306
|
+
this.#fieldAnnotationLayer = deps.fieldAnnotationLayer ?? new FieldAnnotationInteractionLayer;
|
|
247307
|
+
this.#commentHighlightDecorator = deps.commentHighlightDecorator ?? new CommentHighlightDecorator;
|
|
247308
|
+
this.#decorationBridge = deps.decorationBridge ?? new DecorationBridge;
|
|
247309
|
+
this.#proofingDecorator = deps.proofingDecorator ?? new PresentationProofingDecorator;
|
|
247310
|
+
}
|
|
247311
|
+
setContainer(container) {
|
|
247312
|
+
this.#fieldAnnotationLayer.setContainer(container);
|
|
247313
|
+
this.#commentHighlightDecorator.setContainer(container);
|
|
247314
|
+
this.#proofingDecorator.setContainer(container);
|
|
247315
|
+
}
|
|
247316
|
+
setActiveComment(commentId) {
|
|
247317
|
+
return this.#commentHighlightDecorator.setActiveComment(commentId);
|
|
247318
|
+
}
|
|
247319
|
+
recordDecorationTransaction(transaction) {
|
|
247320
|
+
this.#decorationBridge.recordTransaction(transaction);
|
|
247321
|
+
}
|
|
247322
|
+
hasDecorationChanges(editorState) {
|
|
247323
|
+
return this.#decorationBridge.hasChanges(editorState);
|
|
247324
|
+
}
|
|
247325
|
+
collectDecorationRanges(editorState) {
|
|
247326
|
+
return this.#decorationBridge.collectDecorationRanges(editorState);
|
|
247327
|
+
}
|
|
247328
|
+
syncDecorations(editorState, domPositionIndex, options) {
|
|
247329
|
+
if (!editorState)
|
|
247330
|
+
return false;
|
|
247331
|
+
return this.#decorationBridge.sync(editorState, domPositionIndex, options);
|
|
247332
|
+
}
|
|
247333
|
+
applyCommentHighlights() {
|
|
247334
|
+
this.#commentHighlightDecorator.apply();
|
|
247335
|
+
}
|
|
247336
|
+
syncInlineStyleLayers(editorState, domPositionIndex) {
|
|
247337
|
+
this.applyCommentHighlights();
|
|
247338
|
+
return this.syncDecorations(editorState, domPositionIndex);
|
|
247339
|
+
}
|
|
247340
|
+
applyProofingAnnotations(annotations, rebuildDomPositionIndex) {
|
|
247341
|
+
const mutated = this.#proofingDecorator.applyAnnotations(annotations);
|
|
247342
|
+
if (mutated)
|
|
247343
|
+
rebuildDomPositionIndex();
|
|
247344
|
+
return mutated;
|
|
247345
|
+
}
|
|
247346
|
+
refreshAfterPaint(options) {
|
|
247347
|
+
this.#fieldAnnotationLayer.apply(options.layoutEpoch);
|
|
247348
|
+
options.rebuildDomPositionIndex();
|
|
247349
|
+
this.syncInlineStyleLayers(options.editorState, options.domPositionIndex);
|
|
247350
|
+
this.applyProofingAnnotations(options.proofingAnnotations, options.rebuildDomPositionIndex);
|
|
247351
|
+
options.reapplyStructuredContentHover?.();
|
|
247352
|
+
}
|
|
247353
|
+
destroy() {
|
|
247354
|
+
this.#proofingDecorator.clear();
|
|
247355
|
+
this.#fieldAnnotationLayer.clear();
|
|
247356
|
+
this.#commentHighlightDecorator.destroy();
|
|
247357
|
+
this.#decorationBridge.destroy();
|
|
247358
|
+
}
|
|
247359
|
+
}, ProofingStore = class {
|
|
247360
|
+
#issuesBySegment = /* @__PURE__ */ new Map;
|
|
247361
|
+
addIssue(issue) {
|
|
247362
|
+
const list5 = this.#issuesBySegment.get(issue.segmentId);
|
|
247363
|
+
if (list5)
|
|
247364
|
+
list5.push(issue);
|
|
247365
|
+
else
|
|
247366
|
+
this.#issuesBySegment.set(issue.segmentId, [issue]);
|
|
247367
|
+
}
|
|
247368
|
+
remapIssues(segmentIds, mapping, recheckId) {
|
|
247369
|
+
for (const id2 of segmentIds) {
|
|
247370
|
+
const list5 = this.#issuesBySegment.get(id2);
|
|
247371
|
+
if (!list5)
|
|
247372
|
+
continue;
|
|
247373
|
+
const surviving = [];
|
|
247374
|
+
for (const issue of list5) {
|
|
247375
|
+
const fromResult = mapping.mapResult(issue.pmFrom, -1);
|
|
247376
|
+
const toResult2 = mapping.mapResult(issue.pmTo, 1);
|
|
247377
|
+
if (fromResult.deleted || toResult2.deleted)
|
|
247378
|
+
continue;
|
|
247379
|
+
if (fromResult.pos >= toResult2.pos)
|
|
247380
|
+
continue;
|
|
247381
|
+
issue.pmFrom = fromResult.pos;
|
|
247382
|
+
issue.pmTo = toResult2.pos;
|
|
247383
|
+
issue.state = "mapped";
|
|
247384
|
+
issue.recheckId = recheckId;
|
|
247385
|
+
surviving.push(issue);
|
|
247386
|
+
}
|
|
247387
|
+
if (surviving.length > 0)
|
|
247388
|
+
this.#issuesBySegment.set(id2, surviving);
|
|
247389
|
+
else
|
|
247390
|
+
this.#issuesBySegment.delete(id2);
|
|
247391
|
+
}
|
|
247392
|
+
}
|
|
247393
|
+
replaceBatchResults(recheckIds, coveredSegmentIds, freshIssues) {
|
|
247394
|
+
for (const segId of coveredSegmentIds) {
|
|
247395
|
+
const list5 = this.#issuesBySegment.get(segId);
|
|
247396
|
+
if (!list5)
|
|
247397
|
+
continue;
|
|
247398
|
+
const filtered = list5.filter((issue) => issue.recheckId === null || !recheckIds.has(issue.recheckId));
|
|
247399
|
+
if (filtered.length > 0)
|
|
247400
|
+
this.#issuesBySegment.set(segId, filtered);
|
|
247401
|
+
else
|
|
247402
|
+
this.#issuesBySegment.delete(segId);
|
|
247403
|
+
}
|
|
247404
|
+
for (const issue of freshIssues)
|
|
247405
|
+
this.addIssue(issue);
|
|
247406
|
+
}
|
|
247407
|
+
removeBySegmentIds(ids) {
|
|
247408
|
+
for (const id2 of ids)
|
|
247409
|
+
this.#issuesBySegment.delete(id2);
|
|
247410
|
+
}
|
|
247411
|
+
removeOrphanedSegments(currentSegmentIds) {
|
|
247412
|
+
for (const segId of this.#issuesBySegment.keys())
|
|
247413
|
+
if (!currentSegmentIds.has(segId))
|
|
247414
|
+
this.#issuesBySegment.delete(segId);
|
|
247415
|
+
}
|
|
247416
|
+
clear() {
|
|
247417
|
+
this.#issuesBySegment.clear();
|
|
247418
|
+
}
|
|
247419
|
+
getAllIssues() {
|
|
247420
|
+
const result = [];
|
|
247421
|
+
for (const list5 of this.#issuesBySegment.values())
|
|
247422
|
+
result.push(...list5);
|
|
247423
|
+
return result;
|
|
247424
|
+
}
|
|
247425
|
+
getDisplayIssues(ignoredWords) {
|
|
247426
|
+
const normalizedIgnored = new Set(ignoredWords.map((w) => w.normalize("NFC").toLowerCase()));
|
|
247427
|
+
const result = [];
|
|
247428
|
+
for (const list5 of this.#issuesBySegment.values())
|
|
247429
|
+
for (const issue of list5) {
|
|
247430
|
+
if (issue.kind !== "spelling")
|
|
247431
|
+
continue;
|
|
247432
|
+
if (isSuppressed(issue, normalizedIgnored))
|
|
247433
|
+
continue;
|
|
247434
|
+
result.push(issue);
|
|
247435
|
+
}
|
|
247436
|
+
return result;
|
|
247437
|
+
}
|
|
247438
|
+
getActiveRecheckIds() {
|
|
247439
|
+
const ids = /* @__PURE__ */ new Set;
|
|
247440
|
+
for (const list5 of this.#issuesBySegment.values())
|
|
247441
|
+
for (const issue of list5)
|
|
247442
|
+
if (issue.state === "mapped" && issue.recheckId !== null)
|
|
247443
|
+
ids.add(issue.recheckId);
|
|
247444
|
+
return ids;
|
|
247445
|
+
}
|
|
247446
|
+
get isEmpty() {
|
|
247447
|
+
return this.#issuesBySegment.size === 0;
|
|
247448
|
+
}
|
|
247449
|
+
get size() {
|
|
247450
|
+
let count2 = 0;
|
|
247451
|
+
for (const list5 of this.#issuesBySegment.values())
|
|
247452
|
+
count2 += list5.length;
|
|
247453
|
+
return count2;
|
|
247454
|
+
}
|
|
247455
|
+
}, NON_TEXT_INLINE_NODES, DEFAULT_DEBOUNCE_MS = 500, DEFAULT_MAX_WAIT_MS = 2000, DEFAULT_TIMEOUT_MS = 1e4, DEFAULT_MAX_CONCURRENT = 2, DEFAULT_MAX_SEGMENTS_PER_BATCH = 20, DEFAULT_MAX_SUGGESTIONS = 5, ProofingSessionManager = class {
|
|
247456
|
+
#config;
|
|
247457
|
+
#provider = null;
|
|
247458
|
+
#capabilities = null;
|
|
247459
|
+
#status = "disabled";
|
|
247460
|
+
#store = new ProofingStore;
|
|
247461
|
+
#offsetMaps = /* @__PURE__ */ new Map;
|
|
247462
|
+
#segmentHashes = /* @__PURE__ */ new Map;
|
|
247463
|
+
#debounceTimer = null;
|
|
247464
|
+
#pendingAbortControllers = /* @__PURE__ */ new Set;
|
|
247465
|
+
#inFlightCount = 0;
|
|
247466
|
+
#documentEpoch = 0;
|
|
247467
|
+
#disposed = false;
|
|
247468
|
+
#pendingSegments = [];
|
|
247469
|
+
#nextRecheckId = 0;
|
|
247470
|
+
#isComposing = false;
|
|
247471
|
+
#lastCheckFiredAt = 0;
|
|
247472
|
+
#visibilitySource = null;
|
|
247473
|
+
#documentId = null;
|
|
247474
|
+
#pageResolver = null;
|
|
247475
|
+
#lastDoc = null;
|
|
247476
|
+
#lastSegments = [];
|
|
247477
|
+
constructor(config2 = {}) {
|
|
247478
|
+
this.onResultsChanged = null;
|
|
247479
|
+
this.#config = {
|
|
247480
|
+
enabled: config2.enabled ?? false,
|
|
247481
|
+
debounceMs: config2.debounceMs ?? DEFAULT_DEBOUNCE_MS,
|
|
247482
|
+
maxSuggestions: config2.maxSuggestions ?? DEFAULT_MAX_SUGGESTIONS,
|
|
247483
|
+
visibleFirst: config2.visibleFirst ?? true,
|
|
247484
|
+
allowIgnoreWord: config2.allowIgnoreWord ?? true,
|
|
247485
|
+
defaultLanguage: config2.defaultLanguage ?? null,
|
|
247486
|
+
ignoredWords: config2.ignoredWords ?? [],
|
|
247487
|
+
timeoutMs: config2.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
247488
|
+
maxConcurrentRequests: config2.maxConcurrentRequests ?? DEFAULT_MAX_CONCURRENT,
|
|
247489
|
+
maxSegmentsPerBatch: config2.maxSegmentsPerBatch ?? DEFAULT_MAX_SEGMENTS_PER_BATCH,
|
|
247490
|
+
onProofingError: config2.onProofingError ?? null,
|
|
247491
|
+
onStatusChange: config2.onStatusChange ?? null
|
|
247492
|
+
};
|
|
247493
|
+
if (config2.provider)
|
|
247494
|
+
this.#provider = config2.provider;
|
|
247495
|
+
if (this.#config.enabled && this.#provider)
|
|
247496
|
+
this.#setStatus("idle");
|
|
247497
|
+
}
|
|
247498
|
+
get status() {
|
|
247499
|
+
return this.#status;
|
|
247500
|
+
}
|
|
247501
|
+
get isEnabled() {
|
|
247502
|
+
return this.#config.enabled && this.#provider !== null;
|
|
247503
|
+
}
|
|
247504
|
+
get config() {
|
|
247505
|
+
return this.#config;
|
|
247506
|
+
}
|
|
247507
|
+
setVisibilitySource(source) {
|
|
247508
|
+
this.#visibilitySource = source;
|
|
247509
|
+
}
|
|
247510
|
+
setDocumentId(id2) {
|
|
247511
|
+
this.#documentId = id2;
|
|
247512
|
+
}
|
|
247513
|
+
setPageResolver(resolver2) {
|
|
247514
|
+
this.#pageResolver = resolver2;
|
|
247515
|
+
}
|
|
247516
|
+
setComposing(composing) {
|
|
247517
|
+
this.#isComposing = composing;
|
|
247518
|
+
if (!composing && this.#lastSegments.length > 0 && this.isEnabled)
|
|
247519
|
+
this.#scheduleDebouncedCheck(this.#lastSegments);
|
|
247520
|
+
}
|
|
247521
|
+
getPaintSlices(activeWordRange) {
|
|
247522
|
+
if (!this.isEnabled)
|
|
247523
|
+
return [];
|
|
247524
|
+
const slices = buildPaintSlices(this.#store.getDisplayIssues(this.#config.ignoredWords));
|
|
247525
|
+
if (!activeWordRange)
|
|
247526
|
+
return slices;
|
|
247527
|
+
return slices.filter((s2) => s2.pmTo <= activeWordRange.from || s2.pmFrom >= activeWordRange.to);
|
|
247528
|
+
}
|
|
247529
|
+
getIssueAtPosition(pmPos, activeWordRange) {
|
|
247530
|
+
return findSliceAtPosition(this.getPaintSlices(activeWordRange), pmPos)?.issue ?? null;
|
|
247531
|
+
}
|
|
247532
|
+
updateConfig(patch3, doc$12) {
|
|
247533
|
+
const prevEnabled = this.#config.enabled;
|
|
247534
|
+
const prevProvider = this.#provider;
|
|
247535
|
+
const needsRecheck = patch3.provider !== undefined || patch3.defaultLanguage !== undefined;
|
|
247536
|
+
if (patch3.debounceMs !== undefined)
|
|
247537
|
+
this.#config.debounceMs = patch3.debounceMs;
|
|
247538
|
+
if (patch3.maxSuggestions !== undefined)
|
|
247539
|
+
this.#config.maxSuggestions = patch3.maxSuggestions;
|
|
247540
|
+
if (patch3.visibleFirst !== undefined)
|
|
247541
|
+
this.#config.visibleFirst = patch3.visibleFirst;
|
|
247542
|
+
if (patch3.allowIgnoreWord !== undefined)
|
|
247543
|
+
this.#config.allowIgnoreWord = patch3.allowIgnoreWord;
|
|
247544
|
+
if (patch3.timeoutMs !== undefined)
|
|
247545
|
+
this.#config.timeoutMs = patch3.timeoutMs;
|
|
247546
|
+
if (patch3.maxConcurrentRequests !== undefined)
|
|
247547
|
+
this.#config.maxConcurrentRequests = patch3.maxConcurrentRequests;
|
|
247548
|
+
if (patch3.maxSegmentsPerBatch !== undefined)
|
|
247549
|
+
this.#config.maxSegmentsPerBatch = patch3.maxSegmentsPerBatch;
|
|
247550
|
+
if (patch3.onProofingError !== undefined)
|
|
247551
|
+
this.#config.onProofingError = patch3.onProofingError ?? null;
|
|
247552
|
+
if (patch3.onStatusChange !== undefined)
|
|
247553
|
+
this.#config.onStatusChange = patch3.onStatusChange ?? null;
|
|
247554
|
+
if (patch3.defaultLanguage !== undefined)
|
|
247555
|
+
this.#config.defaultLanguage = patch3.defaultLanguage ?? null;
|
|
247556
|
+
if (patch3.ignoredWords !== undefined) {
|
|
247557
|
+
this.#config.ignoredWords = patch3.ignoredWords ?? [];
|
|
247558
|
+
this.onResultsChanged?.();
|
|
247559
|
+
}
|
|
247560
|
+
if (patch3.provider !== undefined) {
|
|
247561
|
+
if (prevProvider && prevProvider !== patch3.provider)
|
|
247562
|
+
prevProvider.dispose?.();
|
|
247563
|
+
this.#provider = patch3.provider ?? null;
|
|
247564
|
+
this.#capabilities = null;
|
|
247565
|
+
}
|
|
247566
|
+
if (patch3.enabled !== undefined) {
|
|
247567
|
+
this.#config.enabled = patch3.enabled;
|
|
247568
|
+
if (!patch3.enabled) {
|
|
247569
|
+
this.#cancelAll();
|
|
247570
|
+
this.#store.clear();
|
|
247571
|
+
this.#segmentHashes.clear();
|
|
247572
|
+
this.#offsetMaps.clear();
|
|
247573
|
+
this.#setStatus("disabled");
|
|
247574
|
+
this.onResultsChanged?.();
|
|
247575
|
+
return;
|
|
247576
|
+
}
|
|
247577
|
+
if (patch3.enabled && !prevEnabled && doc$12) {
|
|
247578
|
+
this.#setStatus("idle");
|
|
247579
|
+
this.#scheduleFullCheck(doc$12);
|
|
247580
|
+
return;
|
|
247581
|
+
}
|
|
247582
|
+
}
|
|
247583
|
+
if (needsRecheck && this.isEnabled && doc$12) {
|
|
247584
|
+
this.#cancelAll();
|
|
247585
|
+
this.#documentEpoch++;
|
|
247586
|
+
this.#store.clear();
|
|
247587
|
+
this.#segmentHashes.clear();
|
|
247588
|
+
this.onResultsChanged?.();
|
|
247589
|
+
this.#scheduleFullCheck(doc$12);
|
|
247590
|
+
}
|
|
247591
|
+
}
|
|
247592
|
+
onDocumentChanged(doc$12, changedRanges, mapping) {
|
|
247593
|
+
if (!this.isEnabled)
|
|
247594
|
+
return;
|
|
247595
|
+
this.#documentEpoch++;
|
|
247596
|
+
this.#lastDoc = doc$12;
|
|
247597
|
+
const { segments, offsetMaps, segmentPositions } = extractSegmentsWithMaps(doc$12, this.#config.defaultLanguage, this.#pageResolver ?? undefined);
|
|
247598
|
+
this.#lastSegments = segments;
|
|
247599
|
+
this.#offsetMaps = offsetMaps;
|
|
247600
|
+
const dirtyIds = computeDirtySegmentIds(segments, segmentPositions, changedRanges);
|
|
247601
|
+
for (const id2 of dirtyIds)
|
|
247602
|
+
this.#segmentHashes.delete(id2);
|
|
247603
|
+
if (dirtyIds.size > 0) {
|
|
247604
|
+
const recheckId = this.#nextRecheckId++;
|
|
247605
|
+
this.#store.remapIssues(dirtyIds, mapping, recheckId);
|
|
247606
|
+
this.#store.removeOrphanedSegments(new Set(segments.map((s2) => s2.id)));
|
|
247607
|
+
}
|
|
247608
|
+
this.#scheduleDebouncedCheck(segments);
|
|
247609
|
+
}
|
|
247610
|
+
runInitialCheck(doc$12) {
|
|
247611
|
+
if (!this.isEnabled)
|
|
247612
|
+
return;
|
|
247613
|
+
this.#scheduleFullCheck(doc$12);
|
|
247614
|
+
}
|
|
247615
|
+
ignoreWord(word$1) {
|
|
247616
|
+
const normalized = word$1.normalize("NFC").toLowerCase();
|
|
247617
|
+
if (!this.#config.ignoredWords.includes(normalized)) {
|
|
247618
|
+
this.#config.ignoredWords = [...this.#config.ignoredWords, normalized];
|
|
247619
|
+
this.onResultsChanged?.();
|
|
247620
|
+
}
|
|
247621
|
+
}
|
|
247622
|
+
removeIgnoredWord(word$1) {
|
|
247623
|
+
const normalized = word$1.normalize("NFC").toLowerCase();
|
|
247624
|
+
this.#config.ignoredWords = this.#config.ignoredWords.filter((w) => w !== normalized);
|
|
247625
|
+
this.onResultsChanged?.();
|
|
247626
|
+
}
|
|
247627
|
+
dispose() {
|
|
247628
|
+
this.#disposed = true;
|
|
247629
|
+
this.#cancelAll();
|
|
247630
|
+
this.#store.clear();
|
|
247631
|
+
this.#offsetMaps.clear();
|
|
247632
|
+
this.#segmentHashes.clear();
|
|
247633
|
+
this.#lastDoc = null;
|
|
247634
|
+
this.#lastSegments = [];
|
|
247635
|
+
this.#pendingSegments = [];
|
|
247636
|
+
this.#provider?.dispose?.();
|
|
247637
|
+
this.#provider = null;
|
|
247638
|
+
this.#setStatus("disabled");
|
|
247639
|
+
}
|
|
247640
|
+
#scheduleFullCheck(doc$12) {
|
|
247641
|
+
this.#lastDoc = doc$12;
|
|
247642
|
+
const { segments, offsetMaps } = extractSegmentsWithMaps(doc$12, this.#config.defaultLanguage, this.#pageResolver ?? undefined);
|
|
247643
|
+
this.#lastSegments = segments;
|
|
247644
|
+
this.#offsetMaps = offsetMaps;
|
|
247645
|
+
this.#segmentHashes.clear();
|
|
247646
|
+
this.#store.clear();
|
|
247647
|
+
this.#scheduleDebouncedCheck(segments);
|
|
247648
|
+
}
|
|
247649
|
+
#scheduleDebouncedCheck(segments) {
|
|
247650
|
+
if (this.#isComposing)
|
|
247651
|
+
return;
|
|
247652
|
+
if (this.#debounceTimer !== null)
|
|
247653
|
+
clearTimeout(this.#debounceTimer);
|
|
247654
|
+
const msSinceLastCheck = Date.now() - this.#lastCheckFiredAt;
|
|
247655
|
+
if (this.#lastCheckFiredAt > 0 && msSinceLastCheck >= DEFAULT_MAX_WAIT_MS)
|
|
247656
|
+
this.#fireCheck(segments);
|
|
247657
|
+
else
|
|
247658
|
+
this.#debounceTimer = setTimeout(() => {
|
|
247659
|
+
this.#debounceTimer = null;
|
|
247660
|
+
this.#fireCheck(segments);
|
|
247661
|
+
}, this.#config.debounceMs);
|
|
247662
|
+
}
|
|
247663
|
+
#fireCheck(segments) {
|
|
247664
|
+
this.#lastCheckFiredAt = Date.now();
|
|
247665
|
+
this.#runCheck(segments);
|
|
247666
|
+
}
|
|
247667
|
+
async#runCheck(segments) {
|
|
247668
|
+
if (this.#disposed || !this.#provider)
|
|
247669
|
+
return;
|
|
247670
|
+
if (!this.#capabilities && this.#provider.getCapabilities)
|
|
247671
|
+
try {
|
|
247672
|
+
this.#capabilities = await this.#provider.getCapabilities();
|
|
247673
|
+
} catch {}
|
|
247674
|
+
const unchecked = segments.filter((seg) => {
|
|
247675
|
+
const hash$3 = hashSegmentText(seg.text);
|
|
247676
|
+
return this.#segmentHashes.get(seg.id) !== hash$3;
|
|
247677
|
+
});
|
|
247678
|
+
if (unchecked.length === 0) {
|
|
247679
|
+
this.#setStatus("idle");
|
|
247680
|
+
return;
|
|
247681
|
+
}
|
|
247682
|
+
const activeRecheckIds = this.#store.getActiveRecheckIds();
|
|
247683
|
+
const ordered = this.#config.visibleFirst && this.#visibilitySource ? prioritizeByVisibility(unchecked, this.#visibilitySource) : unchecked;
|
|
247684
|
+
const batches = this.#batchSegments(ordered);
|
|
247685
|
+
const epoch = this.#documentEpoch;
|
|
247686
|
+
this.#pendingSegments = [];
|
|
247687
|
+
for (let i4 = 0;i4 < batches.length; i4++) {
|
|
247688
|
+
if (this.#disposed || epoch !== this.#documentEpoch)
|
|
247689
|
+
return;
|
|
247690
|
+
if (this.#inFlightCount >= this.#config.maxConcurrentRequests) {
|
|
247691
|
+
for (let j = i4;j < batches.length; j++)
|
|
247692
|
+
this.#pendingSegments.push(...batches[j]);
|
|
247693
|
+
break;
|
|
247694
|
+
}
|
|
247695
|
+
this.#sendBatch(batches[i4], epoch, activeRecheckIds);
|
|
247696
|
+
}
|
|
247697
|
+
}
|
|
247698
|
+
async#sendBatch(segments, epoch, recheckIds) {
|
|
247699
|
+
if (!this.#provider || this.#disposed)
|
|
247700
|
+
return;
|
|
247701
|
+
const controller = new AbortController;
|
|
247702
|
+
this.#pendingAbortControllers.add(controller);
|
|
247703
|
+
this.#inFlightCount++;
|
|
247704
|
+
this.#setStatus("checking");
|
|
247705
|
+
const timeoutId = setTimeout(() => controller.abort(), this.#config.timeoutMs);
|
|
247706
|
+
const request = {
|
|
247707
|
+
documentId: this.#documentId,
|
|
247708
|
+
defaultLanguage: this.#config.defaultLanguage,
|
|
247709
|
+
maxSuggestions: this.#config.maxSuggestions,
|
|
247710
|
+
segments,
|
|
247711
|
+
signal: controller.signal
|
|
247712
|
+
};
|
|
247713
|
+
try {
|
|
247714
|
+
const result = await this.#provider.check(request);
|
|
247715
|
+
clearTimeout(timeoutId);
|
|
247716
|
+
if (!this.#pendingAbortControllers.delete(controller))
|
|
247717
|
+
return;
|
|
247718
|
+
this.#inFlightCount--;
|
|
247719
|
+
if (epoch !== this.#documentEpoch || this.#disposed) {
|
|
247720
|
+
this.#drainPendingSegments();
|
|
247721
|
+
return;
|
|
247722
|
+
}
|
|
247723
|
+
const validSegmentIds = new Set(segments.map((s2) => s2.id));
|
|
247724
|
+
const segmentTextMap = new Map(segments.map((s2) => [s2.id, s2]));
|
|
247725
|
+
const freshIssues = [];
|
|
247726
|
+
for (const issue of result.issues) {
|
|
247727
|
+
if (!this.#validateIssue(issue, validSegmentIds, segmentTextMap))
|
|
247728
|
+
continue;
|
|
247729
|
+
const offsetMap = this.#offsetMaps.get(issue.segmentId);
|
|
247730
|
+
if (!offsetMap)
|
|
247731
|
+
continue;
|
|
247732
|
+
const resolved = resolveIssuePmRangeFromSlices(issue, offsetMap.slices);
|
|
247733
|
+
if (!resolved)
|
|
247734
|
+
continue;
|
|
247735
|
+
const segment = segmentTextMap.get(issue.segmentId);
|
|
247736
|
+
const storedIssue = {
|
|
247737
|
+
...resolved,
|
|
247738
|
+
state: "confirmed",
|
|
247739
|
+
recheckId: null
|
|
247740
|
+
};
|
|
247741
|
+
if (segment)
|
|
247742
|
+
storedIssue.word = segment.text.slice(issue.start, issue.end);
|
|
247743
|
+
freshIssues.push(storedIssue);
|
|
247744
|
+
}
|
|
247745
|
+
this.#store.replaceBatchResults(recheckIds, validSegmentIds, freshIssues);
|
|
247746
|
+
for (const seg of segments)
|
|
247747
|
+
this.#segmentHashes.set(seg.id, hashSegmentText(seg.text));
|
|
247748
|
+
this.#setStatus(this.#inFlightCount > 0 ? "checking" : "idle");
|
|
247749
|
+
this.onResultsChanged?.();
|
|
247750
|
+
this.#schedulePendingSegments(epoch, recheckIds);
|
|
247751
|
+
} catch (err) {
|
|
247752
|
+
clearTimeout(timeoutId);
|
|
247753
|
+
if (!this.#pendingAbortControllers.delete(controller))
|
|
247754
|
+
return;
|
|
247755
|
+
this.#inFlightCount--;
|
|
247756
|
+
if (this.#disposed)
|
|
247757
|
+
return;
|
|
247758
|
+
if (epoch !== this.#documentEpoch) {
|
|
247759
|
+
this.#drainPendingSegments();
|
|
247760
|
+
return;
|
|
247761
|
+
}
|
|
247762
|
+
const isTimeout = controller.signal.aborted;
|
|
247763
|
+
const proofingError = {
|
|
247764
|
+
kind: isTimeout ? "timeout" : "provider-error",
|
|
247765
|
+
message: isTimeout ? "Provider request timed out" : String(err),
|
|
247766
|
+
segmentIds: segments.map((s2) => s2.id),
|
|
247767
|
+
cause: err
|
|
247768
|
+
};
|
|
247769
|
+
this.#config.onProofingError?.(proofingError);
|
|
247770
|
+
this.#setStatus(this.#inFlightCount > 0 ? "checking" : "degraded");
|
|
247771
|
+
this.#schedulePendingSegments(epoch, recheckIds);
|
|
247772
|
+
}
|
|
247773
|
+
}
|
|
247774
|
+
#schedulePendingSegments(epoch, recheckIds) {
|
|
247775
|
+
if (this.#disposed || epoch !== this.#documentEpoch)
|
|
247776
|
+
return;
|
|
247777
|
+
if (this.#pendingSegments.length === 0)
|
|
247778
|
+
return;
|
|
247779
|
+
if (this.#inFlightCount >= this.#config.maxConcurrentRequests)
|
|
247780
|
+
return;
|
|
247781
|
+
const nextBatch = this.#pendingSegments.splice(0, this.#config.maxSegmentsPerBatch);
|
|
247782
|
+
if (nextBatch.length > 0)
|
|
247783
|
+
this.#sendBatch(nextBatch, epoch, recheckIds);
|
|
247784
|
+
}
|
|
247785
|
+
#drainPendingSegments() {
|
|
247786
|
+
if (this.#disposed || this.#pendingSegments.length === 0)
|
|
247787
|
+
return;
|
|
247788
|
+
this.#schedulePendingSegments(this.#documentEpoch, this.#store.getActiveRecheckIds());
|
|
247789
|
+
}
|
|
247790
|
+
#validateIssue(issue, validSegmentIds, segmentTextMap) {
|
|
247791
|
+
if (!validSegmentIds.has(issue.segmentId)) {
|
|
247792
|
+
this.#reportValidationError(`Unknown segmentId: ${issue.segmentId}`, [issue.segmentId]);
|
|
247793
|
+
return false;
|
|
247794
|
+
}
|
|
247795
|
+
const segment = segmentTextMap.get(issue.segmentId);
|
|
247796
|
+
if (!segment)
|
|
247797
|
+
return false;
|
|
247798
|
+
if (issue.start < 0 || issue.end <= issue.start || issue.end > segment.text.length) {
|
|
247799
|
+
this.#reportValidationError(`Invalid offsets [${issue.start}, ${issue.end}) for segment "${issue.segmentId}" (length ${segment.text.length})`, [issue.segmentId]);
|
|
247800
|
+
return false;
|
|
247801
|
+
}
|
|
247802
|
+
return true;
|
|
247803
|
+
}
|
|
247804
|
+
#reportValidationError(message, segmentIds) {
|
|
247805
|
+
this.#config.onProofingError?.({
|
|
247806
|
+
kind: "validation-error",
|
|
247807
|
+
message,
|
|
247808
|
+
segmentIds
|
|
247809
|
+
});
|
|
247810
|
+
}
|
|
247811
|
+
#batchSegments(segments) {
|
|
247812
|
+
const batches = [];
|
|
247813
|
+
for (let i4 = 0;i4 < segments.length; i4 += this.#config.maxSegmentsPerBatch)
|
|
247814
|
+
batches.push(segments.slice(i4, i4 + this.#config.maxSegmentsPerBatch));
|
|
247815
|
+
return batches;
|
|
247816
|
+
}
|
|
247817
|
+
#cancelAll() {
|
|
247818
|
+
if (this.#debounceTimer !== null) {
|
|
247819
|
+
clearTimeout(this.#debounceTimer);
|
|
247820
|
+
this.#debounceTimer = null;
|
|
247821
|
+
}
|
|
247822
|
+
for (const controller of this.#pendingAbortControllers)
|
|
247823
|
+
controller.abort();
|
|
247824
|
+
this.#pendingAbortControllers.clear();
|
|
247825
|
+
this.#inFlightCount = 0;
|
|
247826
|
+
this.#pendingSegments = [];
|
|
247827
|
+
}
|
|
247828
|
+
#setStatus(status) {
|
|
247829
|
+
if (this.#status !== status) {
|
|
247830
|
+
this.#status = status;
|
|
247831
|
+
this.#config.onStatusChange?.(status);
|
|
247832
|
+
}
|
|
247833
|
+
}
|
|
247834
|
+
}, PresentationPaintIndex = class {
|
|
247835
|
+
#snapshot = null;
|
|
247836
|
+
#annotationsByPmStart = /* @__PURE__ */ new Map;
|
|
247837
|
+
#annotationsByType = /* @__PURE__ */ new Map;
|
|
247838
|
+
#structuredContentBlocksById = /* @__PURE__ */ new Map;
|
|
247839
|
+
#structuredContentInlinesById = /* @__PURE__ */ new Map;
|
|
247840
|
+
#inlineImagesByPmStart = /* @__PURE__ */ new Map;
|
|
247841
|
+
#imageFragmentsByPmStart = /* @__PURE__ */ new Map;
|
|
247842
|
+
reset() {
|
|
247843
|
+
this.#snapshot = null;
|
|
247844
|
+
this.#annotationsByPmStart.clear();
|
|
247845
|
+
this.#annotationsByType.clear();
|
|
247846
|
+
this.#structuredContentBlocksById.clear();
|
|
247847
|
+
this.#structuredContentInlinesById.clear();
|
|
247848
|
+
this.#inlineImagesByPmStart.clear();
|
|
247849
|
+
this.#imageFragmentsByPmStart.clear();
|
|
247850
|
+
}
|
|
247851
|
+
update(snapshot2) {
|
|
247852
|
+
this.reset();
|
|
247853
|
+
this.#snapshot = snapshot2;
|
|
247854
|
+
if (!snapshot2?.entities)
|
|
247855
|
+
return;
|
|
247856
|
+
for (const annotation of snapshot2.entities.annotations) {
|
|
247857
|
+
if (!isMountedElement(annotation.element))
|
|
247858
|
+
continue;
|
|
247859
|
+
if (annotation.pmStart != null)
|
|
247860
|
+
this.#annotationsByPmStart.set(annotation.pmStart, annotation);
|
|
247861
|
+
if (annotation.type)
|
|
247862
|
+
appendToArrayMap(this.#annotationsByType, annotation.type, annotation);
|
|
247863
|
+
}
|
|
247864
|
+
for (const block of snapshot2.entities.structuredContentBlocks) {
|
|
247865
|
+
if (!isMountedElement(block.element))
|
|
247866
|
+
continue;
|
|
247867
|
+
appendToArrayMap(this.#structuredContentBlocksById, block.sdtId, block);
|
|
247868
|
+
}
|
|
247869
|
+
for (const inline of snapshot2.entities.structuredContentInlines) {
|
|
247870
|
+
if (!isMountedElement(inline.element))
|
|
247871
|
+
continue;
|
|
247872
|
+
appendToArrayMap(this.#structuredContentInlinesById, inline.sdtId, inline);
|
|
247873
|
+
}
|
|
247874
|
+
for (const image2 of snapshot2.entities.images) {
|
|
247875
|
+
if (!isMountedElement(image2.element) || image2.pmStart == null)
|
|
247876
|
+
continue;
|
|
247877
|
+
if (image2.kind === "inline") {
|
|
247878
|
+
if (shouldReplaceInlineImageEntity(this.#inlineImagesByPmStart.get(image2.pmStart), image2))
|
|
247879
|
+
this.#inlineImagesByPmStart.set(image2.pmStart, image2);
|
|
247880
|
+
continue;
|
|
247881
|
+
}
|
|
247882
|
+
this.#imageFragmentsByPmStart.set(image2.pmStart, image2);
|
|
247883
|
+
}
|
|
247884
|
+
}
|
|
247885
|
+
get snapshot() {
|
|
247886
|
+
return this.#snapshot;
|
|
247887
|
+
}
|
|
247888
|
+
getAnnotationElementByPmStart(pmStart) {
|
|
247889
|
+
return this.#annotationsByPmStart.get(pmStart)?.element ?? null;
|
|
247890
|
+
}
|
|
247891
|
+
getAnnotationEntitiesByType(type) {
|
|
247892
|
+
return [...this.#annotationsByType.get(type) ?? []];
|
|
247893
|
+
}
|
|
247894
|
+
getStructuredContentBlockElementsById(id2) {
|
|
247895
|
+
return (this.#structuredContentBlocksById.get(id2) ?? []).map((entity) => entity.element);
|
|
247896
|
+
}
|
|
247897
|
+
getStructuredContentInlineElementsById(id2) {
|
|
247898
|
+
return (this.#structuredContentInlinesById.get(id2) ?? []).map((entity) => entity.element);
|
|
247899
|
+
}
|
|
247900
|
+
getInlineImageElementByPmStart(pmStart) {
|
|
247901
|
+
return this.#inlineImagesByPmStart.get(pmStart)?.element ?? null;
|
|
247902
|
+
}
|
|
247903
|
+
getImageFragmentElementByPmStart(pmStart) {
|
|
247904
|
+
return this.#imageFragmentsByPmStart.get(pmStart)?.element ?? null;
|
|
247905
|
+
}
|
|
247610
247906
|
}, PresentationPainterAdapter = class {
|
|
247611
247907
|
#painter = null;
|
|
247612
247908
|
#lastPaintSnapshot = null;
|
|
247909
|
+
#paintIndex = new PresentationPaintIndex;
|
|
247910
|
+
#headerProvider;
|
|
247911
|
+
#footerProvider;
|
|
247912
|
+
#zoom = 1;
|
|
247913
|
+
#scrollContainer = null;
|
|
247914
|
+
#virtualizationPins = [];
|
|
247613
247915
|
get hasPainter() {
|
|
247614
247916
|
return this.#painter !== null;
|
|
247615
247917
|
}
|
|
247616
247918
|
ensurePainter(options) {
|
|
247617
|
-
if (!this.#painter)
|
|
247919
|
+
if (!this.#painter) {
|
|
247618
247920
|
this.#painter = createDomPainter({
|
|
247619
247921
|
...options,
|
|
247620
247922
|
onPaintSnapshot: (snapshot2) => {
|
|
247621
247923
|
this.#lastPaintSnapshot = snapshot2;
|
|
247924
|
+
this.#paintIndex.update(snapshot2);
|
|
247622
247925
|
}
|
|
247623
247926
|
});
|
|
247927
|
+
this.#applyPainterSurfaceState();
|
|
247928
|
+
}
|
|
247624
247929
|
}
|
|
247625
247930
|
reset() {
|
|
247626
247931
|
this.#painter = null;
|
|
247627
247932
|
this.#lastPaintSnapshot = null;
|
|
247933
|
+
this.#paintIndex.reset();
|
|
247628
247934
|
}
|
|
247629
247935
|
paint(input2, mount, mapping) {
|
|
247630
247936
|
this.#painter?.paint(input2, mount, mapping);
|
|
247631
247937
|
}
|
|
247632
247938
|
setProviders(header, footer) {
|
|
247633
|
-
this.#
|
|
247939
|
+
if (this.#headerProvider === header && this.#footerProvider === footer)
|
|
247940
|
+
return;
|
|
247941
|
+
this.#headerProvider = header;
|
|
247942
|
+
this.#footerProvider = footer;
|
|
247943
|
+
this.#applyProviders();
|
|
247634
247944
|
}
|
|
247635
247945
|
setZoom(zoom) {
|
|
247636
|
-
this.#
|
|
247946
|
+
if (this.#zoom === zoom)
|
|
247947
|
+
return;
|
|
247948
|
+
this.#zoom = zoom;
|
|
247949
|
+
this.#applyZoom();
|
|
247637
247950
|
}
|
|
247638
247951
|
setScrollContainer(el) {
|
|
247639
|
-
this.#
|
|
247952
|
+
if (this.#scrollContainer === el)
|
|
247953
|
+
return;
|
|
247954
|
+
this.#scrollContainer = el;
|
|
247955
|
+
this.#applyScrollContainer();
|
|
247640
247956
|
}
|
|
247641
247957
|
onScroll() {
|
|
247642
247958
|
this.#painter?.onScroll();
|
|
247643
247959
|
}
|
|
247644
247960
|
setVirtualizationPins(pageIndices) {
|
|
247645
|
-
|
|
247961
|
+
const normalizedPins = normalizePinnedPageIndices(pageIndices);
|
|
247962
|
+
if (areNumberListsEqual(this.#virtualizationPins, normalizedPins))
|
|
247963
|
+
return;
|
|
247964
|
+
this.#virtualizationPins = normalizedPins;
|
|
247965
|
+
this.#applyVirtualizationPins();
|
|
247646
247966
|
}
|
|
247647
247967
|
getPaintSnapshot() {
|
|
247648
247968
|
return this.#lastPaintSnapshot;
|
|
247649
247969
|
}
|
|
247970
|
+
getMountedPageIndices() {
|
|
247971
|
+
const mountedPageIndices = this.#painter?.getMountedPageIndices();
|
|
247972
|
+
if (mountedPageIndices)
|
|
247973
|
+
return [...mountedPageIndices];
|
|
247974
|
+
return this.#lastPaintSnapshot?.pages.map((page) => page.index) ?? [];
|
|
247975
|
+
}
|
|
247976
|
+
getAnnotationElementByPmStart(pmStart) {
|
|
247977
|
+
return this.#paintIndex.getAnnotationElementByPmStart(pmStart);
|
|
247978
|
+
}
|
|
247979
|
+
getAnnotationEntitiesByType(type) {
|
|
247980
|
+
return this.#paintIndex.getAnnotationEntitiesByType(type);
|
|
247981
|
+
}
|
|
247982
|
+
getStructuredContentBlockElementsById(id2) {
|
|
247983
|
+
return this.#paintIndex.getStructuredContentBlockElementsById(id2);
|
|
247984
|
+
}
|
|
247985
|
+
getStructuredContentInlineElementsById(id2) {
|
|
247986
|
+
return this.#paintIndex.getStructuredContentInlineElementsById(id2);
|
|
247987
|
+
}
|
|
247988
|
+
getInlineImageElementByPmStart(pmStart) {
|
|
247989
|
+
return this.#paintIndex.getInlineImageElementByPmStart(pmStart);
|
|
247990
|
+
}
|
|
247991
|
+
getImageFragmentElementByPmStart(pmStart) {
|
|
247992
|
+
return this.#paintIndex.getImageFragmentElementByPmStart(pmStart);
|
|
247993
|
+
}
|
|
247994
|
+
#applyPainterSurfaceState() {
|
|
247995
|
+
this.#applyProviders();
|
|
247996
|
+
this.#applyZoom();
|
|
247997
|
+
this.#applyScrollContainer();
|
|
247998
|
+
this.#applyVirtualizationPins();
|
|
247999
|
+
}
|
|
248000
|
+
#applyProviders() {
|
|
248001
|
+
this.#painter?.setProviders(this.#headerProvider, this.#footerProvider);
|
|
248002
|
+
}
|
|
248003
|
+
#applyZoom() {
|
|
248004
|
+
this.#painter?.setZoom(this.#zoom);
|
|
248005
|
+
}
|
|
248006
|
+
#applyScrollContainer() {
|
|
248007
|
+
this.#painter?.setScrollContainer(this.#scrollContainer);
|
|
248008
|
+
}
|
|
248009
|
+
#applyVirtualizationPins() {
|
|
248010
|
+
this.#painter?.setVirtualizationPins(this.#virtualizationPins);
|
|
248011
|
+
}
|
|
247650
248012
|
}, SINGLE_COLUMN_DEFAULT, isTextRun$5 = (run2) => {
|
|
247651
248013
|
const runWithKind = run2;
|
|
247652
248014
|
return !runWithKind.kind || runWithKind.kind === "text";
|
|
@@ -253465,8 +253827,8 @@ var Node$13 = class Node$14 {
|
|
|
253465
253827
|
this.#handleLinkClick(event, linkEl);
|
|
253466
253828
|
return;
|
|
253467
253829
|
}
|
|
253468
|
-
const annotationEl = target?.closest?.(
|
|
253469
|
-
const isDraggableAnnotation = target?.closest?.(
|
|
253830
|
+
const annotationEl = target?.closest?.(buildAnnotationSelector());
|
|
253831
|
+
const isDraggableAnnotation = target?.closest?.(DRAGGABLE_SELECTOR) != null;
|
|
253470
253832
|
this.#suppressFocusInFromDraggable = isDraggableAnnotation;
|
|
253471
253833
|
if (annotationEl) {
|
|
253472
253834
|
this.#handleAnnotationClick(event, annotationEl);
|
|
@@ -253735,7 +254097,7 @@ var Node$13 = class Node$14 {
|
|
|
253735
254097
|
if (event.button !== 0)
|
|
253736
254098
|
return;
|
|
253737
254099
|
const target = event.target;
|
|
253738
|
-
const annotationEl = target?.closest?.(
|
|
254100
|
+
const annotationEl = target?.closest?.(buildAnnotationSelector());
|
|
253739
254101
|
if (annotationEl) {
|
|
253740
254102
|
event.preventDefault();
|
|
253741
254103
|
event.stopPropagation();
|
|
@@ -254039,7 +254401,7 @@ var Node$13 = class Node$14 {
|
|
|
254039
254401
|
try {
|
|
254040
254402
|
const tr = editor.state.tr.setSelection(NodeSelection.create(doc$12, clampedImgPos));
|
|
254041
254403
|
editor.view?.dispatch(tr);
|
|
254042
|
-
const targetElement = this.#
|
|
254404
|
+
const targetElement = this.#callbacks.resolveInlineImageElementByPmStart?.(imgPmStart) ?? null;
|
|
254043
254405
|
const elementForHighlight = wrapper ?? targetElement ?? targetImg;
|
|
254044
254406
|
this.#callbacks.emit?.("imageSelected", {
|
|
254045
254407
|
element: elementForHighlight,
|
|
@@ -254066,7 +254428,7 @@ var Node$13 = class Node$14 {
|
|
|
254066
254428
|
if (this.#lastSelectedImageBlockId && this.#lastSelectedImageBlockId !== fragmentHit.fragment.blockId)
|
|
254067
254429
|
this.#callbacks.emit?.("imageDeselected", { blockId: this.#lastSelectedImageBlockId });
|
|
254068
254430
|
if (fragmentHit.fragment.kind === "image") {
|
|
254069
|
-
const targetElement = this.#
|
|
254431
|
+
const targetElement = fragmentHit.fragment.pmStart != null ? this.#callbacks.resolveImageFragmentElementByPmStart?.(fragmentHit.fragment.pmStart) ?? null : null;
|
|
254070
254432
|
if (targetElement) {
|
|
254071
254433
|
this.#callbacks.emit?.("imageSelected", {
|
|
254072
254434
|
element: targetElement,
|
|
@@ -254722,7 +255084,7 @@ var Node$13 = class Node$14 {
|
|
|
254722
255084
|
}
|
|
254723
255085
|
#handleDragStart(event) {
|
|
254724
255086
|
const target = event.target;
|
|
254725
|
-
if (!target?.dataset?.
|
|
255087
|
+
if (!target?.dataset?.[DATASET_KEYS.DRAGGABLE] || target.dataset[DATASET_KEYS.DRAGGABLE] !== "true")
|
|
254726
255088
|
return;
|
|
254727
255089
|
const data = extractFieldAnnotationData(target);
|
|
254728
255090
|
if (event.dataTransfer) {
|
|
@@ -256668,12 +257030,53 @@ var Node$13 = class Node$14 {
|
|
|
256668
257030
|
this.#hoverRegion = null;
|
|
256669
257031
|
this.#overlayManager = null;
|
|
256670
257032
|
}
|
|
256671
|
-
}, DEFAULT_SEMANTIC_FOOTNOTE_HEADING_STYLE,
|
|
257033
|
+
}, DEFAULT_SEMANTIC_FOOTNOTE_HEADING_STYLE, NATIVE_SELECTION_STYLES = `
|
|
257034
|
+
/* Hide native browser selection on layout engine content.
|
|
257035
|
+
* We render our own selection overlay via PresentationEditor's #localSelectionLayer
|
|
257036
|
+
* for precise control over selection geometry across pages and zoom levels. */
|
|
257037
|
+
.superdoc-layout *::selection {
|
|
257038
|
+
background: transparent;
|
|
257039
|
+
}
|
|
257040
|
+
|
|
257041
|
+
.superdoc-layout *::-moz-selection {
|
|
257042
|
+
background: transparent;
|
|
257043
|
+
}
|
|
257044
|
+
`, nativeSelectionStylesInjected = false, FIELD_ANNOTATION_INTERACTION_STYLES = `
|
|
257045
|
+
/* Editing affordance: allow text selection on draggable annotations */
|
|
257046
|
+
.superdoc-layout .annotation[data-draggable="true"] {
|
|
257047
|
+
user-select: text;
|
|
257048
|
+
}
|
|
257049
|
+
|
|
257050
|
+
/* Editing affordance: hover feedback */
|
|
257051
|
+
.superdoc-layout .annotation[data-draggable="true"]:hover {
|
|
257052
|
+
opacity: 0.9;
|
|
257053
|
+
}
|
|
257054
|
+
|
|
257055
|
+
/* Editing affordance: active/grab cursor */
|
|
257056
|
+
.superdoc-layout .annotation[data-draggable="true"]:active {
|
|
257057
|
+
cursor: grabbing;
|
|
257058
|
+
}
|
|
257059
|
+
|
|
257060
|
+
/* Editing affordance: drag over indicator for drop targets */
|
|
257061
|
+
.superdoc-layout.drag-over {
|
|
257062
|
+
outline: 2px dashed #b015b3;
|
|
257063
|
+
outline-offset: -2px;
|
|
257064
|
+
}
|
|
257065
|
+
|
|
257066
|
+
/* Editing affordance: drop zone indicator */
|
|
257067
|
+
.superdoc-layout .superdoc-drop-indicator {
|
|
257068
|
+
position: absolute;
|
|
257069
|
+
width: 2px;
|
|
257070
|
+
background-color: #b015b3;
|
|
257071
|
+
pointer-events: none;
|
|
257072
|
+
z-index: 1000;
|
|
257073
|
+
}
|
|
257074
|
+
`, fieldAnnotationInteractionStylesInjected = false, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, layoutDebugEnabled, perfLog = (...args$1) => {
|
|
256672
257075
|
if (!layoutDebugEnabled)
|
|
256673
257076
|
return;
|
|
256674
257077
|
console.log(...args$1);
|
|
256675
257078
|
}, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
|
|
256676
|
-
var
|
|
257079
|
+
var init_src_DIxjKbQ9_es = __esm(() => {
|
|
256677
257080
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
256678
257081
|
init_SuperConverter_C6rVgqDZ_es();
|
|
256679
257082
|
init_jszip_ChlR43oI_es();
|
|
@@ -274765,17 +275168,44 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
274765
275168
|
BLOCK_SDT: "superdoc-structured-content-block",
|
|
274766
275169
|
TABLE_FRAGMENT: "superdoc-table-fragment",
|
|
274767
275170
|
DOCUMENT_SECTION: "superdoc-document-section",
|
|
274768
|
-
|
|
275171
|
+
SDT_GROUP_HOVER: "sdt-group-hover",
|
|
274769
275172
|
IMAGE_FRAGMENT: "superdoc-image-fragment",
|
|
274770
275173
|
INLINE_IMAGE: "superdoc-inline-image",
|
|
274771
|
-
INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper"
|
|
275174
|
+
INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper",
|
|
275175
|
+
ANNOTATION: "annotation",
|
|
275176
|
+
ANNOTATION_CONTENT: "annotation-content",
|
|
275177
|
+
ANNOTATION_CARET_ANCHOR: "annotation-caret-anchor"
|
|
274772
275178
|
};
|
|
274773
275179
|
DATA_ATTRS = {
|
|
274774
275180
|
PM_START: "data-pm-start",
|
|
274775
275181
|
PM_END: "data-pm-end",
|
|
274776
275182
|
LAYOUT_EPOCH: "data-layout-epoch",
|
|
274777
|
-
TABLE_BOUNDARIES: "data-table-boundaries"
|
|
274778
|
-
|
|
275183
|
+
TABLE_BOUNDARIES: "data-table-boundaries",
|
|
275184
|
+
SDT_ID: "data-sdt-id",
|
|
275185
|
+
SDT_TYPE: "data-sdt-type",
|
|
275186
|
+
FIELD_ID: "data-field-id",
|
|
275187
|
+
FIELD_TYPE: "data-field-type",
|
|
275188
|
+
DRAGGABLE: "data-draggable",
|
|
275189
|
+
DISPLAY_LABEL: "data-display-label",
|
|
275190
|
+
VARIANT: "data-variant",
|
|
275191
|
+
TYPE: "data-type"
|
|
275192
|
+
};
|
|
275193
|
+
DATASET_KEYS = {
|
|
275194
|
+
PM_START: "pmStart",
|
|
275195
|
+
PM_END: "pmEnd",
|
|
275196
|
+
LAYOUT_EPOCH: "layoutEpoch",
|
|
275197
|
+
TABLE_BOUNDARIES: "tableBoundaries",
|
|
275198
|
+
SDT_ID: "sdtId",
|
|
275199
|
+
SDT_TYPE: "sdtType",
|
|
275200
|
+
FIELD_ID: "fieldId",
|
|
275201
|
+
FIELD_TYPE: "fieldType",
|
|
275202
|
+
DRAGGABLE: "draggable",
|
|
275203
|
+
DISPLAY_LABEL: "displayLabel",
|
|
275204
|
+
VARIANT: "variant",
|
|
275205
|
+
TYPE: "type"
|
|
275206
|
+
};
|
|
275207
|
+
`${DOM_CLASS_NAMES.BLOCK_SDT}${DATA_ATTRS.SDT_ID}`;
|
|
275208
|
+
DRAGGABLE_SELECTOR = `[${DATA_ATTRS.DRAGGABLE}="true"]`;
|
|
274779
275209
|
VerticalNavigationPluginKey = new PluginKey("verticalNavigation");
|
|
274780
275210
|
VerticalNavigation = Extension.create({
|
|
274781
275211
|
name: "verticalNavigation",
|
|
@@ -282130,16 +282560,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282130
282560
|
"search",
|
|
282131
282561
|
"yjs-cursor"
|
|
282132
282562
|
];
|
|
282133
|
-
|
|
282134
|
-
"
|
|
282135
|
-
"
|
|
282136
|
-
|
|
282137
|
-
"hardBreak",
|
|
282138
|
-
"lineBreak",
|
|
282139
|
-
"tab",
|
|
282140
|
-
"footnoteReference",
|
|
282141
|
-
"symbol"
|
|
282142
|
-
]);
|
|
282563
|
+
DISPLAY_LABEL_SOURCE = {
|
|
282564
|
+
CANONICAL: "canonical",
|
|
282565
|
+
DERIVED: "derived"
|
|
282566
|
+
};
|
|
282143
282567
|
FONT_FAMILY_FALLBACKS2 = Object.freeze({
|
|
282144
282568
|
swiss: "Arial, sans-serif",
|
|
282145
282569
|
roman: "Times New Roman, serif",
|
|
@@ -282346,8 +282770,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282346
282770
|
"wave",
|
|
282347
282771
|
"doubleWave"
|
|
282348
282772
|
]);
|
|
282349
|
-
SDT_BLOCK_SELECTOR = `.${DOM_CLASS_NAMES.BLOCK_SDT}[data-sdt-id]`;
|
|
282350
|
-
HOVER_CLASS = DOM_CLASS_NAMES.SDT_HOVER;
|
|
282351
282773
|
OPERATOR_CHARS = new Set([
|
|
282352
282774
|
"+",
|
|
282353
282775
|
"-",
|
|
@@ -282543,10 +282965,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282543
282965
|
this.zoomFactor = 1;
|
|
282544
282966
|
this.scrollContainer = null;
|
|
282545
282967
|
this.scrollContainerMountOffset = null;
|
|
282546
|
-
this.sdtHover = new SdtGroupedHover;
|
|
282547
282968
|
this.paintSnapshotBuilder = null;
|
|
282548
282969
|
this.lastPaintSnapshot = null;
|
|
282549
282970
|
this.onPaintSnapshotCallback = null;
|
|
282971
|
+
this.mountedPageIndices = [];
|
|
282550
282972
|
this.resolvedLayout = null;
|
|
282551
282973
|
this.options = options;
|
|
282552
282974
|
this.layoutMode = options.layoutMode ?? "vertical";
|
|
@@ -282609,6 +283031,15 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282609
283031
|
getPaintSnapshot() {
|
|
282610
283032
|
return this.lastPaintSnapshot;
|
|
282611
283033
|
}
|
|
283034
|
+
getMountedPageIndices() {
|
|
283035
|
+
return [...this.mountedPageIndices];
|
|
283036
|
+
}
|
|
283037
|
+
createAllPageIndices(pageCount) {
|
|
283038
|
+
return Array.from({ length: pageCount }, (_$1, pageIndex) => pageIndex);
|
|
283039
|
+
}
|
|
283040
|
+
setMountedPageIndices(pageIndices) {
|
|
283041
|
+
this.mountedPageIndices = [...pageIndices];
|
|
283042
|
+
}
|
|
282612
283043
|
emitPaintSnapshot(snapshot2) {
|
|
282613
283044
|
this.lastPaintSnapshot = snapshot2;
|
|
282614
283045
|
this.onPaintSnapshotCallback?.(snapshot2);
|
|
@@ -282627,7 +283058,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282627
283058
|
}))
|
|
282628
283059
|
};
|
|
282629
283060
|
}
|
|
282630
|
-
finalizePaintSnapshotFromBuilder() {
|
|
283061
|
+
finalizePaintSnapshotFromBuilder(rootEl) {
|
|
282631
283062
|
const builder = this.paintSnapshotBuilder;
|
|
282632
283063
|
if (!builder) {
|
|
282633
283064
|
this.lastPaintSnapshot = null;
|
|
@@ -282645,7 +283076,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282645
283076
|
lineCount: builder.lineCount,
|
|
282646
283077
|
markerCount: builder.markerCount,
|
|
282647
283078
|
tabCount: builder.tabCount,
|
|
282648
|
-
pages
|
|
283079
|
+
pages,
|
|
283080
|
+
entities: rootEl ? collectPaintSnapshotEntitiesFromDomRoot(rootEl) : createEmptyPaintSnapshotEntities()
|
|
282649
283081
|
});
|
|
282650
283082
|
this.paintSnapshotBuilder = null;
|
|
282651
283083
|
}
|
|
@@ -282724,7 +283156,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282724
283156
|
lineCount,
|
|
282725
283157
|
markerCount,
|
|
282726
283158
|
tabCount,
|
|
282727
|
-
pages
|
|
283159
|
+
pages,
|
|
283160
|
+
entities: collectPaintSnapshotEntitiesFromDomRoot(rootEl)
|
|
282728
283161
|
};
|
|
282729
283162
|
}
|
|
282730
283163
|
normalizeOptionalBlockMeasurePair(label, blocks2, measures) {
|
|
@@ -282784,7 +283217,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282784
283217
|
ensureFieldAnnotationStyles(doc$12);
|
|
282785
283218
|
ensureSdtContainerStyles(doc$12);
|
|
282786
283219
|
ensureImageSelectionStyles(doc$12);
|
|
282787
|
-
ensureNativeSelectionStyles(doc$12);
|
|
282788
283220
|
if (!this.isSemanticFlow && this.options.ruler?.enabled)
|
|
282789
283221
|
ensureRulerStyles(doc$12);
|
|
282790
283222
|
mount.classList.add(CLASS_NAMES$1.container);
|
|
@@ -282803,6 +283235,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282803
283235
|
this.fullRender(layout);
|
|
282804
283236
|
else
|
|
282805
283237
|
this.patchLayout(layout);
|
|
283238
|
+
this.setMountedPageIndices(this.createAllPageIndices(layout.pages.length));
|
|
282806
283239
|
this.currentLayout = layout;
|
|
282807
283240
|
this.changedBlocks.clear();
|
|
282808
283241
|
this.currentMapping = null;
|
|
@@ -282814,7 +283247,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282814
283247
|
applyStyles(mount, containerStylesHorizontal);
|
|
282815
283248
|
mount.style.gap = `${this.pageGap}px`;
|
|
282816
283249
|
this.renderHorizontal(layout, mount);
|
|
282817
|
-
this.finalizePaintSnapshotFromBuilder();
|
|
283250
|
+
this.finalizePaintSnapshotFromBuilder(mount);
|
|
283251
|
+
this.setMountedPageIndices(this.createAllPageIndices(layout.pages.length));
|
|
282818
283252
|
this.currentLayout = layout;
|
|
282819
283253
|
this.pageStates = [];
|
|
282820
283254
|
this.changedBlocks.clear();
|
|
@@ -282824,7 +283258,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282824
283258
|
if (mode === "book") {
|
|
282825
283259
|
applyStyles(mount, containerStyles);
|
|
282826
283260
|
this.renderBookMode(layout, mount);
|
|
282827
|
-
this.finalizePaintSnapshotFromBuilder();
|
|
283261
|
+
this.finalizePaintSnapshotFromBuilder(mount);
|
|
283262
|
+
this.setMountedPageIndices(this.createAllPageIndices(layout.pages.length));
|
|
282828
283263
|
this.currentLayout = layout;
|
|
282829
283264
|
this.pageStates = [];
|
|
282830
283265
|
this.changedBlocks.clear();
|
|
@@ -282847,12 +283282,13 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282847
283282
|
this.patchLayout(layout);
|
|
282848
283283
|
useDomSnapshotFallback = true;
|
|
282849
283284
|
}
|
|
283285
|
+
this.setMountedPageIndices(this.createAllPageIndices(layout.pages.length));
|
|
282850
283286
|
}
|
|
282851
283287
|
if (useDomSnapshotFallback) {
|
|
282852
283288
|
this.emitPaintSnapshot(this.collectPaintSnapshotFromDomRoot(mount));
|
|
282853
283289
|
this.paintSnapshotBuilder = null;
|
|
282854
283290
|
} else
|
|
282855
|
-
this.finalizePaintSnapshotFromBuilder();
|
|
283291
|
+
this.finalizePaintSnapshotFromBuilder(mount);
|
|
282856
283292
|
this.currentLayout = layout;
|
|
282857
283293
|
this.changedBlocks.clear();
|
|
282858
283294
|
this.currentMapping = null;
|
|
@@ -282920,7 +283356,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282920
283356
|
};
|
|
282921
283357
|
win.addEventListener("resize", this.onResizeHandler);
|
|
282922
283358
|
}
|
|
282923
|
-
this.sdtHover.bind(mount);
|
|
282924
283359
|
}
|
|
282925
283360
|
computeVirtualMetrics() {
|
|
282926
283361
|
if (!this.currentLayout)
|
|
@@ -282971,6 +283406,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
282971
283406
|
const N = layout.pages.length;
|
|
282972
283407
|
if (N === 0) {
|
|
282973
283408
|
this.mount.innerHTML = "";
|
|
283409
|
+
this.setMountedPageIndices([]);
|
|
282974
283410
|
this.processedLayoutVersion = this.layoutVersion;
|
|
282975
283411
|
return;
|
|
282976
283412
|
}
|
|
@@ -283028,6 +283464,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
283028
283464
|
this.virtualMountedKey = mountedKey;
|
|
283029
283465
|
this.virtualStart = start$1;
|
|
283030
283466
|
this.virtualEnd = end$1;
|
|
283467
|
+
this.setMountedPageIndices(mounted);
|
|
283031
283468
|
this.updateSpacersForMountedPages(mounted);
|
|
283032
283469
|
this.clearGapSpacers();
|
|
283033
283470
|
this.sdtLabelsRendered.clear();
|
|
@@ -283081,7 +283518,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
283081
283518
|
}
|
|
283082
283519
|
this.changedBlocks.clear();
|
|
283083
283520
|
this.processedLayoutVersion = this.layoutVersion;
|
|
283084
|
-
this.sdtHover.reapply();
|
|
283085
283521
|
}
|
|
283086
283522
|
updateSpacers(start$1, end$1) {
|
|
283087
283523
|
if (!this.topSpacerEl || !this.bottomSpacerEl)
|
|
@@ -283403,11 +283839,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
283403
283839
|
this.onWindowScrollHandler = null;
|
|
283404
283840
|
this.onResizeHandler = null;
|
|
283405
283841
|
this.scrollContainerMountOffset = null;
|
|
283406
|
-
this.sdtHover.destroy();
|
|
283407
283842
|
this.layoutVersion = 0;
|
|
283408
283843
|
this.processedLayoutVersion = -1;
|
|
283409
283844
|
this.paintSnapshotBuilder = null;
|
|
283410
283845
|
this.lastPaintSnapshot = null;
|
|
283846
|
+
this.mountedPageIndices = [];
|
|
283411
283847
|
}
|
|
283412
283848
|
fullRender(layout) {
|
|
283413
283849
|
if (!this.mount || !this.doc)
|
|
@@ -285195,7 +285631,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
285195
285631
|
const defaultBorderColor = "#b015b3";
|
|
285196
285632
|
const defaultFieldColor = "#980043";
|
|
285197
285633
|
const annotation = this.doc.createElement("span");
|
|
285198
|
-
annotation.classList.add(
|
|
285634
|
+
annotation.classList.add(DOM_CLASS_NAMES.ANNOTATION);
|
|
285199
285635
|
annotation.setAttribute("aria-label", "Field annotation");
|
|
285200
285636
|
if (run2.highlighted !== false) {
|
|
285201
285637
|
const borderColor = run2.borderColor || defaultBorderColor;
|
|
@@ -285241,7 +285677,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
285241
285677
|
annotation.style.textDecoration = "underline";
|
|
285242
285678
|
annotation.style.zIndex = "1";
|
|
285243
285679
|
const content3 = this.doc.createElement("span");
|
|
285244
|
-
content3.classList.add(
|
|
285680
|
+
content3.classList.add(DOM_CLASS_NAMES.ANNOTATION_CONTENT);
|
|
285245
285681
|
content3.style.pointerEvents = "none";
|
|
285246
285682
|
content3.setAttribute("contenteditable", "false");
|
|
285247
285683
|
switch (run2.variant) {
|
|
@@ -285315,48 +285751,20 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
285315
285751
|
}
|
|
285316
285752
|
annotation.appendChild(content3);
|
|
285317
285753
|
annotation.dataset.type = run2.variant;
|
|
285754
|
+
annotation.dataset.displayLabel = run2.displayLabel;
|
|
285318
285755
|
if (run2.fieldId)
|
|
285319
285756
|
annotation.dataset.fieldId = run2.fieldId;
|
|
285320
285757
|
if (run2.fieldType)
|
|
285321
285758
|
annotation.dataset.fieldType = run2.fieldType;
|
|
285322
|
-
annotation.draggable = true;
|
|
285323
|
-
annotation.dataset.draggable = "true";
|
|
285324
|
-
if (run2.displayLabel)
|
|
285325
|
-
annotation.dataset.displayLabel = run2.displayLabel;
|
|
285326
|
-
if (run2.variant)
|
|
285327
|
-
annotation.dataset.variant = run2.variant;
|
|
285328
285759
|
assertPmPositions(run2, "field annotation run");
|
|
285329
285760
|
if (run2.pmStart != null)
|
|
285330
285761
|
annotation.dataset.pmStart = String(run2.pmStart);
|
|
285331
285762
|
if (run2.pmEnd != null)
|
|
285332
285763
|
annotation.dataset.pmEnd = String(run2.pmEnd);
|
|
285333
285764
|
annotation.dataset.layoutEpoch = String(this.layoutEpoch);
|
|
285334
|
-
this.appendAnnotationCaretAnchor(annotation, run2);
|
|
285335
285765
|
this.applySdtDataset(annotation, run2.sdt);
|
|
285336
285766
|
return annotation;
|
|
285337
285767
|
}
|
|
285338
|
-
appendAnnotationCaretAnchor(annotation, run2) {
|
|
285339
|
-
if (!this.doc || run2.pmEnd == null)
|
|
285340
|
-
return;
|
|
285341
|
-
const caretAnchor = this.doc.createElement("span");
|
|
285342
|
-
caretAnchor.dataset.pmStart = String(run2.pmEnd);
|
|
285343
|
-
caretAnchor.dataset.pmEnd = String(run2.pmEnd);
|
|
285344
|
-
caretAnchor.dataset.layoutEpoch = String(this.layoutEpoch);
|
|
285345
|
-
caretAnchor.classList.add("annotation-caret-anchor");
|
|
285346
|
-
caretAnchor.style.position = "absolute";
|
|
285347
|
-
caretAnchor.style.left = "100%";
|
|
285348
|
-
caretAnchor.style.top = "0";
|
|
285349
|
-
caretAnchor.style.width = "0";
|
|
285350
|
-
caretAnchor.style.height = "1em";
|
|
285351
|
-
caretAnchor.style.overflow = "hidden";
|
|
285352
|
-
caretAnchor.style.pointerEvents = "none";
|
|
285353
|
-
caretAnchor.style.userSelect = "none";
|
|
285354
|
-
caretAnchor.style.opacity = "0";
|
|
285355
|
-
caretAnchor.textContent = "";
|
|
285356
|
-
if (!annotation.style.position)
|
|
285357
|
-
annotation.style.position = "relative";
|
|
285358
|
-
annotation.appendChild(caretAnchor);
|
|
285359
|
-
}
|
|
285360
285768
|
renderLine(block, line, context, availableWidthOverride, lineIndex, skipJustify, resolvedListTextStartPx, indentOffsetOverride) {
|
|
285361
285769
|
if (!this.doc)
|
|
285362
285770
|
throw new Error("DomPainter: document is not available");
|
|
@@ -286119,6 +286527,16 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
286119
286527
|
SPLIT_ATTR: "data-sd-proofing-split"
|
|
286120
286528
|
};
|
|
286121
286529
|
splitOriginMap = /* @__PURE__ */ new WeakMap;
|
|
286530
|
+
NON_TEXT_INLINE_NODES = new Set([
|
|
286531
|
+
"fieldAnnotation",
|
|
286532
|
+
"image",
|
|
286533
|
+
"equation",
|
|
286534
|
+
"hardBreak",
|
|
286535
|
+
"lineBreak",
|
|
286536
|
+
"tab",
|
|
286537
|
+
"footnoteReference",
|
|
286538
|
+
"symbol"
|
|
286539
|
+
]);
|
|
286122
286540
|
SINGLE_COLUMN_DEFAULT = {
|
|
286123
286541
|
count: 1,
|
|
286124
286542
|
gap: 0
|
|
@@ -287256,8 +287674,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
287256
287674
|
#htmlAnnotationMeasureAttempts = 0;
|
|
287257
287675
|
#domPositionIndex = new DomPositionIndex;
|
|
287258
287676
|
#domIndexObserverManager = null;
|
|
287259
|
-
#
|
|
287260
|
-
#commentHighlightDecorator = new CommentHighlightDecorator;
|
|
287677
|
+
#postPaintPipeline = new PresentationPostPaintPipeline;
|
|
287261
287678
|
#proofingManager = null;
|
|
287262
287679
|
#decorationSyncRafHandle = null;
|
|
287263
287680
|
#rafHandle = null;
|
|
@@ -287348,15 +287765,16 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
287348
287765
|
this.#painterHost.className = "presentation-editor__pages";
|
|
287349
287766
|
this.#painterHost.style.transformOrigin = "top left";
|
|
287350
287767
|
this.#viewportHost.appendChild(this.#painterHost);
|
|
287351
|
-
this.#
|
|
287768
|
+
this.#postPaintPipeline.setContainer(this.#painterHost);
|
|
287769
|
+
ensureEditorNativeSelectionStyles(doc$12);
|
|
287770
|
+
ensureEditorFieldAnnotationInteractionStyles(doc$12);
|
|
287352
287771
|
this.#painterHost.addEventListener("mouseover", this.#handleStructuredContentBlockMouseEnter);
|
|
287353
287772
|
this.#painterHost.addEventListener("mouseout", this.#handleStructuredContentBlockMouseLeave);
|
|
287354
287773
|
this.#domIndexObserverManager = new DomPositionIndexObserverManager({
|
|
287355
287774
|
windowRoot: this.#visibleHost?.ownerDocument?.defaultView ?? window,
|
|
287356
287775
|
getPainterHost: () => this.#painterHost,
|
|
287357
287776
|
onRebuild: () => {
|
|
287358
|
-
this.#
|
|
287359
|
-
this.#syncInlineStyleLayers();
|
|
287777
|
+
this.#refreshEditorDomAugmentations();
|
|
287360
287778
|
this.#selectionSync.requestRender({ immediate: true });
|
|
287361
287779
|
}
|
|
287362
287780
|
});
|
|
@@ -288624,8 +289042,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288624
289042
|
(this.#visibleHost?.ownerDocument?.defaultView ?? window).cancelAnimationFrame(this.#decorationSyncRafHandle);
|
|
288625
289043
|
this.#decorationSyncRafHandle = null;
|
|
288626
289044
|
}, "Decoration sync RAF");
|
|
288627
|
-
this.#
|
|
288628
|
-
this.#commentHighlightDecorator.destroy();
|
|
289045
|
+
this.#postPaintPipeline.destroy();
|
|
288629
289046
|
this.#proofingManager?.dispose();
|
|
288630
289047
|
this.#proofingManager = null;
|
|
288631
289048
|
if (this.#cursorUpdateTimer !== null) {
|
|
@@ -288744,18 +289161,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288744
289161
|
mgr.setDocumentId(this.#options.documentId ?? null);
|
|
288745
289162
|
mgr.onResultsChanged = () => this.#applyProofingPass();
|
|
288746
289163
|
mgr.setVisibilitySource({ getVisiblePageIndices: () => {
|
|
288747
|
-
|
|
288748
|
-
|
|
288749
|
-
const pageEls = this.#painterHost.querySelectorAll("[data-page-index]");
|
|
288750
|
-
if (pageEls.length === 0)
|
|
288751
|
-
return null;
|
|
288752
|
-
const indices = [];
|
|
288753
|
-
for (let i4 = 0;i4 < pageEls.length; i4++) {
|
|
288754
|
-
const idx = parseInt(pageEls[i4].getAttribute("data-page-index"), 10);
|
|
288755
|
-
if (!isNaN(idx))
|
|
288756
|
-
indices.push(idx);
|
|
288757
|
-
}
|
|
288758
|
-
return indices.length > 0 ? indices : null;
|
|
289164
|
+
const mountedPageIndices = this.#painterAdapter.getMountedPageIndices();
|
|
289165
|
+
return mountedPageIndices.length > 0 ? mountedPageIndices : null;
|
|
288759
289166
|
} });
|
|
288760
289167
|
mgr.setPageResolver(this.#buildPageResolver());
|
|
288761
289168
|
const editorDom = this.#editor?.view?.dom;
|
|
@@ -288764,25 +289171,21 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288764
289171
|
editorDom.addEventListener("compositionend", () => mgr.setComposing(false));
|
|
288765
289172
|
}
|
|
288766
289173
|
}
|
|
288767
|
-
#
|
|
288768
|
-
if (!this.#
|
|
288769
|
-
return;
|
|
288770
|
-
if (!this.#proofingManager?.isEnabled) {
|
|
288771
|
-
if (clearProofingDecorations(this.#painterHost))
|
|
288772
|
-
this.#rebuildDomPositionIndex();
|
|
288773
|
-
return;
|
|
288774
|
-
}
|
|
289174
|
+
#buildProofingAnnotations() {
|
|
289175
|
+
if (!this.#proofingManager?.isEnabled)
|
|
289176
|
+
return null;
|
|
288775
289177
|
const editorState = this.#editor?.state;
|
|
288776
289178
|
let activeWordRange = null;
|
|
288777
289179
|
if (editorState?.selection.empty)
|
|
288778
289180
|
activeWordRange = computeWordSelectionRangeAt(editorState, editorState.selection.head);
|
|
288779
|
-
|
|
289181
|
+
return this.#proofingManager.getPaintSlices(activeWordRange).map((s2) => ({
|
|
288780
289182
|
pmFrom: s2.pmFrom,
|
|
288781
289183
|
pmTo: s2.pmTo,
|
|
288782
289184
|
kind: s2.kind
|
|
288783
289185
|
}));
|
|
288784
|
-
|
|
288785
|
-
|
|
289186
|
+
}
|
|
289187
|
+
#applyProofingPass() {
|
|
289188
|
+
this.#postPaintPipeline.applyProofingAnnotations(this.#buildProofingAnnotations(), () => this.#rebuildDomPositionIndex());
|
|
288786
289189
|
}
|
|
288787
289190
|
#notifyProofingOfDocChange(transaction) {
|
|
288788
289191
|
if (!this.#proofingManager?.isEnabled)
|
|
@@ -288804,18 +289207,26 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288804
289207
|
this.#proofingManager.onDocumentChanged(doc$12, changedRanges, transaction.mapping);
|
|
288805
289208
|
}
|
|
288806
289209
|
#syncCommentHighlights() {
|
|
288807
|
-
this.#
|
|
289210
|
+
this.#postPaintPipeline.applyCommentHighlights();
|
|
288808
289211
|
}
|
|
288809
289212
|
#syncInlineStyleLayers() {
|
|
288810
|
-
this.#
|
|
288811
|
-
|
|
289213
|
+
const state = this.#editor?.view?.state;
|
|
289214
|
+
if (!state) {
|
|
289215
|
+
this.#syncCommentHighlights();
|
|
289216
|
+
return;
|
|
289217
|
+
}
|
|
289218
|
+
try {
|
|
289219
|
+
this.#postPaintPipeline.syncInlineStyleLayers(state, this.#domPositionIndex);
|
|
289220
|
+
} catch (error3) {
|
|
289221
|
+
console.warn("[PresentationEditor] Inline style layer sync failed:", error3);
|
|
289222
|
+
}
|
|
288812
289223
|
}
|
|
288813
289224
|
#syncDecorations() {
|
|
288814
289225
|
const state = this.#editor?.view?.state;
|
|
288815
289226
|
if (!state)
|
|
288816
289227
|
return;
|
|
288817
289228
|
try {
|
|
288818
|
-
this.#
|
|
289229
|
+
this.#postPaintPipeline.syncDecorations(state, this.#domPositionIndex);
|
|
288819
289230
|
} catch (error3) {
|
|
288820
289231
|
console.warn("[PresentationEditor] Decoration sync failed:", error3);
|
|
288821
289232
|
}
|
|
@@ -288824,7 +289235,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288824
289235
|
if (this.#renderScheduled || this.#isRerendering)
|
|
288825
289236
|
return;
|
|
288826
289237
|
const state = this.#editor?.view?.state;
|
|
288827
|
-
if (!state || !this.#
|
|
289238
|
+
if (!state || !this.#postPaintPipeline.hasDecorationChanges(state))
|
|
288828
289239
|
return;
|
|
288829
289240
|
if (this.#decorationSyncRafHandle != null)
|
|
288830
289241
|
return;
|
|
@@ -288872,12 +289283,12 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288872
289283
|
};
|
|
288873
289284
|
const handleTransaction = (event) => {
|
|
288874
289285
|
const tr = event?.transaction;
|
|
288875
|
-
this.#
|
|
289286
|
+
this.#postPaintPipeline.recordDecorationTransaction(tr);
|
|
288876
289287
|
const state = this.#editor?.view?.state;
|
|
288877
|
-
const decorationChanged = state && this.#
|
|
289288
|
+
const decorationChanged = state && this.#postPaintPipeline.hasDecorationChanges(state);
|
|
288878
289289
|
if (decorationChanged) {
|
|
288879
289290
|
const restoreEmpty = tr ? tr.docChanged === true : false;
|
|
288880
|
-
this.#
|
|
289291
|
+
this.#postPaintPipeline.syncDecorations(state, this.#domPositionIndex, { restoreEmptyDecorations: restoreEmpty });
|
|
288881
289292
|
} else
|
|
288882
289293
|
this.#scheduleDecorationSync();
|
|
288883
289294
|
if (decorationChanged) {
|
|
@@ -288965,7 +289376,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
288965
289376
|
const handleCommentsUpdate = (payload) => {
|
|
288966
289377
|
if ("activeCommentId" in payload) {
|
|
288967
289378
|
const activeId = payload.activeCommentId ?? null;
|
|
288968
|
-
if (this.#
|
|
289379
|
+
if (this.#postPaintPipeline.setActiveComment(activeId))
|
|
288969
289380
|
this.#syncInlineStyleLayers();
|
|
288970
289381
|
}
|
|
288971
289382
|
};
|
|
@@ -289056,6 +289467,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289056
289467
|
clearHoverRegion: () => this.#clearHoverRegion(),
|
|
289057
289468
|
renderHoverRegion: (region) => this.#renderHoverRegion(region),
|
|
289058
289469
|
focusEditorAfterImageSelection: () => this.#focusEditorAfterImageSelection(),
|
|
289470
|
+
resolveInlineImageElementByPmStart: (pmStart) => this.#painterAdapter.getInlineImageElementByPmStart(pmStart),
|
|
289471
|
+
resolveImageFragmentElementByPmStart: (pmStart) => this.#painterAdapter.getImageFragmentElementByPmStart(pmStart),
|
|
289059
289472
|
resolveFieldAnnotationSelectionFromElement: (el) => this.#resolveFieldAnnotationSelectionFromElement(el),
|
|
289060
289473
|
computePendingMarginClick: (pointerId, x, y$1) => this.#computePendingMarginClick(pointerId, x, y$1),
|
|
289061
289474
|
selectWordAt: (pos) => this.#selectWordAt(pos),
|
|
@@ -289483,7 +289896,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289483
289896
|
return;
|
|
289484
289897
|
}
|
|
289485
289898
|
const state = this.#editor?.view?.state;
|
|
289486
|
-
const decorationRanges = state ? this.#
|
|
289899
|
+
const decorationRanges = state ? this.#postPaintPipeline.collectDecorationRanges(state) : [];
|
|
289487
289900
|
if (decorationRanges.length > 0)
|
|
289488
289901
|
blocks2 = splitRunsAtDecorationBoundaries(blocks2, decorationRanges.map((r$1) => ({
|
|
289489
289902
|
from: r$1.from,
|
|
@@ -289639,9 +290052,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289639
290052
|
this.#painterAdapter.paint(paintInput, this.#painterHost, mapping ?? undefined);
|
|
289640
290053
|
perfLog(`[Perf] painter.paint: ${(perfNow() - painterPaintStart).toFixed(2)}ms`);
|
|
289641
290054
|
const painterPostStart = perfNow();
|
|
289642
|
-
this.#
|
|
289643
|
-
this.#syncInlineStyleLayers();
|
|
289644
|
-
this.#applyProofingPass();
|
|
290055
|
+
this.#refreshEditorDomAugmentations();
|
|
289645
290056
|
this.#domIndexObserverManager?.resume();
|
|
289646
290057
|
perfLog(`[Perf] painter.postPaint: ${(perfNow() - painterPostStart).toFixed(2)}ms`);
|
|
289647
290058
|
this.#layoutEpoch = layoutEpoch;
|
|
@@ -289734,19 +290145,16 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289734
290145
|
}
|
|
289735
290146
|
#updateHtmlAnnotationMeasurements(layoutEpoch) {
|
|
289736
290147
|
const nextHeights = new Map(this.#htmlAnnotationHeights);
|
|
289737
|
-
const annotations = this.#painterHost.querySelectorAll('.annotation[data-type="html"]');
|
|
289738
290148
|
const threshold = 1;
|
|
289739
290149
|
let changed = false;
|
|
289740
|
-
|
|
289741
|
-
const element3 = annotation;
|
|
289742
|
-
|
|
289743
|
-
const pmEnd = element3.dataset.pmEnd;
|
|
289744
|
-
if (!pmStart || !pmEnd)
|
|
290150
|
+
this.#painterAdapter.getAnnotationEntitiesByType("html").forEach((annotation) => {
|
|
290151
|
+
const element3 = annotation.element;
|
|
290152
|
+
if (annotation.pmStart == null || annotation.pmEnd == null)
|
|
289745
290153
|
return;
|
|
289746
290154
|
const height = element3.offsetHeight;
|
|
289747
290155
|
if (height <= 0)
|
|
289748
290156
|
return;
|
|
289749
|
-
const key$1 = `${pmStart}-${pmEnd}`;
|
|
290157
|
+
const key$1 = `${annotation.pmStart}-${annotation.pmEnd}`;
|
|
289750
290158
|
const prev = nextHeights.get(key$1);
|
|
289751
290159
|
if (prev != null && Math.abs(prev - height) <= threshold)
|
|
289752
290160
|
return;
|
|
@@ -289799,8 +290207,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289799
290207
|
const pmStart = selection.from;
|
|
289800
290208
|
if (this.#lastSelectedFieldAnnotation?.pmStart === pmStart && this.#lastSelectedFieldAnnotation.element)
|
|
289801
290209
|
return;
|
|
289802
|
-
const
|
|
289803
|
-
const element3 = this.#painterHost.querySelector(selector);
|
|
290210
|
+
const element3 = this.#painterAdapter.getAnnotationElementByPmStart(pmStart);
|
|
289804
290211
|
if (!element3) {
|
|
289805
290212
|
this.#clearSelectedFieldAnnotationClass();
|
|
289806
290213
|
return;
|
|
@@ -289863,12 +290270,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289863
290270
|
const rawId = node3.attrs?.id;
|
|
289864
290271
|
id2 = rawId != null ? String(rawId) : null;
|
|
289865
290272
|
let elements = [];
|
|
289866
|
-
if (id2)
|
|
289867
|
-
|
|
289868
|
-
elements = Array.from(this.#painterHost.querySelectorAll(`.superdoc-structured-content-block[data-sdt-id="${escapedId}"]`));
|
|
289869
|
-
}
|
|
290273
|
+
if (id2)
|
|
290274
|
+
elements = this.#painterAdapter.getStructuredContentBlockElementsById(id2);
|
|
289870
290275
|
if (elements.length === 0) {
|
|
289871
|
-
const container = this.getElementAtPos(selection.from, { fallbackToCoords: true })?.closest?.(
|
|
290276
|
+
const container = this.getElementAtPos(selection.from, { fallbackToCoords: true })?.closest?.(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
|
|
289872
290277
|
if (container)
|
|
289873
290278
|
elements = [container];
|
|
289874
290279
|
}
|
|
@@ -289879,7 +290284,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289879
290284
|
this.#setSelectedStructuredContentBlockClass(elements, id2);
|
|
289880
290285
|
}
|
|
289881
290286
|
#handleStructuredContentBlockMouseEnter = (event) => {
|
|
289882
|
-
const block = event.target.closest(
|
|
290287
|
+
const block = event.target.closest(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
|
|
289883
290288
|
if (!block || !(block instanceof HTMLElement))
|
|
289884
290289
|
return;
|
|
289885
290290
|
if (block.classList.contains("ProseMirror-selectednode"))
|
|
@@ -289890,19 +290295,22 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289890
290295
|
this.#setHoveredStructuredContentBlockClass(rawId);
|
|
289891
290296
|
};
|
|
289892
290297
|
#handleStructuredContentBlockMouseLeave = (event) => {
|
|
289893
|
-
const block = event.target.closest(
|
|
290298
|
+
const block = event.target.closest(`.${DOM_CLASS_NAMES.BLOCK_SDT}`);
|
|
289894
290299
|
if (!block)
|
|
289895
290300
|
return;
|
|
289896
290301
|
const relatedTarget = event.relatedTarget;
|
|
289897
|
-
if (relatedTarget && block.dataset.sdtId
|
|
289898
|
-
|
|
290302
|
+
if (relatedTarget && block.dataset.sdtId) {
|
|
290303
|
+
const escapedCheckId = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(block.dataset.sdtId) : block.dataset.sdtId.replace(/"/g, "\\\"");
|
|
290304
|
+
if (relatedTarget.closest(buildSdtBlockSelector(escapedCheckId)))
|
|
290305
|
+
return;
|
|
290306
|
+
}
|
|
289899
290307
|
this.#clearHoveredStructuredContentBlockClass();
|
|
289900
290308
|
};
|
|
289901
290309
|
#clearHoveredStructuredContentBlockClass() {
|
|
289902
290310
|
if (!this.#lastHoveredStructuredContentBlock)
|
|
289903
290311
|
return;
|
|
289904
290312
|
this.#lastHoveredStructuredContentBlock.elements.forEach((element3) => {
|
|
289905
|
-
element3.classList.remove(
|
|
290313
|
+
element3.classList.remove(DOM_CLASS_NAMES.SDT_GROUP_HOVER);
|
|
289906
290314
|
});
|
|
289907
290315
|
this.#lastHoveredStructuredContentBlock = null;
|
|
289908
290316
|
}
|
|
@@ -289912,19 +290320,48 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289912
290320
|
this.#clearHoveredStructuredContentBlockClass();
|
|
289913
290321
|
if (!this.#painterHost)
|
|
289914
290322
|
return;
|
|
289915
|
-
const
|
|
289916
|
-
const elements = Array.from(this.#painterHost.querySelectorAll(`.superdoc-structured-content-block[data-sdt-id="${escapedId}"]`));
|
|
290323
|
+
const elements = this.#painterAdapter.getStructuredContentBlockElementsById(id2);
|
|
289917
290324
|
if (elements.length === 0)
|
|
289918
290325
|
return;
|
|
289919
290326
|
elements.forEach((element3) => {
|
|
289920
290327
|
if (!element3.classList.contains("ProseMirror-selectednode"))
|
|
289921
|
-
element3.classList.add(
|
|
290328
|
+
element3.classList.add(DOM_CLASS_NAMES.SDT_GROUP_HOVER);
|
|
290329
|
+
});
|
|
290330
|
+
this.#lastHoveredStructuredContentBlock = {
|
|
290331
|
+
id: id2,
|
|
290332
|
+
elements
|
|
290333
|
+
};
|
|
290334
|
+
}
|
|
290335
|
+
#reapplySdtGroupHover() {
|
|
290336
|
+
if (!this.#lastHoveredStructuredContentBlock || !this.#painterHost)
|
|
290337
|
+
return;
|
|
290338
|
+
const { id: id2 } = this.#lastHoveredStructuredContentBlock;
|
|
290339
|
+
if (!id2)
|
|
290340
|
+
return;
|
|
290341
|
+
const elements = this.#painterAdapter.getStructuredContentBlockElementsById(id2);
|
|
290342
|
+
if (elements.length === 0) {
|
|
290343
|
+
this.#lastHoveredStructuredContentBlock = null;
|
|
290344
|
+
return;
|
|
290345
|
+
}
|
|
290346
|
+
elements.forEach((element3) => {
|
|
290347
|
+
if (!element3.classList.contains("ProseMirror-selectednode"))
|
|
290348
|
+
element3.classList.add(DOM_CLASS_NAMES.SDT_GROUP_HOVER);
|
|
289922
290349
|
});
|
|
289923
290350
|
this.#lastHoveredStructuredContentBlock = {
|
|
289924
290351
|
id: id2,
|
|
289925
290352
|
elements
|
|
289926
290353
|
};
|
|
289927
290354
|
}
|
|
290355
|
+
#refreshEditorDomAugmentations() {
|
|
290356
|
+
this.#postPaintPipeline.refreshAfterPaint({
|
|
290357
|
+
layoutEpoch: this.#layoutEpoch,
|
|
290358
|
+
editorState: this.#editor?.view?.state,
|
|
290359
|
+
domPositionIndex: this.#domPositionIndex,
|
|
290360
|
+
proofingAnnotations: this.#buildProofingAnnotations(),
|
|
290361
|
+
rebuildDomPositionIndex: () => this.#rebuildDomPositionIndex(),
|
|
290362
|
+
reapplyStructuredContentHover: () => this.#reapplySdtGroupHover()
|
|
290363
|
+
});
|
|
290364
|
+
}
|
|
289928
290365
|
#clearSelectedStructuredContentInlineClass() {
|
|
289929
290366
|
if (!this.#lastSelectedStructuredContentInline)
|
|
289930
290367
|
return;
|
|
@@ -289988,12 +290425,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
289988
290425
|
const rawId = node3.attrs?.id;
|
|
289989
290426
|
id2 = rawId != null ? String(rawId) : null;
|
|
289990
290427
|
let elements = [];
|
|
289991
|
-
if (id2)
|
|
289992
|
-
|
|
289993
|
-
elements = Array.from(this.#painterHost.querySelectorAll(`.superdoc-structured-content-inline[data-sdt-id="${escapedId}"]`));
|
|
289994
|
-
}
|
|
290428
|
+
if (id2)
|
|
290429
|
+
elements = this.#painterAdapter.getStructuredContentInlineElementsById(id2);
|
|
289995
290430
|
if (elements.length === 0) {
|
|
289996
|
-
const container = this.getElementAtPos(pos, { fallbackToCoords: true })?.closest?.(
|
|
290431
|
+
const container = this.getElementAtPos(pos, { fallbackToCoords: true })?.closest?.(`.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER}`);
|
|
289997
290432
|
if (container)
|
|
289998
290433
|
elements = [container];
|
|
289999
290434
|
}
|
|
@@ -291206,7 +291641,7 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
|
|
|
291206
291641
|
|
|
291207
291642
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
291208
291643
|
var init_super_editor_es = __esm(() => {
|
|
291209
|
-
|
|
291644
|
+
init_src_DIxjKbQ9_es();
|
|
291210
291645
|
init_SuperConverter_C6rVgqDZ_es();
|
|
291211
291646
|
init_jszip_ChlR43oI_es();
|
|
291212
291647
|
init_xml_js_40FWvL78_es();
|