diff --git a/.changeset/rare-needles-deny.md b/.changeset/rare-needles-deny.md new file mode 100644 index 000000000..02348662f --- /dev/null +++ b/.changeset/rare-needles-deny.md @@ -0,0 +1,5 @@ +--- +"@keystatic/core": patch +--- + +Fix #340: Enhancement: more configurable collection path diff --git a/packages/keystatic/src/form/fields/text/path-slug-context.tsx b/packages/keystatic/src/form/fields/text/path-slug-context.tsx index ec5907536..da93a5e12 100644 --- a/packages/keystatic/src/form/fields/text/path-slug-context.tsx +++ b/packages/keystatic/src/form/fields/text/path-slug-context.tsx @@ -12,7 +12,7 @@ import { areArraysEqual } from '../document/DocumentEditor/document-features-nor import { Avatar } from '@keystar/ui/avatar'; import { css } from '@keystar/ui/style'; -function CollabAddToPathProvider(props: { +function CollabAddToPathProvider(props: { path: ReadonlyPropPath; children: ReactNode; }) { const yjsInfo = useYjsIfAvailable(); const cloudInfo = useCloudInfo(); const router = useRouter(); const awarenessStates = useAwarenessStates(); const avatarsAtPath = useMemo(() => { if (!yjsInfo || yjsInfo === 'loading' || !cloudInfo) { return []; } const avatars: { avatarUrl?: string; name: string }[] = []; for (const [clientId, val] of awarenessStates) { if (clientId === yjsInfo.awareness.clientID || !val.user || router.href !== `/keystatic/branch/${val.branch}/${val.location}` || !Array.isArray(val.path) || !areArraysEqual(val.path, props.path)) { continue; } avatars.push(val.user); } return avatars; }, [yjsInfo, cloudInfo, awarenessStates, router.href, props.path]); return (
{ if (e.target.closest('[data-ks-path]') === e.currentTarget) { if (yjsInfo && yjsInfo !== 'loading') { yjsInfo.awareness.setLocalStateField('path', props.path); } } }} > {!!avatarsAtPath.length && (
{avatarsAtPath.map((avatar, i) => ())}
)} {props.children}
); }(props: { path: ReadonlyPropPath; children: ReactNode; }) {