sanity 6.5.0-next.21 → 6.5.0-next.24
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/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +11 -1
- package/lib/_chunks-es/index2.js +67 -10
- package/lib/_chunks-es/index2.js.map +1 -1
- package/lib/_chunks-es/index6.js +60 -54
- package/lib/_chunks-es/index6.js.map +1 -1
- package/lib/_chunks-es/index8.js +157 -140
- package/lib/_chunks-es/index8.js.map +1 -1
- package/lib/_chunks-es/version.js +2 -2
- package/package.json +10 -10
|
@@ -7260,6 +7260,8 @@ interface BuildRangeDecorationsProps {
|
|
|
7260
7260
|
onDecorationMoved: (details: RangeDecorationOnMovedDetails) => void;
|
|
7261
7261
|
selectedThreadId: string | null;
|
|
7262
7262
|
value: PortableTextBlock[] | undefined;
|
|
7263
|
+
documentValue?: unknown;
|
|
7264
|
+
basePath?: Path;
|
|
7263
7265
|
}
|
|
7264
7266
|
/**
|
|
7265
7267
|
* @internal
|
|
@@ -7271,6 +7273,13 @@ declare function buildCommentRangeDecorations(props: BuildRangeDecorationsProps)
|
|
|
7271
7273
|
interface BuildCommentsRangeDecorationsProps {
|
|
7272
7274
|
value: PortableTextBlock[] | undefined;
|
|
7273
7275
|
comments: CommentDocument[];
|
|
7276
|
+
/**
|
|
7277
|
+
* Document value the stored `field` paths resolve against. Falls back to a
|
|
7278
|
+
* top-level `value.find` on the editor slice when absent.
|
|
7279
|
+
*/
|
|
7280
|
+
documentValue?: unknown;
|
|
7281
|
+
/** The editor's own document path. */
|
|
7282
|
+
basePath?: Path;
|
|
7274
7283
|
}
|
|
7275
7284
|
/**
|
|
7276
7285
|
* @internal
|
|
@@ -7287,7 +7296,8 @@ interface BuildCommentsRangeDecorationsResultItem {
|
|
|
7287
7296
|
declare function buildRangeDecorationSelectionsFromComments(props: BuildCommentsRangeDecorationsProps): BuildCommentsRangeDecorationsResultItem[];
|
|
7288
7297
|
interface BuildSelectionFromFragmentProps {
|
|
7289
7298
|
fragment: PortableTextBlock[];
|
|
7290
|
-
|
|
7299
|
+
documentValue: unknown;
|
|
7300
|
+
basePath: Path;
|
|
7291
7301
|
selection: EditorSelection;
|
|
7292
7302
|
}
|
|
7293
7303
|
/**
|
package/lib/_chunks-es/index2.js
CHANGED
|
@@ -60182,6 +60182,14 @@ function commentIntentIfDiffers(parent, comment) {
|
|
|
60182
60182
|
if (intent && (!parentIntent || "preview" in intent.params && "preview" in parentIntent.params && intent.params.preview !== parentIntent.params.preview))
|
|
60183
60183
|
return intent;
|
|
60184
60184
|
}
|
|
60185
|
+
function parseCommentFieldPath(fieldPath) {
|
|
60186
|
+
if (fieldPath)
|
|
60187
|
+
try {
|
|
60188
|
+
return PathUtils.fromString(fieldPath);
|
|
60189
|
+
} catch {
|
|
60190
|
+
return;
|
|
60191
|
+
}
|
|
60192
|
+
}
|
|
60185
60193
|
function isTextSelectionComment(comment) {
|
|
60186
60194
|
return comment ? !!(comment?.target?.path?.selection?.type === "text" && comment?.target?.path?.selection?.value) : !1;
|
|
60187
60195
|
}
|
|
@@ -62820,13 +62828,23 @@ const COMMENT_INDICATORS = ["\uF000", "\uF001"], COMMENT_INDICATORS_REGEX = new
|
|
|
62820
62828
|
function buildRangeDecorationSelectionsFromComments(props2) {
|
|
62821
62829
|
const {
|
|
62822
62830
|
value,
|
|
62823
|
-
comments: comments2
|
|
62831
|
+
comments: comments2,
|
|
62832
|
+
documentValue,
|
|
62833
|
+
basePath
|
|
62824
62834
|
} = props2;
|
|
62825
62835
|
if (!value || value.length === 0) return EMPTY_ARRAY$5;
|
|
62826
62836
|
const textSelections = comments2.filter(isTextSelectionComment), decorators = [];
|
|
62827
62837
|
return textSelections.forEach((comment) => {
|
|
62838
|
+
let relative = [];
|
|
62839
|
+
if (documentValue !== void 0 && basePath) {
|
|
62840
|
+
const fieldPath = parseCommentFieldPath(comment.target.path?.field);
|
|
62841
|
+
if (!fieldPath || !PathUtils.startsWith(basePath, fieldPath)) return;
|
|
62842
|
+
relative = fieldPath.slice(basePath.length);
|
|
62843
|
+
}
|
|
62828
62844
|
comment.target.path?.selection?.value.forEach((selectionMember) => {
|
|
62829
|
-
const matchedBlock =
|
|
62845
|
+
const matchedBlock = documentValue !== void 0 && basePath ? getValueAtPath(documentValue, [...basePath, ...relative, {
|
|
62846
|
+
_key: selectionMember._key
|
|
62847
|
+
}]) : value.find((block) => block._key === selectionMember._key);
|
|
62830
62848
|
if (!matchedBlock || !isPortableTextTextBlock(matchedBlock))
|
|
62831
62849
|
return;
|
|
62832
62850
|
const selectionText = selectionMember.text.replaceAll(COMMENT_INDICATORS_REGEX, ""), textWithChildSeparators = toPlainTextWithChildSeparators(matchedBlock), {
|
|
@@ -62842,7 +62860,7 @@ function buildRangeDecorationSelectionsFromComments(props2) {
|
|
|
62842
62860
|
decorators.push({
|
|
62843
62861
|
selection: {
|
|
62844
62862
|
anchor: {
|
|
62845
|
-
path: [{
|
|
62863
|
+
path: [...relative, {
|
|
62846
62864
|
_key: matchedBlock._key
|
|
62847
62865
|
}, "children", {
|
|
62848
62866
|
_key: matchedBlock.children[childIndexAnchor]._key
|
|
@@ -62850,7 +62868,7 @@ function buildRangeDecorationSelectionsFromComments(props2) {
|
|
|
62850
62868
|
offset: anchorOffset
|
|
62851
62869
|
},
|
|
62852
62870
|
focus: {
|
|
62853
|
-
path: [{
|
|
62871
|
+
path: [...relative, {
|
|
62854
62872
|
_key: matchedBlock._key
|
|
62855
62873
|
}, "children", {
|
|
62856
62874
|
_key: matchedBlock.children[childIndexFocus]._key
|
|
@@ -62931,11 +62949,15 @@ function buildCommentRangeDecorations(props2) {
|
|
|
62931
62949
|
onDecorationHoverStart,
|
|
62932
62950
|
onDecorationMoved,
|
|
62933
62951
|
selectedThreadId,
|
|
62934
|
-
value
|
|
62952
|
+
value,
|
|
62953
|
+
documentValue,
|
|
62954
|
+
basePath
|
|
62935
62955
|
} = props2;
|
|
62936
62956
|
return buildRangeDecorationSelectionsFromComments({
|
|
62937
62957
|
comments: comments2,
|
|
62938
|
-
value
|
|
62958
|
+
value,
|
|
62959
|
+
documentValue,
|
|
62960
|
+
basePath
|
|
62939
62961
|
}).map(({
|
|
62940
62962
|
selection,
|
|
62941
62963
|
comment,
|
|
@@ -62955,7 +62977,8 @@ function buildCommentRangeDecorations(props2) {
|
|
|
62955
62977
|
function buildTextSelectionFromFragment(props2) {
|
|
62956
62978
|
const {
|
|
62957
62979
|
fragment,
|
|
62958
|
-
|
|
62980
|
+
documentValue,
|
|
62981
|
+
basePath,
|
|
62959
62982
|
selection
|
|
62960
62983
|
} = props2;
|
|
62961
62984
|
if (!selection)
|
|
@@ -62963,17 +62986,28 @@ function buildTextSelectionFromFragment(props2) {
|
|
|
62963
62986
|
const normalizedSelection = selection.backward ? {
|
|
62964
62987
|
anchor: selection.focus,
|
|
62965
62988
|
focus: selection.anchor
|
|
62966
|
-
} : selection
|
|
62989
|
+
} : selection, {
|
|
62990
|
+
block: anchorBlock,
|
|
62991
|
+
path: anchorBlockPath
|
|
62992
|
+
} = findEnclosingTextBlock(documentValue, basePath, normalizedSelection.anchor.path) ?? {}, {
|
|
62993
|
+
block: focusBlock,
|
|
62994
|
+
path: focusBlockPath
|
|
62995
|
+
} = findEnclosingTextBlock(documentValue, basePath, normalizedSelection.focus.path) ?? {}, containingArrays = [];
|
|
62996
|
+
for (const blockPath of [anchorBlockPath, focusBlockPath]) {
|
|
62997
|
+
if (!blockPath) continue;
|
|
62998
|
+
const containingArray = getValueAtPath(documentValue, [...basePath, ...blockPath.slice(0, -1)]);
|
|
62999
|
+
Array.isArray(containingArray) && !containingArrays.includes(containingArray) && containingArrays.push(containingArray);
|
|
63000
|
+
}
|
|
62967
63001
|
return {
|
|
62968
63002
|
type: "text",
|
|
62969
63003
|
value: fragment.map((fragmentBlock) => {
|
|
62970
|
-
const originalBlock =
|
|
63004
|
+
const originalBlock = findBlockByKey(containingArrays, fragmentBlock._key);
|
|
62971
63005
|
if (!isPortableTextTextBlock(originalBlock))
|
|
62972
63006
|
return {
|
|
62973
63007
|
_key: fragmentBlock._key,
|
|
62974
63008
|
text: ""
|
|
62975
63009
|
};
|
|
62976
|
-
const anchorBlockKey =
|
|
63010
|
+
const anchorBlockKey = anchorBlock?._key, focusBlockKey = focusBlock?._key, fragmentBlockText = toPlainText$1([fragmentBlock]), fragmentStartSpan = isPortableTextTextBlock(fragmentBlock) ? fragmentBlock.children[0] : void 0, fragmentEndSpan = isPortableTextTextBlock(fragmentBlock) ? fragmentBlock.children[fragmentBlock.children.length - 1] : void 0;
|
|
62977
63011
|
let originalTextBeforeSelection = "", startChildIndex = -1;
|
|
62978
63012
|
if (anchorBlockKey === originalBlock._key)
|
|
62979
63013
|
for (const child of originalBlock.children) {
|
|
@@ -62999,6 +63033,27 @@ function buildTextSelectionFromFragment(props2) {
|
|
|
62999
63033
|
})
|
|
63000
63034
|
};
|
|
63001
63035
|
}
|
|
63036
|
+
function getCommentFieldPath(documentValue, basePath, selectionPath) {
|
|
63037
|
+
const enclosingBlockPath = findEnclosingTextBlock(documentValue, basePath, selectionPath)?.path;
|
|
63038
|
+
if (enclosingBlockPath)
|
|
63039
|
+
return PathUtils.toString([...basePath, ...enclosingBlockPath.slice(0, -1)]);
|
|
63040
|
+
}
|
|
63041
|
+
function findEnclosingTextBlock(documentValue, basePath, path) {
|
|
63042
|
+
for (let end = path.length; end > 0; end--) {
|
|
63043
|
+
const relative = path.slice(0, end), candidate = getValueAtPath(documentValue, [...basePath, ...relative]);
|
|
63044
|
+
if (isPortableTextTextBlock(candidate))
|
|
63045
|
+
return {
|
|
63046
|
+
block: candidate,
|
|
63047
|
+
path: relative
|
|
63048
|
+
};
|
|
63049
|
+
}
|
|
63050
|
+
}
|
|
63051
|
+
function findBlockByKey(arrays, key) {
|
|
63052
|
+
for (const array of arrays)
|
|
63053
|
+
for (const block of array)
|
|
63054
|
+
if (isPortableTextTextBlock(block) && block._key === key)
|
|
63055
|
+
return block;
|
|
63056
|
+
}
|
|
63002
63057
|
function mergeCommentReactions(reactionsA, reactionsB) {
|
|
63003
63058
|
const mergedReactions = {};
|
|
63004
63059
|
for (const reaction of reactionsA)
|
|
@@ -88499,6 +88554,7 @@ export {
|
|
|
88499
88554
|
getAnnotationColor,
|
|
88500
88555
|
getApiErrorCode,
|
|
88501
88556
|
getCalendarLabels,
|
|
88557
|
+
getCommentFieldPath,
|
|
88502
88558
|
getConfigContextFromSource,
|
|
88503
88559
|
getDialogPropsFromContext,
|
|
88504
88560
|
getDiffAtPath,
|
|
@@ -88634,6 +88690,7 @@ export {
|
|
|
88634
88690
|
operationEvents,
|
|
88635
88691
|
operatorDefinitions,
|
|
88636
88692
|
oversizedButtonStyle,
|
|
88693
|
+
parseCommentFieldPath,
|
|
88637
88694
|
parseRetryAfter,
|
|
88638
88695
|
passthroughErrorHandler,
|
|
88639
88696
|
pathToString$1 as pathToString,
|