@textbus/adapter-react 4.0.0-alpha.35 → 4.0.0-alpha.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,7 +56,10 @@ class Adapter extends DomAdapter {
56
56
  }
57
57
  });
58
58
  useEffect(() => {
59
- this.componentRendingStack.pop();
59
+ const context = this.componentRendingStack[this.componentRendingStack.length - 1];
60
+ if (context === component) {
61
+ this.componentRendingStack.pop();
62
+ }
60
63
  if (!this.componentRootElementCaches.get(component)) {
61
64
  // eslint-disable-next-line max-len
62
65
  throw adapterError(`Component \`${component.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
@@ -78,8 +81,15 @@ class Adapter extends DomAdapter {
78
81
  throw adapterError(`cannot found view component \`${component.name}\`!`);
79
82
  }
80
83
  slotRender(slot, slotHostRender, renderEnv) {
84
+ var _a;
81
85
  const context = this.componentRendingStack[this.componentRendingStack.length - 1];
82
- context.__slots__.push(slot);
86
+ if (context) {
87
+ context.__slots__.push(slot);
88
+ }
89
+ else if (!this.renderedSlotCache.has(slot)) {
90
+ throw adapterError(`Unrendered slots must be rendered together with the corresponding "${((_a = slot.parent) === null || _a === void 0 ? void 0 : _a.name) || 'unknown'}" component`);
91
+ }
92
+ this.renderedSlotCache.set(slot, true);
83
93
  const vElement = slot.toTree(slotHostRender, renderEnv);
84
94
  this.slotRootVElementCaches.set(slot, vElement);
85
95
  const vNodeToJSX = (vNode) => {
package/bundles/index.js CHANGED
@@ -58,7 +58,10 @@ class Adapter extends platformBrowser.DomAdapter {
58
58
  }
59
59
  });
60
60
  react.useEffect(() => {
61
- this.componentRendingStack.pop();
61
+ const context = this.componentRendingStack[this.componentRendingStack.length - 1];
62
+ if (context === component) {
63
+ this.componentRendingStack.pop();
64
+ }
62
65
  if (!this.componentRootElementCaches.get(component)) {
63
66
  // eslint-disable-next-line max-len
64
67
  throw adapterError(`Component \`${component.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
@@ -80,8 +83,15 @@ class Adapter extends platformBrowser.DomAdapter {
80
83
  throw adapterError(`cannot found view component \`${component.name}\`!`);
81
84
  }
82
85
  slotRender(slot, slotHostRender, renderEnv) {
86
+ var _a;
83
87
  const context = this.componentRendingStack[this.componentRendingStack.length - 1];
84
- context.__slots__.push(slot);
88
+ if (context) {
89
+ context.__slots__.push(slot);
90
+ }
91
+ else if (!this.renderedSlotCache.has(slot)) {
92
+ throw adapterError(`Unrendered slots must be rendered together with the corresponding "${((_a = slot.parent) === null || _a === void 0 ? void 0 : _a.name) || 'unknown'}" component`);
93
+ }
94
+ this.renderedSlotCache.set(slot, true);
85
95
  const vElement = slot.toTree(slotHostRender, renderEnv);
86
96
  this.slotRootVElementCaches.set(slot, vElement);
87
97
  const vNodeToJSX = (vNode) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/adapter-react",
3
- "version": "4.0.0-alpha.35",
3
+ "version": "4.0.0-alpha.37",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -26,8 +26,8 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@tanbo/stream": "^1.2.3",
29
- "@textbus/core": "^4.0.0-alpha.35",
30
- "@textbus/platform-browser": "^4.0.0-alpha.35",
29
+ "@textbus/core": "^4.0.0-alpha.37",
30
+ "@textbus/platform-browser": "^4.0.0-alpha.37",
31
31
  "react": "^17.0.0 || ^18.0.0"
32
32
  },
33
33
  "devDependencies": {
@@ -49,5 +49,5 @@
49
49
  "bugs": {
50
50
  "url": "https://github.com/textbus/textbus.git/issues"
51
51
  },
52
- "gitHead": "a50ac82617ef249feadbe926bae178912ed9a310"
52
+ "gitHead": "7a67eda8ef99b52bbc356002ca3396d64b6c1e89"
53
53
  }