@it-consultis/page-builder 1.1.34
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/Editor.d.ts +77 -0
- package/Editor.js +312 -0
- package/LICENSE.txt +674 -0
- package/README.md +248 -0
- package/assets/svg/mp.d.ts +2 -0
- package/assets/svg/mp.js +37 -0
- package/assets/svg/status-bar.d.ts +2 -0
- package/assets/svg/status-bar.js +38 -0
- package/constants/index.d.ts +11 -0
- package/constants/index.js +17 -0
- package/contexts/I18nContext.d.ts +15 -0
- package/contexts/I18nContext.js +56 -0
- package/controls/AlignmentControl/AlignmentControl.d.ts +5 -0
- package/controls/AlignmentControl/AlignmentControl.js +58 -0
- package/controls/AlignmentControl/index.d.ts +3 -0
- package/controls/AlignmentControl/index.js +9 -0
- package/controls/DeviceSwitcher/DeviceSwitcher.d.ts +10 -0
- package/controls/DeviceSwitcher/DeviceSwitcher.js +64 -0
- package/controls/DeviceSwitcher/index.d.ts +2 -0
- package/controls/DeviceSwitcher/index.js +9 -0
- package/controls/GradientColorPicker/GradientColorPicker.d.ts +8 -0
- package/controls/GradientColorPicker/GradientColorPicker.js +81 -0
- package/controls/GradientColorPicker/index.d.ts +2 -0
- package/controls/GradientColorPicker/index.js +9 -0
- package/controls/HeadingControl/HeadingControl.d.ts +14 -0
- package/controls/HeadingControl/HeadingControl.js +251 -0
- package/controls/HeadingControl/HeadingView.d.ts +21 -0
- package/controls/HeadingControl/HeadingView.js +43 -0
- package/controls/HeadingControl/index.d.ts +4 -0
- package/controls/HeadingControl/index.js +16 -0
- package/controls/MediaLibraryControl/FileBrowserDialog.d.ts +14 -0
- package/controls/MediaLibraryControl/FileBrowserDialog.js +138 -0
- package/controls/MediaLibraryControl/MediaLibraryControl.d.ts +38 -0
- package/controls/MediaLibraryControl/MediaLibraryControl.js +537 -0
- package/controls/MediaLibraryControl/index.d.ts +3 -0
- package/controls/MediaLibraryControl/index.js +9 -0
- package/controls/PaddingMarginControl/PaddingMarginControl.d.ts +30 -0
- package/controls/PaddingMarginControl/PaddingMarginControl.js +88 -0
- package/controls/PaddingMarginControl/PaddingMarginForm.d.ts +8 -0
- package/controls/PaddingMarginControl/PaddingMarginForm.js +109 -0
- package/controls/PaddingMarginControl/index.d.ts +4 -0
- package/controls/PaddingMarginControl/index.js +16 -0
- package/controls/PaddingMarginControl/utils.d.ts +3 -0
- package/controls/PaddingMarginControl/utils.js +21 -0
- package/controls/SelectableControl/SelectableControl.d.ts +5 -0
- package/controls/SelectableControl/SelectableControl.js +35 -0
- package/controls/SelectableControl/index.d.ts +3 -0
- package/controls/SelectableControl/index.js +9 -0
- package/hooks/ui-optimizations/useDebounce.d.ts +3 -0
- package/hooks/ui-optimizations/useDebounce.js +23 -0
- package/hooks/ui-optimizations/useThrottle.d.ts +3 -0
- package/hooks/ui-optimizations/useThrottle.js +22 -0
- package/hooks/useMediaImageQuery.d.ts +10 -0
- package/hooks/useMediaImageQuery.js +51 -0
- package/hooks/useSortable.d.ts +20 -0
- package/hooks/useSortable.js +70 -0
- package/index.d.ts +7 -0
- package/index.js +54 -0
- package/layouts/BlocksBar/LayerPanel.d.ts +8 -0
- package/layouts/BlocksBar/LayerPanel.js +299 -0
- package/layouts/BlocksBar/index.d.ts +7 -0
- package/layouts/BlocksBar/index.js +575 -0
- package/layouts/EditorPreview/BlockView.d.ts +16 -0
- package/layouts/EditorPreview/BlockView.js +435 -0
- package/layouts/EditorPreview/index.d.ts +9 -0
- package/layouts/EditorPreview/index.js +463 -0
- package/layouts/Header/index.d.ts +18 -0
- package/layouts/Header/index.js +202 -0
- package/layouts/Header/menus/ExportDataDialog.d.ts +4 -0
- package/layouts/Header/menus/ExportDataDialog.js +95 -0
- package/layouts/Header/menus/ImportDataDialog.d.ts +4 -0
- package/layouts/Header/menus/ImportDataDialog.js +100 -0
- package/layouts/Header/menus/LeftMenu.d.ts +9 -0
- package/layouts/Header/menus/LeftMenu.js +369 -0
- package/layouts/Header/menus/RightMenu.d.ts +14 -0
- package/layouts/Header/menus/RightMenu.js +91 -0
- package/layouts/Header/menus/SaveTemplateDialog.d.ts +4 -0
- package/layouts/Header/menus/SaveTemplateDialog.js +203 -0
- package/layouts/MessageBus.d.ts +13 -0
- package/layouts/MessageBus.js +76 -0
- package/layouts/Sidebar/AddBlockButton.d.ts +12 -0
- package/layouts/Sidebar/AddBlockButton.js +267 -0
- package/layouts/Sidebar/BlockForm.d.ts +20 -0
- package/layouts/Sidebar/BlockForm.js +517 -0
- package/layouts/Sidebar/BlocksControl.d.ts +21 -0
- package/layouts/Sidebar/BlocksControl.js +190 -0
- package/layouts/Sidebar/index.d.ts +10 -0
- package/layouts/Sidebar/index.js +451 -0
- package/layouts/Snackbar.d.ts +3 -0
- package/layouts/Snackbar.js +43 -0
- package/package.json +133 -0
- package/store/Provider.d.ts +15 -0
- package/store/Provider.js +71 -0
- package/store/editor-store-core.d.ts +4 -0
- package/store/editor-store-core.js +271 -0
- package/store/index.d.ts +112 -0
- package/store/index.js +178 -0
- package/theme.d.ts +10 -0
- package/theme.js +9 -0
- package/translation/cn.json +29 -0
- package/translation/en.json +29 -0
- package/translation/fr.json +31 -0
- package/translation/index.d.ts +6 -0
- package/translation/index.js +23 -0
- package/translation/types.d.ts +13 -0
- package/translation/types.js +5 -0
- package/types/Block.d.ts +22 -0
- package/types/Block.js +5 -0
- package/types/BlockType.d.ts +50 -0
- package/types/BlockType.js +5 -0
- package/types/ConfigStorageAdapter.d.ts +11 -0
- package/types/ConfigStorageAdapter.js +5 -0
- package/types/ObjectStorageAdapter.d.ts +68 -0
- package/types/ObjectStorageAdapter.js +5 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +100 -0
- package/types/throttle-and-debounce.d.ts +2 -0
- package/types/throttle-and-debounce.js +5 -0
- package/utils/block.d.ts +16 -0
- package/utils/block.js +41 -0
- package/utils/helpers.d.ts +5 -0
- package/utils/helpers.js +22 -0
- package/utils/strings.d.ts +1 -0
- package/utils/strings.js +11 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _PaddingMarginControl = require("./PaddingMarginControl");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function PaddingMarginForm({
|
|
15
|
+
label = 'Margin & Padding',
|
|
16
|
+
current,
|
|
17
|
+
onChange
|
|
18
|
+
}) {
|
|
19
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
20
|
+
className: "margin-container",
|
|
21
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
|
|
22
|
+
style: {
|
|
23
|
+
paddingBottom: 8
|
|
24
|
+
},
|
|
25
|
+
children: label
|
|
26
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
27
|
+
style: {
|
|
28
|
+
position: 'relative',
|
|
29
|
+
border: '1px solid #ccc',
|
|
30
|
+
padding: '40px 64px',
|
|
31
|
+
background: '#e2e8f0'
|
|
32
|
+
},
|
|
33
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
34
|
+
style: {
|
|
35
|
+
height: 80,
|
|
36
|
+
border: '1px dashed #ccc',
|
|
37
|
+
background: 'white'
|
|
38
|
+
}
|
|
39
|
+
}), _PaddingMarginControl.paddingMarginKeys.map(key => {
|
|
40
|
+
const style = {};
|
|
41
|
+
if (key === 'marginTop') {
|
|
42
|
+
style.background = 'white';
|
|
43
|
+
style.left = '50%';
|
|
44
|
+
style.top = '4px';
|
|
45
|
+
style.transform = 'translateX(-50%)';
|
|
46
|
+
}
|
|
47
|
+
if (key === 'marginBottom') {
|
|
48
|
+
style.background = 'white';
|
|
49
|
+
style.left = '50%';
|
|
50
|
+
style.bottom = '4px';
|
|
51
|
+
style.transform = 'translateX(-50%)';
|
|
52
|
+
}
|
|
53
|
+
if (key === 'marginLeft') {
|
|
54
|
+
style.background = 'white';
|
|
55
|
+
style.left = '4px';
|
|
56
|
+
style.top = '50%';
|
|
57
|
+
style.transform = 'translateY(-50%)';
|
|
58
|
+
}
|
|
59
|
+
if (key === 'marginRight') {
|
|
60
|
+
style.background = 'white';
|
|
61
|
+
style.right = '4px';
|
|
62
|
+
style.top = '50%';
|
|
63
|
+
style.transform = 'translateY(-50%)';
|
|
64
|
+
}
|
|
65
|
+
if (key === 'paddingTop') {
|
|
66
|
+
style.background = '#f8fafc';
|
|
67
|
+
style.left = '50%';
|
|
68
|
+
style.top = '40px';
|
|
69
|
+
style.transform = 'translateX(-50%)';
|
|
70
|
+
}
|
|
71
|
+
if (key === 'paddingBottom') {
|
|
72
|
+
style.background = '#f8fafc';
|
|
73
|
+
style.left = '50%';
|
|
74
|
+
style.bottom = '40px';
|
|
75
|
+
style.transform = 'translateX(-50%)';
|
|
76
|
+
}
|
|
77
|
+
if (key === 'paddingLeft') {
|
|
78
|
+
style.background = '#f8fafc';
|
|
79
|
+
style.left = '64px';
|
|
80
|
+
style.top = '50%';
|
|
81
|
+
style.transform = 'translateY(-50%)';
|
|
82
|
+
}
|
|
83
|
+
if (key === 'paddingRight') {
|
|
84
|
+
style.background = '#f8fafc';
|
|
85
|
+
style.right = '64px';
|
|
86
|
+
style.top = '50%';
|
|
87
|
+
style.transform = 'translateY(-50%)';
|
|
88
|
+
}
|
|
89
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
|
|
90
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
91
|
+
style: {
|
|
92
|
+
position: 'absolute',
|
|
93
|
+
width: '48px',
|
|
94
|
+
padding: '4px 0',
|
|
95
|
+
border: '1px solid #ccc',
|
|
96
|
+
...style
|
|
97
|
+
},
|
|
98
|
+
className: (0, _clsx.default)(`input-${key.toLowerCase()}`),
|
|
99
|
+
defaultValue: current?.[key] || 0,
|
|
100
|
+
onChange: e => {
|
|
101
|
+
onChange(key, e.target.value);
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}, key);
|
|
105
|
+
})]
|
|
106
|
+
})]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
var _default = exports.default = PaddingMarginForm;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
Object.defineProperty(exports, "defaultPaddingMargin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _PaddingMarginControl.defaultPaddingMargin;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _PaddingMarginControl = _interopRequireWildcard(require("./PaddingMarginControl"));
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
var _default = exports.default = _PaddingMarginControl.default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPaddingValue = exports.getMarginValue = void 0;
|
|
7
|
+
var _helpers = require("../../utils/helpers");
|
|
8
|
+
const getMarginValue = value => {
|
|
9
|
+
const margin = (0, _helpers.pick)(value, ['marginTop', 'marginRight', 'marginBottom', 'marginLeft']);
|
|
10
|
+
return `${margin.marginTop}
|
|
11
|
+
${margin.marginRight} ${margin.marginBottom}
|
|
12
|
+
${margin.marginLeft}`;
|
|
13
|
+
};
|
|
14
|
+
exports.getMarginValue = getMarginValue;
|
|
15
|
+
const getPaddingValue = value => {
|
|
16
|
+
const padding = (0, _helpers.pick)(value, ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft']);
|
|
17
|
+
return `${padding.paddingTop}
|
|
18
|
+
${padding.paddingRight} ${padding.paddingBottom}
|
|
19
|
+
${padding.paddingLeft}`;
|
|
20
|
+
};
|
|
21
|
+
exports.getPaddingValue = getPaddingValue;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = SelectableControl;
|
|
8
|
+
var _Switch = _interopRequireDefault(require("@mui/material/Switch"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function SelectableControl({
|
|
13
|
+
current,
|
|
14
|
+
onChange
|
|
15
|
+
}) {
|
|
16
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
17
|
+
style: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
gap: 10
|
|
21
|
+
},
|
|
22
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
23
|
+
style: {
|
|
24
|
+
fontWeight: 'bold',
|
|
25
|
+
textTransform: 'uppercase'
|
|
26
|
+
},
|
|
27
|
+
children: "Content Selectable"
|
|
28
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
29
|
+
checked: current === 'auto',
|
|
30
|
+
onChange: ev => {
|
|
31
|
+
onChange(ev.target.checked ? 'auto' : 'none');
|
|
32
|
+
}
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _SelectableControl = _interopRequireDefault(require("./SelectableControl"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = _SelectableControl.default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const useDebounce = (fn, delay = 300) => {
|
|
9
|
+
const timer = (0, _react.useRef)(null);
|
|
10
|
+
const fnRef = (0, _react.useRef)(fn);
|
|
11
|
+
(0, _react.useEffect)(() => {
|
|
12
|
+
fnRef.current = fn;
|
|
13
|
+
}, [fn]);
|
|
14
|
+
return (0, _react.useCallback)((...args) => {
|
|
15
|
+
if (timer.current) {
|
|
16
|
+
clearTimeout(timer.current);
|
|
17
|
+
}
|
|
18
|
+
timer.current = setTimeout(() => {
|
|
19
|
+
fnRef.current(...args);
|
|
20
|
+
}, delay);
|
|
21
|
+
}, [delay]);
|
|
22
|
+
};
|
|
23
|
+
var _default = exports.default = useDebounce;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const useThrottle = (fn, delay = 300) => {
|
|
9
|
+
const lastCall = (0, _react.useRef)(0);
|
|
10
|
+
const fnRef = (0, _react.useRef)(fn);
|
|
11
|
+
(0, _react.useEffect)(() => {
|
|
12
|
+
fnRef.current = fn;
|
|
13
|
+
}, [fn]);
|
|
14
|
+
return (0, _react.useCallback)((...args) => {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
if (now - lastCall.current >= delay) {
|
|
17
|
+
lastCall.current = now;
|
|
18
|
+
fnRef.current(...args);
|
|
19
|
+
}
|
|
20
|
+
}, [delay]);
|
|
21
|
+
};
|
|
22
|
+
var _default = exports.default = useThrottle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MediaItem } from '../controls/MediaLibraryControl';
|
|
2
|
+
declare const useMediaImageQuery: ({ data, width, fill }: {
|
|
3
|
+
data: MediaItem;
|
|
4
|
+
width?: number | undefined;
|
|
5
|
+
fill: boolean;
|
|
6
|
+
}) => import("@tanstack/react-query").UseQueryResult<{
|
|
7
|
+
original: string | undefined;
|
|
8
|
+
thumbnails: [number, string][];
|
|
9
|
+
}, unknown>;
|
|
10
|
+
export default useMediaImageQuery;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
8
|
+
var _store = require("../store");
|
|
9
|
+
const deviceSizes = [375, 640, 750, 828, 1080, 1200, 1920, 2048, 3840];
|
|
10
|
+
const imgSizes = [16, 32, 64, 128, 144, 192, 256, 320];
|
|
11
|
+
const useMediaImageQuery = ({
|
|
12
|
+
data,
|
|
13
|
+
width,
|
|
14
|
+
fill
|
|
15
|
+
}) => {
|
|
16
|
+
const storage = (0, _store.useObjectStorage)();
|
|
17
|
+
return (0, _reactQuery.useQuery)({
|
|
18
|
+
queryKey: ['MediaImage', data?.key, width, fill],
|
|
19
|
+
async queryFn() {
|
|
20
|
+
if (!data?.key) return {
|
|
21
|
+
original: '',
|
|
22
|
+
thumbnails: []
|
|
23
|
+
};
|
|
24
|
+
const allSizes = [...imgSizes, ...deviceSizes].filter((size, i, array) => {
|
|
25
|
+
if (fill) {
|
|
26
|
+
return deviceSizes.includes(size);
|
|
27
|
+
}
|
|
28
|
+
if (size <= (width ?? 0)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const prevSize = i === 0 ? 0 : array[i - 1];
|
|
32
|
+
return prevSize < (width ?? 0);
|
|
33
|
+
});
|
|
34
|
+
const thumbnailsPromises = allSizes.map(async size => {
|
|
35
|
+
const url = await storage?.imagePreviewUrl({
|
|
36
|
+
key: data.key,
|
|
37
|
+
width: size
|
|
38
|
+
});
|
|
39
|
+
return [size, url];
|
|
40
|
+
});
|
|
41
|
+
const [original, thumbnails] = await Promise.all([storage?.objectUrl({
|
|
42
|
+
key: data.key
|
|
43
|
+
}), Promise.all(thumbnailsPromises)]);
|
|
44
|
+
return {
|
|
45
|
+
original,
|
|
46
|
+
thumbnails: thumbnails.sort((a, b) => a[0] > b[0] ? 1 : -1)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var _default = exports.default = useMediaImageQuery;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type TSortable from 'sortablejs';
|
|
2
|
+
import { SortableEvent, SortableOptions as BaseSortableOptions } from 'sortablejs';
|
|
3
|
+
type SortableOptions = Omit<BaseSortableOptions, 'onStart' | 'onEnd' | 'onAdd' | 'onClone' | 'onChoose' | 'onUnchoose' | 'onUpdate' | 'onSort' | 'onRemove' | 'onFilter' | 'onChange'> & {
|
|
4
|
+
onStart?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
5
|
+
onEnd?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
6
|
+
onAdd?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
7
|
+
onClone?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
8
|
+
onChoose?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
9
|
+
onUnchoose?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
10
|
+
onUpdate?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
11
|
+
onSort?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
12
|
+
onRemove?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
13
|
+
onFilter?: ((event: SortableEvent, instance: TSortable) => void) | undefined;
|
|
14
|
+
onChange?: ((evt: SortableEvent) => void) | undefined;
|
|
15
|
+
};
|
|
16
|
+
declare const useSortable: (options: SortableOptions) => {
|
|
17
|
+
containerRef(node: HTMLElement | null): void;
|
|
18
|
+
getInstance(): TSortable | null;
|
|
19
|
+
};
|
|
20
|
+
export default useSortable;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
const useSortable = options => {
|
|
11
|
+
const {
|
|
12
|
+
disabled
|
|
13
|
+
} = options;
|
|
14
|
+
const sortableRef = (0, _react.useRef)(null);
|
|
15
|
+
const [container, setContainer] = (0, _react.useState)(null);
|
|
16
|
+
const containerRef = (0, _react.useRef)(container);
|
|
17
|
+
containerRef.current = container;
|
|
18
|
+
const optionsRef = (0, _react.useRef)(options);
|
|
19
|
+
(0, _react.useEffect)(() => {
|
|
20
|
+
if (disabled || !container || sortableRef.current) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let newSortable = null;
|
|
24
|
+
let active = true;
|
|
25
|
+
(async () => {
|
|
26
|
+
const Sortable = (await Promise.resolve().then(() => _interopRequireWildcard(require('sortablejs')))).default;
|
|
27
|
+
if (!active) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const currOptions = optionsRef.current;
|
|
31
|
+
newSortable = new Sortable(container, {
|
|
32
|
+
...currOptions,
|
|
33
|
+
disabled: true
|
|
34
|
+
});
|
|
35
|
+
Object.keys(currOptions).forEach(key => {
|
|
36
|
+
const optionKey = key;
|
|
37
|
+
const optionVal = currOptions[optionKey];
|
|
38
|
+
if (!key.startsWith('on') || key === 'onMove' || !newSortable) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
newSortable.option(optionKey, ev => {
|
|
42
|
+
if (!active || disabled) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
optionVal(ev, newSortable);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
newSortable.option('disabled', false);
|
|
49
|
+
sortableRef.current = newSortable;
|
|
50
|
+
})();
|
|
51
|
+
return () => {
|
|
52
|
+
active = false;
|
|
53
|
+
if (newSortable) {
|
|
54
|
+
newSortable.destroy();
|
|
55
|
+
sortableRef.current = null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}, [container, disabled]);
|
|
59
|
+
return {
|
|
60
|
+
containerRef(node) {
|
|
61
|
+
if (!containerRef.current) {
|
|
62
|
+
setContainer(node);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
getInstance() {
|
|
66
|
+
return sortableRef.current;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
var _default = exports.default = useSortable;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Editor from './Editor';
|
|
2
|
+
export { default as Editor } from './Editor';
|
|
3
|
+
export { default as BlocksControl } from './layouts/Sidebar/BlocksControl';
|
|
4
|
+
export { default as MediaLibraryControl } from './controls/MediaLibraryControl';
|
|
5
|
+
export { useEditorStore } from './store';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export default Editor;
|
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
Editor: true,
|
|
8
|
+
BlocksControl: true,
|
|
9
|
+
MediaLibraryControl: true,
|
|
10
|
+
useEditorStore: true
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "BlocksControl", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _BlocksControl.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Editor", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Editor.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "MediaLibraryControl", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _MediaLibraryControl.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
exports.default = void 0;
|
|
31
|
+
Object.defineProperty(exports, "useEditorStore", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _store.useEditorStore;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var _Editor = _interopRequireDefault(require("./Editor"));
|
|
38
|
+
var _BlocksControl = _interopRequireDefault(require("./layouts/Sidebar/BlocksControl"));
|
|
39
|
+
var _MediaLibraryControl = _interopRequireDefault(require("./controls/MediaLibraryControl"));
|
|
40
|
+
var _store = require("./store");
|
|
41
|
+
var _types = require("./types");
|
|
42
|
+
Object.keys(_types).forEach(function (key) {
|
|
43
|
+
if (key === "default" || key === "__esModule") return;
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
45
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
46
|
+
Object.defineProperty(exports, key, {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return _types[key];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
54
|
+
var _default = exports.default = _Editor.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Block } from '../../types';
|
|
2
|
+
import { type FC, type MouseEvent } from 'react';
|
|
3
|
+
interface LayerPanelProps {
|
|
4
|
+
onMenuOpen: (event: MouseEvent<HTMLElement>, blockId: string) => void;
|
|
5
|
+
onChange?: (data: Block[]) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const LayerPanel: FC<LayerPanelProps>;
|
|
8
|
+
export default LayerPanel;
|