sanity-plugin-graph-view 3.0.0-studio-v3.0 → 3.0.0-studio-v3.1
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/index.d.ts.map +1 -1
- package/lib/index.js +137 -137
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +137 -137
- package/lib/index.modern.js.map +1 -1
- package/package.json +14 -7
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AKMA;IACE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,OAAO,MAAM,0DAmBX,CAAA","sources":["src/src/tool/hooks.ts","src/src/tool/utils.ts","src/src/tool/GraphViewStyle.tsx","src/src/tool/GraphView.tsx","src/src/tool/GraphViewIcon.tsx","src/src/index.tsx","src/index.tsx"],"sourcesContent":[null,null,null,null,null,null,"import {GraphView} from './tool/GraphView'\nimport {GraphViewIcon} from './tool/GraphViewIcon'\nimport {createPlugin} from 'sanity'\nimport {route} from 'sanity/_unstable'\nimport React from 'react'\n\ninterface GraphViewConfig {\n query?: string\n}\n\nexport const contentGraphView = createPlugin<GraphViewConfig>((config: GraphViewConfig = {}) => {\n return {\n name: '@sanity/content-graph-view',\n\n tools: (prev) => {\n return [\n ...prev,\n {\n name: 'graph-your-content',\n title: 'Graph',\n icon: GraphViewIcon,\n component: function component() {\n return <GraphView {...config} />\n },\n router: route.create('/:selectedDocumentId'),\n },\n ]\n },\n }\n})\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
|
1
|
+
{"mappings":"AKMA;IACE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,OAAO,MAAM,0DAmBX,CAAA","sources":["src/src/tool/hooks.ts","src/src/tool/utils.ts","src/src/tool/GraphViewStyle.tsx","src/src/tool/GraphView.tsx","src/src/tool/GraphViewIcon.tsx","src/src/index.tsx","src/index.tsx"],"sourcesContent":[null,null,null,null,null,null,"import {GraphView} from './tool/GraphView'\nimport {GraphViewIcon} from './tool/GraphViewIcon'\nimport {createPlugin} from 'sanity'\nimport {route} from 'sanity/_unstable'\nimport React from 'react'\n\ninterface GraphViewConfig {\n query?: string\n}\n\nexport const contentGraphView = createPlugin<GraphViewConfig>((config: GraphViewConfig = {}) => {\n return {\n name: '@sanity/content-graph-view',\n\n tools: (prev) => {\n return [\n ...prev,\n {\n name: 'graph-your-content',\n title: 'Graph',\n icon: GraphViewIcon,\n component: function component() {\n return <GraphView {...config} />\n },\n router: route.create('/:selectedDocumentId'),\n },\n ]\n },\n }\n})\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../"}
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
7
|
-
var $
|
|
8
|
-
var $
|
|
9
|
-
var $
|
|
10
|
-
var $
|
|
11
|
-
var $
|
|
12
|
-
var $
|
|
1
|
+
var $kbR6r$reactjsxruntime = require("react/jsx-runtime");
|
|
2
|
+
var $kbR6r$sanity = require("sanity");
|
|
3
|
+
var $kbR6r$sanity_unstable = require("sanity/_unstable");
|
|
4
|
+
var $kbR6r$react = require("react");
|
|
5
|
+
var $kbR6r$polished = require("polished");
|
|
6
|
+
var $kbR6r$deepequal = require("deep-equal");
|
|
7
|
+
var $kbR6r$reactforcegraph = require("react-force-graph");
|
|
8
|
+
var $kbR6r$uuid = require("uuid");
|
|
9
|
+
var $kbR6r$beziereasing = require("bezier-easing");
|
|
10
|
+
var $kbR6r$sanityui = require("@sanity/ui");
|
|
11
|
+
var $kbR6r$sanitycolor = require("@sanity/color");
|
|
12
|
+
var $kbR6r$styledcomponents = require("styled-components");
|
|
13
13
|
|
|
14
14
|
function $parcel$export(e, n, v, s) {
|
|
15
15
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -18,7 +18,7 @@ function $parcel$interopDefault(a) {
|
|
|
18
18
|
return a && a.__esModule ? a.default : a;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$parcel$export(module.exports, "contentGraphView", () => $
|
|
21
|
+
$parcel$export(module.exports, "contentGraphView", () => $329a1cedcedb1349$export$e3438defddc96622);
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -30,9 +30,9 @@ $parcel$export(module.exports, "contentGraphView", () => $9233cea927cb9637$expor
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
function $
|
|
34
|
-
const client = (0, $
|
|
35
|
-
(0, $
|
|
33
|
+
function $8984dbba39ce9ccc$export$c006713bb64ff575(query, params, options, onUpdate, dependencies) {
|
|
34
|
+
const client = (0, $kbR6r$sanity.useClient)();
|
|
35
|
+
(0, $kbR6r$react.useEffect)(()=>{
|
|
36
36
|
const subscription = client.listen(query, params, options).subscribe((update)=>{
|
|
37
37
|
onUpdate(update);
|
|
38
38
|
});
|
|
@@ -41,9 +41,9 @@ function $393280ec8c68ebf5$export$c006713bb64ff575(query, params, options, onUpd
|
|
|
41
41
|
};
|
|
42
42
|
}, dependencies);
|
|
43
43
|
}
|
|
44
|
-
function $
|
|
45
|
-
const client = (0, $
|
|
46
|
-
(0, $
|
|
44
|
+
function $8984dbba39ce9ccc$export$7b4649445b8cee9f(query, onFetch, dependencies) {
|
|
45
|
+
const client = (0, $kbR6r$sanity.useClient)();
|
|
46
|
+
(0, $kbR6r$react.useEffect)(()=>{
|
|
47
47
|
client.fetch(query).then((result)=>{
|
|
48
48
|
onFetch(result);
|
|
49
49
|
});
|
|
@@ -51,14 +51,14 @@ function $393280ec8c68ebf5$export$7b4649445b8cee9f(query, onFetch, dependencies)
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
function $
|
|
54
|
+
function $6e34c00d870cf067$export$30043de3fae42dd1(value) {
|
|
55
55
|
if (value === null) return 0;
|
|
56
|
-
if (typeof value === "object") return Object.entries(value).reduce((total, [k, v])=>total + $
|
|
57
|
-
if (Array.isArray(value)) return Object.entries(value).reduce((total, v)=>total + $
|
|
56
|
+
if (typeof value === "object") return Object.entries(value).reduce((total, [k, v])=>total + $6e34c00d870cf067$export$30043de3fae42dd1(k) + $6e34c00d870cf067$export$30043de3fae42dd1(v), 0);
|
|
57
|
+
if (Array.isArray(value)) return Object.entries(value).reduce((total, v)=>total + $6e34c00d870cf067$export$30043de3fae42dd1(v), 0);
|
|
58
58
|
if (typeof value === "string") return value.length;
|
|
59
59
|
return 1;
|
|
60
60
|
}
|
|
61
|
-
function $
|
|
61
|
+
function $6e34c00d870cf067$export$fe58198efe02b173(url, w, h) {
|
|
62
62
|
return new Promise((resolve)=>{
|
|
63
63
|
const img = new Image(w, h);
|
|
64
64
|
img.onload = ()=>{
|
|
@@ -72,7 +72,7 @@ function $a089bc01333b231d$export$fe58198efe02b173(url, w, h) {
|
|
|
72
72
|
img.src = url;
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function $
|
|
75
|
+
function $6e34c00d870cf067$export$b035e44d7bb4278f(array, f) {
|
|
76
76
|
return array.sort((a, b)=>{
|
|
77
77
|
const va = f(a);
|
|
78
78
|
const vb = f(b);
|
|
@@ -80,7 +80,7 @@ function $a089bc01333b231d$export$b035e44d7bb4278f(array, f) {
|
|
|
80
80
|
return va < vb ? -1 : va > vb ? 1 : 0;
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
function $
|
|
83
|
+
function $6e34c00d870cf067$export$6a506b36fdea397d(s, limit) {
|
|
84
84
|
if (s.length > limit) return `${s.substring(0, limit)}…`;
|
|
85
85
|
return s;
|
|
86
86
|
}
|
|
@@ -91,21 +91,21 @@ function $a089bc01333b231d$export$6a506b36fdea397d(s, limit) {
|
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
const $
|
|
94
|
+
const $4a8c3f9c5fc1d022$export$3865e82159b2890b = (0, ($parcel$interopDefault($kbR6r$styledcomponents))).div`
|
|
95
95
|
font-family: ${({ theme: theme })=>theme.fonts.text.family};
|
|
96
96
|
position: absolute;
|
|
97
97
|
top: 0;
|
|
98
98
|
left: 0;
|
|
99
99
|
width: 100%;
|
|
100
100
|
height: 100%;
|
|
101
|
-
background: ${(0, $
|
|
101
|
+
background: ${(0, $kbR6r$sanitycolor.black).hex};
|
|
102
102
|
`;
|
|
103
|
-
const $
|
|
103
|
+
const $4a8c3f9c5fc1d022$export$c4a562231524e009 = (0, ($parcel$interopDefault($kbR6r$styledcomponents))).div`
|
|
104
104
|
position: relative;
|
|
105
105
|
width: 100%;
|
|
106
106
|
height: 100%;
|
|
107
107
|
`;
|
|
108
|
-
const $
|
|
108
|
+
const $4a8c3f9c5fc1d022$export$c33c2949cc668daf = (0, ($parcel$interopDefault($kbR6r$styledcomponents))).div`
|
|
109
109
|
font-family: ${({ theme: theme })=>theme.fonts.text.family};
|
|
110
110
|
display: none;
|
|
111
111
|
position: absolute;
|
|
@@ -121,7 +121,7 @@ const $8b263c4d4ee77dee$export$c33c2949cc668daf = (0, ($parcel$interopDefault($8
|
|
|
121
121
|
display: none;
|
|
122
122
|
}
|
|
123
123
|
`;
|
|
124
|
-
const $
|
|
124
|
+
const $4a8c3f9c5fc1d022$export$ed247974535929c7 = (0, ($parcel$interopDefault($kbR6r$styledcomponents))).div`
|
|
125
125
|
color: #ccc;
|
|
126
126
|
position: absolute;
|
|
127
127
|
top: ${({ theme: theme })=>theme.space[4]}px;
|
|
@@ -131,10 +131,10 @@ const $8b263c4d4ee77dee$export$ed247974535929c7 = (0, ($parcel$interopDefault($8
|
|
|
131
131
|
margin: 5px 0;
|
|
132
132
|
}
|
|
133
133
|
`;
|
|
134
|
-
const $
|
|
134
|
+
const $4a8c3f9c5fc1d022$export$3953a5b2d12dbab1 = (0, ($parcel$interopDefault($kbR6r$styledcomponents))).div`
|
|
135
135
|
display: flex;
|
|
136
136
|
`;
|
|
137
|
-
const $
|
|
137
|
+
const $4a8c3f9c5fc1d022$export$f6aea9731eb36ee8 = (0, ($parcel$interopDefault($kbR6r$styledcomponents))).div`
|
|
138
138
|
width: 1.25em;
|
|
139
139
|
height: 1.25em;
|
|
140
140
|
background: currentColor;
|
|
@@ -145,71 +145,71 @@ const $8b263c4d4ee77dee$export$f6aea9731eb36ee8 = (0, ($parcel$interopDefault($8
|
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
|
|
148
|
-
const $
|
|
148
|
+
const $c64ff3a0172967ed$var$DEFAULT_QUERY = `
|
|
149
149
|
*[
|
|
150
150
|
!(_id in path("_.*")) &&
|
|
151
151
|
!(_type match "system.*") &&
|
|
152
152
|
!(_type match "sanity.*")
|
|
153
153
|
]
|
|
154
154
|
`;
|
|
155
|
-
const $
|
|
156
|
-
const $
|
|
157
|
-
const $
|
|
158
|
-
const $
|
|
159
|
-
function $
|
|
160
|
-
return (0, $
|
|
155
|
+
const $c64ff3a0172967ed$var$fadeEasing = (0, ($parcel$interopDefault($kbR6r$beziereasing)))(0, 0.9, 1, 1);
|
|
156
|
+
const $c64ff3a0172967ed$var$softEasing = (0, ($parcel$interopDefault($kbR6r$beziereasing)))(0.25, 0.1, 0.0, 1.0);
|
|
157
|
+
const $c64ff3a0172967ed$var$idleTimeout = 10000;
|
|
158
|
+
const $c64ff3a0172967ed$var$imageSize = 40;
|
|
159
|
+
function $c64ff3a0172967ed$var$getTopDocTypes(counts) {
|
|
160
|
+
return (0, $6e34c00d870cf067$export$b035e44d7bb4278f)(Object.keys(counts), (docType)=>counts[docType] || 0).reverse().slice(0, 10);
|
|
161
161
|
}
|
|
162
|
-
function $
|
|
162
|
+
function $c64ff3a0172967ed$var$formatDocType(docType) {
|
|
163
163
|
return (docType.substring(0, 1).toUpperCase() + docType.substring(1)).replace(/\./g, " ").replace(/[A-Z]/g, " $&").trim();
|
|
164
164
|
}
|
|
165
|
-
function $
|
|
165
|
+
function $c64ff3a0172967ed$var$getDocTypeCounts(docs) {
|
|
166
166
|
const types = {};
|
|
167
167
|
for (const doc of docs)types[doc._type] = (types[doc._type] || 0) + 1;
|
|
168
168
|
return types;
|
|
169
169
|
}
|
|
170
|
-
function $
|
|
170
|
+
function $c64ff3a0172967ed$var$labelFor(doc) {
|
|
171
171
|
return `${doc.title || doc.name || doc._id}`.trim();
|
|
172
172
|
}
|
|
173
|
-
function $
|
|
174
|
-
return 5 + 100 * ((0, $
|
|
173
|
+
function $c64ff3a0172967ed$var$valueFor(doc, maxSize) {
|
|
174
|
+
return 5 + 100 * ((0, $6e34c00d870cf067$export$30043de3fae42dd1)(doc) / maxSize);
|
|
175
175
|
}
|
|
176
|
-
function $
|
|
176
|
+
function $c64ff3a0172967ed$var$findRefs(obj, dest = []) {
|
|
177
177
|
if (obj !== null) {
|
|
178
178
|
if (typeof obj === "object") for (const [k, v] of Object.entries(obj)){
|
|
179
|
-
if (k === "_ref" && typeof v === "string" && v.length > 0) dest.push($
|
|
180
|
-
$
|
|
179
|
+
if (k === "_ref" && typeof v === "string" && v.length > 0) dest.push($c64ff3a0172967ed$var$stripDraftId(v));
|
|
180
|
+
$c64ff3a0172967ed$var$findRefs(v, dest);
|
|
181
181
|
}
|
|
182
|
-
else if (Array.isArray(obj)) for (const v1 of obj)$
|
|
182
|
+
else if (Array.isArray(obj)) for (const v1 of obj)$c64ff3a0172967ed$var$findRefs(v1, dest);
|
|
183
183
|
}
|
|
184
184
|
return dest;
|
|
185
185
|
}
|
|
186
|
-
function $
|
|
186
|
+
function $c64ff3a0172967ed$var$stripDraftId(id) {
|
|
187
187
|
return id.replace(/^drafts\./, "");
|
|
188
188
|
}
|
|
189
|
-
function $
|
|
189
|
+
function $c64ff3a0172967ed$var$deduplicateDrafts(docs) {
|
|
190
190
|
const deduped = {};
|
|
191
191
|
for (const doc of docs)if (!/^drafts\./.test(doc._id)) deduped[doc._id] = doc;
|
|
192
192
|
for (const doc1 of docs)if (/^drafts\./.test(doc1._id)) {
|
|
193
|
-
const id = $
|
|
193
|
+
const id = $c64ff3a0172967ed$var$stripDraftId(doc1._id);
|
|
194
194
|
deduped[id] = Object.assign(doc1, {
|
|
195
195
|
_id: id
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
return Object.values(deduped);
|
|
199
199
|
}
|
|
200
|
-
class $
|
|
200
|
+
class $c64ff3a0172967ed$var$Users {
|
|
201
201
|
_users = [];
|
|
202
202
|
async getById(id, client) {
|
|
203
203
|
let user = this._users.find((u)=>u._id === id);
|
|
204
204
|
if (!user) {
|
|
205
205
|
user = await client.users.getById(id);
|
|
206
206
|
this._users.push(user);
|
|
207
|
-
user.image = await (0, $
|
|
207
|
+
user.image = await (0, $6e34c00d870cf067$export$fe58198efe02b173)(user.imageUrl || "https://raw.githubusercontent.com/sanity-io/sanity-plugin-graph-view/main/assets/head-silhouette.jpg", $c64ff3a0172967ed$var$imageSize, $c64ff3a0172967ed$var$imageSize);
|
|
208
208
|
}
|
|
209
209
|
return user;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
class $
|
|
212
|
+
class $c64ff3a0172967ed$var$Session {
|
|
213
213
|
id = null;
|
|
214
214
|
user = null;
|
|
215
215
|
doc = null;
|
|
@@ -217,7 +217,7 @@ class $833d2067d906ddd2$var$Session {
|
|
|
217
217
|
startTime = 0;
|
|
218
218
|
angle = 0;
|
|
219
219
|
}
|
|
220
|
-
class $
|
|
220
|
+
class $c64ff3a0172967ed$var$GraphData {
|
|
221
221
|
sessions = [];
|
|
222
222
|
constructor(docs = []){
|
|
223
223
|
const docsById = {};
|
|
@@ -228,7 +228,7 @@ class $833d2067d906ddd2$var$GraphData {
|
|
|
228
228
|
type: "document",
|
|
229
229
|
doc: d
|
|
230
230
|
})),
|
|
231
|
-
links: docs.flatMap((doc)=>$
|
|
231
|
+
links: docs.flatMap((doc)=>$c64ff3a0172967ed$var$findRefs(doc).map((ref)=>({
|
|
232
232
|
source: doc._id,
|
|
233
233
|
target: ref
|
|
234
234
|
}))).filter((link)=>docsById[link.source] && docsById[link.target])
|
|
@@ -237,8 +237,8 @@ class $833d2067d906ddd2$var$GraphData {
|
|
|
237
237
|
setSession(user, docNode) {
|
|
238
238
|
let session = this.sessions.find((s)=>s.user.id === user.id && s.doc?._id === docNode.doc._id);
|
|
239
239
|
if (!session) {
|
|
240
|
-
session = new $
|
|
241
|
-
session.id = (0, $
|
|
240
|
+
session = new $c64ff3a0172967ed$var$Session();
|
|
241
|
+
session.id = (0, $kbR6r$uuid.v4)();
|
|
242
242
|
session.user = user;
|
|
243
243
|
session.startTime = Date.now();
|
|
244
244
|
session.doc = docNode.doc;
|
|
@@ -250,7 +250,7 @@ class $833d2067d906ddd2$var$GraphData {
|
|
|
250
250
|
reapSessions() {
|
|
251
251
|
for(let i = 0; i < this.sessions.length; i++){
|
|
252
252
|
const session = this.sessions[i];
|
|
253
|
-
if (Date.now() - session.lastActive > $
|
|
253
|
+
if (Date.now() - session.lastActive > $c64ff3a0172967ed$var$idleTimeout) {
|
|
254
254
|
this.sessions = [
|
|
255
255
|
...this.sessions.slice(0, i),
|
|
256
256
|
...this.sessions.slice(i + 1)
|
|
@@ -260,7 +260,7 @@ class $833d2067d906ddd2$var$GraphData {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
clone() {
|
|
263
|
-
const copy = new $
|
|
263
|
+
const copy = new $c64ff3a0172967ed$var$GraphData();
|
|
264
264
|
Object.assign(copy, this);
|
|
265
265
|
copy.data = {
|
|
266
266
|
nodes: [
|
|
@@ -273,28 +273,28 @@ class $833d2067d906ddd2$var$GraphData {
|
|
|
273
273
|
return copy;
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
const $
|
|
277
|
-
function $
|
|
278
|
-
const query = props.query || $
|
|
279
|
-
const userColorManager = (0, $
|
|
280
|
-
const [maxSize, setMaxSize] = (0, $
|
|
281
|
-
const [hoverNode, setHoverNode] = (0, $
|
|
282
|
-
const [documents, setDocuments] = (0, $
|
|
283
|
-
const [docTypes, setDocTypes] = (0, $
|
|
284
|
-
const [graph, setGraph] = (0, $
|
|
285
|
-
const router = (0, $
|
|
286
|
-
const client = (0, $
|
|
287
|
-
const fetchCallback = (0, $
|
|
288
|
-
const docs = $
|
|
289
|
-
setMaxSize(Math.max(...docs.map((0, $
|
|
276
|
+
const $c64ff3a0172967ed$var$users = new $c64ff3a0172967ed$var$Users();
|
|
277
|
+
function $c64ff3a0172967ed$export$6a7fe3ef90e8d566(props) {
|
|
278
|
+
const query = props.query || $c64ff3a0172967ed$var$DEFAULT_QUERY;
|
|
279
|
+
const userColorManager = (0, $kbR6r$sanity_unstable.useUserColorManager)();
|
|
280
|
+
const [maxSize, setMaxSize] = (0, $kbR6r$react.useState)(0);
|
|
281
|
+
const [hoverNode, setHoverNode] = (0, $kbR6r$react.useState)(null);
|
|
282
|
+
const [documents, setDocuments] = (0, $kbR6r$react.useState)([]);
|
|
283
|
+
const [docTypes, setDocTypes] = (0, $kbR6r$react.useState)({});
|
|
284
|
+
const [graph, setGraph] = (0, $kbR6r$react.useState)(()=>new $c64ff3a0172967ed$var$GraphData());
|
|
285
|
+
const router = (0, $kbR6r$sanity_unstable.useRouter)();
|
|
286
|
+
const client = (0, $kbR6r$sanity.useClient)();
|
|
287
|
+
const fetchCallback = (0, $kbR6r$react.useCallback)((_docs)=>{
|
|
288
|
+
const docs = $c64ff3a0172967ed$var$deduplicateDrafts(_docs);
|
|
289
|
+
setMaxSize(Math.max(...docs.map((0, $6e34c00d870cf067$export$30043de3fae42dd1))));
|
|
290
290
|
setDocuments(docs);
|
|
291
|
-
setDocTypes($
|
|
292
|
-
setGraph(new $
|
|
291
|
+
setDocTypes($c64ff3a0172967ed$var$getDocTypeCounts(docs));
|
|
292
|
+
setGraph(new $c64ff3a0172967ed$var$GraphData(docs));
|
|
293
293
|
}, []);
|
|
294
|
-
const listenCallback = (0, $
|
|
294
|
+
const listenCallback = (0, $kbR6r$react.useCallback)(async (update)=>{
|
|
295
295
|
const doc = update.result;
|
|
296
296
|
if (doc) {
|
|
297
|
-
doc._id = $
|
|
297
|
+
doc._id = $c64ff3a0172967ed$var$stripDraftId(doc._id);
|
|
298
298
|
const docsById = {};
|
|
299
299
|
for (const d1 of documents)docsById[d1._id] = d1;
|
|
300
300
|
let oldDoc;
|
|
@@ -307,12 +307,12 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
307
307
|
docs[idx] = doc;
|
|
308
308
|
} else docs.push(doc);
|
|
309
309
|
setDocuments(docs);
|
|
310
|
-
setDocTypes($
|
|
311
|
-
setMaxSize(Math.max(...docs.map((0, $
|
|
310
|
+
setDocTypes($c64ff3a0172967ed$var$getDocTypeCounts(docs));
|
|
311
|
+
setMaxSize(Math.max(...docs.map((0, $6e34c00d870cf067$export$30043de3fae42dd1))));
|
|
312
312
|
const newGraph = graph.clone();
|
|
313
|
-
const oldRefs = $
|
|
314
|
-
const newRefs = $
|
|
315
|
-
let graphChanged = !(0, ($parcel$interopDefault($
|
|
313
|
+
const oldRefs = $c64ff3a0172967ed$var$findRefs(oldDoc || {}).filter((id)=>id === doc._id || docsById[id] !== null);
|
|
314
|
+
const newRefs = $c64ff3a0172967ed$var$findRefs(doc).filter((id)=>id === doc._id || docsById[id] !== null);
|
|
315
|
+
let graphChanged = !(0, ($parcel$interopDefault($kbR6r$deepequal)))(oldRefs, newRefs);
|
|
316
316
|
if (graphChanged) newGraph.data.links = newGraph.data.links.filter((l)=>l.source.id !== doc._id).concat(newRefs.map((ref)=>({
|
|
317
317
|
source: doc._id,
|
|
318
318
|
target: ref
|
|
@@ -332,14 +332,14 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
332
332
|
graphChanged = true;
|
|
333
333
|
}
|
|
334
334
|
if (graphChanged) setGraph(newGraph);
|
|
335
|
-
const user = await $
|
|
335
|
+
const user = await $c64ff3a0172967ed$var$users.getById(update.identity, client);
|
|
336
336
|
graph.setSession(user, docNode);
|
|
337
337
|
} else if (update.transition === "disappear") {
|
|
338
|
-
const docId = $
|
|
338
|
+
const docId = $c64ff3a0172967ed$var$stripDraftId(update.documentId);
|
|
339
339
|
const docs = documents.filter((d)=>d._id !== docId);
|
|
340
340
|
setDocuments(docs);
|
|
341
|
-
setDocTypes($
|
|
342
|
-
setMaxSize(Math.max(...docs.map((0, $
|
|
341
|
+
setDocTypes($c64ff3a0172967ed$var$getDocTypeCounts(docs));
|
|
342
|
+
setMaxSize(Math.max(...docs.map((0, $6e34c00d870cf067$export$30043de3fae42dd1))));
|
|
343
343
|
const newGraph = graph.clone();
|
|
344
344
|
newGraph.data.links = newGraph.data.links.filter((l)=>l.source.id !== docId && l.target.id !== docId);
|
|
345
345
|
newGraph.data.nodes = newGraph.data.nodes.filter((n)=>n.id !== docId);
|
|
@@ -350,45 +350,45 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
350
350
|
graph,
|
|
351
351
|
client
|
|
352
352
|
]);
|
|
353
|
-
(0, $
|
|
354
|
-
(0, $
|
|
353
|
+
(0, $8984dbba39ce9ccc$export$7b4649445b8cee9f)(query, fetchCallback, []);
|
|
354
|
+
(0, $8984dbba39ce9ccc$export$c006713bb64ff575)(query, {}, {}, listenCallback, [
|
|
355
355
|
documents,
|
|
356
356
|
graph
|
|
357
357
|
]);
|
|
358
|
-
(0, $
|
|
358
|
+
(0, $kbR6r$react.useEffect)(()=>{
|
|
359
359
|
const interval = setInterval(()=>graph.reapSessions(), 1000);
|
|
360
360
|
return ()=>clearInterval(interval);
|
|
361
361
|
}, [
|
|
362
362
|
graph
|
|
363
363
|
]);
|
|
364
|
-
const theme = (0, $
|
|
365
|
-
return /*#__PURE__*/ (0, $
|
|
364
|
+
const theme = (0, $kbR6r$sanityui.useTheme)().sanity;
|
|
365
|
+
return /*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)((0, $4a8c3f9c5fc1d022$export$c4a562231524e009), {
|
|
366
366
|
theme: theme,
|
|
367
|
-
children: /*#__PURE__*/ (0, $
|
|
367
|
+
children: /*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsxs)((0, $4a8c3f9c5fc1d022$export$3865e82159b2890b), {
|
|
368
368
|
theme: theme,
|
|
369
369
|
children: [
|
|
370
|
-
/*#__PURE__*/ (0, $
|
|
370
|
+
/*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)((0, $4a8c3f9c5fc1d022$export$ed247974535929c7), {
|
|
371
371
|
theme: theme,
|
|
372
|
-
children: $
|
|
372
|
+
children: $c64ff3a0172967ed$var$getTopDocTypes(docTypes).map((docType)=>/*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsxs)((0, $4a8c3f9c5fc1d022$export$3953a5b2d12dbab1), {
|
|
373
373
|
className: "legend__row",
|
|
374
374
|
style: {
|
|
375
|
-
color: $
|
|
375
|
+
color: $c64ff3a0172967ed$var$getDocTypeColor(docType).fill
|
|
376
376
|
},
|
|
377
377
|
children: [
|
|
378
|
-
/*#__PURE__*/ (0, $
|
|
378
|
+
/*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)((0, $4a8c3f9c5fc1d022$export$f6aea9731eb36ee8), {
|
|
379
379
|
theme: theme
|
|
380
380
|
}),
|
|
381
|
-
/*#__PURE__*/ (0, $
|
|
382
|
-
children: $
|
|
381
|
+
/*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)("div", {
|
|
382
|
+
children: $c64ff3a0172967ed$var$formatDocType(docType)
|
|
383
383
|
})
|
|
384
384
|
]
|
|
385
385
|
}, docType))
|
|
386
386
|
}),
|
|
387
|
-
hoverNode && /*#__PURE__*/ (0, $
|
|
387
|
+
hoverNode && /*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)((0, $4a8c3f9c5fc1d022$export$c33c2949cc668daf), {
|
|
388
388
|
theme: theme,
|
|
389
|
-
children: $
|
|
389
|
+
children: $c64ff3a0172967ed$var$labelFor(hoverNode.doc)
|
|
390
390
|
}),
|
|
391
|
-
/*#__PURE__*/ (0, $
|
|
391
|
+
/*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)((0, $kbR6r$reactforcegraph.ForceGraph2D), {
|
|
392
392
|
graphData: graph.data,
|
|
393
393
|
nodeAutoColorBy: "group",
|
|
394
394
|
enableNodeDrag: false,
|
|
@@ -399,17 +399,17 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
399
399
|
documentType: node.doc._type
|
|
400
400
|
});
|
|
401
401
|
},
|
|
402
|
-
linkColor: ()=>(0, $
|
|
402
|
+
linkColor: ()=>(0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.gray)[500].hex, 0.25),
|
|
403
403
|
nodeLabel: ()=>"",
|
|
404
404
|
nodeRelSize: 1,
|
|
405
|
-
nodeVal: (node)=>$
|
|
405
|
+
nodeVal: (node)=>$c64ff3a0172967ed$var$valueFor(node.doc, maxSize),
|
|
406
406
|
onRenderFramePost: (ctx, globalScale)=>{
|
|
407
407
|
for (const session of graph.sessions){
|
|
408
408
|
const node = graph.data.nodes.find((n)=>n.doc && n.doc._id === session?.doc?._id);
|
|
409
409
|
if (node) {
|
|
410
|
-
const idleFactorRange = $
|
|
410
|
+
const idleFactorRange = $c64ff3a0172967ed$var$idleTimeout;
|
|
411
411
|
const angle = session.angle;
|
|
412
|
-
const radius = Math.sqrt($
|
|
412
|
+
const radius = Math.sqrt($c64ff3a0172967ed$var$valueFor(node.doc, maxSize));
|
|
413
413
|
const image = session.user.image;
|
|
414
414
|
const userColor = userColorManager.get(session.user.displayName).tints[400].hex;
|
|
415
415
|
const distance = radius * globalScale + 40;
|
|
@@ -419,16 +419,16 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
419
419
|
const y = node.y + Math.cos(angle) * distance / globalScale;
|
|
420
420
|
ctx.save();
|
|
421
421
|
try {
|
|
422
|
-
ctx.globalAlpha = $
|
|
422
|
+
ctx.globalAlpha = $c64ff3a0172967ed$var$fadeEasing(1 - Math.min(idleFactorRange, Date.now() - session.lastActive) / idleFactorRange);
|
|
423
423
|
ctx.font = `bold ${Math.round(12 / globalScale)}px sans-serif`;
|
|
424
424
|
ctx.beginPath();
|
|
425
|
-
ctx.strokeStyle = (0, $
|
|
425
|
+
ctx.strokeStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.white).hex, 1.0);
|
|
426
426
|
ctx.lineWidth = 2 / globalScale;
|
|
427
427
|
ctx.moveTo(node.x + Math.sin(angle) * (distance - imgW / 2) / globalScale, node.y + Math.cos(angle) * (distance - imgH / 2) / globalScale);
|
|
428
428
|
ctx.lineTo(node.x + Math.sin(angle) * radius, node.y + Math.cos(angle) * radius);
|
|
429
429
|
ctx.stroke();
|
|
430
430
|
ctx.beginPath();
|
|
431
|
-
ctx.strokeStyle = (0, $
|
|
431
|
+
ctx.strokeStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.white).hex, 1.0);
|
|
432
432
|
ctx.lineWidth = 2 / globalScale;
|
|
433
433
|
ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false);
|
|
434
434
|
ctx.stroke();
|
|
@@ -437,20 +437,20 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
437
437
|
// eslint-disable-next-line max-depth
|
|
438
438
|
try {
|
|
439
439
|
const dur = 700;
|
|
440
|
-
const f = $
|
|
440
|
+
const f = $c64ff3a0172967ed$var$softEasing(Math.max(0, (dur - (Date.now() - session.startTime)) / dur));
|
|
441
441
|
// eslint-disable-next-line max-depth
|
|
442
442
|
if (f > 0) {
|
|
443
443
|
ctx.beginPath();
|
|
444
|
-
ctx.fillStyle = (0, $
|
|
444
|
+
ctx.fillStyle = (0, $kbR6r$polished.rgba)(userColor, f);
|
|
445
445
|
ctx.arc(x, y, (imgW / 2 + 10) / globalScale, 0, 2 * Math.PI, false);
|
|
446
446
|
ctx.fill();
|
|
447
447
|
}
|
|
448
448
|
ctx.beginPath();
|
|
449
|
-
ctx.fillStyle = (0, $
|
|
449
|
+
ctx.fillStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.white).hex, 1.0);
|
|
450
450
|
ctx.arc(x, y, imgW / globalScale / 2, 0, 2 * Math.PI, false);
|
|
451
451
|
ctx.clip();
|
|
452
452
|
ctx.drawImage(image, x - imgW / globalScale / 2, y - imgH / globalScale / 2, imgW / globalScale, imgH / globalScale);
|
|
453
|
-
ctx.strokeStyle = (0, $
|
|
453
|
+
ctx.strokeStyle = (0, $kbR6r$sanitycolor.black).hex;
|
|
454
454
|
ctx.lineWidth = 6 / globalScale;
|
|
455
455
|
ctx.stroke();
|
|
456
456
|
ctx.strokeStyle = userColor;
|
|
@@ -461,13 +461,13 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
ctx.beginPath();
|
|
464
|
-
ctx.strokeStyle = (0, $
|
|
464
|
+
ctx.strokeStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.black).hex, 1);
|
|
465
465
|
ctx.lineWidth = 0.5 / globalScale;
|
|
466
466
|
ctx.arc(x, y, imgW / globalScale / 2, 0, 2 * Math.PI, false);
|
|
467
467
|
ctx.stroke();
|
|
468
468
|
const above = angle >= Math.PI / 2 && angle < Math.PI * 1.5;
|
|
469
469
|
const textY = above ? y - (imgH / 2 + 5) / globalScale : y + (imgH / 2 + 5) / globalScale;
|
|
470
|
-
ctx.fillStyle = (0, $
|
|
470
|
+
ctx.fillStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.white).hex, 1.0);
|
|
471
471
|
ctx.textAlign = "center";
|
|
472
472
|
ctx.textBaseline = above ? "bottom" : "top";
|
|
473
473
|
ctx.fillText(session.user.displayName, x, textY);
|
|
@@ -482,11 +482,11 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
482
482
|
switch(node.type){
|
|
483
483
|
case "document":
|
|
484
484
|
{
|
|
485
|
-
const nodeColor = $
|
|
486
|
-
const radius = Math.sqrt($
|
|
485
|
+
const nodeColor = $c64ff3a0172967ed$var$getDocTypeColor(node.doc._type);
|
|
486
|
+
const radius = Math.sqrt($c64ff3a0172967ed$var$valueFor(node.doc, maxSize));
|
|
487
487
|
const fontSize = Math.min(100, 10.0 / globalScale);
|
|
488
488
|
ctx.beginPath();
|
|
489
|
-
ctx.fillStyle = hoverNode !== null && node.doc._id === hoverNode.doc._id ? (0, $
|
|
489
|
+
ctx.fillStyle = hoverNode !== null && node.doc._id === hoverNode.doc._id ? (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.gray)[500].hex, 0.8) : nodeColor.fill;
|
|
490
490
|
ctx.strokeStyle = nodeColor.border;
|
|
491
491
|
ctx.lineWidth = 0.5;
|
|
492
492
|
ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false);
|
|
@@ -496,13 +496,13 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
496
496
|
ctx.font = `${fontSize}px sans-serif`;
|
|
497
497
|
const w = radius * 2 + 30 / globalScale;
|
|
498
498
|
for(let len = 50; len >= 5; len /= 1.2){
|
|
499
|
-
const label = (0, $
|
|
499
|
+
const label = (0, $6e34c00d870cf067$export$6a506b36fdea397d)($c64ff3a0172967ed$var$labelFor(node.doc), Math.round(len));
|
|
500
500
|
const textMetrics = ctx.measureText(label);
|
|
501
501
|
if (textMetrics.width < w) {
|
|
502
502
|
// ctx.fillStyle = rgba(color.white.hex, 1.0)
|
|
503
503
|
ctx.textAlign = "center";
|
|
504
504
|
ctx.textBaseline = "top";
|
|
505
|
-
ctx.strokeStyle = (0, $
|
|
505
|
+
ctx.strokeStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.black).hex, 0.5);
|
|
506
506
|
ctx.lineWidth = 2 / globalScale;
|
|
507
507
|
ctx.strokeText(label, node.x, node.y + radius + 5 / globalScale);
|
|
508
508
|
ctx.fillText(label, node.x, node.y + radius + 5 / globalScale);
|
|
@@ -515,7 +515,7 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
515
515
|
},
|
|
516
516
|
linkCanvasObject: (link, ctx, globalScale)=>{
|
|
517
517
|
ctx.beginPath();
|
|
518
|
-
ctx.strokeStyle = (0, $
|
|
518
|
+
ctx.strokeStyle = (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.gray)[500].hex, 0.125);
|
|
519
519
|
ctx.lineWidth = 2 / globalScale;
|
|
520
520
|
ctx.moveTo(link.source.x, link.source.y);
|
|
521
521
|
ctx.lineTo(link.target.x, link.target.y);
|
|
@@ -526,28 +526,28 @@ function $833d2067d906ddd2$export$6a7fe3ef90e8d566(props) {
|
|
|
526
526
|
})
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
|
-
const $
|
|
530
|
-
let $
|
|
531
|
-
function $
|
|
532
|
-
if ($
|
|
533
|
-
const hue = (0, $
|
|
534
|
-
$
|
|
535
|
-
$
|
|
536
|
-
fill: (0, $
|
|
537
|
-
border: (0, $
|
|
529
|
+
const $c64ff3a0172967ed$var$colorCache = {};
|
|
530
|
+
let $c64ff3a0172967ed$var$typeColorNum = 0;
|
|
531
|
+
function $c64ff3a0172967ed$var$getDocTypeColor(docType) {
|
|
532
|
+
if ($c64ff3a0172967ed$var$colorCache[docType]) return $c64ff3a0172967ed$var$colorCache[docType];
|
|
533
|
+
const hue = (0, $kbR6r$sanitycolor.COLOR_HUES)[$c64ff3a0172967ed$var$typeColorNum % (0, $kbR6r$sanitycolor.COLOR_HUES).length];
|
|
534
|
+
$c64ff3a0172967ed$var$typeColorNum += 1;
|
|
535
|
+
$c64ff3a0172967ed$var$colorCache[docType] = {
|
|
536
|
+
fill: (0, $kbR6r$sanitycolor.hues)[hue][400].hex,
|
|
537
|
+
border: (0, $kbR6r$polished.rgba)((0, $kbR6r$sanitycolor.black).hex, 0.5)
|
|
538
538
|
};
|
|
539
|
-
return $
|
|
539
|
+
return $c64ff3a0172967ed$var$colorCache[docType];
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
|
|
543
543
|
|
|
544
544
|
|
|
545
|
-
const $
|
|
545
|
+
const $b644a7c47dec28f9$export$401cc1e36cc18bf0 = ()=>/*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)("svg", {
|
|
546
546
|
xmlns: "http://www.w3.org/2000/svg",
|
|
547
547
|
width: "1em",
|
|
548
548
|
height: "1em",
|
|
549
549
|
viewBox: "0 0 46.063 46.063",
|
|
550
|
-
children: /*#__PURE__*/ (0, $
|
|
550
|
+
children: /*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)("path", {
|
|
551
551
|
fill: "currentColor",
|
|
552
552
|
d: "M18.022 38.676v2.813h-1.21q-4.864 0-6.525-1.447-1.64-1.445-1.64-5.762v-4.666q0-2.95-1.055-4.083-1.055-1.13-3.828-1.13h-1.19v-2.794h1.19q2.793 0 3.828-1.114 1.055-1.132 1.055-4.043V11.76q0-4.316 1.64-5.742 1.66-1.446 6.524-1.446h1.212v2.793h-1.328q-2.754 0-3.594.86-.84.86-.84 3.613v4.844q0 3.066-.898 4.453-.88 1.387-3.028 1.875 2.168.527 3.047 1.914.88 1.387.88 4.434v4.843q0 2.754.84 3.614.84.86 3.594.86h1.328zM28.04 38.676h1.368q2.735 0 3.555-.84.84-.84.84-3.633V29.36q0-3.047.88-4.434.878-1.387 3.046-1.914-2.17-.488-3.048-1.875-.88-1.387-.88-4.453V11.84q0-2.773-.84-3.613-.82-.86-3.554-.86H28.04V4.574h1.232q4.863 0 6.484 1.446 1.64 1.426 1.64 5.742v4.687q0 2.91 1.055 4.042 1.056 1.114 3.83 1.114h1.21V24.4h-1.21q-2.774 0-3.83 1.13-1.053 1.134-1.053 4.084v4.667q0 4.318-1.64 5.763-1.622 1.446-6.485 1.446h-1.23v-2.814z"
|
|
553
553
|
})
|
|
@@ -557,7 +557,7 @@ const $e7681ca455a0a554$export$401cc1e36cc18bf0 = ()=>/*#__PURE__*/ (0, $83Duu$r
|
|
|
557
557
|
|
|
558
558
|
|
|
559
559
|
|
|
560
|
-
const $
|
|
560
|
+
const $329a1cedcedb1349$export$e3438defddc96622 = (0, $kbR6r$sanity.createPlugin)((config = {})=>{
|
|
561
561
|
return {
|
|
562
562
|
name: "@sanity/content-graph-view",
|
|
563
563
|
tools: (prev)=>{
|
|
@@ -566,13 +566,13 @@ const $9233cea927cb9637$export$e3438defddc96622 = (0, $83Duu$sanity.createPlugin
|
|
|
566
566
|
{
|
|
567
567
|
name: "graph-your-content",
|
|
568
568
|
title: "Graph",
|
|
569
|
-
icon: (0, $
|
|
569
|
+
icon: (0, $b644a7c47dec28f9$export$401cc1e36cc18bf0),
|
|
570
570
|
component: function component() {
|
|
571
|
-
return /*#__PURE__*/ (0, $
|
|
571
|
+
return /*#__PURE__*/ (0, $kbR6r$reactjsxruntime.jsx)((0, $c64ff3a0172967ed$export$6a7fe3ef90e8d566), {
|
|
572
572
|
...config
|
|
573
573
|
});
|
|
574
574
|
},
|
|
575
|
-
router: (0, $
|
|
575
|
+
router: (0, $kbR6r$sanity_unstable.route).create("/:selectedDocumentId")
|
|
576
576
|
},
|
|
577
577
|
];
|
|
578
578
|
}
|