@tiptap/react 2.23.1 → 2.24.0

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.umd.js CHANGED
@@ -1294,16 +1294,9 @@
1294
1294
  if (className) {
1295
1295
  this.element.classList.add(...className.split(' '));
1296
1296
  }
1297
- if (this.editor.isInitialized) {
1298
- // On first render, we need to flush the render synchronously
1299
- // Renders afterwards can be async, but this fixes a cursor positioning issue
1300
- ReactDOM.flushSync(() => {
1301
- this.render();
1302
- });
1303
- }
1304
- else {
1297
+ queueMicrotask(() => {
1305
1298
  this.render();
1306
- }
1299
+ });
1307
1300
  }
1308
1301
  /**
1309
1302
  * Render the React component.
@@ -1360,6 +1353,24 @@
1360
1353
  }
1361
1354
 
1362
1355
  class ReactNodeView extends core.NodeView {
1356
+ constructor(component, props, options) {
1357
+ super(component, props, options);
1358
+ if (!this.node.isLeaf) {
1359
+ if (this.options.contentDOMElementTag) {
1360
+ this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
1361
+ }
1362
+ else {
1363
+ this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div');
1364
+ }
1365
+ this.contentDOMElement.dataset.nodeViewContentReact = '';
1366
+ this.contentDOMElement.dataset.nodeViewWrapper = '';
1367
+ // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
1368
+ // With this fix it seems to work fine
1369
+ // See: https://github.com/ueberdosis/tiptap/issues/1197
1370
+ this.contentDOMElement.style.whiteSpace = 'inherit';
1371
+ this.dom.appendChild(this.contentDOMElement);
1372
+ }
1373
+ }
1363
1374
  /**
1364
1375
  * Setup the React component.
1365
1376
  * Called on initialization.
@@ -1388,6 +1399,10 @@
1388
1399
  const onDragStart = this.onDragStart.bind(this);
1389
1400
  const nodeViewContentRef = element => {
1390
1401
  if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
1402
+ // remove the nodeViewWrapper attribute from the element
1403
+ if (element.hasAttribute('data-node-view-wrapper')) {
1404
+ element.removeAttribute('data-node-view-wrapper');
1405
+ }
1391
1406
  element.appendChild(this.contentDOMElement);
1392
1407
  }
1393
1408
  };
@@ -1399,22 +1414,6 @@
1399
1414
  return (React.createElement(ReactNodeViewContext.Provider, { value: context }, React.createElement(Component, componentProps)));
1400
1415
  });
1401
1416
  ReactNodeViewProvider.displayName = 'ReactNodeView';
1402
- if (this.node.isLeaf) {
1403
- this.contentDOMElement = null;
1404
- }
1405
- else if (this.options.contentDOMElementTag) {
1406
- this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
1407
- }
1408
- else {
1409
- this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div');
1410
- }
1411
- if (this.contentDOMElement) {
1412
- this.contentDOMElement.dataset.nodeViewContentReact = '';
1413
- // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
1414
- // With this fix it seems to work fine
1415
- // See: https://github.com/ueberdosis/tiptap/issues/1197
1416
- this.contentDOMElement.style.whiteSpace = 'inherit';
1417
- }
1418
1417
  let as = this.node.isInline ? 'span' : 'div';
1419
1418
  if (this.options.as) {
1420
1419
  as = this.options.as;