WYSIWYG relies on default styling of html elements.

Open
#8,620 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start by locating the DocumentRenderer and the WYSIWYG rendering path, then reproduce the issue with reset.css and the listed global h1 and ul styles. Done means rendered documents retain appropriate default element styling without being changed by the consuming app's global styles, while allowing intentional customization.

Written by the indexing model from the issue text.

Description

Hey there 👋🏽, Just happened to notice that the WYSIWYG relies on default styling of html elements. In my app, I start off with using reset.css and then add my own custom styles for default html styling (h1, h2, p, etc). However the issue is that when using the DocumentRenderer and passing the document from my list, All html elements in the rendering of the document are picking up my custom styling that I had mentioned in the last sentence. This is causing me to having to create a "wrapper" and change all the html stylings back to the originals defaults so the WYSIWYG looks good again.

Its not the worst but it would be great if the WYSIWYG could come with the default styling by default this way if anyone else wanted to change the default behavior of say a h1 then they could do so without affecting styling in the WYSIWYG.

  • change global h1 tag to font-size:2px
  • make a list that has document field
  • add a heading 1 to the document in the admin UI
  • render document with DocumentRenderer

example
I have a global style to remove the list-style from ul elements and the WYSIWYG got effected as well. Similar with background color (would never actually do this, but for demo it works perfect)

Screenshot 2023-06-08 at 11 28 42 AM
Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
38

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from keystonejs/keystone

All issues in keystonejs/keystone

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.