@tiptap/react 2.23.0 → 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/ReactNodeViewRenderer.d.ts +2 -1
- package/dist/ReactNodeViewRenderer.d.ts.map +1 -1
- package/dist/ReactRenderer.d.ts.map +1 -1
- package/dist/index.cjs +24 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -26
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +24 -25
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/ReactNodeViewRenderer.tsx +31 -17
- package/src/ReactRenderer.tsx +2 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Editor, NodeViewRenderer, NodeViewRendererOptions } from '@tiptap/core';
|
|
1
|
+
import type { Editor, NodeViewRenderer, NodeViewRendererOptions, NodeViewRendererProps } from '@tiptap/core';
|
|
2
2
|
import { NodeView } from '@tiptap/core';
|
|
3
3
|
import type { Node, Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
4
4
|
import type { Decoration, DecorationSource } from '@tiptap/pm/view';
|
|
@@ -46,6 +46,7 @@ export declare class ReactNodeView<T = HTMLElement, Component extends ComponentT
|
|
|
46
46
|
* The element that holds the rich-text content of the node.
|
|
47
47
|
*/
|
|
48
48
|
contentDOMElement: HTMLElement | null;
|
|
49
|
+
constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
|
|
49
50
|
/**
|
|
50
51
|
* Setup the React component.
|
|
51
52
|
* Called on initialization.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNodeViewRenderer.d.ts","sourceRoot":"","sources":["../src/ReactNodeViewRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ReactNodeViewRenderer.d.ts","sourceRoot":"","sources":["../src/ReactNodeViewRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAA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AC,CAAC,EAAE,CAAC,CAAC,EAAE,EAC1C,MAAM,EACN,KAAU,EACV,EAAU,EACV,SAAc,GACf,EAAE,oBAAoB;IAiBvB;;OAEG;IACH,MAAM,IAAI,IAAI;IA6Bd;;OAEG;IACH,WAAW,CAAC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,IAAI;IASlD;;OAEG;IACH,OAAO,IAAI,IAAI;IAMf;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;CAK3D"}
|
package/dist/index.cjs
CHANGED
|
@@ -1301,16 +1301,9 @@ class ReactRenderer {
|
|
|
1301
1301
|
if (className) {
|
|
1302
1302
|
this.element.classList.add(...className.split(' '));
|
|
1303
1303
|
}
|
|
1304
|
-
|
|
1305
|
-
// On first render, we need to flush the render synchronously
|
|
1306
|
-
// Renders afterwards can be async, but this fixes a cursor positioning issue
|
|
1307
|
-
ReactDOM.flushSync(() => {
|
|
1308
|
-
this.render();
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
1311
|
-
else {
|
|
1304
|
+
queueMicrotask(() => {
|
|
1312
1305
|
this.render();
|
|
1313
|
-
}
|
|
1306
|
+
});
|
|
1314
1307
|
}
|
|
1315
1308
|
/**
|
|
1316
1309
|
* Render the React component.
|
|
@@ -1367,6 +1360,24 @@ class ReactRenderer {
|
|
|
1367
1360
|
}
|
|
1368
1361
|
|
|
1369
1362
|
class ReactNodeView extends core.NodeView {
|
|
1363
|
+
constructor(component, props, options) {
|
|
1364
|
+
super(component, props, options);
|
|
1365
|
+
if (!this.node.isLeaf) {
|
|
1366
|
+
if (this.options.contentDOMElementTag) {
|
|
1367
|
+
this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div');
|
|
1371
|
+
}
|
|
1372
|
+
this.contentDOMElement.dataset.nodeViewContentReact = '';
|
|
1373
|
+
this.contentDOMElement.dataset.nodeViewWrapper = '';
|
|
1374
|
+
// For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
|
|
1375
|
+
// With this fix it seems to work fine
|
|
1376
|
+
// See: https://github.com/ueberdosis/tiptap/issues/1197
|
|
1377
|
+
this.contentDOMElement.style.whiteSpace = 'inherit';
|
|
1378
|
+
this.dom.appendChild(this.contentDOMElement);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1370
1381
|
/**
|
|
1371
1382
|
* Setup the React component.
|
|
1372
1383
|
* Called on initialization.
|
|
@@ -1395,6 +1406,10 @@ class ReactNodeView extends core.NodeView {
|
|
|
1395
1406
|
const onDragStart = this.onDragStart.bind(this);
|
|
1396
1407
|
const nodeViewContentRef = element => {
|
|
1397
1408
|
if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
|
|
1409
|
+
// remove the nodeViewWrapper attribute from the element
|
|
1410
|
+
if (element.hasAttribute('data-node-view-wrapper')) {
|
|
1411
|
+
element.removeAttribute('data-node-view-wrapper');
|
|
1412
|
+
}
|
|
1398
1413
|
element.appendChild(this.contentDOMElement);
|
|
1399
1414
|
}
|
|
1400
1415
|
};
|
|
@@ -1406,22 +1421,6 @@ class ReactNodeView extends core.NodeView {
|
|
|
1406
1421
|
return (React__default.default.createElement(ReactNodeViewContext.Provider, { value: context }, React.createElement(Component, componentProps)));
|
|
1407
1422
|
});
|
|
1408
1423
|
ReactNodeViewProvider.displayName = 'ReactNodeView';
|
|
1409
|
-
if (this.node.isLeaf) {
|
|
1410
|
-
this.contentDOMElement = null;
|
|
1411
|
-
}
|
|
1412
|
-
else if (this.options.contentDOMElementTag) {
|
|
1413
|
-
this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
|
|
1414
|
-
}
|
|
1415
|
-
else {
|
|
1416
|
-
this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div');
|
|
1417
|
-
}
|
|
1418
|
-
if (this.contentDOMElement) {
|
|
1419
|
-
this.contentDOMElement.dataset.nodeViewContentReact = '';
|
|
1420
|
-
// For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
|
|
1421
|
-
// With this fix it seems to work fine
|
|
1422
|
-
// See: https://github.com/ueberdosis/tiptap/issues/1197
|
|
1423
|
-
this.contentDOMElement.style.whiteSpace = 'inherit';
|
|
1424
|
-
}
|
|
1425
1424
|
let as = this.node.isInline ? 'span' : 'div';
|
|
1426
1425
|
if (this.options.as) {
|
|
1427
1426
|
as = this.options.as;
|