@quadrats/react 0.5.6 → 0.5.7
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface ToolbarProps {
|
|
3
3
|
/**
|
|
4
4
|
* If there are any nodes which type match it, toolbar will hide.
|
|
@@ -8,6 +8,10 @@ export interface ToolbarProps {
|
|
|
8
8
|
* A render props which provide a flag `expanded` which useful for rendering different things between collapsed and expanded.
|
|
9
9
|
*/
|
|
10
10
|
children: (expanded: boolean) => JSX.Element | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Toolbar container
|
|
13
|
+
*/
|
|
14
|
+
containerRef?: React.MutableRefObject<HTMLElement | undefined>;
|
|
11
15
|
}
|
|
12
16
|
declare function Toolbar(props: ToolbarProps): JSX.Element | null;
|
|
13
17
|
export default Toolbar;
|
|
@@ -80,6 +80,13 @@ function Toolbar(props) {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
+
const getPortalContainer = useCallback(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
if ((_a = props.containerRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
86
|
+
return props.containerRef.current;
|
|
87
|
+
}
|
|
88
|
+
return document.body;
|
|
89
|
+
}, [props.containerRef]);
|
|
83
90
|
if (!shouldRender || (disabledElementTypes && isNodesTypeIn(editor, disabledElementTypes, { mode: 'all' }))) {
|
|
84
91
|
return null;
|
|
85
92
|
}
|
|
@@ -88,7 +95,7 @@ function Toolbar(props) {
|
|
|
88
95
|
if (!tools) {
|
|
89
96
|
return null;
|
|
90
97
|
}
|
|
91
|
-
return (React.createElement(Portal,
|
|
98
|
+
return (React.createElement(Portal, { getContainer: getPortalContainer },
|
|
92
99
|
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
93
100
|
React.createElement("div", { className: "qdr-toolbar__arrow" }),
|
|
94
101
|
React.createElement("div", { className: "qdr-toolbar" },
|
package/toolbar/index.cjs.js
CHANGED
|
@@ -120,6 +120,13 @@ function Toolbar(props) {
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
|
+
const getPortalContainer = React.useCallback(() => {
|
|
124
|
+
var _a;
|
|
125
|
+
if ((_a = props.containerRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
126
|
+
return props.containerRef.current;
|
|
127
|
+
}
|
|
128
|
+
return document.body;
|
|
129
|
+
}, [props.containerRef]);
|
|
123
130
|
if (!shouldRender || (disabledElementTypes && core.isNodesTypeIn(editor, disabledElementTypes, { mode: 'all' }))) {
|
|
124
131
|
return null;
|
|
125
132
|
}
|
|
@@ -128,7 +135,7 @@ function Toolbar(props) {
|
|
|
128
135
|
if (!tools) {
|
|
129
136
|
return null;
|
|
130
137
|
}
|
|
131
|
-
return (React__default.createElement(components.Portal,
|
|
138
|
+
return (React__default.createElement(components.Portal, { getContainer: getPortalContainer },
|
|
132
139
|
React__default.createElement("div", { ref: toolbarRef, className: clsx__default('qdr-toolbar__wrapper', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
133
140
|
React__default.createElement("div", { className: "qdr-toolbar__arrow" }),
|
|
134
141
|
React__default.createElement("div", { className: "qdr-toolbar" },
|