Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@snorreeb/orderable-document-list
Advanced tools
Readme
NOTE
This is the Sanity Studio v3 version of @sanity/orderable-document-list.
For the v2 version, please refer to the v2-branch.
Drag-and-drop Document Ordering without leaving the Editing surface.
This plugin aims to be OS-like in that you can select and move multiple documents by holding shift
and clicking a second item, and toggling on/off selections by holding command/control
.
A Sanity Studio with Desk Structure configured:
import {createConfig} from "sanity";
import {deskTool, StructureBuilder} from "sanity/desk";
export default createConfig({
//...
plugins: [
deskTool({
structure: (S, context) => { /* Strucure code */},
})
]
})
Run the following command in your studio directory
npm install --save @sanity/orderable-document-list@studio-v3
or
yarn add @sanity/orderable-document-list@studio-v3
The config parameter requires type
and also accepts title
and icon
.
import {createConfig} from "sanity";
import {deskTool, StructureBuilder} from "sanity/desk";
import {orderableDocumentListDeskItem} from '@sanity/orderable-document-list'
export default createConfig({
//...
plugins: [
deskTool({
structure: (S, context) => {
return S.list()
.title('Content')
.items([
// Minimum required configuration
orderableDocumentListDeskItem({type: 'category'}),
// Optional configuration
orderableDocumentListDeskItem({
type: 'project',
title: 'Projects',
icon: Paint
}),
// ... all other desk items
])
},
})
]
})
orderRank
field to your schema(s).You must pass in the type
of the schema, to create an initialValue
value.
Additionally, pass in overrides for the field, such as making it visible by passing hidden: false
.
You cannot override the name
, type
or initialValue
attributes.
Take note that orderRankField requires a configured sanity client, that must be passed from the schema configuration context as shown in the following example:
// sanity.config.js
import {createConfig} from "sanity";
import {deskTool, StructureBuilder} from "sanity/desk";
import {orderableDocumentListDeskItem} from '@sanity/orderable-document-list'
export default createConfig({
//...
plugins: [
deskTool({structure: (S, context) => {/* snip */}})
],
schema: {
// get client from context ant pass to orderRankField
types: (previousTypes, {client}) => {
return [
...previousTypes,
{
name: "category",
title: "Category",
type: "document",
// Optional: The plugin also exports a set of 'orderings' for use in other Document Lists
orderings: [orderRankOrdering],
fields: [
// Minimum required configuration
orderRankField({ type: "category", client }),
// OR you can override _some_ of the field settings
// orderRankField({ type: 'category', hidden: false }),
// ...all other fields
],
},
]
}
}
}
On first load, your Document list will not have any Order. You can select "Reset Order" from the menu in the top right of the list. You can also re-run this at any time.
The orderRankField
will query the last Document to set an initialValue
to come after it.
New Documents always start at the end of the Ordered list.
Now when writing a GROQ Query for Documents, use the orderRank
field value to return ordered results:
*[_type == "category"]|order(orderRank)
To get this first version out the door there are few configuration settings and a lot of opinions. Such as:
name
of the orderRank
field is constanttype
filter
configuration on the Document ListFeedback and PRs welcome :)
Uses kvandakes's TypeScript implementation of Jira's Lexorank to create a "lexographical" Document order.
Put simply it updates the position of an individual – or many – Documents in an ordered list without updating any others. It's fast.
MIT © Simeon Griggs See LICENSE
Make sure to run npm run build
once, then run
npm run link-watch
In another shell, cd
to your test studio and run:
npx yalc add @sanity/orderable-document-list && yarn install
Now, changes in this repo will be automatically built and pushed to the studio, triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
This plugin uses @sanity/plugin-sdk with default configuration for build & watch scripts.
FAQs
Drag-and-drop Document Ordering without leaving the Editing surface
We found that @snorreeb/orderable-document-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.