Giter Club home page Giter Club logo

sanity-plugin-markdown's Introduction

sanity-plugin-markdown

This is a Sanity Studio v3 plugin. For the v2 version, please refer to the v2-branch.

What is it?

A Markdown editor with preview for Sanity Studio.

Supports Github flavored markdown and image uploads. You can either drag image(s) into the editor or click the bottom bar to bring up a file selector. The resulting image URL(s) are inserted with a default width parameter which you can change to your liking using the Sanity image pipeline parameters.

The current version is a wrapper around React SimpleMDE (EasyMDE) Markdown Editor, and by extension, EasyMDE.

example.png

Installation

Install sanity-plugin-markdown and easymde@2 (peer dependency).

npm install --save sanity-plugin-markdown easymde@2

Usage

Add it as a plugin in sanity.config.ts (or .js):

import { markdownSchema } from "sanity-plugin-markdown";

export default defineConfig({
  // ...
  plugins: [
    markdownSchema(),
  ] 
})

Then, declare a field in your schema to be markdown

const myDocument = {
  type: "document",
  name: "myDocument",
  fields: [
    {
      type: "markdown",
      description: "A Github flavored markdown field with image uploading",
      name: "bio"
    }
  ]
}

Next.js compatability

Next.js without Next 13 app directory does not support css imports from node_modules.

To use this plugin in this context (pages directory), use the sanity-plugin-markdown/next import instead of sanity-plugin-markdown:

import { markdownSchema } from "sanity-plugin-markdown/next";

Then, make sure to add

import 'easymde/dist/easymde.min.css'

to the top of pages/_app.tsx.

Customizing the default markdown input editor

The plugin takes an input config option that can be used in combination with the MarkdownInput export to configure the underlying React SimpleMDE component:

  • Create a custom component that wraps MarkdownInput
  • Memoize reactMdeProps and pass along
// CustomMarkdownInput.tsx
import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'

export function CustomMarkdownInput(props) {
  const reactMdeProps: MarkdownInputProps['reactMdeProps'] =
    useMemo(() => {
      return {
        options: {
          toolbar: ['bold', 'italic'],
          // more options available, see:
          // https://github.com/Ionaru/easy-markdown-editor#options-list
        },
        // more props available, see:
        // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
      }
    }, [])

  return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />
}

Set the plugin input option:

// studio.config.ts
import {markdownSchema} from 'sanity-plugin-markdown'
import {CustomMarkdownInput} from './CustomMarkdownInput'

export default defineConfig({
  // ... rest of the config
  plugins: [
    markdownSchema({input: CustomMarkdownInput}),
  ]
})

Customize editor for a single field

Implement a custom input similar to the one above, and use it as components.input on the field directly.

defineField({
  type: 'markdown',
  name: 'markdown',
  title: 'Markdown',
  components: {input: CustomMarkdownInput}
})

Customizing editor preview

One way to customize the preview that does not involve ReactDOMServer (used by React SimpleMDE) is to install marked and DOMPurify and create a custom preview:

npm i marked dompurify

Then use these to create a custom editor:

// MarkdownInputCustomPreview.tsx
import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'
import DOMPurify from 'dompurify'
import {marked} from 'marked'

export function CustomMarkdownInput(props) {
  const reactMdeProps: MarkdownInputProps['reactMdeProps'] =
    useMemo(() => {
      return {
        options: {
          previewRender: (markdownText) => {
            // configure as needed according to 
            // https://github.com/markedjs/marked#docs
            return DOMPurify.sanitize(marked.parse(markdownText))
          }
          //customizing using renderingConfig is also an option
        },
      }
    }, [])

  return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />
}

Use the component as described in previous sections.

Custom image urls

Provide a function to options.imageUrl that takes a SanityImageAssetDocument and returns a string.

The function will be invoked whenever an image is pasted or dragged into the markdown editor, after upload completes.

The default implementation uses

imageAsset => `${imageAsset.url}?w=450`

Example imageUrl option

