@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
package/card/components/Card.js
CHANGED
|
@@ -3,93 +3,101 @@ import clsx from 'clsx';
|
|
|
3
3
|
import { Transforms } from '@quadrats/core';
|
|
4
4
|
import { useModal, useSlateStatic, ReactEditor } from '@quadrats/react';
|
|
5
5
|
import { InlineToolbar } from '@quadrats/react/toolbar';
|
|
6
|
-
import {
|
|
6
|
+
import { BlockLeft, BlockRight, Edit, Trash } from '@quadrats/icons';
|
|
7
7
|
|
|
8
8
|
function Card({ attributes, children, element, controller, }) {
|
|
9
9
|
const { setCardModalConfig, setConfirmModalConfig } = useModal();
|
|
10
10
|
const editor = useSlateStatic();
|
|
11
11
|
const path = ReactEditor.findPath(editor, element);
|
|
12
12
|
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: clsx('qdr-card', `qdr-card--${element.alignment}`) }),
|
|
13
|
-
React.createElement(InlineToolbar, { className: "qdr-card__inline-toolbar",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
icon: BlockRight,
|
|
29
|
-
onClick: () => {
|
|
30
|
-
controller.updateCardAlignment({
|
|
31
|
-
editor,
|
|
32
|
-
alignment: 'rightImageLeftText',
|
|
33
|
-
path,
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
active: element.alignment === 'rightImageLeftText',
|
|
37
|
-
},
|
|
38
|
-
], rightIcons: [
|
|
39
|
-
{
|
|
40
|
-
icon: Edit,
|
|
41
|
-
onClick: () => {
|
|
42
|
-
setCardModalConfig({
|
|
43
|
-
controller,
|
|
44
|
-
initialValue: {
|
|
45
|
-
values: {
|
|
46
|
-
alignment: element.alignment,
|
|
47
|
-
title: element.title,
|
|
48
|
-
description: element.description,
|
|
49
|
-
remark: element.remark,
|
|
50
|
-
linkText: element.linkText,
|
|
51
|
-
linkUrl: element.linkUrl,
|
|
13
|
+
React.createElement(InlineToolbar, { className: "qdr-card__inline-toolbar", iconGroups: [
|
|
14
|
+
element.alignment === 'noImage'
|
|
15
|
+
? { icons: [] }
|
|
16
|
+
: {
|
|
17
|
+
enabledBgColor: true,
|
|
18
|
+
icons: [
|
|
19
|
+
{
|
|
20
|
+
icon: BlockLeft,
|
|
21
|
+
onClick: () => {
|
|
22
|
+
controller.updateCardAlignment({
|
|
23
|
+
editor,
|
|
24
|
+
alignment: 'leftImageRightText',
|
|
25
|
+
path,
|
|
26
|
+
});
|
|
52
27
|
},
|
|
53
|
-
|
|
54
|
-
haveLink: element.haveLink,
|
|
28
|
+
active: element.alignment === 'leftImageRightText',
|
|
55
29
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
linkText: values.linkText,
|
|
67
|
-
linkUrl: values.linkUrl,
|
|
68
|
-
},
|
|
69
|
-
path,
|
|
70
|
-
});
|
|
30
|
+
{
|
|
31
|
+
icon: BlockRight,
|
|
32
|
+
onClick: () => {
|
|
33
|
+
controller.updateCardAlignment({
|
|
34
|
+
editor,
|
|
35
|
+
alignment: 'rightImageLeftText',
|
|
36
|
+
path,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
active: element.alignment === 'rightImageLeftText',
|
|
71
40
|
},
|
|
72
|
-
|
|
41
|
+
],
|
|
73
42
|
},
|
|
74
|
-
},
|
|
75
43
|
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
44
|
+
icons: [
|
|
45
|
+
{
|
|
46
|
+
icon: Edit,
|
|
47
|
+
onClick: () => {
|
|
48
|
+
setCardModalConfig({
|
|
49
|
+
controller,
|
|
50
|
+
initialValue: {
|
|
51
|
+
values: {
|
|
52
|
+
alignment: element.alignment,
|
|
53
|
+
title: element.title,
|
|
54
|
+
description: element.description,
|
|
55
|
+
remark: element.remark,
|
|
56
|
+
linkText: element.linkText,
|
|
57
|
+
linkUrl: element.linkUrl,
|
|
58
|
+
},
|
|
59
|
+
imageItem: element.imageItem,
|
|
60
|
+
haveLink: element.haveLink,
|
|
61
|
+
},
|
|
62
|
+
onConfirm: ({ values, imageItem, haveLink }) => {
|
|
63
|
+
controller.updateCardElement({
|
|
64
|
+
editor,
|
|
65
|
+
cardValues: {
|
|
66
|
+
alignment: values.alignment,
|
|
67
|
+
imageItem,
|
|
68
|
+
title: values.title,
|
|
69
|
+
description: values.description,
|
|
70
|
+
remark: values.remark,
|
|
71
|
+
haveLink,
|
|
72
|
+
linkText: values.linkText,
|
|
73
|
+
linkUrl: values.linkUrl,
|
|
74
|
+
},
|
|
75
|
+
path,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
icon: Trash,
|
|
83
|
+
onClick: () => {
|
|
84
|
+
if (controller.confirmModal) {
|
|
85
|
+
// TODO: i18n
|
|
86
|
+
setConfirmModalConfig({
|
|
87
|
+
title: '刪除卡片',
|
|
88
|
+
content: '是否確認刪除此卡片?刪除後將立即移除,且此操作無法復原。',
|
|
89
|
+
confirmText: '刪除卡片',
|
|
90
|
+
onConfirm: () => {
|
|
91
|
+
Transforms.removeNodes(editor, { at: path });
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
85
96
|
Transforms.removeNodes(editor, { at: path });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
Transforms.removeNodes(editor, { at: path });
|
|
91
|
-
}
|
|
92
|
-
},
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
93
101
|
},
|
|
94
102
|
] }),
|
|
95
103
|
children));
|
package/card/index.cjs.js
CHANGED
|
@@ -15,86 +15,94 @@ function Card({ attributes, children, element, controller, }) {
|
|
|
15
15
|
const editor = react.useSlateStatic();
|
|
16
16
|
const path = react.ReactEditor.findPath(editor, element);
|
|
17
17
|
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: clsx('qdr-card', `qdr-card--${element.alignment}`) }),
|
|
18
|
-
React.createElement(toolbar.InlineToolbar, { className: "qdr-card__inline-toolbar",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
icon: icons.BlockRight,
|
|
34
|
-
onClick: () => {
|
|
35
|
-
controller.updateCardAlignment({
|
|
36
|
-
editor,
|
|
37
|
-
alignment: 'rightImageLeftText',
|
|
38
|
-
path,
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
active: element.alignment === 'rightImageLeftText',
|
|
42
|
-
},
|
|
43
|
-
], rightIcons: [
|
|
44
|
-
{
|
|
45
|
-
icon: icons.Edit,
|
|
46
|
-
onClick: () => {
|
|
47
|
-
setCardModalConfig({
|
|
48
|
-
controller,
|
|
49
|
-
initialValue: {
|
|
50
|
-
values: {
|
|
51
|
-
alignment: element.alignment,
|
|
52
|
-
title: element.title,
|
|
53
|
-
description: element.description,
|
|
54
|
-
remark: element.remark,
|
|
55
|
-
linkText: element.linkText,
|
|
56
|
-
linkUrl: element.linkUrl,
|
|
18
|
+
React.createElement(toolbar.InlineToolbar, { className: "qdr-card__inline-toolbar", iconGroups: [
|
|
19
|
+
element.alignment === 'noImage'
|
|
20
|
+
? { icons: [] }
|
|
21
|
+
: {
|
|
22
|
+
enabledBgColor: true,
|
|
23
|
+
icons: [
|
|
24
|
+
{
|
|
25
|
+
icon: icons.BlockLeft,
|
|
26
|
+
onClick: () => {
|
|
27
|
+
controller.updateCardAlignment({
|
|
28
|
+
editor,
|
|
29
|
+
alignment: 'leftImageRightText',
|
|
30
|
+
path,
|
|
31
|
+
});
|
|
57
32
|
},
|
|
58
|
-
|
|
59
|
-
haveLink: element.haveLink,
|
|
33
|
+
active: element.alignment === 'leftImageRightText',
|
|
60
34
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
linkText: values.linkText,
|
|
72
|
-
linkUrl: values.linkUrl,
|
|
73
|
-
},
|
|
74
|
-
path,
|
|
75
|
-
});
|
|
35
|
+
{
|
|
36
|
+
icon: icons.BlockRight,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
controller.updateCardAlignment({
|
|
39
|
+
editor,
|
|
40
|
+
alignment: 'rightImageLeftText',
|
|
41
|
+
path,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
active: element.alignment === 'rightImageLeftText',
|
|
76
45
|
},
|
|
77
|
-
|
|
46
|
+
],
|
|
78
47
|
},
|
|
79
|
-
},
|
|
80
48
|
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
49
|
+
icons: [
|
|
50
|
+
{
|
|
51
|
+
icon: icons.Edit,
|
|
52
|
+
onClick: () => {
|
|
53
|
+
setCardModalConfig({
|
|
54
|
+
controller,
|
|
55
|
+
initialValue: {
|
|
56
|
+
values: {
|
|
57
|
+
alignment: element.alignment,
|
|
58
|
+
title: element.title,
|
|
59
|
+
description: element.description,
|
|
60
|
+
remark: element.remark,
|
|
61
|
+
linkText: element.linkText,
|
|
62
|
+
linkUrl: element.linkUrl,
|
|
63
|
+
},
|
|
64
|
+
imageItem: element.imageItem,
|
|
65
|
+
haveLink: element.haveLink,
|
|
66
|
+
},
|
|
67
|
+
onConfirm: ({ values, imageItem, haveLink }) => {
|
|
68
|
+
controller.updateCardElement({
|
|
69
|
+
editor,
|
|
70
|
+
cardValues: {
|
|
71
|
+
alignment: values.alignment,
|
|
72
|
+
imageItem,
|
|
73
|
+
title: values.title,
|
|
74
|
+
description: values.description,
|
|
75
|
+
remark: values.remark,
|
|
76
|
+
haveLink,
|
|
77
|
+
linkText: values.linkText,
|
|
78
|
+
linkUrl: values.linkUrl,
|
|
79
|
+
},
|
|
80
|
+
path,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
icon: icons.Trash,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
if (controller.confirmModal) {
|
|
90
|
+
// TODO: i18n
|
|
91
|
+
setConfirmModalConfig({
|
|
92
|
+
title: '刪除卡片',
|
|
93
|
+
content: '是否確認刪除此卡片?刪除後將立即移除,且此操作無法復原。',
|
|
94
|
+
confirmText: '刪除卡片',
|
|
95
|
+
onConfirm: () => {
|
|
96
|
+
core.Transforms.removeNodes(editor, { at: path });
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
90
101
|
core.Transforms.removeNodes(editor, { at: path });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
core.Transforms.removeNodes(editor, { at: path });
|
|
96
|
-
}
|
|
97
|
-
},
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
98
106
|
},
|
|
99
107
|
] }),
|
|
100
108
|
children));
|
|
@@ -15,37 +15,41 @@ function Carousel({ attributes, children, element, controller, }) {
|
|
|
15
15
|
setActiveIndex,
|
|
16
16
|
} },
|
|
17
17
|
React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: "qdr-carousel qdr-carousel--with-inline-toolbar" }),
|
|
18
|
-
React.createElement(InlineToolbar, { className: "qdr-carousel__inline-toolbar",
|
|
18
|
+
React.createElement(InlineToolbar, { className: "qdr-carousel__inline-toolbar", iconGroups: [
|
|
19
19
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
icons: [
|
|
21
|
+
{
|
|
22
|
+
icon: Edit,
|
|
23
|
+
onClick: () => {
|
|
24
|
+
setCarouselModalConfig({
|
|
25
|
+
controller,
|
|
26
|
+
initialValue: element.items,
|
|
27
|
+
onConfirm: (items) => {
|
|
28
|
+
controller.updateCarouselElement({ editor, items, path });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
27
31
|
},
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
icon: Trash,
|
|
35
|
+
onClick: () => {
|
|
36
|
+
if (controller.confirmModal) {
|
|
37
|
+
// TODO: i18n
|
|
38
|
+
setConfirmModalConfig({
|
|
39
|
+
title: '刪除輪播',
|
|
40
|
+
content: '是否確認刪除此輪播?刪除後將立即移除,且此操作無法復原。',
|
|
41
|
+
confirmText: '刪除輪播',
|
|
42
|
+
onConfirm: () => {
|
|
43
|
+
Transforms.removeNodes(editor, { at: path });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
41
48
|
Transforms.removeNodes(editor, { at: path });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
Transforms.removeNodes(editor, { at: path });
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
49
53
|
},
|
|
50
54
|
] }),
|
|
51
55
|
children)));
|
package/carousel/index.cjs.js
CHANGED
|
@@ -26,37 +26,41 @@ function Carousel({ attributes, children, element, controller, }) {
|
|
|
26
26
|
setActiveIndex,
|
|
27
27
|
} },
|
|
28
28
|
React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: "qdr-carousel qdr-carousel--with-inline-toolbar" }),
|
|
29
|
-
React.createElement(toolbar.InlineToolbar, { className: "qdr-carousel__inline-toolbar",
|
|
29
|
+
React.createElement(toolbar.InlineToolbar, { className: "qdr-carousel__inline-toolbar", iconGroups: [
|
|
30
30
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
icons: [
|
|
32
|
+
{
|
|
33
|
+
icon: icons.Edit,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
setCarouselModalConfig({
|
|
36
|
+
controller,
|
|
37
|
+
initialValue: element.items,
|
|
38
|
+
onConfirm: (items) => {
|
|
39
|
+
controller.updateCarouselElement({ editor, items, path });
|
|
40
|
+
},
|
|
41
|
+
});
|
|
38
42
|
},
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
icon: icons.Trash,
|
|
46
|
+
onClick: () => {
|
|
47
|
+
if (controller.confirmModal) {
|
|
48
|
+
// TODO: i18n
|
|
49
|
+
setConfirmModalConfig({
|
|
50
|
+
title: '刪除輪播',
|
|
51
|
+
content: '是否確認刪除此輪播?刪除後將立即移除,且此操作無法復原。',
|
|
52
|
+
confirmText: '刪除輪播',
|
|
53
|
+
onConfirm: () => {
|
|
54
|
+
core.Transforms.removeNodes(editor, { at: path });
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
52
59
|
core.Transforms.removeNodes(editor, { at: path });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
core.Transforms.removeNodes(editor, { at: path });
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
60
64
|
},
|
|
61
65
|
] }),
|
|
62
66
|
children)));
|
|
@@ -52,7 +52,7 @@ function Tooltip({ children, triggers = defaultTriggers, popup, getContainer = d
|
|
|
52
52
|
if (triggers.includes('click')) {
|
|
53
53
|
triggerProps.onClick = (event) => {
|
|
54
54
|
var _a, _b;
|
|
55
|
-
delaySetVisible(prevVisible => !prevVisible, 0);
|
|
55
|
+
delaySetVisible((prevVisible) => !prevVisible, 0);
|
|
56
56
|
(_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
57
57
|
};
|
|
58
58
|
}
|
|
@@ -83,7 +83,10 @@ function Tooltip({ children, triggers = defaultTriggers, popup, getContainer = d
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
const { top, left } = calculatePosition({
|
|
86
|
-
placement,
|
|
86
|
+
placement,
|
|
87
|
+
getContainer,
|
|
88
|
+
horizontalOffset,
|
|
89
|
+
verticalOffset,
|
|
87
90
|
}, triggerEl, popupEl);
|
|
88
91
|
popupEl.style.top = `${top}px`;
|
|
89
92
|
popupEl.style.left = `${left}px`;
|
package/components/index.cjs.js
CHANGED
|
@@ -780,7 +780,7 @@ function Tooltip({ children, triggers = defaultTriggers, popup, getContainer = d
|
|
|
780
780
|
if (triggers.includes('click')) {
|
|
781
781
|
triggerProps.onClick = (event) => {
|
|
782
782
|
var _a, _b;
|
|
783
|
-
delaySetVisible(prevVisible => !prevVisible, 0);
|
|
783
|
+
delaySetVisible((prevVisible) => !prevVisible, 0);
|
|
784
784
|
(_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
785
785
|
};
|
|
786
786
|
}
|
|
@@ -811,7 +811,10 @@ function Tooltip({ children, triggers = defaultTriggers, popup, getContainer = d
|
|
|
811
811
|
return;
|
|
812
812
|
}
|
|
813
813
|
const { top, left } = calculatePosition({
|
|
814
|
-
placement,
|
|
814
|
+
placement,
|
|
815
|
+
getContainer,
|
|
816
|
+
horizontalOffset,
|
|
817
|
+
verticalOffset,
|
|
815
818
|
}, triggerEl, popupEl);
|
|
816
819
|
popupEl.style.top = `${top}px`;
|
|
817
820
|
popupEl.style.left = `${left}px`;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Slate } from 'slate-react';
|
|
3
|
+
import { DndProvider } from 'react-dnd';
|
|
4
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
3
5
|
import { ConfigsProvider } from '@quadrats/react/configs';
|
|
4
6
|
import { ModalProvider } from '../contexts/modal/ModalProvider.js';
|
|
5
7
|
import { MessageProvider } from '../contexts/message/MessageProvider.js';
|
|
@@ -11,8 +13,9 @@ function Quadrats(props) {
|
|
|
11
13
|
const { children, editor, locale, onChange, theme, value, needConfirmModal, setNeedConfirmModal } = props;
|
|
12
14
|
return (React.createElement(ConfigsProvider, { theme: theme, locale: locale },
|
|
13
15
|
React.createElement(Slate, { editor: editor, onChange: onChange, initialValue: value },
|
|
14
|
-
React.createElement(
|
|
15
|
-
React.createElement(
|
|
16
|
+
React.createElement(DndProvider, { backend: HTML5Backend },
|
|
17
|
+
React.createElement(MessageProvider, null,
|
|
18
|
+
React.createElement(ModalProvider, { needConfirmModal: needConfirmModal, setNeedConfirmModal: setNeedConfirmModal }, children))))));
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
export { Quadrats as default };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import React, { useState, useEffect, useMemo, useCallback } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
5
|
-
import { DndProvider } from 'react-dnd';
|
|
6
4
|
import { Plus, Upload } from '@quadrats/icons';
|
|
7
5
|
import { usePreviousValue, readFileAsBase64, upload } from '@quadrats/react/utils';
|
|
8
6
|
import { useSlateStatic } from 'slate-react';
|
|
@@ -154,21 +152,20 @@ const CarouselModal = ({ isOpen, close, controller, initialValue = [], onConfirm
|
|
|
154
152
|
}, 0);
|
|
155
153
|
}
|
|
156
154
|
} },
|
|
157
|
-
React.createElement(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
React.createElement("div", { className: "qdr-carousel-
|
|
166
|
-
React.createElement(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
: `僅能上傳 ${acceptText};檔案大小不可超過 ${controller === null || controller === void 0 ? void 0 : controller.limitSize}MB`))))))));
|
|
155
|
+
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', {
|
|
156
|
+
'qdr-carousel-modal__grid--isDragging': isDragging,
|
|
157
|
+
}) }, 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) => {
|
|
158
|
+
change(index, { url: item.url, caption: value });
|
|
159
|
+
}, onRemove: () => {
|
|
160
|
+
remove(index);
|
|
161
|
+
}, swap: swap }))))) : (React.createElement("div", { className: "qdr-carousel-modal__placeholder" },
|
|
162
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__block" },
|
|
163
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__icon" },
|
|
164
|
+
React.createElement(Icon, { icon: Upload, width: 32, height: 32 })),
|
|
165
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__title" }, "\u62D6\u66F3\u6A94\u6848\u5230\u6B64\u4E0A\u50B3"),
|
|
166
|
+
React.createElement("div", { className: "qdr-carousel-modal__placeholder__hint" }, (controller === null || controller === void 0 ? void 0 : controller.ratio)
|
|
167
|
+
? `僅能上傳 ${acceptText};建議比例為 ${controller.ratio[0]}:${controller.ratio[1]} 且寬度至少達 2000px 以上;檔案大小不可超過 ${controller === null || controller === void 0 ? void 0 : controller.limitSize}MB`
|
|
168
|
+
: `僅能上傳 ${acceptText};檔案大小不可超過 ${controller === null || controller === void 0 ? void 0 : controller.limitSize}MB`)))))));
|
|
172
169
|
};
|
|
173
170
|
|
|
174
171
|
export { CarouselModal };
|