@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
package/Editor.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type MessageEventDataType, type PostMessageParamsType } from './layouts/MessageBus';
|
|
2
|
+
import { AddBlockButtonProps } from './layouts/Sidebar/AddBlockButton';
|
|
3
|
+
import { EditorState } from './store';
|
|
4
|
+
import { LocaleType } from './translation';
|
|
5
|
+
import { Block, BlockType } from './types';
|
|
6
|
+
import { Theme } from '@mui/material/styles';
|
|
7
|
+
import React, { type FC } from 'react';
|
|
8
|
+
declare module '@mui/material/useMediaQuery' {
|
|
9
|
+
interface Options {
|
|
10
|
+
defaultMatches?: boolean;
|
|
11
|
+
noSsr?: boolean;
|
|
12
|
+
ssrMatchMedia?: (query: string) => {
|
|
13
|
+
matches: boolean;
|
|
14
|
+
};
|
|
15
|
+
matchMedia?: typeof window.matchMedia;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export type DeviceType = 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
19
|
+
type EditorBaseProps = {
|
|
20
|
+
data?: Block[];
|
|
21
|
+
blockTypes: BlockType[];
|
|
22
|
+
onChange?(data: Block[]): void;
|
|
23
|
+
onInit?(data: Block[]): void;
|
|
24
|
+
title?: string;
|
|
25
|
+
cardinality?: number;
|
|
26
|
+
addBlockDisplayFormat?: AddBlockButtonProps['displayFormat'];
|
|
27
|
+
storage: EditorState['storage'];
|
|
28
|
+
mpQueries?: {
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
platinum?: boolean;
|
|
33
|
+
platinumQueries?: {
|
|
34
|
+
key: string;
|
|
35
|
+
value: string;
|
|
36
|
+
};
|
|
37
|
+
mp?: boolean;
|
|
38
|
+
previewDeviceList: DeviceType[];
|
|
39
|
+
theme?: Theme | null;
|
|
40
|
+
headerSlots?: Partial<{
|
|
41
|
+
left: FC;
|
|
42
|
+
middle: FC;
|
|
43
|
+
right: FC;
|
|
44
|
+
}>;
|
|
45
|
+
storageKey?: string;
|
|
46
|
+
postMessageParams?: PostMessageParamsType;
|
|
47
|
+
messageBus?: FC<MessageEventDataType>;
|
|
48
|
+
locale?: LocaleType;
|
|
49
|
+
};
|
|
50
|
+
type ValidPreviewWidth<T> = T extends DeviceType[] ? T extends readonly [] ? DeviceType : T[number] : DeviceType;
|
|
51
|
+
type FullEditorProps<T extends DeviceType[] = DeviceType[]> = Omit<EditorBaseProps, 'previewDeviceList'> & {
|
|
52
|
+
format: 'full';
|
|
53
|
+
editorTheme?: Theme;
|
|
54
|
+
isFullScreen?: boolean;
|
|
55
|
+
onFullScreen?(): void;
|
|
56
|
+
onFullScreenExit?(): void;
|
|
57
|
+
onPreviewIframeLoad?(iframe: HTMLIFrameElement): void;
|
|
58
|
+
previewWrapperComponent?: React.ElementType;
|
|
59
|
+
previewSrc?: string;
|
|
60
|
+
previewDeviceList: T;
|
|
61
|
+
previewWidth?: ValidPreviewWidth<T>;
|
|
62
|
+
onAction?(action: {
|
|
63
|
+
type: string;
|
|
64
|
+
payload: any;
|
|
65
|
+
}): void;
|
|
66
|
+
allowedOrigins?: string[];
|
|
67
|
+
};
|
|
68
|
+
type EditorOnlyProps = EditorBaseProps & {
|
|
69
|
+
format: 'sidebar';
|
|
70
|
+
onBack?(): void;
|
|
71
|
+
};
|
|
72
|
+
type InlineEditorProps = EditorBaseProps & {
|
|
73
|
+
format: 'inline';
|
|
74
|
+
};
|
|
75
|
+
export type EditorProps<T extends DeviceType[] = DeviceType[]> = FullEditorProps<T> | EditorOnlyProps | InlineEditorProps;
|
|
76
|
+
declare const Editor: <T extends DeviceType[] = DeviceType[]>(props: EditorProps<T>) => React.ReactElement | null;
|
|
77
|
+
export default Editor;
|
package/Editor.js
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _constants = require("./constants");
|
|
8
|
+
var _BlocksBar = _interopRequireDefault(require("./layouts/BlocksBar"));
|
|
9
|
+
var _EditorPreview = _interopRequireDefault(require("./layouts/EditorPreview"));
|
|
10
|
+
var _Header = _interopRequireDefault(require("./layouts/Header"));
|
|
11
|
+
var _MessageBus = _interopRequireDefault(require("./layouts/MessageBus"));
|
|
12
|
+
var _Sidebar = _interopRequireDefault(require("./layouts/Sidebar"));
|
|
13
|
+
var _Snackbar = _interopRequireDefault(require("./layouts/Snackbar"));
|
|
14
|
+
var _Provider = _interopRequireDefault(require("./store/Provider"));
|
|
15
|
+
var _theme = _interopRequireDefault(require("./theme"));
|
|
16
|
+
var _block = require("./utils/block");
|
|
17
|
+
var _styles = require("@mui/material/styles");
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
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); }
|
|
21
|
+
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; }
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
const PREFIX = 'Editor';
|
|
24
|
+
const DEFAULT_BAR_WIDTH = 365;
|
|
25
|
+
const classes = {
|
|
26
|
+
root: `${PREFIX}-root`,
|
|
27
|
+
main: `${PREFIX}-main`,
|
|
28
|
+
sidebarWrapper: `${PREFIX}-sidebarWrapper`,
|
|
29
|
+
dragBarLeft: `${PREFIX}-dragBar-left`,
|
|
30
|
+
dragBarRight: `${PREFIX}-dragBar-right`
|
|
31
|
+
};
|
|
32
|
+
const Root = (0, _styles.styled)('div')(({
|
|
33
|
+
theme
|
|
34
|
+
}) => ({
|
|
35
|
+
'*:not(#editor-preview, #editor-preview *)': {
|
|
36
|
+
fontSize: theme.typography.fontSize
|
|
37
|
+
},
|
|
38
|
+
width: '100%',
|
|
39
|
+
height: '100%',
|
|
40
|
+
overflow: 'none',
|
|
41
|
+
position: 'relative',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
[`& .${classes.main}`]: {
|
|
45
|
+
height: '100vh',
|
|
46
|
+
display: 'flex',
|
|
47
|
+
flexDirection: 'column',
|
|
48
|
+
overflow: 'auto',
|
|
49
|
+
flexGrow: 1,
|
|
50
|
+
zIndex: 0
|
|
51
|
+
},
|
|
52
|
+
[`& .${classes.sidebarWrapper}`]: {
|
|
53
|
+
top: 0,
|
|
54
|
+
zIndex: 2,
|
|
55
|
+
position: 'relative',
|
|
56
|
+
maxWidth: DEFAULT_BAR_WIDTH,
|
|
57
|
+
width: '100%',
|
|
58
|
+
height: '100%',
|
|
59
|
+
minHeight: '97px',
|
|
60
|
+
maxHeight: '100vh',
|
|
61
|
+
// overflowY: 'scroll'
|
|
62
|
+
overflowX: 'hidden'
|
|
63
|
+
},
|
|
64
|
+
[`& .${classes.dragBarLeft}, & .${classes.dragBarRight}`]: {
|
|
65
|
+
width: 0,
|
|
66
|
+
height: '100%',
|
|
67
|
+
top: 0,
|
|
68
|
+
left: 0,
|
|
69
|
+
position: 'relative',
|
|
70
|
+
userSelect: 'none',
|
|
71
|
+
zIndex: 10,
|
|
72
|
+
cursor: 'col-resize',
|
|
73
|
+
'&::before': {
|
|
74
|
+
content: "''",
|
|
75
|
+
display: 'block',
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
width: 10,
|
|
78
|
+
height: '100%',
|
|
79
|
+
zIndex: 10
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
[`& .${classes.dragBarLeft}::before`]: {
|
|
83
|
+
right: -5
|
|
84
|
+
},
|
|
85
|
+
[`& .${classes.dragBarRight}::before`]: {
|
|
86
|
+
left: -5
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
const Editor = props => {
|
|
90
|
+
const {
|
|
91
|
+
data,
|
|
92
|
+
onChange,
|
|
93
|
+
onInit,
|
|
94
|
+
blockTypes = [],
|
|
95
|
+
cardinality = -1,
|
|
96
|
+
title,
|
|
97
|
+
addBlockDisplayFormat = 'select',
|
|
98
|
+
storage,
|
|
99
|
+
mp = false,
|
|
100
|
+
mpQueries,
|
|
101
|
+
platinum = false,
|
|
102
|
+
platinumQueries,
|
|
103
|
+
previewDeviceList,
|
|
104
|
+
storageKey = 'dev:blocks',
|
|
105
|
+
postMessageParams,
|
|
106
|
+
messageBus: MessageBusComponent = _MessageBus.default,
|
|
107
|
+
locale = 'en' // 默认语言为英文
|
|
108
|
+
} = props;
|
|
109
|
+
const blocksBarVisibleRef = (0, _react.useRef)(true);
|
|
110
|
+
const sidebarVisibleRef = (0, _react.useRef)(true);
|
|
111
|
+
const [mpNavigationProps, setMpNavigationProps] = (0, _react.useState)(null);
|
|
112
|
+
const mainRef = (0, _react.useRef)(null);
|
|
113
|
+
const [initialed, setInitialed] = (0, _react.useState)(false);
|
|
114
|
+
const mergedSidebarProps = (0, _react.useMemo)(() => ({
|
|
115
|
+
title: title || 'Blocks',
|
|
116
|
+
cardinality,
|
|
117
|
+
addBlockDisplayFormat,
|
|
118
|
+
onChange
|
|
119
|
+
}), [addBlockDisplayFormat, cardinality, onChange, title]);
|
|
120
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
121
|
+
const mpQueryString = {
|
|
122
|
+
key: mpQueries?.key || _constants.MP_QUERY_KEY,
|
|
123
|
+
value: mpQueries?.value || _constants.MP_QUERY_VALUE
|
|
124
|
+
};
|
|
125
|
+
const platinumQueryString = {
|
|
126
|
+
key: platinumQueries?.key || _constants.PLATINUM_QUERY_KEY,
|
|
127
|
+
value: platinumQueries?.value || _constants.PLATINUM_QUERY_VALUE
|
|
128
|
+
};
|
|
129
|
+
const includingMp = mp || urlSearchParams.get(mpQueryString.key) === mpQueryString.value;
|
|
130
|
+
const isPlatinum = platinum || urlSearchParams.get(platinumQueryString.key) === platinumQueryString.value;
|
|
131
|
+
const initialData = (0, _react.useMemo)(() => {
|
|
132
|
+
if (!includingMp) {
|
|
133
|
+
const hasMpNav = data?.some(block => (0, _block.blockFilteredMPNav)(block, true));
|
|
134
|
+
if (hasMpNav) window.localStorage.removeItem(storageKey);
|
|
135
|
+
return hasMpNav ? [] : data;
|
|
136
|
+
}
|
|
137
|
+
if (data?.length) return data;
|
|
138
|
+
return mpNavigationProps ? [(0, _block.createBlock)(mpNavigationProps)] : [];
|
|
139
|
+
}, [data, includingMp, mpNavigationProps, storageKey]);
|
|
140
|
+
|
|
141
|
+
// Initialize editor state
|
|
142
|
+
(0, _react.useEffect)(() => {
|
|
143
|
+
if (data?.length && !initialed) {
|
|
144
|
+
onInit?.(data);
|
|
145
|
+
setInitialed(true);
|
|
146
|
+
}
|
|
147
|
+
const root = document.documentElement;
|
|
148
|
+
root.style.setProperty('--editor-sidebar-width', `${DEFAULT_BAR_WIDTH}px`);
|
|
149
|
+
root.style.setProperty('--editor-blocksbar-width', `${DEFAULT_BAR_WIDTH}px`);
|
|
150
|
+
}, [data, initialed, onInit]);
|
|
151
|
+
(0, _react.useEffect)(() => {
|
|
152
|
+
if (!includingMp) return;
|
|
153
|
+
blockTypes?.forEach(block => {
|
|
154
|
+
if ((0, _block.blockFilteredMPNav)(block, true, 'id')) {
|
|
155
|
+
setMpNavigationProps(block);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}, [blockTypes, includingMp, setMpNavigationProps]);
|
|
159
|
+
if (props.format === 'inline') {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (props.format === 'sidebar') {
|
|
163
|
+
const {
|
|
164
|
+
onBack
|
|
165
|
+
} = props;
|
|
166
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Provider.default, {
|
|
167
|
+
locale: locale,
|
|
168
|
+
editorTheme: _theme.default,
|
|
169
|
+
blockTypes: blockTypes,
|
|
170
|
+
isFullScreen: false,
|
|
171
|
+
data: initialData,
|
|
172
|
+
storage: storage,
|
|
173
|
+
includingMp: includingMp,
|
|
174
|
+
isNested: true,
|
|
175
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.default, {
|
|
176
|
+
onBack: onBack,
|
|
177
|
+
...mergedSidebarProps
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const handleDragSidebar = (e, position) => {
|
|
182
|
+
const dragBarEl = e.target;
|
|
183
|
+
const stopDrag = () => {
|
|
184
|
+
requestAnimationFrame(() => {
|
|
185
|
+
dragBarEl.style.width = '0px';
|
|
186
|
+
dragBarEl.style.position = 'relative';
|
|
187
|
+
});
|
|
188
|
+
dragBarEl.removeEventListener('mouseleave', stopDrag);
|
|
189
|
+
dragBarEl.removeEventListener('mouseup', stopDrag);
|
|
190
|
+
dragBarEl.removeEventListener('mousemove', handleMove);
|
|
191
|
+
};
|
|
192
|
+
let animationId = 0;
|
|
193
|
+
const handleMove = mouseMoveEvent => {
|
|
194
|
+
const root = document.documentElement;
|
|
195
|
+
window.cancelAnimationFrame(animationId);
|
|
196
|
+
animationId = window.requestAnimationFrame(() => {
|
|
197
|
+
let barWidth = position === 'right' ? window.innerWidth - mouseMoveEvent.clientX : window.innerWidth - (window.innerWidth - mouseMoveEvent.clientX);
|
|
198
|
+
const sidebarMaxWidth = Math.floor(window.innerWidth * 0.4);
|
|
199
|
+
if (barWidth < 60) {
|
|
200
|
+
barWidth = 40;
|
|
201
|
+
}
|
|
202
|
+
if (barWidth > sidebarMaxWidth) {
|
|
203
|
+
barWidth = sidebarMaxWidth;
|
|
204
|
+
}
|
|
205
|
+
if (position === 'right') {
|
|
206
|
+
root.style.setProperty('--editor-sidebar-width', `${barWidth}px`);
|
|
207
|
+
}
|
|
208
|
+
if (position === 'left') {
|
|
209
|
+
root.style.setProperty('--editor-blocksbar-width', `${barWidth}px`);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
dragBarEl.style.width = '100vw';
|
|
214
|
+
dragBarEl.style.position = 'fixed';
|
|
215
|
+
dragBarEl.addEventListener('mouseleave', stopDrag);
|
|
216
|
+
dragBarEl.addEventListener('mouseup', stopDrag);
|
|
217
|
+
dragBarEl.addEventListener('mousemove', handleMove);
|
|
218
|
+
};
|
|
219
|
+
const toggleBlocksBar = () => {
|
|
220
|
+
blocksBarVisibleRef.current = !blocksBarVisibleRef.current;
|
|
221
|
+
const root = document.documentElement;
|
|
222
|
+
root.style.setProperty('--editor-blocksbar-width', blocksBarVisibleRef.current ? `${DEFAULT_BAR_WIDTH}px` : '0px');
|
|
223
|
+
};
|
|
224
|
+
const toggleSidebar = () => {
|
|
225
|
+
sidebarVisibleRef.current = !sidebarVisibleRef.current;
|
|
226
|
+
const root = document.documentElement;
|
|
227
|
+
root.style.setProperty('--editor-sidebar-width', sidebarVisibleRef.current ? `${DEFAULT_BAR_WIDTH}px` : '0px');
|
|
228
|
+
};
|
|
229
|
+
const {
|
|
230
|
+
editorTheme = _theme.default,
|
|
231
|
+
onFullScreen,
|
|
232
|
+
onFullScreenExit,
|
|
233
|
+
isFullScreen,
|
|
234
|
+
previewSrc,
|
|
235
|
+
allowedOrigins = [],
|
|
236
|
+
onAction,
|
|
237
|
+
previewWidth,
|
|
238
|
+
headerSlots
|
|
239
|
+
} = props;
|
|
240
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Provider.default, {
|
|
241
|
+
locale: locale,
|
|
242
|
+
editorTheme: editorTheme,
|
|
243
|
+
theme: editorTheme,
|
|
244
|
+
allowedOrigins: allowedOrigins,
|
|
245
|
+
blockTypes: blockTypes,
|
|
246
|
+
data: initialData,
|
|
247
|
+
isFullScreen: isFullScreen,
|
|
248
|
+
includingMp: includingMp,
|
|
249
|
+
isMp: includingMp,
|
|
250
|
+
previewSrc: previewSrc,
|
|
251
|
+
previewWidth: previewWidth,
|
|
252
|
+
previewDeviceList: previewDeviceList,
|
|
253
|
+
storage: storage,
|
|
254
|
+
mpNavigationProps: mpNavigationProps,
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(MessageBusComponent, {
|
|
256
|
+
onAction: onAction,
|
|
257
|
+
postMessageParams: postMessageParams
|
|
258
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Root, {
|
|
259
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
260
|
+
ref: mainRef,
|
|
261
|
+
className: classes.main,
|
|
262
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Header.default, {
|
|
263
|
+
platinum: isPlatinum,
|
|
264
|
+
onExitFullScreen: onFullScreenExit,
|
|
265
|
+
onFullScreen: onFullScreen,
|
|
266
|
+
onToggleBlocksBar: toggleBlocksBar,
|
|
267
|
+
isBlocksBarVisible: blocksBarVisibleRef.current,
|
|
268
|
+
onToggleSidebar: toggleSidebar,
|
|
269
|
+
isSidebarVisible: sidebarVisibleRef.current,
|
|
270
|
+
onChange: onChange,
|
|
271
|
+
headerSlots: headerSlots
|
|
272
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
273
|
+
style: {
|
|
274
|
+
display: 'flex',
|
|
275
|
+
height: '100%',
|
|
276
|
+
overflow: 'hidden'
|
|
277
|
+
},
|
|
278
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
279
|
+
className: classes.sidebarWrapper,
|
|
280
|
+
style: {
|
|
281
|
+
maxWidth: 'var(--editor-blocksbar-width)',
|
|
282
|
+
transition: 'all 0.3s ease-in-out'
|
|
283
|
+
},
|
|
284
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_BlocksBar.default, {
|
|
285
|
+
onChange: onChange
|
|
286
|
+
})
|
|
287
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
288
|
+
className: classes.dragBarLeft,
|
|
289
|
+
onMouseDown: e => handleDragSidebar(e, 'left'),
|
|
290
|
+
role: "presentation"
|
|
291
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditorPreview.default, {
|
|
292
|
+
onChange: onChange
|
|
293
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
294
|
+
className: classes.dragBarRight,
|
|
295
|
+
onMouseDown: e => handleDragSidebar(e, 'right'),
|
|
296
|
+
role: "presentation"
|
|
297
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
298
|
+
className: classes.sidebarWrapper,
|
|
299
|
+
style: {
|
|
300
|
+
maxWidth: 'var(--editor-sidebar-width)',
|
|
301
|
+
transition: 'all 0.3s ease-in-out'
|
|
302
|
+
},
|
|
303
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Sidebar.default, {
|
|
304
|
+
...mergedSidebarProps
|
|
305
|
+
})
|
|
306
|
+
})]
|
|
307
|
+
})]
|
|
308
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Snackbar.default, {})]
|
|
309
|
+
})]
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
var _default = exports.default = Editor;
|