defineField({
  type: 'markdown',
  name: 'markdown',
  title: 'Markdown',
  options: {
    imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`
  }
})

License

MIT-licensed. See LICENSE.

Develop & test

This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.

See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

sanity-plugin-markdown's People

Contributors

jtpetty avatar renovate[bot] avatar rexxars avatar robinpyon avatar runeb avatar semantic-release-bot avatar snorrees avatar stipsan avatar surjithctly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sanity-plugin-markdown's Issues

Layout in editor broken

I set up Studio locally and added the markdown plugin. I cannot see my cursor when typing though which makes it really difficult to see what I'm doing.

font size change in studio after installing plugin

The font size of the studio (dashboard, desk etc) change when I install this plugin. I am unsure where the problem is, but as a user I found this happen.

After uninstalling the plugin, the font changes back to being the bigger font I usually have. I was earlier using version 1.0.1

Error: Plugin "markdown@studio-v2" not found

I used Sanity Studio V2 and after installing the plugins using sanity install markdown@studio-v2 command, I get the following error.

Error: Plugin "markdown@studio-v2" not found.
Locations tried:
  * /Users/username/sanity-test/plugins/sanity-plugin-markdown@studio-v2
  * /Users/username/sanity-test/plugins/markdown@studio-v2
  * /Users/username/sanity-test/node_modules/sanity-plugin-markdown@studio-v2
  * /Users/username/sanity-test/node_modules/sanity-plugin-markdown@studio-v2
  * /Users/username/Personal/node_modules/sanity-plugin-markdown@studio-v2
  * /Users/username/node_modules/sanity-plugin-markdown@studio-v2
  * /Users/node_modules/sanity-plugin-markdown@studio-v2
  * /node_modules/sanity-plugin-markdown@studio-v2
Try running "sanity install sanity-plugin-markdown@studio-v2"?
    at getPluginNotFoundError (~/sanity-test/node_modules/@sanity/resolver/lib/resolvePlugins.js:110:13)
    at ~/sanity-test/node_modules/@sanity/resolver/lib/resolvePlugins.js:104:13
    at async Promise.all (index 5)

Don't add width param to image url, or make it configurable.

When uploading an image to markdown, the plugin adds ?w=450 to the end of the url. My content creators then need to manually strip that url param. In my case, if the width exists in the url, and in my site if I use that url in next/image, next/image will pull the 450 width version of the image, then scale it up to render it how i want. This creates very low resolution images.

I believe this the offending code https://github.com/sanity-io/sanity-plugin-markdown/blob/main/src/components/Editor.jsx#L60

Is it's purpose to render nicely in the preview? I would prefer it totally removed or at least allow configuration so that I can unset it.

In the meantime I am stripping this url param on my app side, which isn't the end of the world but not idea.

Thanks!

Large image overflows the preview container

Thank for the plugin

When I include a large image, it will overflow the preview panel. Is it possible to view the image within the preview container?

image

Also, could we have a full-view button like the portable text?
Screenshot 2022-03-30 at 20 02 53

[3.0.0-v3-studio.3] release seems to be broken

I'm getting The desk tool crashed with this configuration:

package.json:

"dependencies": {
    "@sanity/vision": "3.0.0-dev-preview.21",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-is": "^18.2.0",
    "sanity": "3.0.0-dev-preview.21",
    "sanity-plugin-markdown": "3.0.0-v3-studio.3",
    "styled-components": "^5.2.0",
    "url": "^0.11.0"
  },
  "devDependencies": {
    "@sanity/eslint-config-studio": "^2.0.0",
    "eslint": "^8.6.0",
    "prettier": "^2.7.1",
    "typescript": "^4.0.0"
  }
TypeError: (0 , import_is_hotkey.default) is not a function
    at http://localhost:3333/node_modules/.vite/deps/chunk-3UOK4GGL.js?v=a63b6f03:10829:49
    at Lazy
    at Suspense
    at Ga (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55998:5)
    at RouteScope (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:65151:5)
    at div
    at O6 (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45122:6)
    at http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55812:15
    at O6 (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45122:6)
    at Fe (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45077:40)
    at Eo (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55448:44)
    at Co (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55468:21)
    at http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55886:33
    at div
    at O6 (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45122:6)
    at http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55812:15
    at O6 (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45122:6)
    at http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55837:18
    at StudioLayout$1 (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:115828:34)
    at StudioLayout (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117592:19)
    at ResourceCacheProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:113706:9)
    at RouterProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:65179:5)
    at SourceProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:115882:9)
    at WorkspaceProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:115685:9)
    at WorkspaceLoader (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117528:9)
    at Ga (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55998:5)
    at WorkspaceLoaderBoundary (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117573:9)
    at AuthBoundary (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117307:9)
    at UserColorManagerProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117300:9)
    at ed (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:56027:21)
    at Fe (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45077:40)
    at Eo (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55448:44)
    at StudioThemeProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117340:9)
    at ActiveWorkspaceMatcher (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:116032:9)
    at WorkspacesProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:115715:17)
    at Ga (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55998:5)
    at StudioErrorBoundary (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117356:9)
    at Ul (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:56942:21)
    at Fe (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:45077:40)
    at Eo (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:55448:44)
    at ColorSchemeProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:115696:9)
    at StudioProvider (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117587:9)
    at Studio (http://localhost:3333/node_modules/.vite/deps/chunk-NHZD4FGU.js?v=a63b6f03:117596:34)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.


Using a curated preset maintained by


Sanity: The Composable Content Cloud

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm npm-run-all Available

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update commitlint monorepo to v19 (major) (@commitlint/cli, @commitlint/config-conventional)
  • chore(deps): update dependency @sanity/pkg-utils to v4
  • chore(deps): update dependency @sanity/pkg-utils to v5
  • chore(deps): update dependency @sanity/pkg-utils to v6
  • chore(deps): update dependency @sanity/plugin-kit to v4
  • chore(deps): update dependency @sanity/semantic-release-preset to v5
  • chore(deps): update dependency eslint-plugin-prettier to v5
  • chore(deps): update dependency prettier to v3
  • chore(deps): update linters to v6 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • chore(deps): update linters to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser, eslint-config-sanity)
  • chore(deps): update linters to v8 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • fix(deps): Update dependency @sanity/ui to v2
  • 🔐 Create all pending approval PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v3@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
  • actions/setup-node v3@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
  • actions/checkout v3@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
  • actions/setup-node v3@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
  • actions/checkout v3@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
  • actions/setup-node v3@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
npm
package.json
  • @sanity/incompatible-plugin ^1.0.4
  • @sanity/ui ^1.0.0
  • react-simplemde-editor ^5.2.0
  • @commitlint/cli ^17.2.0
  • @commitlint/config-conventional ^17.2.0
  • @sanity/pkg-utils ^2.2.6
  • @sanity/plugin-kit ^3.1.7
  • @sanity/semantic-release-preset ^2.0.2
  • @types/react ^18.0.26
  • @types/styled-components ^5.1.26
  • @typescript-eslint/eslint-plugin ^5.48.0
  • @typescript-eslint/parser ^5.48.0
  • easymde ^2.18.0
  • eslint ^8.31.0
  • eslint-config-prettier ^8.6.0
  • eslint-config-sanity ^6.0.0
  • eslint-plugin-prettier ^4.2.1
  • eslint-plugin-react ^7.31.11
  • eslint-plugin-react-hooks ^4.6.0
  • npm-run-all ^4.1.5
  • prettier ^2.8.1
  • prettier-plugin-packagejson ^2.3.0
  • react ^18.2.0
  • react-dom ^18.2.0
  • react-is ^18.2.0
  • rimraf ^5.0.0
  • sanity ^3.1.4
  • styled-components ^5.3.6
  • typescript ^5.0.0
  • easymde ^2
  • react ^18
  • sanity ^3
  • styled-components ^5.2 || ^6
  • node >=14

  • Check this box to trigger a request for Renovate to run again on this repository

Allow toolbar config via options

As of version 2.0.0 we hard-code the available styles and Toolbar options

toolbarCommands={[
['header', 'bold', 'italic', 'strikethrough'],
['link', 'quote', 'code'],
['unordered-list', 'ordered-list', 'checked-list'],
]}

It would be relatively trivial to make these configurable via options to the field, something like

{
  name: "body",
  type: "markdown",
  options: {
    toolbarCommands: [
      ['header', 'bold', 'italic', 'strikethrough'], 
      ['link', 'quote', 'code'], 
      ['unordered-list', 'ordered-list', 'checked-list'], 
    ]
  }
}

Support full page preview

Current markdown view page is very small, it would be better if it can support fullscreen preview.

bug: Debounce triggers mutation on first value set

This causes a mutate call with the same data as loaded. This is not a problem, content-wise, but it does mark the document as edited "just now" and might cause some confusion.

Should be fixed by having the first value set not trigger the onChange handler

Crash when I try to use Markdown at RichEditor

Thanks a lot for the plugin.
It works good when I use the markdown as separate field
Screenshot 2021-05-18 at 16 43 43

But the app crash when I try to use the Markdown at RichEditor.

    {
      name: 'body',
      title: 'Body content',
      type: 'array',
      fieldset: 'main',
      of: [
        {
          type: 'block',
        },
        {
          title: 'Table',
          type: 'table',
        },
        {
          title: 'Markdown',
          type: 'markdown',
        },
      ],
    },

Screenshot 2021-05-18 at 16 37 47

Screenshot 2021-05-18 at 16 37 54

Screenshot 2021-05-18 at 16 38 30

Stack trace:
Error: Cannot set value of an object to a non-object
    at apply (/static/js/app.bundle.js:283385:15)
    at applyPatch (/static/js/app.bundle.js:85492:32)
    at _apply (/static/js/app.bundle.js:85499:13)
    at Array.reduce (<anonymous>)
    at applyAll (/static/js/app.bundle.js:85479:18)
    at handleChange (/static/js/app.bundle.js:282934:41)
    at handleChange (/static/js/app.bundle.js:283622:36)
    at Object.onChange (/static/js/app.bundle.js:32552:7)
    at http://localhost:3333/static/js/app.bundle.js:221927:13
    at commitHookEffectListMount (/static/js/vendor.bundle.js:22468:26)
Component stack:
    in Editor (created by FormBuilderInputInner)
    in ChangeIndicatorProvider (created by FormBuilderInputInner)
    in div (created by FormBuilderInputInner)
    in FormBuilderInputInner (created by FormBuilderInput)
    in FormBuilderInput (created by DefaultObjectEditing)
    in div (created by ForwardRef(RegionsWithIntersections))
    in div (created by ForwardRef(RegionsWithIntersections))
    in ForwardRef(RegionsWithIntersections) (created by StickyOverlay)
    in StickyOverlay (created by OverlayEnabled)
    in Tracker (created by OverlayEnabled)
    in OverlayEnabled (created by DefaultObjectEditing)
    in div (created by DefaultDialogChildren)
    in div (created by ForwardRef(ScrollContainer))
    in ForwardRef(ScrollContainer) (created by DefaultDialogChildren)
    in div (created by DefaultDialogChildren)
    in div (created by DefaultDialogChildren)
    in div (created by ContainerQuery)
    in ContainerQuery (created by DefaultDialogChildren)
    in DefaultDialogChildren (created by DefaultDialog)
    in LayerProvider (created by LegacyLayerProvider)
    in LegacyLayerProvider (created by DefaultDialog)
    in Portal (created by DefaultDialog)
    in DefaultDialog (created by DefaultObjectEditing)
    in DefaultObjectEditing (created by EditObject)
    in EditObject (created by PortableTextInput)
    in div (created by PortableTextInput)
    in PortableTextInput (created by ForwardRef(PortableTextInput))
    in PortableTextEditor (created by ForwardRef(PortableTextInput))
    in ForwardRef(PortableTextInput) (created by PortableTextInputWithFocusAndBlur)
    in div (created by DefaultFormField)
    in div (created by DefaultFormField)
    in DefaultFormField (created by PortableTextInputWithFocusAndBlur)
    in PortableTextInputWithFocusAndBlur (created by withPatches(PortableTextInputWithFocusAndBlur))
    in withPatches(PortableTextInputWithFocusAndBlur) (created by FormBuilderInputInner)
    in ChangeIndicatorProvider (created by FormBuilderInputInner)
    in div (created by FormBuilderInputInner)
    in FormBuilderInputInner (created by FormBuilderInput)
    in FormBuilderInput (created by Tabs)
    in div (created by Tabs)
    in div (created by Tabs)
    in div (created by Tabs)
    in Tabs (created by withDocument(Tabs))
    in withDocument(Tabs) (created by FormBuilderInputInner)
    in ChangeIndicatorProvider (created by FormBuilderInputInner)
    in div (created by FormBuilderInputInner)
    in FormBuilderInputInner (created by FormBuilderInput)
    in FormBuilderInput (created by Field)
    in div (created by Field)
    in Field (created by ObjectInput)
    in div (created by ObjectInput)
    in div (created by ObjectInput)
    in ObjectInput (created by FormBuilderInputInner)
    in ChangeIndicatorProvider (created by FormBuilderInputInner)
    in div (created by FormBuilderInputInner)
    in FormBuilderInputInner (created by FormBuilderInput)
    in FormBuilderInput (created by SanityFormBuilder)
    in FormBuilderContext (created by SanityFormBuilderContext)
    in SanityFormBuilderContext (created by SanityFormBuilder)
    in SanityFormBuilder
    in form
    in Unknown (created by FormView)
    in div (created by ForwardRef(RegionsWithIntersections))
    in div (created by ForwardRef(RegionsWithIntersections))
    in ForwardRef(RegionsWithIntersections) (created by StickyOverlay)
    in StickyOverlay (created by OverlayEnabled)
    in Tracker (created by OverlayEnabled)
    in OverlayEnabled (created by FormView)
    in div (created by FormView)
    in FormView (created by DocumentPanel)
    in div (created by ForwardRef(ScrollContainer))
    in ForwardRef(ScrollContainer) (created by DocumentPanel)
    in div (created by DocumentPanel)
    in BoundaryElementProvider (created by DocumentPanel)
    in PortalProvider (created by DocumentPanel)
    in div (created by styled.div)
    in styled.div (created by Box)
    in Box (created by Styled(Box))
    in Styled(Box) (created by Card)
    in Ge (created by ThemeProvider)
    in ThemeProvider (created by ThemeColorProvider)
    in ThemeColorProvider (created by Card)
    in Card (created by DocumentPanel)
    in DocumentPanel (created by DocumentPane)
    in div (created by DocumentPane)
    in div (created by ForwardRef(ScrollContainer))
    in ForwardRef(ScrollContainer) (created by EnabledChangeConnectorRoot)
    in Tracker (created by EnabledChangeConnectorRoot)
    in EnabledChangeConnectorRoot (created by DocumentPane)
    in DialogProvider (created by DocumentPane)
    in div (created by KeyboardShortcutResponder)
    in KeyboardShortcutResponder (created by GetHookCollectionState)
    in GetHookCollectionState (created by RenderActionCollectionState)
    in RenderActionCollectionState
    in Unknown (created by DocumentPane)
    in LayerProvider (created by LegacyLayerProvider)
    in LegacyLayerProvider (created by DocumentPane)
    in DocumentPane (created by DocumentPaneProvider)
    in DocumentHistoryProvider (created by DocumentPaneProvider)
    in DocumentPaneProvider
    in StreamingComponent
    in StreamingComponent (created by Context.Consumer)
    in WithInitialValueWrapper (created by DeskToolPane)
    in DeskToolPane (created by DeskToolPanes)
    in SplitPaneWrapper (created by DeskToolPanes)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in PanesSplitController (created by DeskToolPanes)
    in PortalProvider (created by DeskToolPanes)
    in div (created by DeskToolPanes)
    in DeskToolPanes (created by DeskTool)
    in DeskTool (created by withRouter(DeskTool))
    in withRouter(DeskTool) (created by DeskToolPaneStateSyncer)
    in DeskToolPaneStateSyncer (created by DeskTool)
    in DeskToolFeaturesProvider (created by DeskTool)
    in DeskTool (created by RenderTool)
    in RenderTool (created by SchemaErrorReporter)
    in RouteScope (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in SchemaErrorReporter (created by DefaultLayout)
    in DefaultLayout (created by withRouter(DefaultLayout))
    in withRouter(DefaultLayout) (created by DefaultLayoutRoot)
    in RouterProvider (created by DefaultLayoutRoot)
    in LoginWrapper (created by DefaultLayoutRoot)
    in DefaultLayoutRoot (created by AppProvider)
    in div (created by styled.div)
    in styled.div (created by Box)
    in Box (created by Styled(Box))
    in Styled(Box) (created by Card)
    in Ge (created by ThemeProvider)
    in ThemeProvider (created by ThemeColorProvider)
    in ThemeColorProvider (created by Card)
    in Card (created by Styled(Card))
    in Styled(Card) (created by AppProvider)
    in SnackbarProvider (created by AppProvider)
    in ToastProvider (created by AppProvider)
    in LayerProvider (created by AppProvider)
    in PortalProvider (created by AppProvider)
    in UserColorManagerProvider (created by AppProvider)
    in AppProvider (created by SanityRoot)
    in Ge (created by ThemeProvider)
    in ThemeProvider (created by SanityRoot)
    in ZIndexProvider (created by SanityRoot)
    in SanityRoot
    in AppContainer

Sanity V3 Embedding System don't load styles

When i use the new Sanity.io embedding system the page crashes and it is not possible to run the app because it cannot find the react-mde CSS

Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/sanity-plugin-markdown/lib/index.modern.js

image

Drag to upload and formatting buttons not working

Installing the latest version of sanity-plugin-markdown on a clean Sanity project - seems to result in slightly broken markdown editor. Text editing and Preview button works but in-line images, drag images and formatting buttons do not.

Ability to provide a field description

Hello there and thank you for the very nice plugin. :)

I was wondering if it would be possible to provide a description to that field. Our use case would be to provide a link to a cheatsheet for our editors who are not overly familiar with Markdown.

I tried the following, but it did not work:

{
  name: 'my_field',
  title: 'My field',
  type: 'markdown',
  description: 'Some description here'
}

Is the ability to pass a description something that could be added or is it a no-no?

Thank you! ✨

Trouble installing with `sanity install` (Unknown type: markdown)

sanity install markdown not working as expected:

 Valid types are: settings, post, author, category, blockContent, comment, array, block, boolean, datetime, date, document, email, file, geopoint, image, number, object, reference, slug, string, telephone, text and url

V3 deploy issue with developer preview 13 and later

When I did a fresh yarn install I got this message:

warning " > [email protected]" has incorrect peer dependency "sanity@dev-preview".

Running the studio with sanity start works. But if I try to deploy it sanity deploy I get this error:

yarn run v1.22.19
$ sanity deploy
✔ Checking project info
✔ Clean output folder (4ms)
✖ Build Sanity Studio

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received '/Users/myuser/dev/studio/dist/static//[email protected]'
    at writeOutputFile (file://~/dev/studio/node_modules/rollup/dist/es/shared/rollup.js:23800:34)
    at async Queue.work (file://~/dev/studio/node_modules/rollup/dist/es/shared/rollup.js:22773:32)
error Command failed with exit code 1.

Im running sanity 3.0.0-dev-preview.14
$ sanity --version
@sanity/cli version 3.0.0-v3-pte.17+4b7aeb686f

Issue with nextjs + hosted studio

Heyo,

I'm getting an error when using with nextjs 13.

When I navigate to my desk, at /studio I'm seeing a big ole error:

Error: require() of ES Module /Users/magicspon/bla/node_modules/react-markdown/index.js from /Users/magicspon/bla/node_modules/@uiw/react-markdown-preview/lib/index.js not supported.
Instead change the require of /Users/magicspon/bla/node_modules/react-markdown/index.js in /Users/magicspon/bla/node_modules/@uiw/react-markdown-preview/lib/index.js to a dynamic import() which is available in all CommonJS modules.

Has anyone managed to use this on a hosted nextjs site? I suspect the issue is next expects import/export rather than common js.

cheers

Code snippets

Hi. Quick question. Does this plugin support code snippets maybe with syntax highlighting? eg.

console.log('Blah blah')

Or better yet, is there any markdown that isn't supported?
If this is the wrong place to ask, let me know. Thanks in advance.

Issues when using Next and Sanity Studio

Hello, I'm configuring a local Sanity Studio with my Next project. I'm getting this issue. Following the steps as indicated in the README of this repository.

./node_modules/easymde/dist/easymde.min.css
Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/sanity-plugin-markdown/lib/index.esm.js

Feature: Possibility to add references to documents instead of links

Hi 🖐 been using markdown plugin for while, mostly on blog posts and long form writing.

I have encountered a couple of situations where instead of adding url's through markdown the users and myself needed to add url that reference to posts already published

I was wondering if this is something super complicated to do or even if it's on your pipeline?

Thanks!

Add functionality to enter and leave full screen mode

Hey everyone!

I've been using the markdown plugin for a bit now to write content and show it in a Svelkit-powered blog. But the ergonomics of writing have been a bit difficult to deal with.

An experience such as the following one is currently not possible with the markdown editor:

image

Here's the available space to write with the markdown editor (dark mode plugin installed):

image

Then the suggestion here would be to make it so that the markdown editor can be maximized and minimized the same way as in the Block/Portable Text editor.

Thanks for reading

The structure tool crashed when running the build preview

Describe the bug

When running the preview, I get an error: Cannot read properties of undefined (reading 'color')

To Reproduce

Steps to reproduce the behavior:

  1. build sanity
  2. run preview

Screenshots
image

Which versions of Sanity are you using?

@sanity/cli 3.30.0 (up to date)
@sanity/google-maps-input 3.0.2 (up to date)
@sanity/vision 3.30.0 (up to date)
sanity 3.30.0 (up to date)
sanity-plugin-markdown 4.1.1 (up to date)

Which versions of Node.js / npm are you running?

10.2.3
v18.19.0

✕ unmet peer styled-components@^5.2: found 6.1.8

I guess peer dependencies need an update

❯ pnpm install @sanity/code-input                                                                                                            (base) 
Packages: +16
++++++++++++++++
Progress: resolved 981, reused 922, downloaded 16, added 16, done

dependencies:
+ @sanity/code-input 4.1.3

 WARN  Issues with peer dependencies found
.
└─┬ sanity-plugin-markdown 4.1.1
  └── ✕ unmet peer styled-components@^5.2: found 6.1.8

Done in 14.3s

Support markdown comment

Is it possible to support the markdown comment? It would be great if the comment section is hidden from the preview. Thank you so much!

image

image

Studio carsh after install plugin in Remix / vite based project :: Unexpected token 'export'

Describe the bug
Sanity studio crash after install markdown plugin following readme instructions.
The error message is Unexpected token 'export'

The solution of nextjs doesn't work.

To Reproduce

Steps to reproduce the behavior:

  1. Initiate Sanity project with remix and vite based template.
  2. Add sanity-plugin-markdown
  3. run dev server.

Expected behavior

Screenshots
image

Which versions of Sanity are you using?

@sanity/cli (global)        3.32.0 (up to date)
@sanity/asset-utils          1.3.0 (up to date)
@sanity/demo                 2.0.0 (up to date)
@sanity/icons               2.11.2 (up to date)
@sanity/image-url            1.0.2 (up to date)
@sanity/presentation        1.11.4 (latest: 1.11.5)
@sanity/preview-url-secret   1.6.4 (up to date)
@sanity/react-loader         1.9.3 (up to date)
@sanity/schema              3.32.0 (up to date)
@sanity/ui                   2.0.7 (latest: 2.0.10)
@sanity/vision              3.32.0 (up to date)
@sanity/visual-editing       1.7.0 (latest: 1.7.1)
sanity                      3.32.0 (up to date)

What operating system are you using?
MacOS Sonoma 14.4(ARM)

Which versions of Node.js / npm are you running?

pnpm -v && node -v
8.15.4
v20.11.1

Additional context

you can find the remix/vite based sanity template from here
: https://github.com/SimeonGriggs/sanity-remix-template

Expose on paste event api

We are facing a situation where our editors are coping/pasting table from GDocs or Word but when they paste the table we are getting the following content on the markdown textarea:

Property Name
Data type
Default value
required
sponsorName
varchar

When we should be getting(the following markdown was pasted from a google doc table to here which means its possible):

  | Property Name | Data type | Default value
-- | -- | -- | --
required | sponsorName | varchar |  

If we have on pasted event, we could be able to transform the event data to valid a markdown or whatever the format is to a valid markdown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.