Skip to content

Commit

Permalink
Emit a warning when white-space is left as normal on the editable ele…
Browse files Browse the repository at this point in the history
…ment

Issue #62
Issue ProseMirror/prosemirror#981
  • Loading branch information
marijnh committed Oct 15, 2019
1 parent bc1b864 commit b8b814c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/domobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ export class DOMObserver {
}
}
if (from > -1 || newSel) {
if (from > -1) this.view.docView.markDirty(from, to)
if (from > -1) {
this.view.docView.markDirty(from, to)
checkCSS(this.view)
}
this.handleDOMChange(from, to, typeOver)
if (this.view.docView.dirty) this.view.updateState(this.view.state)
else if (!this.currentSelection.eq(sel)) selectionToDOM(this.view)
Expand Down Expand Up @@ -192,3 +195,12 @@ export class DOMObserver {
}
}
}

let cssChecked = false

function checkCSS(view) {
if (cssChecked) return
cssChecked = true
if (getComputedStyle(view.dom).whiteSpace == "normal")
console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.")
}

0 comments on commit b8b814c

Please sign in to comment.