@tiptap/react 2.23.1 → 2.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu';
2
2
  import React, { forwardRef, useState, useDebugValue, useLayoutEffect, useEffect, useRef, createContext, useContext, version, createRef, memo, createElement } from 'react';
3
- import ReactDOM, { flushSync } from 'react-dom';
3
+ import ReactDOM from 'react-dom';
4
4
  import { Editor, NodeView, getRenderedAttributes } from '@tiptap/core';
5
5
  export * from '@tiptap/core';
6
6
  import { FloatingMenuPlugin } from '@tiptap/extension-floating-menu';
@@ -1295,16 +1295,9 @@ class ReactRenderer {
1295
1295
  if (className) {
1296
1296
  this.element.classList.add(...className.split(' '));
1297
1297
  }
1298
- if (this.editor.isInitialized) {
1299
- // On first render, we need to flush the render synchronously
1300
- // Renders afterwards can be async, but this fixes a cursor positioning issue
1301
- flushSync(() => {
1302
- this.render();
1303
- });
1304
- }
1305
- else {
1298
+ queueMicrotask(() => {
1306
1299
  this.render();
1307
- }
1300
+ });
1308
1301
  }
1309
1302
  /**
1310
1303
  * Render the React component.
@@ -1361,6 +1354,24 @@ class ReactRenderer {
1361
1354
  }
1362
1355
 
1363
1356
  class ReactNodeView extends NodeView {
1357
+ constructor(component, props, options) {
1358
+ super(component, props, options);
1359
+ if (!this.node.isLeaf) {
1360
+ if (this.options.contentDOMElementTag) {
1361
+ this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
1362
+ }
1363
+ else {
1364
+ this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div');
1365
+ }
1366
+ this.contentDOMElement.dataset.nodeViewContentReact = '';
1367
+ this.contentDOMElement.dataset.nodeViewWrapper = '';
1368
+ // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
1369
+ // With this fix it seems to work fine
1370
+ // See: https://github.com/ueberdosis/tiptap/issues/1197
1371
+ this.contentDOMElement.style.whiteSpace = 'inherit';
1372
+ this.dom.appendChild(this.contentDOMElement);
1373
+ }
1374
+ }
1364
1375
  /**
1365
1376
  * Setup the React component.
1366
1377
  * Called on initialization.
@@ -1389,6 +1400,10 @@ class ReactNodeView extends NodeView {
1389
1400
  const onDragStart = this.onDragStart.bind(this);
1390
1401
  const nodeViewContentRef = element => {
1391
1402
  if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
1403
+ // remove the nodeViewWrapper attribute from the element
1404
+ if (element.hasAttribute('data-node-view-wrapper')) {
1405
+ element.removeAttribute('data-node-view-wrapper');
1406
+ }
1392
1407
  element.appendChild(this.contentDOMElement);
1393
1408
  }
1394
1409
  };
@@ -1400,22 +1415,6 @@ class ReactNodeView extends NodeView {
1400
1415
  return (React.createElement(ReactNodeViewContext.Provider, { value: context }, createElement(Component, componentProps)));
1401
1416
  });
1402
1417
  ReactNodeViewProvider.displayName = 'ReactNodeView';
1403
- if (this.node.isLeaf) {
1404
- this.contentDOMElement = null;
1405
- }
1406
- else if (this.options.contentDOMElementTag) {
1407
- this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
1408
- }
1409
- else {
1410
- this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div');
1411
- }
1412
- if (this.contentDOMElement) {
1413
- this.contentDOMElement.dataset.nodeViewContentReact = '';
1414
- // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
1415
- // With this fix it seems to work fine
1416
- // See: https://github.com/ueberdosis/tiptap/issues/1197
1417
- this.contentDOMElement.style.whiteSpace = 'inherit';
1418
- }
1419
1418
  let as = this.node.isInline ? 'span' : 'div';
1420
1419
  if (this.options.as) {
1421
1420
  as = this.options.as;