@quadrats/react 1.0.0 → 1.1.1
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/card/components/Card.js +83 -75
- package/card/index.cjs.js +82 -74
- package/carousel/components/Carousel.js +32 -28
- package/carousel/index.cjs.js +32 -28
- package/components/Tooltip/index.js +5 -2
- package/components/index.cjs.js +5 -2
- package/core/components/Quadrats.js +5 -2
- package/core/contexts/modal/CarouselModal/CarouselModal.js +14 -17
- package/embed/renderers/base/components/BaseEmbedElement.js +51 -43
- package/embed/renderers/base/index.cjs.js +50 -42
- package/image/components/Image.js +34 -26
- package/image/createReactImage.js +1 -1
- package/image/index.cjs.js +34 -26
- package/index.cjs.js +19 -19
- package/package.json +4 -4
- package/table/components/ColumnDragButton.d.ts +10 -0
- package/table/components/ColumnDragButton.js +41 -0
- package/table/components/RowDragButton.d.ts +10 -0
- package/table/components/RowDragButton.js +42 -0
- package/table/components/Table.d.ts +9 -0
- package/table/components/Table.js +236 -0
- package/table/components/TableBody.d.ts +5 -0
- package/table/components/TableBody.js +8 -0
- package/table/components/TableCell.d.ts +5 -0
- package/table/components/TableCell.js +297 -0
- package/table/components/TableDragLayer.d.ts +6 -0
- package/table/components/TableDragLayer.js +89 -0
- package/table/components/TableHeader.d.ts +5 -0
- package/table/components/TableHeader.js +13 -0
- package/table/components/TableMain.d.ts +5 -0
- package/table/components/TableMain.js +233 -0
- package/table/components/TableRow.d.ts +5 -0
- package/table/components/TableRow.js +8 -0
- package/table/components/TableTitle.d.ts +5 -0
- package/table/components/TableTitle.js +18 -0
- package/table/contexts/TableActionsContext.d.ts +3 -0
- package/table/contexts/TableActionsContext.js +5 -0
- package/table/contexts/TableDragContext.d.ts +26 -0
- package/table/contexts/TableDragContext.js +26 -0
- package/table/contexts/TableHeaderContext.d.ts +2 -0
- package/table/contexts/TableHeaderContext.js +7 -0
- package/table/contexts/TableMetadataContext.d.ts +3 -0
- package/table/contexts/TableMetadataContext.js +5 -0
- package/table/contexts/TableScrollContext.d.ts +2 -0
- package/table/contexts/TableScrollContext.js +9 -0
- package/table/contexts/TableStateContext.d.ts +3 -0
- package/table/contexts/TableStateContext.js +5 -0
- package/table/createReactTable.d.ts +4 -0
- package/table/createReactTable.js +297 -0
- package/table/defaultRenderTableElements.d.ts +2 -0
- package/table/defaultRenderTableElements.js +20 -0
- package/table/hooks/useColumnResize.d.ts +12 -0
- package/table/hooks/useColumnResize.js +168 -0
- package/table/hooks/useTableActions.d.ts +27 -0
- package/table/hooks/useTableActions.js +1092 -0
- package/table/hooks/useTableActionsContext.d.ts +1 -0
- package/table/hooks/useTableActionsContext.js +12 -0
- package/table/hooks/useTableCell.d.ts +16 -0
- package/table/hooks/useTableCell.js +166 -0
- package/table/hooks/useTableCellToolbarActions.d.ts +34 -0
- package/table/hooks/useTableCellToolbarActions.js +526 -0
- package/table/hooks/useTableMetadata.d.ts +1 -0
- package/table/hooks/useTableMetadata.js +12 -0
- package/table/hooks/useTableStateContext.d.ts +1 -0
- package/table/hooks/useTableStateContext.js +12 -0
- package/table/hooks/useTableStates.d.ts +18 -0
- package/table/hooks/useTableStates.js +14 -0
- package/table/index.cjs.js +4002 -0
- package/table/index.d.ts +16 -0
- package/table/index.js +27 -0
- package/table/jsx-serializer/components/Table.d.ts +3 -0
- package/table/jsx-serializer/components/Table.js +7 -0
- package/table/jsx-serializer/components/TableBody.d.ts +3 -0
- package/table/jsx-serializer/components/TableBody.js +7 -0
- package/table/jsx-serializer/components/TableCell.d.ts +5 -0
- package/table/jsx-serializer/components/TableCell.js +33 -0
- package/table/jsx-serializer/components/TableHeader.d.ts +3 -0
- package/table/jsx-serializer/components/TableHeader.js +10 -0
- package/table/jsx-serializer/components/TableMain.d.ts +6 -0
- package/table/jsx-serializer/components/TableMain.js +18 -0
- package/table/jsx-serializer/components/TableRow.d.ts +3 -0
- package/table/jsx-serializer/components/TableRow.js +7 -0
- package/table/jsx-serializer/components/TableTitle.d.ts +3 -0
- package/table/jsx-serializer/components/TableTitle.js +7 -0
- package/table/jsx-serializer/contexts/TableHeaderContext.d.ts +1 -0
- package/table/jsx-serializer/contexts/TableHeaderContext.js +5 -0
- package/table/jsx-serializer/contexts/TableScrollContext.d.ts +2 -0
- package/table/jsx-serializer/contexts/TableScrollContext.js +7 -0
- package/table/jsx-serializer/createJsxSerializeTable.d.ts +5 -0
- package/table/jsx-serializer/createJsxSerializeTable.js +113 -0
- package/table/jsx-serializer/defaultRenderTableElements.d.ts +2 -0
- package/table/jsx-serializer/defaultRenderTableElements.js +20 -0
- package/table/jsx-serializer/index.cjs.js +195 -0
- package/table/jsx-serializer/index.d.ts +3 -0
- package/table/jsx-serializer/index.js +2 -0
- package/table/jsx-serializer/package.json +7 -0
- package/table/jsx-serializer/typings.d.ts +12 -0
- package/table/package.json +10 -0
- package/table/table.css +1 -0
- package/table/table.scss +428 -0
- package/table/toolbar/TableToolbarIcon.d.ts +8 -0
- package/table/toolbar/TableToolbarIcon.js +12 -0
- package/table/toolbar/index.cjs.js +24 -0
- package/table/toolbar/index.d.ts +2 -0
- package/table/toolbar/index.js +2 -0
- package/table/toolbar/package.json +7 -0
- package/table/toolbar/useTableTool.d.ts +4 -0
- package/table/toolbar/useTableTool.js +13 -0
- package/table/typings.d.ts +68 -0
- package/table/utils/helper.d.ts +186 -0
- package/table/utils/helper.js +799 -0
- package/toolbar/components/InlineToolbar.d.ts +12 -11
- package/toolbar/components/InlineToolbar.js +23 -19
- package/toolbar/components/Toolbar.js +2 -2
- package/toolbar/index.cjs.js +24 -21
- package/toolbar/toolbar.css +1 -1
- package/toolbar/toolbar.scss +4 -1
- package/utils/index.cjs.js +7 -1
- package/utils/removePreviousElement.js +7 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Transforms } from '@quadrats/core';
|
|
3
|
-
import {
|
|
3
|
+
import { AlignLeft, AlignCenter, AlignRight, Edit, Trash } from '@quadrats/icons';
|
|
4
4
|
import { useModal, useSlateStatic, ReactEditor } from '@quadrats/react';
|
|
5
5
|
import { InlineToolbar } from '@quadrats/react/toolbar';
|
|
6
6
|
|
|
@@ -11,50 +11,58 @@ const BaseEmbedElement = ({ element, haveAlignConfig = true, type = 'input', pla
|
|
|
11
11
|
const { setEmbedModalConfig } = useModal();
|
|
12
12
|
const editor = useSlateStatic();
|
|
13
13
|
const path = ReactEditor.findPath(editor, element);
|
|
14
|
-
return (React.createElement("div", { className: "qdr-embed" }, children(React.createElement(InlineToolbar, { className: "qdr-embed__inline-toolbar",
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
onClick: () => {
|
|
26
|
-
Transforms.setNodes(editor, { align: 'center' }, { at: path });
|
|
27
|
-
},
|
|
28
|
-
active: element.align === 'center',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
icon: AlignRight,
|
|
32
|
-
onClick: () => {
|
|
33
|
-
Transforms.setNodes(editor, { align: 'right' }, { at: path });
|
|
34
|
-
},
|
|
35
|
-
active: element.align === 'right',
|
|
36
|
-
},
|
|
37
|
-
]
|
|
38
|
-
: [], rightIcons: [
|
|
39
|
-
{
|
|
40
|
-
icon: Edit,
|
|
41
|
-
onClick: () => {
|
|
42
|
-
setEmbedModalConfig({
|
|
43
|
-
placeholder: placeholder || '',
|
|
44
|
-
confirmText: confirmText || '',
|
|
45
|
-
hint: hint || '',
|
|
46
|
-
type,
|
|
47
|
-
onConfirm: (value) => {
|
|
48
|
-
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(editor, path, value);
|
|
14
|
+
return (React.createElement("div", { className: "qdr-embed" }, children(React.createElement(InlineToolbar, { className: "qdr-embed__inline-toolbar", iconGroups: [
|
|
15
|
+
haveAlignConfig
|
|
16
|
+
? {
|
|
17
|
+
enabledBgColor: true,
|
|
18
|
+
icons: [
|
|
19
|
+
{
|
|
20
|
+
icon: AlignLeft,
|
|
21
|
+
onClick: () => {
|
|
22
|
+
Transforms.setNodes(editor, { align: 'left' }, { at: path });
|
|
23
|
+
},
|
|
24
|
+
active: element.align === 'left' || !element.align,
|
|
49
25
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
{
|
|
27
|
+
icon: AlignCenter,
|
|
28
|
+
onClick: () => {
|
|
29
|
+
Transforms.setNodes(editor, { align: 'center' }, { at: path });
|
|
30
|
+
},
|
|
31
|
+
active: element.align === 'center',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
icon: AlignRight,
|
|
35
|
+
onClick: () => {
|
|
36
|
+
Transforms.setNodes(editor, { align: 'right' }, { at: path });
|
|
37
|
+
},
|
|
38
|
+
active: element.align === 'right',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}
|
|
42
|
+
: { icons: [] },
|
|
53
43
|
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
icons: [
|
|
45
|
+
{
|
|
46
|
+
icon: Edit,
|
|
47
|
+
onClick: () => {
|
|
48
|
+
setEmbedModalConfig({
|
|
49
|
+
placeholder: placeholder || '',
|
|
50
|
+
confirmText: confirmText || '',
|
|
51
|
+
hint: hint || '',
|
|
52
|
+
type,
|
|
53
|
+
onConfirm: (value) => {
|
|
54
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(editor, path, value);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
icon: Trash,
|
|
61
|
+
onClick: () => {
|
|
62
|
+
Transforms.removeNodes(editor, { at: path });
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
58
66
|
},
|
|
59
67
|
] }))));
|
|
60
68
|
};
|
|
@@ -13,50 +13,58 @@ const BaseEmbedElement = ({ element, haveAlignConfig = true, type = 'input', pla
|
|
|
13
13
|
const { setEmbedModalConfig } = react.useModal();
|
|
14
14
|
const editor = react.useSlateStatic();
|
|
15
15
|
const path = react.ReactEditor.findPath(editor, element);
|
|
16
|
-
return (React.createElement("div", { className: "qdr-embed" }, children(React.createElement(toolbar.InlineToolbar, { className: "qdr-embed__inline-toolbar",
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onClick: () => {
|
|
28
|
-
core.Transforms.setNodes(editor, { align: 'center' }, { at: path });
|
|
29
|
-
},
|
|
30
|
-
active: element.align === 'center',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
icon: icons.AlignRight,
|
|
34
|
-
onClick: () => {
|
|
35
|
-
core.Transforms.setNodes(editor, { align: 'right' }, { at: path });
|
|
36
|
-
},
|
|
37
|
-
active: element.align === 'right',
|
|
38
|
-
},
|
|
39
|
-
]
|
|
40
|
-
: [], rightIcons: [
|
|
41
|
-
{
|
|
42
|
-
icon: icons.Edit,
|
|
43
|
-
onClick: () => {
|
|
44
|
-
setEmbedModalConfig({
|
|
45
|
-
placeholder: placeholder || '',
|
|
46
|
-
confirmText: confirmText || '',
|
|
47
|
-
hint: hint || '',
|
|
48
|
-
type,
|
|
49
|
-
onConfirm: (value) => {
|
|
50
|
-
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(editor, path, value);
|
|
16
|
+
return (React.createElement("div", { className: "qdr-embed" }, children(React.createElement(toolbar.InlineToolbar, { className: "qdr-embed__inline-toolbar", iconGroups: [
|
|
17
|
+
haveAlignConfig
|
|
18
|
+
? {
|
|
19
|
+
enabledBgColor: true,
|
|
20
|
+
icons: [
|
|
21
|
+
{
|
|
22
|
+
icon: icons.AlignLeft,
|
|
23
|
+
onClick: () => {
|
|
24
|
+
core.Transforms.setNodes(editor, { align: 'left' }, { at: path });
|
|
25
|
+
},
|
|
26
|
+
active: element.align === 'left' || !element.align,
|
|
51
27
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
28
|
+
{
|
|
29
|
+
icon: icons.AlignCenter,
|
|
30
|
+
onClick: () => {
|
|
31
|
+
core.Transforms.setNodes(editor, { align: 'center' }, { at: path });
|
|
32
|
+
},
|
|
33
|
+
active: element.align === 'center',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
icon: icons.AlignRight,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
core.Transforms.setNodes(editor, { align: 'right' }, { at: path });
|
|
39
|
+
},
|
|
40
|
+
active: element.align === 'right',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}
|
|
44
|
+
: { icons: [] },
|
|
55
45
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
icons: [
|
|
47
|
+
{
|
|
48
|
+
icon: icons.Edit,
|
|
49
|
+
onClick: () => {
|
|
50
|
+
setEmbedModalConfig({
|
|
51
|
+
placeholder: placeholder || '',
|
|
52
|
+
confirmText: confirmText || '',
|
|
53
|
+
hint: hint || '',
|
|
54
|
+
type,
|
|
55
|
+
onConfirm: (value) => {
|
|
56
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(editor, path, value);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
icon: icons.Trash,
|
|
63
|
+
onClick: () => {
|
|
64
|
+
core.Transforms.removeNodes(editor, { at: path });
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
60
68
|
},
|
|
61
69
|
] }))));
|
|
62
70
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Editor, Element, Transforms } from '@quadrats/core';
|
|
3
|
-
import {
|
|
3
|
+
import { AlignLeft, AlignCenter, AlignRight, Trash } from '@quadrats/icons';
|
|
4
4
|
import { useSlateStatic, ReactEditor } from '@quadrats/react';
|
|
5
5
|
import { InlineToolbar } from '@quadrats/react/toolbar';
|
|
6
6
|
|
|
@@ -22,34 +22,42 @@ function Image(props) {
|
|
|
22
22
|
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-image qdr-image--with-inline-toolbar", onClick: () => Transforms.select(editor, ReactEditor.findPath(editor, element)), onMouseDown: (event) => event.preventDefault(), role: "img" }),
|
|
23
23
|
React.createElement("div", { className: "qdr-image__spacer" }, children),
|
|
24
24
|
React.createElement("div", { contentEditable: false, style: { position: 'relative' } },
|
|
25
|
-
React.createElement(InlineToolbar, { className: "qdr-image__inline-toolbar",
|
|
25
|
+
React.createElement(InlineToolbar, { className: "qdr-image__inline-toolbar", iconGroups: [
|
|
26
26
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
enabledBgColor: true,
|
|
28
|
+
icons: [
|
|
29
|
+
{
|
|
30
|
+
icon: AlignLeft,
|
|
31
|
+
onClick: () => {
|
|
32
|
+
Transforms.setNodes(editor, { align: 'start' }, { at: parentPath });
|
|
33
|
+
},
|
|
34
|
+
active: parentNode.align === 'start' || !parentNode.align,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
icon: AlignCenter,
|
|
38
|
+
onClick: () => {
|
|
39
|
+
Transforms.setNodes(editor, { align: 'center' }, { at: parentPath });
|
|
40
|
+
},
|
|
41
|
+
active: parentNode.align === 'center',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
icon: AlignRight,
|
|
45
|
+
onClick: () => {
|
|
46
|
+
Transforms.setNodes(editor, { align: 'end' }, { at: parentPath });
|
|
47
|
+
},
|
|
48
|
+
active: parentNode.align === 'end',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
32
51
|
},
|
|
33
52
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onClick: () => {
|
|
43
|
-
Transforms.setNodes(editor, { align: 'end' }, { at: parentPath });
|
|
44
|
-
},
|
|
45
|
-
active: parentNode.align === 'end',
|
|
46
|
-
},
|
|
47
|
-
], rightIcons: [
|
|
48
|
-
{
|
|
49
|
-
icon: Trash,
|
|
50
|
-
onClick: () => {
|
|
51
|
-
Transforms.removeNodes(editor, { at: parentPath });
|
|
52
|
-
},
|
|
53
|
+
icons: [
|
|
54
|
+
{
|
|
55
|
+
icon: Trash,
|
|
56
|
+
onClick: () => {
|
|
57
|
+
Transforms.removeNodes(editor, { at: parentPath });
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
53
61
|
},
|
|
54
62
|
] }),
|
|
55
63
|
React.createElement("img", {
|
|
@@ -101,7 +101,7 @@ function createReactImage(options = {}, getUploadOptions) {
|
|
|
101
101
|
})
|
|
102
102
|
.reduce((prev, imageFile) => __awaiter(this, void 0, void 0, function* () {
|
|
103
103
|
yield prev;
|
|
104
|
-
return readFileAsDataURL(imageFile).then(dataURL => core.insertImage(editor, dataURL));
|
|
104
|
+
return readFileAsDataURL(imageFile).then((dataURL) => core.insertImage(editor, dataURL));
|
|
105
105
|
}), Promise.resolve());
|
|
106
106
|
return;
|
|
107
107
|
}
|
package/image/index.cjs.js
CHANGED
|
@@ -41,34 +41,42 @@ function Image(props) {
|
|
|
41
41
|
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-image qdr-image--with-inline-toolbar", onClick: () => core.Transforms.select(editor, react.ReactEditor.findPath(editor, element)), onMouseDown: (event) => event.preventDefault(), role: "img" }),
|
|
42
42
|
React.createElement("div", { className: "qdr-image__spacer" }, children),
|
|
43
43
|
React.createElement("div", { contentEditable: false, style: { position: 'relative' } },
|
|
44
|
-
React.createElement(toolbar.InlineToolbar, { className: "qdr-image__inline-toolbar",
|
|
44
|
+
React.createElement(toolbar.InlineToolbar, { className: "qdr-image__inline-toolbar", iconGroups: [
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
enabledBgColor: true,
|
|
47
|
+
icons: [
|
|
48
|
+
{
|
|
49
|
+
icon: icons.AlignLeft,
|
|
50
|
+
onClick: () => {
|
|
51
|
+
core.Transforms.setNodes(editor, { align: 'start' }, { at: parentPath });
|
|
52
|
+
},
|
|
53
|
+
active: parentNode.align === 'start' || !parentNode.align,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
icon: icons.AlignCenter,
|
|
57
|
+
onClick: () => {
|
|
58
|
+
core.Transforms.setNodes(editor, { align: 'center' }, { at: parentPath });
|
|
59
|
+
},
|
|
60
|
+
active: parentNode.align === 'center',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
icon: icons.AlignRight,
|
|
64
|
+
onClick: () => {
|
|
65
|
+
core.Transforms.setNodes(editor, { align: 'end' }, { at: parentPath });
|
|
66
|
+
},
|
|
67
|
+
active: parentNode.align === 'end',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
51
70
|
},
|
|
52
71
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
onClick: () => {
|
|
62
|
-
core.Transforms.setNodes(editor, { align: 'end' }, { at: parentPath });
|
|
63
|
-
},
|
|
64
|
-
active: parentNode.align === 'end',
|
|
65
|
-
},
|
|
66
|
-
], rightIcons: [
|
|
67
|
-
{
|
|
68
|
-
icon: icons.Trash,
|
|
69
|
-
onClick: () => {
|
|
70
|
-
core.Transforms.removeNodes(editor, { at: parentPath });
|
|
71
|
-
},
|
|
72
|
+
icons: [
|
|
73
|
+
{
|
|
74
|
+
icon: icons.Trash,
|
|
75
|
+
onClick: () => {
|
|
76
|
+
core.Transforms.removeNodes(editor, { at: parentPath });
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
72
80
|
},
|
|
73
81
|
] }),
|
|
74
82
|
React.createElement("img", {
|
|
@@ -290,7 +298,7 @@ function createReactImage(options = {}, getUploadOptions) {
|
|
|
290
298
|
})
|
|
291
299
|
.reduce((prev, imageFile) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
292
300
|
yield prev;
|
|
293
|
-
return utils.readFileAsDataURL(imageFile).then(dataURL => core$1.insertImage(editor, dataURL));
|
|
301
|
+
return utils.readFileAsDataURL(imageFile).then((dataURL) => core$1.insertImage(editor, dataURL));
|
|
294
302
|
}), Promise.resolve());
|
|
295
303
|
return;
|
|
296
304
|
}
|
package/index.cjs.js
CHANGED
|
@@ -7,9 +7,9 @@ var tslib = require('tslib');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var slate = require('slate');
|
|
9
9
|
var clsx = require('clsx');
|
|
10
|
-
var components = require('@quadrats/react/components');
|
|
11
|
-
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
12
10
|
var reactDnd = require('react-dnd');
|
|
11
|
+
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
12
|
+
var components = require('@quadrats/react/components');
|
|
13
13
|
var icons = require('@quadrats/icons');
|
|
14
14
|
var utils = require('@quadrats/react/utils');
|
|
15
15
|
var _internal = require('@quadrats/react/_internal');
|
|
@@ -366,21 +366,20 @@ const CarouselModal = ({ isOpen, close, controller, initialValue = [], onConfirm
|
|
|
366
366
|
}, 0);
|
|
367
367
|
}
|
|
368
368
|
} },
|
|
369
|
-
React.createElement(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
React.createElement("div", { className: "qdr-carousel-
|
|
378
|
-
React.createElement(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
: `僅能上傳 ${acceptText};檔案大小不可超過 ${controller === null || controller === void 0 ? void 0 : controller.limitSize}MB`))))))));
|
|
369
|
+
React.createElement(FilesDropZone, { isDragging: isDragging, setIsDragging: setIsDragging, isOverMaxLength: isOverMaxLength, controller: controller, uploadFiles: uploadFiles }, items.length > 0 ? (React.createElement("div", { className: clsx('qdr-carousel-modal__grid', {
|
|
370
|
+
'qdr-carousel-modal__grid--isDragging': isDragging,
|
|
371
|
+
}) }, items.map((item, index) => (React.createElement(CarouselItem, { key: `${item.url}-${item.caption || ''}-${index}`, url: item.url, preview: item.preview, progress: item.progress, caption: item.caption, index: index, ratio: controller === null || controller === void 0 ? void 0 : controller.ratio, isError: item.isError, onChange: (value) => {
|
|
372
|
+
change(index, { url: item.url, caption: value });
|
|
373
|
+
}, onRemove: () => {
|
|
374
|
+
remove(index);
|
|
375
|
+
}, swap: swap }))))) : (React.createElement("div", { className: "qdr-carousel-modal__placeholder" },
|
|
376
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__block" },
|
|
377
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__icon" },
|
|
378
|
+
React.createElement(components.Icon, { icon: icons.Upload, width: 32, height: 32 })),
|
|
379
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__title" }, "\u62D6\u66F3\u6A94\u6848\u5230\u6B64\u4E0A\u50B3"),
|
|
380
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__hint" }, (controller === null || controller === void 0 ? void 0 : controller.ratio)
|
|
381
|
+
? `僅能上傳 ${acceptText};建議比例為 ${controller.ratio[0]}:${controller.ratio[1]} 且寬度至少達 2000px 以上;檔案大小不可超過 ${controller === null || controller === void 0 ? void 0 : controller.limitSize}MB`
|
|
382
|
+
: `僅能上傳 ${acceptText};檔案大小不可超過 ${controller === null || controller === void 0 ? void 0 : controller.limitSize}MB`)))))));
|
|
384
383
|
};
|
|
385
384
|
|
|
386
385
|
const options = [
|
|
@@ -601,8 +600,9 @@ function Quadrats(props) {
|
|
|
601
600
|
const { children, editor, locale, onChange, theme, value, needConfirmModal, setNeedConfirmModal } = props;
|
|
602
601
|
return (React.createElement(configs.ConfigsProvider, { theme: theme, locale: locale },
|
|
603
602
|
React.createElement(slateReact.Slate, { editor: editor, onChange: onChange, initialValue: value },
|
|
604
|
-
React.createElement(
|
|
605
|
-
React.createElement(
|
|
603
|
+
React.createElement(reactDnd.DndProvider, { backend: reactDndHtml5Backend.HTML5Backend },
|
|
604
|
+
React.createElement(MessageProvider, null,
|
|
605
|
+
React.createElement(ModalProvider, { needConfirmModal: needConfirmModal, setNeedConfirmModal: setNeedConfirmModal }, children))))));
|
|
606
606
|
}
|
|
607
607
|
|
|
608
608
|
function createEventHandler(editor, handlers) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadrats/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Rytass",
|
|
6
6
|
"homepage": "https://github.com/Quadrats/quadrats#readme",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"url": "https://github.com/Quadrats/quadrats/issues"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@quadrats/common": "^1.
|
|
24
|
-
"@quadrats/core": "^1.
|
|
25
|
-
"@quadrats/icons": "^1.
|
|
23
|
+
"@quadrats/common": "^1.1.1",
|
|
24
|
+
"@quadrats/core": "^1.1.0",
|
|
25
|
+
"@quadrats/icons": "^1.1.1",
|
|
26
26
|
"@quadrats/locales": "^1.0.0",
|
|
27
27
|
"@quadrats/theme": "^1.0.0",
|
|
28
28
|
"@quadrats/utils": "^1.0.0",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ColumnDragButtonProps {
|
|
3
|
+
columnIndex: number;
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
onClick: (e: React.MouseEvent) => void;
|
|
6
|
+
checkIsTitleColumn: (columnIndex: number) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const COLUMN_DRAG_TYPE = "TABLE_COLUMN";
|
|
9
|
+
export declare const ColumnDragButton: React.FC<ColumnDragButtonProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { useDrag } from 'react-dnd';
|
|
3
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { Icon } from '@quadrats/react/components';
|
|
6
|
+
import { Drag } from '@quadrats/icons';
|
|
7
|
+
import { useTableDragContext } from '../contexts/TableDragContext.js';
|
|
8
|
+
|
|
9
|
+
const COLUMN_DRAG_TYPE = 'TABLE_COLUMN';
|
|
10
|
+
const ColumnDragButton = ({ columnIndex, style, onClick, checkIsTitleColumn, }) => {
|
|
11
|
+
const buttonRef = useRef(null);
|
|
12
|
+
const { setDragState, setDropTargetIndex, setDragDirection } = useTableDragContext();
|
|
13
|
+
const isTitle = checkIsTitleColumn(columnIndex);
|
|
14
|
+
const [{ isDragging }, drag, preview] = useDrag(() => ({
|
|
15
|
+
type: COLUMN_DRAG_TYPE,
|
|
16
|
+
item: () => {
|
|
17
|
+
const dragItem = { columnIndex, isTitle };
|
|
18
|
+
setDragState({ type: 'column', columnIndex, isTitle });
|
|
19
|
+
return dragItem;
|
|
20
|
+
},
|
|
21
|
+
collect: (monitor) => ({
|
|
22
|
+
isDragging: monitor.isDragging(),
|
|
23
|
+
}),
|
|
24
|
+
end: () => {
|
|
25
|
+
setDragState(null);
|
|
26
|
+
setDropTargetIndex(null);
|
|
27
|
+
setDragDirection(null);
|
|
28
|
+
},
|
|
29
|
+
}), [columnIndex, isTitle, setDragState, setDropTargetIndex, setDragDirection]);
|
|
30
|
+
// 使用空白圖片作為 drag preview,避免顯示預設的拖曳圖像
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
preview(getEmptyImage(), { captureDraggingState: true });
|
|
33
|
+
}, [preview]);
|
|
34
|
+
drag(buttonRef);
|
|
35
|
+
return (React.createElement("button", { ref: buttonRef, type: "button", contentEditable: false, style: style, onClick: onClick, title: "\u9EDE\u64CA\u958B\u555F\u9078\u55AE\uFF0C\u62D6\u66F3\u4EE5\u79FB\u52D5", className: clsx('qdr-table__cell-column-action', {
|
|
36
|
+
'qdr-table__cell-column-action--dragging': isDragging,
|
|
37
|
+
}) },
|
|
38
|
+
React.createElement(Icon, { icon: Drag, width: 20, height: 20 })));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { COLUMN_DRAG_TYPE, ColumnDragButton };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RowDragButtonProps {
|
|
3
|
+
rowIndex: number;
|
|
4
|
+
headerRowCount: number;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
onClick: (e: React.MouseEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ROW_DRAG_TYPE = "TABLE_ROW";
|
|
9
|
+
export declare const RowDragButton: React.FC<RowDragButtonProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { useDrag } from 'react-dnd';
|
|
3
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { Icon } from '@quadrats/react/components';
|
|
6
|
+
import { Drag } from '@quadrats/icons';
|
|
7
|
+
import { useTableDragContext } from '../contexts/TableDragContext.js';
|
|
8
|
+
|
|
9
|
+
const ROW_DRAG_TYPE = 'TABLE_ROW';
|
|
10
|
+
const RowDragButton = ({ rowIndex, headerRowCount, style, onClick }) => {
|
|
11
|
+
const buttonRef = useRef(null);
|
|
12
|
+
const { setDragState, setDropTargetIndex, setDragDirection } = useTableDragContext();
|
|
13
|
+
// 判斷當前 row 是否在 header 中
|
|
14
|
+
const isInHeader = rowIndex < headerRowCount;
|
|
15
|
+
const [{ isDragging }, drag, preview] = useDrag(() => ({
|
|
16
|
+
type: ROW_DRAG_TYPE,
|
|
17
|
+
item: () => {
|
|
18
|
+
const dragItem = { rowIndex, isInHeader };
|
|
19
|
+
setDragState({ type: 'row', rowIndex, isInHeader });
|
|
20
|
+
return dragItem;
|
|
21
|
+
},
|
|
22
|
+
collect: (monitor) => ({
|
|
23
|
+
isDragging: monitor.isDragging(),
|
|
24
|
+
}),
|
|
25
|
+
end: () => {
|
|
26
|
+
setDragState(null);
|
|
27
|
+
setDropTargetIndex(null);
|
|
28
|
+
setDragDirection(null);
|
|
29
|
+
},
|
|
30
|
+
}), [rowIndex, isInHeader, setDragState, setDropTargetIndex, setDragDirection]);
|
|
31
|
+
// 使用空白圖片作為 drag preview,避免顯示預設的拖曳圖像
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
preview(getEmptyImage(), { captureDraggingState: true });
|
|
34
|
+
}, [preview]);
|
|
35
|
+
drag(buttonRef);
|
|
36
|
+
return (React.createElement("button", { ref: buttonRef, type: "button", contentEditable: false, style: style, onClick: onClick, title: "\u9EDE\u64CA\u958B\u555F\u9078\u55AE\uFF0C\u62D6\u66F3\u4EE5\u79FB\u52D5", className: clsx('qdr-table__cell-row-action', {
|
|
37
|
+
'qdr-table__cell-row-action--dragging': isDragging,
|
|
38
|
+
}) },
|
|
39
|
+
React.createElement(Icon, { icon: Drag, width: 20, height: 20 })));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { ROW_DRAG_TYPE, RowDragButton };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderElementProps } from '@quadrats/react';
|
|
3
|
+
import { RenderTableElementProps } from '../typings';
|
|
4
|
+
declare function Table({ attributes, children, element, }: {
|
|
5
|
+
attributes?: RenderElementProps['attributes'];
|
|
6
|
+
children: RenderElementProps['children'];
|
|
7
|
+
element: RenderTableElementProps['element'];
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export default Table;
|