Studio

Comments for Sanity Studio

Presence Cursors in Portable Text Editor, Comments and Tasks Out of Beta, and TypeGen Improvements

v3.40.0

Install or upgrade Sanity Studio

To initiate a new Sanity Studio project or upgrade an existing one, please refer to our comprehensive guide on Installing and Upgrading Sanity Studio.

If you are updating from a version earlier than 3.37.0, you should also check out this article to ensure your dependencies are up to date.

✨ Highlights

Presence cursors in the Portable Text Editor

Sanity Studio has always supported real-time collaboration, but you have yet to be able to see where others are working within the Portable Text Editor. By upgrading, you'll get a similar experience to Google Docs when editing block content.

Portable Text Editor with presence markers showing where users are working

This release also includes bug fixes for the Portable Text Editor:

  • The Portable Text Editor will now remove the invisible Stega-encoded characters if you copy-paste from a preview using Visual Editing
  • The cursor will not move out of viewpoint when deleting a character in PTE.
  • Creating an annotation at the bottom of a PTE will no longer scroll you to the top.
  • Fixes an issue where changing positions of items of an array within PTE would launch a cryptic error

Comments and Tasks are now out of beta

Comments and Tasks are now officially out of beta; hence, we have updated the configuration APIs. Both comments and tasks are enabled by default and for all document types.

Comments configuration migration

Configuration during beta:

// ./sanity.config.ts|js

export default defineConfig({
  // ... rest of config
  document: {
    unstable_comments: {
      enabled: false,
    },
  },
});

New configuration (remove unstable_):

// ./sanity.config.ts|js

