From b8b814c332f2bb51f07a4a397a074c7d0178434f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Oct 2019 16:27:08 +0200 Subject: [PATCH] Emit a warning when white-space is left as normal on the editable element Issue #62 Issue prosemirror/prosemirror#981 --- src/domobserver.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/domobserver.js b/src/domobserver.js index 9d0ce35d..5b3489c3 100644 --- a/src/domobserver.js +++ b/src/domobserver.js @@ -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) @@ -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.") +}