fix: prevents a bug where a line break was incorrectly added at enter in react node views, fix #1197

This commit is contained in:
Philipp Kühn
2021-04-22 14:23:48 +02:00
parent 711b99a624
commit e885ffa15b

View File

@@ -20,7 +20,7 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor> {
renderer!: ReactRenderer renderer!: ReactRenderer
contentDOMElement!: Element | null contentDOMElement!: HTMLElement | null
mount() { mount() {
const props: NodeViewProps = { const props: NodeViewProps = {
@@ -58,6 +58,13 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor> {
? null ? null
: document.createElement(this.node.isInline ? 'span' : 'div') : document.createElement(this.node.isInline ? 'span' : 'div')
if (this.contentDOMElement) {
// For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
// With this fix it seems to work fine
// See: https://github.com/ueberdosis/tiptap/issues/1197
this.contentDOMElement.style.whiteSpace = 'inherit'
}
this.renderer = new ReactRenderer(ReactNodeViewProvider, { this.renderer = new ReactRenderer(ReactNodeViewProvider, {
editor: this.editor, editor: this.editor,
props, props,