export default defineConfig({
  // ... rest of config
  document: {
-   unstable_comments: {
+   comments: {
      enabled: false,
    },
  },
});

Tasks configuration migration

Configuration during beta:

// ./sanity.config.ts|js

export default defineConfig({
  // ... rest of config
  unstable_tasks: { enabled: false },
})

New configuration (remove unstable_):

// ./sanity.config.ts|js

export default defineConfig({
  // ... rest of config
- unstable_tasks: { enabled: false },
+ tasks: { enabled: false },
})

Sanity TypeGen improvements

Thanks for all the feedback about Sanity TypeGen so far! This release ships several improvements and bug fixes:

  • Sanity Typegen now supports count in GROQ projections
  • TypeGen code (sanity.types.ts) is now formatted when a project has a Prettier configuration
  • The TypeGen search path now includes src, app, and sanity folders by default
  • Various bug fixes for type generation
  • Fixes an issue where typegen command would fail on relative imports
  • Fixes a bug where we could not extract or validate schema when the sanity-plugin-mux-input plugin was installed.

Do continue to give us feedback in #typescript in the community!

🐛 Notable bugfixes

  • Fixes ambiguous aria-labels on some Status buttons
  • Fixes issue with inline text comments that would include an inline object.
  • Fixes toast message for document duplicate action

Deprecation Support for Documents and Fields, Comment Reactions ++

v3.26.0

Installation and upgrading

To initiate a new Studio without installing the CLI globally:

npm create sanity@latest

To upgrade a v3 Studio, run this command in its folder:

npm install sanity@latest

✨ Highlights

Deprecation support for Documents and Fields

This release introduces the option to mark document and field types as deprecated. This can be used to gently steer Studio users towards updated schemas or to phase out legacy fields without abrupt changes.

export const deprecatedDocument = defineType({
  name: 'deprecatedDocument',
  title: 'Deprecated Document',
  type: 'document',
  deprecated: {
    reason: 'Use the Author document type instead',
  },
  fields: [
    defineField({
      name: 'title',
      type: 'string',
      deprecated: {
        reason: 'This field was used in a legacy system and is no longer used.',
      },
    }),
  ],
})
 The image displays a user interface from Sanity Studio with a notification at the top. The notification is a warning message that reads, "This document type has been deprecated. Use the Author document type instead." Below the notification, there is a section titled "My Document" with a field labeled "Title," which contains the word "deprecated" highlighted in yellow. The subtitle under the field states "This field was used in a legacy system and is no longer used." The main content area has a text box with the placeholder text "My Document" in it.

When a field or document is deprecated, an informative message will appear in the Studio, clearly indicating the recommended action to take. This aids in maintaining a clean and up-to-date content structure.

Bonus: Deprecation messages now appear in the GraphQL schema, providing clarity during transitions. Deprecated document types and fields should be appropriately treated in documentation and tooling.

Reactions to Comments

This release also introduces a new layer of interactivity in the Studio with the ability for users to react to comments! 🎉

Far be it from us to speak ill of verbose and precise communication using full sentences, but sometimes you just want to express a sentiment quickly with a 🚀 or a 👍 and Sanity Studio now has you covered for those occasions. Streamline feedback processes and consensus building, and make your Studio a more vibrant collaborative space in one fell swoop with comment reactions. 🎩

Shows a comment section in Sanity Studio with a single comment. There are emoji reactions below the comment indicating that one person found the comment surprising (with an astonished face emoji), another found it funny (with a laughing face emoji), and one reacted with a rocket emoji. Next to the emojis, there is a button with a plus sign, possibly for adding more reactions. A small pop-up message is also visible saying, "You reacted with :rocket:" accompanied by the rocket emoji.

🐛 Notable bugfixes

  • Enhances user experience in the Studio by adding localized browser document titles and correcting unlocalized strings, accommodating users who prefer languages other than English.
  • Fixes an issue where number-like string flags passed to CLI commands were parsed as numbers by the option parser, leading to truncation of large integer-only document IDs and similar.
  • Resolves a restoration issue with the token login method ensuring the active session is retained post webpage reloads when cookieless auth is in effect.
  • Enhances UI components consistency in tooltips and delay groups for better UX.
  • Fixes a performance issue by re-applying useMemo on DocumentPaneContext values, reducing unnecessary re-renders and improving document pane performances.
  • Ensures that errors in the useFeatureEnabled hook result in an empty features list rather than disruptive error toasts; this minimizes user interruption when feature availability checks fail.
  • Fixes multiple bugs in the sanity documents validate CLI command relating to visibility, unnecessary validation reports, reference checks batch processing, and unknown field validation for images and file types.
  • Improves spacing between the published date and the last updated date in the document status bar for better readability.

Renamed API, Theming improvements ++

v3.24.1

Installation and upgrading

To initiate a new Studio without installing the CLI globally:

npm create sanity@latest

To upgrade a v3 Studio, run this command in its folder:

npm install sanity@latest

✨ Highlights

Updated legacy theme customization

Legacy themes for Sanity Studio will now handle custom colors without losing the scaffolding provided by the default studio theme. This improvement means that the custom colors you define will no longer revert to default values, but instead integrate seamlessly with Sanity Studio.

Experimental document pane title opt-out

A new flag __experimental_formPreviewTitle has been introduced, allowing you to hide the large preview title displayed in the document pane form. This grants more control to users with custom implementations that do not benefit from this title being displayed.

import {defineType} from 'sanity'

export const playlistType = defineType({
  name: 'playlist',
  type: 'document',
  // 👇👇👇
  __experimental_formPreviewTitle: false,
  // 👆👆👆
  // ...
})

Comments feature now enabled by default

The comments feature within Sanity Studio is now enabled by default, embracing collaboration and social interactions on your documents right out of the box.

Importing Structure as structureTool

The import path for the structure tool has been updated. Developers should now import from sanity/structure instead of sanity/desk. A helpful codemod is available to facilitate the migration of any existing code. Existing imports to sanity/desk will still work but those imports have been marked as deprecated and will be removed in a later major version.

A codemod is available to migrate any code that may be using it:

npx @sanity/cli codemod deskRename

Be sure to check in any local changes to version control before running the codemod in case it should fail.

GraphQL deployment optimization

A new opt-in cache, --with-union-cache, improves GraphQL schema generation speed by up to 95% for schemas with numerous self-referencing documents. This optimization is essential for larger projects and significantly improves the deploy experience.

🐛 Notable bugfixes

  • Fixes a regression where custom document action modal dialogs were not rendering footer content correctly.
  • Resolves issues related to incorrect default locale strings, ensuring the restoration process of document revisions is accompanied by proper messaging.
  • Fixes problems with the strike-through formatting when pasting content from Google Docs.
  • Corrects font weight rendering issues on iOS16, ensuring consistent visual experience across platforms.
  • Fixes the improper alignment of button text in the Portable Text Editor to match standard UI practices.
  • Ensures annotation toolbar popover in PTE follows the correct element on scroll, enhancing usability.
  • Fixes fieldset border issues in forms for a cleaner UI presentation.
  • Resolves console warnings stemming from passing non-DOM properties to styled-components.
  • Updates navbar button positions for better user discoverability and accessibility by adding aria labels to expand buttons in PTE.