@quadrats/react 0.5.3 → 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/core/components/Editable.d.ts +5 -1
- package/core/components/Quadrats.d.ts +5 -1
- package/core/index.d.ts +3 -2
- package/core/typings/descendant.d.ts +2 -0
- package/embed/toolbar/EmbedToolbarIcon.d.ts +2 -2
- package/package.json +1 -1
- package/toolbar/components/Toolbar.d.ts +5 -1
- package/toolbar/components/Toolbar.js +8 -1
- package/toolbar/index.cjs.js +8 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { EditableProps as SlateEditableProps } from 'slate-react/dist/components/editable';
|
|
3
|
-
|
|
3
|
+
import { RenderElementProps, RenderLeafProps } from '../typings/renderer';
|
|
4
|
+
export declare type EditableProps = Omit<SlateEditableProps, 'renderLeaf' | 'renderElement'> & {
|
|
5
|
+
renderLeaf?: (props: RenderLeafProps) => JSX.Element;
|
|
6
|
+
renderElement?: (props: RenderElementProps) => JSX.Element;
|
|
7
|
+
};
|
|
4
8
|
declare function Editable(props: EditableProps): JSX.Element;
|
|
5
9
|
export default Editable;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Slate } from 'slate-react';
|
|
3
3
|
import { ConfigsProviderProps } from '@quadrats/react/configs';
|
|
4
|
-
|
|
4
|
+
import { Descendant } from '..';
|
|
5
|
+
export declare type QuadratsProps = Pick<Parameters<typeof Slate>[0], 'children' | 'editor'> & Omit<ConfigsProviderProps, 'children'> & {
|
|
6
|
+
onChange: (value: Descendant[]) => void;
|
|
7
|
+
value: Descendant[];
|
|
8
|
+
};
|
|
5
9
|
/**
|
|
6
10
|
* Provide configs of quadrats and control the value.
|
|
7
11
|
*/
|
package/core/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QuadratsElement, QuadratsText } from '@quadrats/core';
|
|
2
2
|
import { ReactEditor } from 'slate-react';
|
|
3
3
|
export { useSlateStatic, useFocused, useReadOnly, useSelected, useSlate as useQuadrats, ReactEditor, } from 'slate-react';
|
|
4
4
|
export * from './typings/handler';
|
|
5
5
|
export * from './typings/renderer';
|
|
6
6
|
export * from './typings/with';
|
|
7
|
+
export * from './typings/descendant';
|
|
7
8
|
export { default as Editable, EditableProps } from './components/Editable';
|
|
8
9
|
export { default as DefaultElement } from './components/DefaultElement';
|
|
9
10
|
export { default as DefaultLeaf } from './components/DefaultLeaf';
|
|
@@ -17,7 +18,7 @@ export { createRenderElements } from './createRenderElements';
|
|
|
17
18
|
export { createRenderMark } from './createRenderMark';
|
|
18
19
|
declare module 'slate' {
|
|
19
20
|
interface CustomTypes {
|
|
20
|
-
Editor:
|
|
21
|
+
Editor: ReactEditor;
|
|
21
22
|
Element: QuadratsElement;
|
|
22
23
|
Text: QuadratsText;
|
|
23
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ReactEditor } from '@quadrats/react';
|
|
3
3
|
import { InputWidgetConfig } from '@quadrats/common/input-widget';
|
|
4
4
|
import { ReactEmbed } from '@quadrats/react/embed';
|
|
5
5
|
import { ToolbarIconProps } from '@quadrats/react/toolbar';
|
|
@@ -9,7 +9,7 @@ export interface EmbedToolbarIconProps<Provider extends string> extends Omit<Too
|
|
|
9
9
|
* The providers supported by this icon.
|
|
10
10
|
*/
|
|
11
11
|
providers: Provider[];
|
|
12
|
-
startToolInput?: (editor:
|
|
12
|
+
startToolInput?: (editor: ReactEditor, inputConfig: InputWidgetConfig) => void;
|
|
13
13
|
}
|
|
14
14
|
declare function EmbedToolbarIcon<Provider extends string>(props: EmbedToolbarIconProps<Provider>): JSX.Element;
|
|
15
15
|
export default EmbedToolbarIcon;
|
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" },
|