diff --git a/README.md b/README.md index cc4d464..463bd32 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,15 @@ You can also re-run this at any time. The `orderRankField` will query the last/first Document to set an `initialValue` to come after/before it. The placement of new documents can be configured by `newItemPosition` on the `orderRankField` in the document. +### 4. Position of new items + +New Documents appear at the end of the list by default. You can configure where new Documents are inserted by configuring `orderRankField` with the optional `newItemPosition` option: + +```typescript +// default value of newItemPosition is "after" +orderRankField({ type: "category", newItemPosition: "before" }), +``` + ## Querying Ordered Documents Now when writing a GROQ Query for Documents, use the `orderRank` field value to return ordered results: diff --git a/package-lock.json b/package-lock.json index 3d2e0d0..0ed88f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sanity/orderable-document-list", - "version": "1.2.1", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@sanity/orderable-document-list", - "version": "1.2.1", + "version": "1.2.0", "license": "MIT", "dependencies": { "@hello-pangea/dnd": "^16.2.0", diff --git a/package.json b/package.json index c041b3a..ef53121 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sanity/orderable-document-list", - "version": "1.2.1", + "version": "1.2.0", "description": "Drag-and-drop Document Ordering without leaving the Editing surface", "keywords": [ "sanity", diff --git a/src/Document.tsx b/src/Document.tsx index 7029b75..bccd806 100644 --- a/src/Document.tsx +++ b/src/Document.tsx @@ -1,5 +1,5 @@ import {useContext, useMemo, type ReactNode} from 'react' -import {ChevronDownIcon, ChevronUpIcon, DragHandleIcon} from '@sanity/icons' +import {ChevronDownIcon, ChevronUpIcon, DoubleChevronUpIcon, DragHandleIcon} from '@sanity/icons' import {AvatarCounter, Card, Box, Button, Flex, Text} from '@sanity/ui' import {useSchema, SchemaType, PreviewCard, Preview} from 'sanity' import {usePaneRouter} from 'sanity/structure' @@ -88,6 +88,15 @@ export default function Document({ onClick={() => increment(index, index + 1, doc._id, entities)} icon={ChevronDownIcon} /> + +