# The whitespace at the beginning of the paragraph disappears

**URL:** <https://discuss.prosemirror.net/t/the-whitespace-at-the-beginning-of-the-paragraph-disappears/5012>\
**Category:** Uncategorized\
**Created:** [November 10, 2022, 5:49am UTC](https://discuss.prosemirror.net/t/the-whitespace-at-the-beginning-of-the-paragraph-disappears/5012 "2022-11-10T05:49:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rayangmoon](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/rayangmoon/32/3146_2.png) [@Rayangmoon](https://discuss.prosemirror.net/u/Rayangmoon)\
**Post date:** [November 10, 2022, 5:49am UTC](https://discuss.prosemirror.net/t/the-whitespace-at-the-beginning-of-the-paragraph-disappears/5012/1 "2022-11-10T05:49:57Z")

</div>

hello，i am new with prosemirror 。Recently I used it to develop my editor , but i found that if i import exist doc into editor , the whitespace at the beginning of the paragraph disappears , whitch is based on the normal paragraph define:

```auto
paragraph: {
    content: "inline*",
    group: "block",
    defining: true,
    parseDOM: [{tag: "p"}],
    toDOM() { return ["p", 0] }
  },

```

so I decide to change the way to define it to retain the whitespace like this:

```auto
  paragraph: {
    attrs: {
      content: {default: ''}
    },
    content: "inline*",
    group: "block",
    defining: true,
    parseDOM: [{
      tag: 'p',
      getAttrs(dom) {
        let content = dom.innerHTML
        return {
          content:content
        }
      } 
    }],
    toDOM(node) {
      let pDom = document.createElement('p')
      pDom.innerHTML = node.attrs.content
      return pDom
    }
  },

```

but it will cause a crash with

like: ![a_pitem](https://discuss.prosemirror.net/uploads/secondsite/original/2X/f/f4b9043518062911eb43193e7f93c74b0fe95e45.png)On this issue, I don’t know what to do now 😣. How can I keep the space at the beginning of the paragraph,I hope I can get your help. Thank you very much

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 10, 2022, 9:33am UTC](https://discuss.prosemirror.net/t/the-whitespace-at-the-beginning-of-the-paragraph-disappears/5012/2 "2022-11-10T09:33:12Z")

</div>

Does passing the [`preserveWhitespace`](https://prosemirror.net/docs/ref/#model.ParseOptions.preserveWhitespace)`: true` option to `DOMParser.parse` help here?

---

<div class="post-metadata">

**Author:** ![Rayangmoon](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/rayangmoon/32/3146_2.png) [@Rayangmoon](https://discuss.prosemirror.net/u/Rayangmoon)\
**Post date:** [November 10, 2022, 9:47am UTC](https://discuss.prosemirror.net/t/the-whitespace-at-the-beginning-of-the-paragraph-disappears/5012/3 "2022-11-10T09:47:44Z")

</div>

I set it to ` preserveWhitespace: 'full'` , but it only takes effect for other spaces, not for the first space
