superdoc 2.0.0-next.51 → 2.0.0-next.53
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/chunks/{create-super-doc-ui-CXCqHc2m.cjs → create-super-doc-ui-BWFYti_W.cjs} +158 -61
- package/dist/chunks/{create-super-doc-ui-fxF2Q8Ib.es.js → create-super-doc-ui-Bqkk1Ios.es.js} +158 -61
- package/dist/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/public/ui-react.cjs +1 -1
- package/dist/public/ui-react.es.js +1 -1
- package/dist/public/ui.cjs +1 -1
- package/dist/public/ui.es.js +1 -1
- package/dist/style.css +62 -62
- package/dist/style.layered.css +62 -62
- package/dist/superdoc.cjs +9 -5
- package/dist/superdoc.es.js +9 -5
- package/dist-cdn/style.layered.css +1 -1
- package/dist-cdn/superdoc.min.css +1 -1
- package/dist-cdn/superdoc.min.js +35 -35
- package/package.json +2 -2
|
@@ -1886,6 +1886,48 @@ function readEntityTarget(row) {
|
|
|
1886
1886
|
const target = row.target;
|
|
1887
1887
|
return target && typeof target === "object" ? target : null;
|
|
1888
1888
|
}
|
|
1889
|
+
function isHostGeometryTarget(target) {
|
|
1890
|
+
if (!target || typeof target !== "object") return false;
|
|
1891
|
+
const record = target;
|
|
1892
|
+
const isTextPoint = (point) => {
|
|
1893
|
+
if (!point || typeof point !== "object") return false;
|
|
1894
|
+
const candidate = point;
|
|
1895
|
+
return candidate.kind === "text" && typeof candidate.blockId === "string" && typeof candidate.offset === "number";
|
|
1896
|
+
};
|
|
1897
|
+
const isTextSegment = (segment) => {
|
|
1898
|
+
if (!segment || typeof segment !== "object") return false;
|
|
1899
|
+
const candidate = segment;
|
|
1900
|
+
const range$1 = candidate.range;
|
|
1901
|
+
return typeof candidate.blockId === "string" && typeof range$1?.start === "number" && typeof range$1.end === "number";
|
|
1902
|
+
};
|
|
1903
|
+
if (Array.isArray(record.segments)) {
|
|
1904
|
+
const first = record.segments[0];
|
|
1905
|
+
const last = record.segments[record.segments.length - 1];
|
|
1906
|
+
return isTextSegment(first) && isTextSegment(last);
|
|
1907
|
+
}
|
|
1908
|
+
if (record.kind === "selection") return isTextPoint(record.start) && isTextPoint(record.end);
|
|
1909
|
+
if (record.kind !== "text" || typeof record.blockId !== "string") return false;
|
|
1910
|
+
const range = record.range;
|
|
1911
|
+
return typeof range?.start === "number" && typeof range.end === "number";
|
|
1912
|
+
}
|
|
1913
|
+
function readTrackedChangeNavigationTarget(row) {
|
|
1914
|
+
if (!row || typeof row !== "object") return null;
|
|
1915
|
+
const target = readEntityTarget(row);
|
|
1916
|
+
if (isHostGeometryTarget(target)) return target;
|
|
1917
|
+
const record = row;
|
|
1918
|
+
const navigationTarget = record.navigationTarget && typeof record.navigationTarget === "object" ? record.navigationTarget : null;
|
|
1919
|
+
if (navigationTarget?.kind === "block" && typeof navigationTarget.blockId === "string" && navigationTarget.blockId.length > 0) return {
|
|
1920
|
+
kind: "text",
|
|
1921
|
+
blockId: navigationTarget.blockId,
|
|
1922
|
+
range: {
|
|
1923
|
+
start: 0,
|
|
1924
|
+
end: 0
|
|
1925
|
+
},
|
|
1926
|
+
...navigationTarget.story && typeof navigationTarget.story === "object" ? { story: navigationTarget.story } : {},
|
|
1927
|
+
...record.address && typeof record.address === "object" ? { address: record.address } : {}
|
|
1928
|
+
};
|
|
1929
|
+
return target;
|
|
1930
|
+
}
|
|
1889
1931
|
function storyLocatorSignature(story) {
|
|
1890
1932
|
if (!story || typeof story !== "object") return "story:body";
|
|
1891
1933
|
const record = story;
|
|
@@ -3082,11 +3124,14 @@ function createSuperDocUI(options) {
|
|
|
3082
3124
|
let explicitActiveChange = null;
|
|
3083
3125
|
let explicitActiveChangeRevision = 0;
|
|
3084
3126
|
let queuedTrackChangeNavigationInvalidation = 0;
|
|
3127
|
+
let trackChangeRevealInvalidation = 0;
|
|
3128
|
+
const pendingTrackChangeRevealFocuses = /* @__PURE__ */ new Set();
|
|
3085
3129
|
const explicitActiveChangesEqual = (left, right) => {
|
|
3086
3130
|
if (left === right) return true;
|
|
3087
3131
|
if (!left || !right) return false;
|
|
3088
3132
|
return left.id === right.id && left.paintedEntityId === right.paintedEntityId && storyLocatorSignature(left.story) === storyLocatorSignature(right.story);
|
|
3089
3133
|
};
|
|
3134
|
+
const hasPendingTrackChangeRevealFocus = (focus) => Array.from(pendingTrackChangeRevealFocuses).some((pendingFocus) => explicitActiveChangesEqual(pendingFocus, focus));
|
|
3090
3135
|
const mirrorTrackedChangeFocusToHost = (next) => {
|
|
3091
3136
|
const host = getHost();
|
|
3092
3137
|
if (typeof host?.getHandles !== "function") return;
|
|
@@ -3115,6 +3160,7 @@ function createSuperDocUI(options) {
|
|
|
3115
3160
|
const setExplicitActiveChange = (next, options$1) => {
|
|
3116
3161
|
explicitActiveChange = next;
|
|
3117
3162
|
explicitActiveChangeRevision += 1;
|
|
3163
|
+
trackChangeRevealInvalidation += 1;
|
|
3118
3164
|
if (options$1?.invalidateQueuedNavigation !== false) queuedTrackChangeNavigationInvalidation += 1;
|
|
3119
3165
|
};
|
|
3120
3166
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -5852,6 +5898,7 @@ function createSuperDocUI(options) {
|
|
|
5852
5898
|
...typeof target.paintedEntityId === "string" && target.paintedEntityId.length > 0 ? { paintedEntityId: target.paintedEntityId } : {}
|
|
5853
5899
|
};
|
|
5854
5900
|
}
|
|
5901
|
+
if (rawTarget == null && next == null && explicitActiveChange != null && hasPendingTrackChangeRevealFocus(explicitActiveChange)) return false;
|
|
5855
5902
|
if (explicitActiveChangesEqual(explicitActiveChange, next)) return false;
|
|
5856
5903
|
setExplicitActiveChange(next);
|
|
5857
5904
|
return true;
|
|
@@ -6122,8 +6169,9 @@ function createSuperDocUI(options) {
|
|
|
6122
6169
|
const story = selectionStoryLocator(state.selection);
|
|
6123
6170
|
const item = items.find((candidate) => entityRowMatchesRequest(candidate, activeId, story));
|
|
6124
6171
|
if (!item) return "unavailable";
|
|
6125
|
-
const
|
|
6126
|
-
const
|
|
6172
|
+
const change = trackChangesItemPayload(item);
|
|
6173
|
+
const type = change.type;
|
|
6174
|
+
const grouping = change.grouping;
|
|
6127
6175
|
if (type === "replacement" && grouping === "replacement-pair") return "range";
|
|
6128
6176
|
return (type === "insertion" || type === "deletion" || type === "insert" || type === "delete") && grouping === "standalone" ? "range" : "id";
|
|
6129
6177
|
}
|
|
@@ -6176,6 +6224,15 @@ function createSuperDocUI(options) {
|
|
|
6176
6224
|
const target = trackDecisionRangeFromSelection(state.selection);
|
|
6177
6225
|
return target ? executeTrackDecisionTarget(command.kind, target, null) : false;
|
|
6178
6226
|
}
|
|
6227
|
+
if (route === "id") {
|
|
6228
|
+
const activeId = state.selection.activeChangeIds[0];
|
|
6229
|
+
const selectedStory = selectionStoryLocator(state.selection);
|
|
6230
|
+
const story = selectedStory && storyLocatorSignature(selectedStory) !== storyLocatorSignature(null) ? selectedStory : void 0;
|
|
6231
|
+
return executeTrackDecision(command.kind, story ? {
|
|
6232
|
+
id: activeId,
|
|
6233
|
+
story
|
|
6234
|
+
} : activeId);
|
|
6235
|
+
}
|
|
6179
6236
|
}
|
|
6180
6237
|
}
|
|
6181
6238
|
const resolved = resolveTrackDecisionTarget(command, payload);
|
|
@@ -7700,11 +7757,12 @@ function createSuperDocUI(options) {
|
|
|
7700
7757
|
reason: SUPERDOC_UI_REASONS.hostCapabilityUnavailable
|
|
7701
7758
|
};
|
|
7702
7759
|
try {
|
|
7703
|
-
const
|
|
7760
|
+
const input = {
|
|
7704
7761
|
target,
|
|
7705
7762
|
block: options$1?.block ?? "center",
|
|
7706
7763
|
behavior: options$1?.behavior ?? "smooth"
|
|
7707
|
-
}
|
|
7764
|
+
};
|
|
7765
|
+
const result = await Promise.resolve(options$1?.shouldContinue ? scroll.call(host, input, options$1.shouldContinue) : scroll.call(host, input));
|
|
7708
7766
|
if (result && typeof result === "object" && result.success === false) return {
|
|
7709
7767
|
success: false,
|
|
7710
7768
|
ok: false,
|
|
@@ -7734,19 +7792,32 @@ function createSuperDocUI(options) {
|
|
|
7734
7792
|
story: requestedStory
|
|
7735
7793
|
};
|
|
7736
7794
|
};
|
|
7737
|
-
const
|
|
7738
|
-
|
|
7795
|
+
const readTarget = namespace === "trackChanges" ? readTrackedChangeNavigationTarget : readEntityTarget;
|
|
7796
|
+
const loadedRow = loaded.find((row) => entityRowMatchesRequest(row, id, requestedStory));
|
|
7797
|
+
const loadedRecord = loadedRow && typeof loadedRow === "object" ? loadedRow : null;
|
|
7798
|
+
const moveSide = namespace === "trackChanges" && loadedRecord?.type === "move" && (loadedRecord.subtype === "move-to" || loadedRecord.subtype === "move-from") ? loadedRecord.subtype : null;
|
|
7799
|
+
const trackedChangeLookupId = moveSide && typeof loadedRecord?.trackedChangeCanonicalId === "string" ? loadedRecord.trackedChangeCanonicalId : id;
|
|
7800
|
+
const readResolvedTarget = (row) => {
|
|
7801
|
+
if (!moveSide) return readTarget(row);
|
|
7802
|
+
const moveTarget = readEntityTarget(row);
|
|
7803
|
+
if (moveTarget?.kind !== "move") return null;
|
|
7804
|
+
const sideTarget = moveSide === "move-to" ? moveTarget.destination : moveTarget.source;
|
|
7805
|
+
return isHostGeometryTarget(sideTarget) ? sideTarget : null;
|
|
7806
|
+
};
|
|
7807
|
+
const fromList = readTarget(loadedRow);
|
|
7808
|
+
const listTargetIsAuthoritative = namespace !== "trackChanges" || !moveSide && isHostGeometryTarget(readEntityTarget(loadedRow));
|
|
7809
|
+
if (fromList && listTargetIsAuthoritative) return withRequestedStory(fromList);
|
|
7739
7810
|
const api = getDoc()?.[namespace];
|
|
7740
7811
|
const input = namespace === "comments" ? { commentId: id } : {
|
|
7741
|
-
id,
|
|
7812
|
+
id: trackedChangeLookupId,
|
|
7742
7813
|
...requestedStory ? { story: requestedStory } : {}
|
|
7743
7814
|
};
|
|
7744
7815
|
const get = api?.get;
|
|
7745
|
-
if (typeof get !== "function") return
|
|
7816
|
+
if (typeof get !== "function") return withRequestedStory(fromList);
|
|
7746
7817
|
try {
|
|
7747
|
-
return withRequestedStory(
|
|
7818
|
+
return withRequestedStory(readResolvedTarget(await Promise.resolve(get.call(api, input))) ?? fromList);
|
|
7748
7819
|
} catch {
|
|
7749
|
-
return
|
|
7820
|
+
return withRequestedStory(fromList);
|
|
7750
7821
|
}
|
|
7751
7822
|
};
|
|
7752
7823
|
function patchCommentStatus(commentId, status) {
|
|
@@ -7908,33 +7979,41 @@ function createSuperDocUI(options) {
|
|
|
7908
7979
|
if (activeId == null) return { success: false };
|
|
7909
7980
|
const optimisticActiveChange = explicitActiveChange;
|
|
7910
7981
|
const optimisticRevision = explicitActiveChangeRevision;
|
|
7911
|
-
const isCurrent = () => explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
7982
|
+
const isCurrent = () => queuedTrackChangeNavigationInvalidation === requestedAtInvalidation && explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
7912
7983
|
const rollback = () => {
|
|
7913
7984
|
if (!isCurrent()) return;
|
|
7914
7985
|
setExplicitActiveChange(previousActiveChange, { invalidateQueuedNavigation: false });
|
|
7915
7986
|
recompute();
|
|
7916
7987
|
};
|
|
7917
|
-
|
|
7918
|
-
if (!isCurrent()) return { success: false };
|
|
7919
|
-
if (!target) {
|
|
7920
|
-
rollback();
|
|
7921
|
-
return { success: false };
|
|
7922
|
-
}
|
|
7923
|
-
trackedChangeNavigationInFlight += 1;
|
|
7988
|
+
if (optimisticActiveChange) pendingTrackChangeRevealFocuses.add(optimisticActiveChange);
|
|
7924
7989
|
try {
|
|
7925
|
-
const
|
|
7990
|
+
const target = await resolveEntityTarget("trackChanges", activeId, trackChangesSub.get().items, optimisticActiveChange?.story ? { story: optimisticActiveChange.story } : void 0);
|
|
7926
7991
|
if (!isCurrent()) return { success: false };
|
|
7927
|
-
if (!
|
|
7992
|
+
if (!target) {
|
|
7928
7993
|
rollback();
|
|
7929
|
-
|
|
7930
|
-
}
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7994
|
+
return { success: false };
|
|
7995
|
+
}
|
|
7996
|
+
trackedChangeNavigationInFlight += 1;
|
|
7997
|
+
try {
|
|
7998
|
+
const result = await scrollTargetIntoView(target, {
|
|
7999
|
+
behavior: "auto",
|
|
8000
|
+
shouldContinue: isCurrent
|
|
8001
|
+
});
|
|
8002
|
+
if (!isCurrent()) return { success: false };
|
|
8003
|
+
if (!result.ok && result.reason !== SUPERDOC_UI_REASONS.targetNotVisible) {
|
|
8004
|
+
rollback();
|
|
8005
|
+
mirrorTrackedChangeFocusToHost(previousActiveChange);
|
|
8006
|
+
} else mirrorTrackedChangeFocusToHost(optimisticActiveChange);
|
|
8007
|
+
return { success: result.ok };
|
|
8008
|
+
} finally {
|
|
8009
|
+
trackedChangeNavigationInFlight = Math.max(0, trackedChangeNavigationInFlight - 1);
|
|
8010
|
+
if (trackedChangeNavigationInFlight === 0) {
|
|
8011
|
+
if (!isCurrent()) mirrorTrackedChangeFocusToHost(explicitActiveChange);
|
|
8012
|
+
else if (currentHostReviewSource) syncTrackedChangeFocusFromHostReviewTarget(readHostActiveReviewTarget(currentHostReviewSource));
|
|
8013
|
+
}
|
|
7937
8014
|
}
|
|
8015
|
+
} finally {
|
|
8016
|
+
if (optimisticActiveChange) pendingTrackChangeRevealFocuses.delete(optimisticActiveChange);
|
|
7938
8017
|
}
|
|
7939
8018
|
};
|
|
7940
8019
|
const navigateAndScroll = (step) => {
|
|
@@ -8036,47 +8115,65 @@ function createSuperDocUI(options) {
|
|
|
8036
8115
|
ok: false,
|
|
8037
8116
|
reason: getEditor() ? SUPERDOC_UI_REASONS.documentApiUnavailable : SUPERDOC_UI_REASONS.notReady
|
|
8038
8117
|
};
|
|
8118
|
+
queuedTrackChangeNavigationInvalidation += 1;
|
|
8119
|
+
trackChangeRevealInvalidation += 1;
|
|
8120
|
+
const requestedAtInvalidation = trackChangeRevealInvalidation;
|
|
8039
8121
|
const loadedItems = trackChangesSub.get().items;
|
|
8040
|
-
const
|
|
8041
|
-
const
|
|
8042
|
-
if (!target) return {
|
|
8043
|
-
success: false,
|
|
8044
|
-
ok: false,
|
|
8045
|
-
reason: SUPERDOC_UI_REASONS.targetUnresolved
|
|
8046
|
-
};
|
|
8122
|
+
const publicId = buildTrackedChangeIdContext(loadedItems).toPublicId(changeId) ?? changeId;
|
|
8123
|
+
const story = readEntityRequestStory(loadedItems.find((item) => readEntityId(item) === publicId));
|
|
8047
8124
|
const previousActiveChange = explicitActiveChange;
|
|
8048
|
-
const requestedActiveChange =
|
|
8049
|
-
id:
|
|
8050
|
-
story
|
|
8051
|
-
|
|
8052
|
-
setExplicitActiveChange(requestedActiveChange);
|
|
8053
|
-
recompute();
|
|
8054
|
-
const optimisticActiveChange = explicitActiveChange;
|
|
8055
|
-
const optimisticRevision = explicitActiveChangeRevision;
|
|
8056
|
-
const isCurrent = () => explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
8057
|
-
const rollback = () => {
|
|
8058
|
-
if (!isCurrent()) return;
|
|
8059
|
-
setExplicitActiveChange(previousActiveChange, { invalidateQueuedNavigation: false });
|
|
8060
|
-
recompute();
|
|
8125
|
+
const requestedActiveChange = {
|
|
8126
|
+
id: publicId,
|
|
8127
|
+
...story ? { story } : {},
|
|
8128
|
+
...publicId !== changeId ? { paintedEntityId: changeId } : {}
|
|
8061
8129
|
};
|
|
8062
|
-
|
|
8130
|
+
pendingTrackChangeRevealFocuses.add(requestedActiveChange);
|
|
8063
8131
|
try {
|
|
8064
|
-
const
|
|
8065
|
-
if (
|
|
8132
|
+
const target = await resolveEntityTarget("trackChanges", publicId, loadedItems, story ? { story } : void 0);
|
|
8133
|
+
if (trackChangeRevealInvalidation !== requestedAtInvalidation) return {
|
|
8066
8134
|
success: false,
|
|
8067
8135
|
ok: false
|
|
8068
8136
|
};
|
|
8069
|
-
if (!
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8137
|
+
if (!target) return {
|
|
8138
|
+
success: false,
|
|
8139
|
+
ok: false,
|
|
8140
|
+
reason: SUPERDOC_UI_REASONS.targetUnresolved
|
|
8141
|
+
};
|
|
8142
|
+
setExplicitActiveChange(requestedActiveChange);
|
|
8143
|
+
const revealInvalidation = trackChangeRevealInvalidation;
|
|
8144
|
+
const optimisticActiveChange = explicitActiveChange;
|
|
8145
|
+
const optimisticRevision = explicitActiveChangeRevision;
|
|
8146
|
+
const isCurrent = () => trackChangeRevealInvalidation === revealInvalidation && explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
8147
|
+
const rollback = () => {
|
|
8148
|
+
if (!isCurrent()) return;
|
|
8149
|
+
setExplicitActiveChange(previousActiveChange, { invalidateQueuedNavigation: false });
|
|
8150
|
+
recompute();
|
|
8151
|
+
};
|
|
8152
|
+
recompute();
|
|
8153
|
+
trackedChangeNavigationInFlight += 1;
|
|
8154
|
+
try {
|
|
8155
|
+
const result = await scrollTargetIntoView(target, {
|
|
8156
|
+
behavior: "auto",
|
|
8157
|
+
shouldContinue: isCurrent
|
|
8158
|
+
});
|
|
8159
|
+
if (!isCurrent()) return {
|
|
8160
|
+
success: false,
|
|
8161
|
+
ok: false
|
|
8162
|
+
};
|
|
8163
|
+
if (!result.ok && result.reason !== SUPERDOC_UI_REASONS.targetNotVisible) {
|
|
8164
|
+
rollback();
|
|
8165
|
+
mirrorTrackedChangeFocusToHost(previousActiveChange);
|
|
8166
|
+
} else mirrorTrackedChangeFocusToHost(requestedActiveChange);
|
|
8167
|
+
return result;
|
|
8168
|
+
} finally {
|
|
8169
|
+
trackedChangeNavigationInFlight = Math.max(0, trackedChangeNavigationInFlight - 1);
|
|
8170
|
+
if (trackedChangeNavigationInFlight === 0) {
|
|
8171
|
+
if (!isCurrent()) mirrorTrackedChangeFocusToHost(explicitActiveChange);
|
|
8172
|
+
else if (currentHostReviewSource) syncTrackedChangeFocusFromHostReviewTarget(readHostActiveReviewTarget(currentHostReviewSource));
|
|
8173
|
+
}
|
|
8079
8174
|
}
|
|
8175
|
+
} finally {
|
|
8176
|
+
pendingTrackChangeRevealFocuses.delete(requestedActiveChange);
|
|
8080
8177
|
}
|
|
8081
8178
|
}
|
|
8082
8179
|
};
|
package/dist/chunks/{create-super-doc-ui-fxF2Q8Ib.es.js → create-super-doc-ui-Bqkk1Ios.es.js}
RENAMED
|
@@ -1664,6 +1664,48 @@ function readEntityTarget(row) {
|
|
|
1664
1664
|
const target = row.target;
|
|
1665
1665
|
return target && typeof target === "object" ? target : null;
|
|
1666
1666
|
}
|
|
1667
|
+
function isHostGeometryTarget(target) {
|
|
1668
|
+
if (!target || typeof target !== "object") return false;
|
|
1669
|
+
const record = target;
|
|
1670
|
+
const isTextPoint = (point) => {
|
|
1671
|
+
if (!point || typeof point !== "object") return false;
|
|
1672
|
+
const candidate = point;
|
|
1673
|
+
return candidate.kind === "text" && typeof candidate.blockId === "string" && typeof candidate.offset === "number";
|
|
1674
|
+
};
|
|
1675
|
+
const isTextSegment = (segment) => {
|
|
1676
|
+
if (!segment || typeof segment !== "object") return false;
|
|
1677
|
+
const candidate = segment;
|
|
1678
|
+
const range$1 = candidate.range;
|
|
1679
|
+
return typeof candidate.blockId === "string" && typeof range$1?.start === "number" && typeof range$1.end === "number";
|
|
1680
|
+
};
|
|
1681
|
+
if (Array.isArray(record.segments)) {
|
|
1682
|
+
const first = record.segments[0];
|
|
1683
|
+
const last = record.segments[record.segments.length - 1];
|
|
1684
|
+
return isTextSegment(first) && isTextSegment(last);
|
|
1685
|
+
}
|
|
1686
|
+
if (record.kind === "selection") return isTextPoint(record.start) && isTextPoint(record.end);
|
|
1687
|
+
if (record.kind !== "text" || typeof record.blockId !== "string") return false;
|
|
1688
|
+
const range = record.range;
|
|
1689
|
+
return typeof range?.start === "number" && typeof range.end === "number";
|
|
1690
|
+
}
|
|
1691
|
+
function readTrackedChangeNavigationTarget(row) {
|
|
1692
|
+
if (!row || typeof row !== "object") return null;
|
|
1693
|
+
const target = readEntityTarget(row);
|
|
1694
|
+
if (isHostGeometryTarget(target)) return target;
|
|
1695
|
+
const record = row;
|
|
1696
|
+
const navigationTarget = record.navigationTarget && typeof record.navigationTarget === "object" ? record.navigationTarget : null;
|
|
1697
|
+
if (navigationTarget?.kind === "block" && typeof navigationTarget.blockId === "string" && navigationTarget.blockId.length > 0) return {
|
|
1698
|
+
kind: "text",
|
|
1699
|
+
blockId: navigationTarget.blockId,
|
|
1700
|
+
range: {
|
|
1701
|
+
start: 0,
|
|
1702
|
+
end: 0
|
|
1703
|
+
},
|
|
1704
|
+
...navigationTarget.story && typeof navigationTarget.story === "object" ? { story: navigationTarget.story } : {},
|
|
1705
|
+
...record.address && typeof record.address === "object" ? { address: record.address } : {}
|
|
1706
|
+
};
|
|
1707
|
+
return target;
|
|
1708
|
+
}
|
|
1667
1709
|
function storyLocatorSignature(story) {
|
|
1668
1710
|
if (!story || typeof story !== "object") return "story:body";
|
|
1669
1711
|
const record = story;
|
|
@@ -2860,11 +2902,14 @@ function createSuperDocUI(options) {
|
|
|
2860
2902
|
let explicitActiveChange = null;
|
|
2861
2903
|
let explicitActiveChangeRevision = 0;
|
|
2862
2904
|
let queuedTrackChangeNavigationInvalidation = 0;
|
|
2905
|
+
let trackChangeRevealInvalidation = 0;
|
|
2906
|
+
const pendingTrackChangeRevealFocuses = /* @__PURE__ */ new Set();
|
|
2863
2907
|
const explicitActiveChangesEqual = (left, right) => {
|
|
2864
2908
|
if (left === right) return true;
|
|
2865
2909
|
if (!left || !right) return false;
|
|
2866
2910
|
return left.id === right.id && left.paintedEntityId === right.paintedEntityId && storyLocatorSignature(left.story) === storyLocatorSignature(right.story);
|
|
2867
2911
|
};
|
|
2912
|
+
const hasPendingTrackChangeRevealFocus = (focus) => Array.from(pendingTrackChangeRevealFocuses).some((pendingFocus) => explicitActiveChangesEqual(pendingFocus, focus));
|
|
2868
2913
|
const mirrorTrackedChangeFocusToHost = (next) => {
|
|
2869
2914
|
const host = getHost();
|
|
2870
2915
|
if (typeof host?.getHandles !== "function") return;
|
|
@@ -2893,6 +2938,7 @@ function createSuperDocUI(options) {
|
|
|
2893
2938
|
const setExplicitActiveChange = (next, options$1) => {
|
|
2894
2939
|
explicitActiveChange = next;
|
|
2895
2940
|
explicitActiveChangeRevision += 1;
|
|
2941
|
+
trackChangeRevealInvalidation += 1;
|
|
2896
2942
|
if (options$1?.invalidateQueuedNavigation !== false) queuedTrackChangeNavigationInvalidation += 1;
|
|
2897
2943
|
};
|
|
2898
2944
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -5630,6 +5676,7 @@ function createSuperDocUI(options) {
|
|
|
5630
5676
|
...typeof target.paintedEntityId === "string" && target.paintedEntityId.length > 0 ? { paintedEntityId: target.paintedEntityId } : {}
|
|
5631
5677
|
};
|
|
5632
5678
|
}
|
|
5679
|
+
if (rawTarget == null && next == null && explicitActiveChange != null && hasPendingTrackChangeRevealFocus(explicitActiveChange)) return false;
|
|
5633
5680
|
if (explicitActiveChangesEqual(explicitActiveChange, next)) return false;
|
|
5634
5681
|
setExplicitActiveChange(next);
|
|
5635
5682
|
return true;
|
|
@@ -5900,8 +5947,9 @@ function createSuperDocUI(options) {
|
|
|
5900
5947
|
const story = selectionStoryLocator(state.selection);
|
|
5901
5948
|
const item = items.find((candidate) => entityRowMatchesRequest(candidate, activeId, story));
|
|
5902
5949
|
if (!item) return "unavailable";
|
|
5903
|
-
const
|
|
5904
|
-
const
|
|
5950
|
+
const change = trackChangesItemPayload(item);
|
|
5951
|
+
const type = change.type;
|
|
5952
|
+
const grouping = change.grouping;
|
|
5905
5953
|
if (type === "replacement" && grouping === "replacement-pair") return "range";
|
|
5906
5954
|
return (type === "insertion" || type === "deletion" || type === "insert" || type === "delete") && grouping === "standalone" ? "range" : "id";
|
|
5907
5955
|
}
|
|
@@ -5954,6 +6002,15 @@ function createSuperDocUI(options) {
|
|
|
5954
6002
|
const target = trackDecisionRangeFromSelection(state.selection);
|
|
5955
6003
|
return target ? executeTrackDecisionTarget(command.kind, target, null) : false;
|
|
5956
6004
|
}
|
|
6005
|
+
if (route === "id") {
|
|
6006
|
+
const activeId = state.selection.activeChangeIds[0];
|
|
6007
|
+
const selectedStory = selectionStoryLocator(state.selection);
|
|
6008
|
+
const story = selectedStory && storyLocatorSignature(selectedStory) !== storyLocatorSignature(null) ? selectedStory : void 0;
|
|
6009
|
+
return executeTrackDecision(command.kind, story ? {
|
|
6010
|
+
id: activeId,
|
|
6011
|
+
story
|
|
6012
|
+
} : activeId);
|
|
6013
|
+
}
|
|
5957
6014
|
}
|
|
5958
6015
|
}
|
|
5959
6016
|
const resolved = resolveTrackDecisionTarget(command, payload);
|
|
@@ -7478,11 +7535,12 @@ function createSuperDocUI(options) {
|
|
|
7478
7535
|
reason: SUPERDOC_UI_REASONS.hostCapabilityUnavailable
|
|
7479
7536
|
};
|
|
7480
7537
|
try {
|
|
7481
|
-
const
|
|
7538
|
+
const input = {
|
|
7482
7539
|
target,
|
|
7483
7540
|
block: options$1?.block ?? "center",
|
|
7484
7541
|
behavior: options$1?.behavior ?? "smooth"
|
|
7485
|
-
}
|
|
7542
|
+
};
|
|
7543
|
+
const result = await Promise.resolve(options$1?.shouldContinue ? scroll.call(host, input, options$1.shouldContinue) : scroll.call(host, input));
|
|
7486
7544
|
if (result && typeof result === "object" && result.success === false) return {
|
|
7487
7545
|
success: false,
|
|
7488
7546
|
ok: false,
|
|
@@ -7512,19 +7570,32 @@ function createSuperDocUI(options) {
|
|
|
7512
7570
|
story: requestedStory
|
|
7513
7571
|
};
|
|
7514
7572
|
};
|
|
7515
|
-
const
|
|
7516
|
-
|
|
7573
|
+
const readTarget = namespace === "trackChanges" ? readTrackedChangeNavigationTarget : readEntityTarget;
|
|
7574
|
+
const loadedRow = loaded.find((row) => entityRowMatchesRequest(row, id, requestedStory));
|
|
7575
|
+
const loadedRecord = loadedRow && typeof loadedRow === "object" ? loadedRow : null;
|
|
7576
|
+
const moveSide = namespace === "trackChanges" && loadedRecord?.type === "move" && (loadedRecord.subtype === "move-to" || loadedRecord.subtype === "move-from") ? loadedRecord.subtype : null;
|
|
7577
|
+
const trackedChangeLookupId = moveSide && typeof loadedRecord?.trackedChangeCanonicalId === "string" ? loadedRecord.trackedChangeCanonicalId : id;
|
|
7578
|
+
const readResolvedTarget = (row) => {
|
|
7579
|
+
if (!moveSide) return readTarget(row);
|
|
7580
|
+
const moveTarget = readEntityTarget(row);
|
|
7581
|
+
if (moveTarget?.kind !== "move") return null;
|
|
7582
|
+
const sideTarget = moveSide === "move-to" ? moveTarget.destination : moveTarget.source;
|
|
7583
|
+
return isHostGeometryTarget(sideTarget) ? sideTarget : null;
|
|
7584
|
+
};
|
|
7585
|
+
const fromList = readTarget(loadedRow);
|
|
7586
|
+
const listTargetIsAuthoritative = namespace !== "trackChanges" || !moveSide && isHostGeometryTarget(readEntityTarget(loadedRow));
|
|
7587
|
+
if (fromList && listTargetIsAuthoritative) return withRequestedStory(fromList);
|
|
7517
7588
|
const api = getDoc()?.[namespace];
|
|
7518
7589
|
const input = namespace === "comments" ? { commentId: id } : {
|
|
7519
|
-
id,
|
|
7590
|
+
id: trackedChangeLookupId,
|
|
7520
7591
|
...requestedStory ? { story: requestedStory } : {}
|
|
7521
7592
|
};
|
|
7522
7593
|
const get = api?.get;
|
|
7523
|
-
if (typeof get !== "function") return
|
|
7594
|
+
if (typeof get !== "function") return withRequestedStory(fromList);
|
|
7524
7595
|
try {
|
|
7525
|
-
return withRequestedStory(
|
|
7596
|
+
return withRequestedStory(readResolvedTarget(await Promise.resolve(get.call(api, input))) ?? fromList);
|
|
7526
7597
|
} catch {
|
|
7527
|
-
return
|
|
7598
|
+
return withRequestedStory(fromList);
|
|
7528
7599
|
}
|
|
7529
7600
|
};
|
|
7530
7601
|
function patchCommentStatus(commentId, status) {
|
|
@@ -7686,33 +7757,41 @@ function createSuperDocUI(options) {
|
|
|
7686
7757
|
if (activeId == null) return { success: false };
|
|
7687
7758
|
const optimisticActiveChange = explicitActiveChange;
|
|
7688
7759
|
const optimisticRevision = explicitActiveChangeRevision;
|
|
7689
|
-
const isCurrent = () => explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
7760
|
+
const isCurrent = () => queuedTrackChangeNavigationInvalidation === requestedAtInvalidation && explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
7690
7761
|
const rollback = () => {
|
|
7691
7762
|
if (!isCurrent()) return;
|
|
7692
7763
|
setExplicitActiveChange(previousActiveChange, { invalidateQueuedNavigation: false });
|
|
7693
7764
|
recompute();
|
|
7694
7765
|
};
|
|
7695
|
-
|
|
7696
|
-
if (!isCurrent()) return { success: false };
|
|
7697
|
-
if (!target) {
|
|
7698
|
-
rollback();
|
|
7699
|
-
return { success: false };
|
|
7700
|
-
}
|
|
7701
|
-
trackedChangeNavigationInFlight += 1;
|
|
7766
|
+
if (optimisticActiveChange) pendingTrackChangeRevealFocuses.add(optimisticActiveChange);
|
|
7702
7767
|
try {
|
|
7703
|
-
const
|
|
7768
|
+
const target = await resolveEntityTarget("trackChanges", activeId, trackChangesSub.get().items, optimisticActiveChange?.story ? { story: optimisticActiveChange.story } : void 0);
|
|
7704
7769
|
if (!isCurrent()) return { success: false };
|
|
7705
|
-
if (!
|
|
7770
|
+
if (!target) {
|
|
7706
7771
|
rollback();
|
|
7707
|
-
|
|
7708
|
-
}
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7772
|
+
return { success: false };
|
|
7773
|
+
}
|
|
7774
|
+
trackedChangeNavigationInFlight += 1;
|
|
7775
|
+
try {
|
|
7776
|
+
const result = await scrollTargetIntoView(target, {
|
|
7777
|
+
behavior: "auto",
|
|
7778
|
+
shouldContinue: isCurrent
|
|
7779
|
+
});
|
|
7780
|
+
if (!isCurrent()) return { success: false };
|
|
7781
|
+
if (!result.ok && result.reason !== SUPERDOC_UI_REASONS.targetNotVisible) {
|
|
7782
|
+
rollback();
|
|
7783
|
+
mirrorTrackedChangeFocusToHost(previousActiveChange);
|
|
7784
|
+
} else mirrorTrackedChangeFocusToHost(optimisticActiveChange);
|
|
7785
|
+
return { success: result.ok };
|
|
7786
|
+
} finally {
|
|
7787
|
+
trackedChangeNavigationInFlight = Math.max(0, trackedChangeNavigationInFlight - 1);
|
|
7788
|
+
if (trackedChangeNavigationInFlight === 0) {
|
|
7789
|
+
if (!isCurrent()) mirrorTrackedChangeFocusToHost(explicitActiveChange);
|
|
7790
|
+
else if (currentHostReviewSource) syncTrackedChangeFocusFromHostReviewTarget(readHostActiveReviewTarget(currentHostReviewSource));
|
|
7791
|
+
}
|
|
7715
7792
|
}
|
|
7793
|
+
} finally {
|
|
7794
|
+
if (optimisticActiveChange) pendingTrackChangeRevealFocuses.delete(optimisticActiveChange);
|
|
7716
7795
|
}
|
|
7717
7796
|
};
|
|
7718
7797
|
const navigateAndScroll = (step) => {
|
|
@@ -7814,47 +7893,65 @@ function createSuperDocUI(options) {
|
|
|
7814
7893
|
ok: false,
|
|
7815
7894
|
reason: getEditor() ? SUPERDOC_UI_REASONS.documentApiUnavailable : SUPERDOC_UI_REASONS.notReady
|
|
7816
7895
|
};
|
|
7896
|
+
queuedTrackChangeNavigationInvalidation += 1;
|
|
7897
|
+
trackChangeRevealInvalidation += 1;
|
|
7898
|
+
const requestedAtInvalidation = trackChangeRevealInvalidation;
|
|
7817
7899
|
const loadedItems = trackChangesSub.get().items;
|
|
7818
|
-
const
|
|
7819
|
-
const
|
|
7820
|
-
if (!target) return {
|
|
7821
|
-
success: false,
|
|
7822
|
-
ok: false,
|
|
7823
|
-
reason: SUPERDOC_UI_REASONS.targetUnresolved
|
|
7824
|
-
};
|
|
7900
|
+
const publicId = buildTrackedChangeIdContext(loadedItems).toPublicId(changeId) ?? changeId;
|
|
7901
|
+
const story = readEntityRequestStory(loadedItems.find((item) => readEntityId(item) === publicId));
|
|
7825
7902
|
const previousActiveChange = explicitActiveChange;
|
|
7826
|
-
const requestedActiveChange =
|
|
7827
|
-
id:
|
|
7828
|
-
story
|
|
7829
|
-
|
|
7830
|
-
setExplicitActiveChange(requestedActiveChange);
|
|
7831
|
-
recompute();
|
|
7832
|
-
const optimisticActiveChange = explicitActiveChange;
|
|
7833
|
-
const optimisticRevision = explicitActiveChangeRevision;
|
|
7834
|
-
const isCurrent = () => explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
7835
|
-
const rollback = () => {
|
|
7836
|
-
if (!isCurrent()) return;
|
|
7837
|
-
setExplicitActiveChange(previousActiveChange, { invalidateQueuedNavigation: false });
|
|
7838
|
-
recompute();
|
|
7903
|
+
const requestedActiveChange = {
|
|
7904
|
+
id: publicId,
|
|
7905
|
+
...story ? { story } : {},
|
|
7906
|
+
...publicId !== changeId ? { paintedEntityId: changeId } : {}
|
|
7839
7907
|
};
|
|
7840
|
-
|
|
7908
|
+
pendingTrackChangeRevealFocuses.add(requestedActiveChange);
|
|
7841
7909
|
try {
|
|
7842
|
-
const
|
|
7843
|
-
if (
|
|
7910
|
+
const target = await resolveEntityTarget("trackChanges", publicId, loadedItems, story ? { story } : void 0);
|
|
7911
|
+
if (trackChangeRevealInvalidation !== requestedAtInvalidation) return {
|
|
7844
7912
|
success: false,
|
|
7845
7913
|
ok: false
|
|
7846
7914
|
};
|
|
7847
|
-
if (!
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7915
|
+
if (!target) return {
|
|
7916
|
+
success: false,
|
|
7917
|
+
ok: false,
|
|
7918
|
+
reason: SUPERDOC_UI_REASONS.targetUnresolved
|
|
7919
|
+
};
|
|
7920
|
+
setExplicitActiveChange(requestedActiveChange);
|
|
7921
|
+
const revealInvalidation = trackChangeRevealInvalidation;
|
|
7922
|
+
const optimisticActiveChange = explicitActiveChange;
|
|
7923
|
+
const optimisticRevision = explicitActiveChangeRevision;
|
|
7924
|
+
const isCurrent = () => trackChangeRevealInvalidation === revealInvalidation && explicitActiveChange === optimisticActiveChange && explicitActiveChangeRevision === optimisticRevision;
|
|
7925
|
+
const rollback = () => {
|
|
7926
|
+
if (!isCurrent()) return;
|
|
7927
|
+
setExplicitActiveChange(previousActiveChange, { invalidateQueuedNavigation: false });
|
|
7928
|
+
recompute();
|
|
7929
|
+
};
|
|
7930
|
+
recompute();
|
|
7931
|
+
trackedChangeNavigationInFlight += 1;
|
|
7932
|
+
try {
|
|
7933
|
+
const result = await scrollTargetIntoView(target, {
|
|
7934
|
+
behavior: "auto",
|
|
7935
|
+
shouldContinue: isCurrent
|
|
7936
|
+
});
|
|
7937
|
+
if (!isCurrent()) return {
|
|
7938
|
+
success: false,
|
|
7939
|
+
ok: false
|
|
7940
|
+
};
|
|
7941
|
+
if (!result.ok && result.reason !== SUPERDOC_UI_REASONS.targetNotVisible) {
|
|
7942
|
+
rollback();
|
|
7943
|
+
mirrorTrackedChangeFocusToHost(previousActiveChange);
|
|
7944
|
+
} else mirrorTrackedChangeFocusToHost(requestedActiveChange);
|
|
7945
|
+
return result;
|
|
7946
|
+
} finally {
|
|
7947
|
+
trackedChangeNavigationInFlight = Math.max(0, trackedChangeNavigationInFlight - 1);
|
|
7948
|
+
if (trackedChangeNavigationInFlight === 0) {
|
|
7949
|
+
if (!isCurrent()) mirrorTrackedChangeFocusToHost(explicitActiveChange);
|
|
7950
|
+
else if (currentHostReviewSource) syncTrackedChangeFocusFromHostReviewTarget(readHostActiveReviewTarget(currentHostReviewSource));
|
|
7951
|
+
}
|
|
7857
7952
|
}
|
|
7953
|
+
} finally {
|
|
7954
|
+
pendingTrackChangeRevealFocuses.delete(requestedActiveChange);
|
|
7858
7955
|
}
|
|
7859
7956
|
}
|
|
7860
7957
|
};
|
|
@@ -7,7 +7,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
|
|
|
7
7
|
var PRIVATE_ENGINE_INFO = (0, __superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
|
|
8
8
|
var ENGINE_INFO = Object.freeze({
|
|
9
9
|
...PRIVATE_ENGINE_INFO,
|
|
10
|
-
superdocVersion: "2.0.0-next.
|
|
10
|
+
superdocVersion: "2.0.0-next.53",
|
|
11
11
|
roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
|
|
12
12
|
supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
|
|
13
13
|
supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
|
|
@@ -6,7 +6,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
|
|
|
6
6
|
var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
|
|
7
7
|
var ENGINE_INFO = Object.freeze({
|
|
8
8
|
...PRIVATE_ENGINE_INFO,
|
|
9
|
-
superdocVersion: "2.0.0-next.
|
|
9
|
+
superdocVersion: "2.0.0-next.53",
|
|
10
10
|
roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
|
|
11
11
|
supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
|
|
12
12
|
supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
|