prisma / studio

🎙️ The easiest way to explore and manipulate your data in all of your Prisma projects.
https://www.prisma.io/studio
1.88k stars 48 forks source link

Prisma Studio - Model `Text` Fields and Markdown Content Formatting #1080

Open e2corporation opened 1 year ago

e2corporation commented 1 year ago

Bug description

When using Prisma Studio is used to save Markdown Content into a String field (DataSource = MySQL), it appears that Newlines, Tabs, and possibly other spaces are trimmed, which results in a loss of markdown formatting when the content is retrieved from database.

Before: User Submitted Content (Example)

## Heading

Paragraph

After: Prisma Content Saved

## Heading
Paragraph

How to reproduce

This Assumes there is a working Project with Next.js and Prisma ORM, and a Database Model that utilizes a Text field with rich content such as HTML or Markdown.

  1. Launch Prisma Studio (npx prisma studio)
  2. Edit a content field with Markdown Content
  3. Save Changes to DB
  4. Retrieve Markdown Content from DB
  5. Parse Markdown Content
  6. Notice content formatting and render is incorrect

Expected behavior

Prisma Studio should honor Newlines, Tabs, spaces and possibly other characters for rich content stored in Text or String based fields. The Studio UI could support both a Plain-Text and Rich-Text mode editor so edited content is preserved exactly as entered.

Prisma information

 model Post {
  id        Int         @id @default(autoincrement())
  createdAt DateTime    @default(now())
  updatedAt DateTime    @updatedAt
  published Boolean     @default(false)
  title     String      @db.VarChar(255)
  slug      String?     @unique @db.VarChar(255)
  content   String?     @db.Text
  author    User?       @relation(fields: [authorId], references: [id])
  authorId  Int?
}
  const post = await prisma.post.findUnique({
    where: {
      slug: slug
    }
  })
  return {
    post
  }

// Content in Markdown
// console.log(post.content)

Environment & setup

Prisma Version

prisma                  : 4.6.1
@prisma/client          : 4.6.1
Current platform        : darwin
Studio                  : 0.476.0
zpaceway commented 1 year ago

I think prisma studio should have a built in rich text editor

JovanJevtic commented 10 months ago

+1

ianwatts22 commented 5 months ago

this would be awesome. more than markdown, just new lines would be great

alexander-rebai commented 4 months ago

I am experiencing same problem