@wordpress/edit-widgets 6.32.0 → 6.32.1-next.47f435fc9.0
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/build/blocks/widget-area/block.json +26 -0
- package/build/blocks/widget-area/edit/index.js +94 -87
- package/build/blocks/widget-area/edit/index.js.map +7 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +68 -50
- package/build/blocks/widget-area/edit/inner-blocks.js.map +7 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +34 -40
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
- package/build/blocks/widget-area/index.js +49 -52
- package/build/blocks/widget-area/index.js.map +7 -1
- package/build/components/error-boundary/index.js +49 -51
- package/build/components/error-boundary/index.js.map +7 -1
- package/build/components/header/document-tools/index.js +104 -74
- package/build/components/header/document-tools/index.js.map +7 -1
- package/build/components/header/index.js +81 -62
- package/build/components/header/index.js.map +7 -1
- package/build/components/header/undo-redo/redo.js +50 -38
- package/build/components/header/undo-redo/redo.js.map +7 -1
- package/build/components/header/undo-redo/undo.js +49 -37
- package/build/components/header/undo-redo/undo.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
- package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +154 -103
- package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +74 -56
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +89 -82
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/layout/index.js +75 -49
- package/build/components/layout/index.js.map +7 -1
- package/build/components/layout/interface.js +89 -75
- package/build/components/layout/interface.js.map +7 -1
- package/build/components/layout/unsaved-changes-warning.js +35 -42
- package/build/components/layout/unsaved-changes-warning.js.map +7 -1
- package/build/components/more-menu/index.js +189 -108
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/more-menu/tools-more-menu-group.js +29 -23
- package/build/components/more-menu/tools-more-menu-group.js.map +7 -1
- package/build/components/notices/index.js +62 -48
- package/build/components/notices/index.js.map +7 -1
- package/build/components/save-button/index.js +55 -47
- package/build/components/save-button/index.js.map +7 -1
- package/build/components/secondary-sidebar/index.js +41 -34
- package/build/components/secondary-sidebar/index.js.map +7 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +55 -46
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +76 -67
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
- package/build/components/sidebar/index.js +149 -138
- package/build/components/sidebar/index.js.map +7 -1
- package/build/components/sidebar/widget-areas.js +73 -57
- package/build/components/sidebar/widget-areas.js.map +7 -1
- package/build/components/welcome-guide/index.js +182 -137
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/components/widget-areas-block-editor-content/index.js +64 -43
- package/build/components/widget-areas-block-editor-content/index.js.map +7 -1
- package/build/components/widget-areas-block-editor-provider/index.js +115 -92
- package/build/components/widget-areas-block-editor-provider/index.js.map +7 -1
- package/build/constants.js +30 -8
- package/build/constants.js.map +7 -1
- package/build/filters/index.js +3 -5
- package/build/filters/index.js.map +7 -1
- package/build/filters/move-to-widget-area.js +52 -59
- package/build/filters/move-to-widget-area.js.map +7 -1
- package/build/filters/replace-media-upload.js +9 -11
- package/build/filters/replace-media-upload.js.map +7 -1
- package/build/hooks/use-last-selected-widget-area.js +38 -44
- package/build/hooks/use-last-selected-widget-area.js.map +7 -1
- package/build/hooks/use-widget-library-insertion-point.js +60 -55
- package/build/hooks/use-widget-library-insertion-point.js.map +7 -1
- package/build/index.js +86 -93
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +181 -313
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -10
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +51 -51
- package/build/store/index.js.map +7 -1
- package/build/store/private-selectors.js +28 -7
- package/build/store/private-selectors.js.map +7 -1
- package/build/store/reducer.js +65 -118
- package/build/store/reducer.js.map +7 -1
- package/build/store/resolvers.js +64 -63
- package/build/store/resolvers.js.map +7 -1
- package/build/store/selectors.js +194 -231
- package/build/store/selectors.js.map +7 -1
- package/build/store/transformers.js +47 -41
- package/build/store/transformers.js.map +7 -1
- package/build/store/utils.js +47 -70
- package/build/store/utils.js.map +7 -1
- package/build-module/blocks/widget-area/block.json +26 -0
- package/build-module/blocks/widget-area/edit/index.js +63 -75
- package/build-module/blocks/widget-area/edit/index.js.map +7 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +38 -41
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +7 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +14 -33
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
- package/build-module/blocks/widget-area/index.js +14 -46
- package/build-module/blocks/widget-area/index.js.map +7 -1
- package/build-module/components/error-boundary/index.js +30 -43
- package/build-module/components/error-boundary/index.js.map +7 -1
- package/build-module/components/header/document-tools/index.js +75 -66
- package/build-module/components/header/document-tools/index.js.map +7 -1
- package/build-module/components/header/index.js +52 -54
- package/build-module/components/header/index.js.map +7 -1
- package/build-module/components/header/undo-redo/redo.js +32 -32
- package/build-module/components/header/undo-redo/redo.js.map +7 -1
- package/build-module/components/header/undo-redo/undo.js +31 -31
- package/build-module/components/header/undo-redo/undo.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -97
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +56 -50
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +73 -75
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/layout/index.js +46 -41
- package/build-module/components/layout/index.js.map +7 -1
- package/build-module/components/layout/interface.js +63 -66
- package/build-module/components/layout/interface.js.map +7 -1
- package/build-module/components/layout/unsaved-changes-warning.js +17 -37
- package/build-module/components/layout/unsaved-changes-warning.js.map +7 -1
- package/build-module/components/more-menu/index.js +167 -102
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +11 -17
- package/build-module/components/more-menu/tools-more-menu-group.js.map +7 -1
- package/build-module/components/notices/index.js +43 -42
- package/build-module/components/notices/index.js.map +7 -1
- package/build-module/components/save-button/index.js +37 -41
- package/build-module/components/save-button/index.js.map +7 -1
- package/build-module/components/secondary-sidebar/index.js +14 -27
- package/build-module/components/secondary-sidebar/index.js.map +7 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +26 -38
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +57 -60
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
- package/build-module/components/sidebar/index.js +129 -127
- package/build-module/components/sidebar/index.js.map +7 -1
- package/build-module/components/sidebar/widget-areas.js +53 -49
- package/build-module/components/sidebar/widget-areas.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +165 -132
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +43 -36
- package/build-module/components/widget-areas-block-editor-content/index.js.map +7 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +85 -83
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +7 -1
- package/build-module/constants.js +7 -3
- package/build-module/constants.js.map +7 -1
- package/build-module/filters/index.js +3 -6
- package/build-module/filters/index.js.map +7 -1
- package/build-module/filters/move-to-widget-area.js +52 -57
- package/build-module/filters/move-to-widget-area.js.map +7 -1
- package/build-module/filters/replace-media-upload.js +8 -7
- package/build-module/filters/replace-media-upload.js.map +7 -1
- package/build-module/hooks/use-last-selected-widget-area.js +20 -39
- package/build-module/hooks/use-last-selected-widget-area.js.map +7 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +42 -49
- package/build-module/hooks/use-widget-library-insertion-point.js.map +7 -1
- package/build-module/index.js +60 -72
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +153 -293
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -5
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +16 -40
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/private-selectors.js +7 -3
- package/build-module/store/private-selectors.js.map +7 -1
- package/build-module/store/reducer.js +42 -111
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/resolvers.js +43 -51
- package/build-module/store/resolvers.js.map +7 -1
- package/build-module/store/selectors.js +171 -224
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/store/transformers.js +23 -34
- package/build-module/store/transformers.js.map +7 -1
- package/build-module/store/utils.js +22 -63
- package/build-module/store/utils.js.map +7 -1
- package/build-style/style-rtl.css +216 -88
- package/build-style/style.css +216 -88
- package/package.json +36 -29
- package/src/blocks/widget-area/editor.scss +3 -0
- package/src/components/customizer-edit-widgets-initializer/style.scss +3 -0
- package/src/components/error-boundary/style.scss +2 -0
- package/src/components/header/style.scss +5 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
- package/src/components/layout/style.scss +3 -0
- package/src/components/more-menu/style.scss +2 -0
- package/src/components/notices/style.scss +3 -0
- package/src/components/secondary-sidebar/style.scss +4 -0
- package/src/components/sidebar/style.scss +2 -0
- package/src/components/welcome-guide/style.scss +2 -0
- package/src/components/widget-areas-block-editor-content/style.scss +2 -0
- package/src/style.scss +16 -13
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "core/widget-area",
|
|
5
|
+
"title": "Widget Area",
|
|
6
|
+
"category": "widgets",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"supports": {
|
|
16
|
+
"html": false,
|
|
17
|
+
"inserter": false,
|
|
18
|
+
"customClassName": false,
|
|
19
|
+
"reusable": false,
|
|
20
|
+
"__experimentalToolbar": false,
|
|
21
|
+
"__experimentalParentSelector": false,
|
|
22
|
+
"__experimentalDisableBlockOverlay": true
|
|
23
|
+
},
|
|
24
|
+
"editorStyle": "wp-block-widget-area-editor",
|
|
25
|
+
"style": "wp-block-widget-area"
|
|
26
|
+
}
|
|
@@ -1,44 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var edit_exports = {};
|
|
29
|
+
__export(edit_exports, {
|
|
30
|
+
default: () => WidgetAreaEdit
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
* WordPress dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Internal dependencies
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/** @typedef {import('@wordpress/element').RefObject} RefObject */function WidgetAreaEdit({
|
|
32
|
+
module.exports = __toCommonJS(edit_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_element = require("@wordpress/element");
|
|
35
|
+
var import_data = require("@wordpress/data");
|
|
36
|
+
var import_core_data = require("@wordpress/core-data");
|
|
37
|
+
var import_components = require("@wordpress/components");
|
|
38
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
39
|
+
var import_inner_blocks = __toESM(require("./inner-blocks"));
|
|
40
|
+
var import_store = require("../../../store");
|
|
41
|
+
var import_use_is_dragging_within = __toESM(require("./use-is-dragging-within"));
|
|
42
|
+
function WidgetAreaEdit({
|
|
26
43
|
clientId,
|
|
27
|
-
attributes: {
|
|
28
|
-
id,
|
|
29
|
-
name
|
|
30
|
-
}
|
|
44
|
+
attributes: { id, name }
|
|
31
45
|
}) {
|
|
32
|
-
const isOpen = (0,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
46
|
+
const isOpen = (0, import_data.useSelect)(
|
|
47
|
+
(select) => select(import_store.store).getIsWidgetAreaOpen(clientId),
|
|
48
|
+
[clientId]
|
|
49
|
+
);
|
|
50
|
+
const { setIsWidgetAreaOpen } = (0, import_data.useDispatch)(import_store.store);
|
|
51
|
+
const wrapper = (0, import_element.useRef)();
|
|
52
|
+
const setOpen = (0, import_element.useCallback)(
|
|
53
|
+
(openState) => setIsWidgetAreaOpen(clientId, openState),
|
|
54
|
+
[clientId]
|
|
55
|
+
);
|
|
38
56
|
const isDragging = useIsDragging(wrapper);
|
|
39
|
-
const isDraggingWithin = (0,
|
|
40
|
-
const [openedWhileDragging, setOpenedWhileDragging] = (0,
|
|
41
|
-
(0,
|
|
57
|
+
const isDraggingWithin = (0, import_use_is_dragging_within.default)(wrapper);
|
|
58
|
+
const [openedWhileDragging, setOpenedWhileDragging] = (0, import_element.useState)(false);
|
|
59
|
+
(0, import_element.useEffect)(() => {
|
|
42
60
|
if (!isDragging) {
|
|
43
61
|
setOpenedWhileDragging(false);
|
|
44
62
|
return;
|
|
@@ -50,69 +68,58 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
50
68
|
setOpen(false);
|
|
51
69
|
}
|
|
52
70
|
}, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]);
|
|
53
|
-
const blockProps = (0,
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
scrollAfterOpen: !isDragging,
|
|
65
|
-
children: ({
|
|
66
|
-
opened
|
|
67
|
-
}) =>
|
|
68
|
-
/*#__PURE__*/
|
|
71
|
+
const blockProps = (0, import_block_editor.useBlockProps)();
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Panel, { ref: wrapper, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
73
|
+
import_components.PanelBody,
|
|
74
|
+
{
|
|
75
|
+
title: name,
|
|
76
|
+
opened: isOpen,
|
|
77
|
+
onToggle: () => {
|
|
78
|
+
setIsWidgetAreaOpen(clientId, !isOpen);
|
|
79
|
+
},
|
|
80
|
+
scrollAfterOpen: !isDragging,
|
|
81
|
+
children: ({ opened }) => (
|
|
69
82
|
// This is required to ensure LegacyWidget blocks are not
|
|
70
83
|
// unmounted when the panel is collapsed. Unmounting legacy
|
|
71
84
|
// widgets may have unintended consequences (e.g. TinyMCE
|
|
72
85
|
// not being properly reinitialized)
|
|
73
|
-
(0,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
+
import_components.__unstableDisclosureContent,
|
|
88
|
+
{
|
|
89
|
+
className: "wp-block-widget-area__panel-body-content",
|
|
90
|
+
visible: opened,
|
|
91
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
import_core_data.EntityProvider,
|
|
93
|
+
{
|
|
94
|
+
kind: "root",
|
|
95
|
+
type: "postType",
|
|
96
|
+
id: `widget-area-${id}`,
|
|
97
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_inner_blocks.default, { id })
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
) }) });
|
|
88
105
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* @param {RefObject<HTMLElement>} elementRef The target elementRef object.
|
|
94
|
-
*
|
|
95
|
-
* @return {boolean} Is dragging within the entire document.
|
|
96
|
-
*/
|
|
97
|
-
const useIsDragging = elementRef => {
|
|
98
|
-
const [isDragging, setIsDragging] = (0, _element.useState)(false);
|
|
99
|
-
(0, _element.useEffect)(() => {
|
|
100
|
-
const {
|
|
101
|
-
ownerDocument
|
|
102
|
-
} = elementRef.current;
|
|
106
|
+
const useIsDragging = (elementRef) => {
|
|
107
|
+
const [isDragging, setIsDragging] = (0, import_element.useState)(false);
|
|
108
|
+
(0, import_element.useEffect)(() => {
|
|
109
|
+
const { ownerDocument } = elementRef.current;
|
|
103
110
|
function handleDragStart() {
|
|
104
111
|
setIsDragging(true);
|
|
105
112
|
}
|
|
106
113
|
function handleDragEnd() {
|
|
107
114
|
setIsDragging(false);
|
|
108
115
|
}
|
|
109
|
-
ownerDocument.addEventListener(
|
|
110
|
-
ownerDocument.addEventListener(
|
|
116
|
+
ownerDocument.addEventListener("dragstart", handleDragStart);
|
|
117
|
+
ownerDocument.addEventListener("dragend", handleDragEnd);
|
|
111
118
|
return () => {
|
|
112
|
-
ownerDocument.removeEventListener(
|
|
113
|
-
ownerDocument.removeEventListener(
|
|
119
|
+
ownerDocument.removeEventListener("dragstart", handleDragStart);
|
|
120
|
+
ownerDocument.removeEventListener("dragend", handleDragEnd);
|
|
114
121
|
};
|
|
115
122
|
}, []);
|
|
116
123
|
return isDragging;
|
|
117
124
|
};
|
|
118
|
-
//# sourceMappingURL=index.js.map
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/blocks/widget-area/edit/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\nimport { useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Panel ref={ wrapper }>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ name }\n\t\t\t\t\topened={ isOpen }\n\t\t\t\t\tonToggle={ () => {\n\t\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t\t} }\n\t\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t\t>\n\t\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</DisclosureContent>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</Panel>\n\t\t</div>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmFQ;AAhFR,qBAAyD;AACzD,kBAAuC;AACvC,uBAA+B;AAC/B,wBAIO;AACP,0BAA8B;AAK9B,0BAAkC;AAClC,mBAA0C;AAC1C,oCAAgC;AAIjB,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA,YAAY,EAAE,IAAI,KAAK;AACxB,GAAI;AACH,QAAM,aAAS;AAAA,IACd,CAAE,WACD,OAAQ,aAAAA,KAAiB,EAAE,oBAAqB,QAAS;AAAA,IAC1D,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,EAAE,oBAAoB,QAAI,yBAAa,aAAAA,KAAiB;AAE9D,QAAM,cAAU,uBAAO;AACvB,QAAM,cAAU;AAAA,IACf,CAAE,cAAe,oBAAqB,UAAU,SAAU;AAAA,IAC1D,CAAE,QAAS;AAAA,EACZ;AACA,QAAM,aAAa,cAAe,OAAQ;AAC1C,QAAM,uBAAmB,8BAAAC,SAAqB,OAAQ;AAEtD,QAAM,CAAE,qBAAqB,sBAAuB,QAAI,yBAAU,KAAM;AACxE,gCAAW,MAAM;AAChB,QAAK,CAAE,YAAa;AACnB,6BAAwB,KAAM;AAC9B;AAAA,IACD;AAEA,QAAK,oBAAoB,CAAE,QAAS;AACnC,cAAS,IAAK;AACd,6BAAwB,IAAK;AAAA,IAC9B,WAAY,CAAE,oBAAoB,UAAU,qBAAsB;AACjE,cAAS,KAAM;AAAA,IAChB;AAAA,EACD,GAAG,CAAE,QAAQ,YAAY,kBAAkB,mBAAoB,CAAE;AAEjE,QAAM,iBAAa,mCAAc;AAEjC,SACC,4CAAC,SAAM,GAAG,YACT,sDAAC,2BAAM,KAAM,SACZ;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA,MACR,QAAS;AAAA,MACT,UAAW,MAAM;AAChB,4BAAqB,UAAU,CAAE,MAAO;AAAA,MACzC;AAAA,MACA,iBAAkB,CAAE;AAAA,MAElB,WAAE,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,QAKZ;AAAA,UAAC,kBAAAC;AAAA,UAAA;AAAA,YACA,WAAU;AAAA,YACV,SAAU;AAAA,YAEV;AAAA,cAAC;AAAA;AAAA,gBACA,MAAK;AAAA,gBACL,MAAK;AAAA,gBACL,IAAK,eAAgB,EAAG;AAAA,gBAExB,sDAAC,oBAAAC,SAAA,EAAsB,IAAU;AAAA;AAAA,YAClC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD,GACD;AAEF;AASA,MAAM,gBAAgB,CAAE,eAAgB;AACvC,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAU,KAAM;AAEtD,gCAAW,MAAM;AAChB,UAAM,EAAE,cAAc,IAAI,WAAW;AAErC,aAAS,kBAAkB;AAC1B,oBAAe,IAAK;AAAA,IACrB;AAEA,aAAS,gBAAgB;AACxB,oBAAe,KAAM;AAAA,IACtB;AAEA,kBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAc,iBAAkB,WAAW,aAAc;AAEzD,WAAO,MAAM;AACZ,oBAAc,oBAAqB,aAAa,eAAgB;AAChE,oBAAc,oBAAqB,WAAW,aAAc;AAAA,IAC7D;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;",
|
|
6
|
+
"names": ["editWidgetsStore", "useIsDraggingWithin", "DisclosureContent", "WidgetAreaInnerBlocks"]
|
|
7
|
+
}
|
|
@@ -1,53 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var inner_blocks_exports = {};
|
|
29
|
+
__export(inner_blocks_exports, {
|
|
30
|
+
default: () => WidgetAreaInnerBlocks
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function WidgetAreaInnerBlocks({
|
|
27
|
-
id
|
|
28
|
-
}) {
|
|
29
|
-
const [blocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('root', 'postType');
|
|
30
|
-
const innerBlocksRef = (0, _element.useRef)();
|
|
31
|
-
const isDraggingWithinInnerBlocks = (0, _useIsDraggingWithin.default)(innerBlocksRef);
|
|
32
|
+
module.exports = __toCommonJS(inner_blocks_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_clsx = __toESM(require("clsx"));
|
|
35
|
+
var import_core_data = require("@wordpress/core-data");
|
|
36
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_use_is_dragging_within = __toESM(require("./use-is-dragging-within"));
|
|
39
|
+
function WidgetAreaInnerBlocks({ id }) {
|
|
40
|
+
const [blocks, onInput, onChange] = (0, import_core_data.useEntityBlockEditor)(
|
|
41
|
+
"root",
|
|
42
|
+
"postType"
|
|
43
|
+
);
|
|
44
|
+
const innerBlocksRef = (0, import_element.useRef)();
|
|
45
|
+
const isDraggingWithinInnerBlocks = (0, import_use_is_dragging_within.default)(innerBlocksRef);
|
|
32
46
|
const shouldHighlightDropZone = isDraggingWithinInnerBlocks;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const innerBlocksProps = (0, import_block_editor.useInnerBlocksProps)(
|
|
48
|
+
{ ref: innerBlocksRef },
|
|
49
|
+
{
|
|
50
|
+
value: blocks,
|
|
51
|
+
onInput,
|
|
52
|
+
onChange,
|
|
53
|
+
templateLock: false,
|
|
54
|
+
renderAppender: import_block_editor.InnerBlocks.ButtonBlockAppender
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
"data-widget-area-id": id,
|
|
61
|
+
className: (0, import_clsx.default)(
|
|
62
|
+
"wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper",
|
|
63
|
+
{
|
|
64
|
+
"wp-block-widget-area__highlight-drop-zone": shouldHighlightDropZone
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...innerBlocksProps })
|
|
68
|
+
}
|
|
69
|
+
);
|
|
52
70
|
}
|
|
53
|
-
//# sourceMappingURL=inner-blocks.js.map
|
|
71
|
+
//# sourceMappingURL=inner-blocks.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/blocks/widget-area/edit/inner-blocks.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone':\n\t\t\t\t\t\tshouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDG;AA7CH,kBAAiB;AAKjB,uBAAqC;AACrC,0BAAiD;AACjD,qBAAuB;AAKvB,oCAAgC;AAEjB,SAAR,sBAAwC,EAAE,GAAG,GAAI;AACvD,QAAM,CAAE,QAAQ,SAAS,QAAS,QAAI;AAAA,IACrC;AAAA,IACA;AAAA,EACD;AACA,QAAM,qBAAiB,uBAAO;AAC9B,QAAM,kCAA8B,8BAAAA,SAAqB,cAAe;AACxE,QAAM,0BAA0B;AAEhC,QAAM,uBAAmB;AAAA,IACxB,EAAE,KAAK,eAAe;AAAA,IACtB;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,gBAAgB,gCAAY;AAAA,IAC7B;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAsB;AAAA,MACtB,eAAY,YAAAC;AAAA,QACX;AAAA,QACA;AAAA,UACC,6CACC;AAAA,QACF;AAAA,MACD;AAAA,MAEA,sDAAC,SAAM,GAAG,kBAAmB;AAAA;AAAA,EAC9B;AAEF;",
|
|
6
|
+
"names": ["useIsDraggingWithin", "clsx"]
|
|
7
|
+
}
|
|
@@ -1,59 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var use_is_dragging_within_exports = {};
|
|
19
|
+
__export(use_is_dragging_within_exports, {
|
|
20
|
+
default: () => use_is_dragging_within_default
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** @typedef {import('@wordpress/element').RefObject} RefObject */
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A React hook to determine if it's dragging within the target element.
|
|
16
|
-
*
|
|
17
|
-
* @param {RefObject<HTMLElement>} elementRef The target elementRef object.
|
|
18
|
-
*
|
|
19
|
-
* @return {boolean} Is dragging within the target element.
|
|
20
|
-
*/
|
|
21
|
-
const useIsDraggingWithin = elementRef => {
|
|
22
|
-
const [isDraggingWithin, setIsDraggingWithin] = (0, _element.useState)(false);
|
|
23
|
-
(0, _element.useEffect)(() => {
|
|
24
|
-
const {
|
|
25
|
-
ownerDocument
|
|
26
|
-
} = elementRef.current;
|
|
22
|
+
module.exports = __toCommonJS(use_is_dragging_within_exports);
|
|
23
|
+
var import_element = require("@wordpress/element");
|
|
24
|
+
const useIsDraggingWithin = (elementRef) => {
|
|
25
|
+
const [isDraggingWithin, setIsDraggingWithin] = (0, import_element.useState)(false);
|
|
26
|
+
(0, import_element.useEffect)(() => {
|
|
27
|
+
const { ownerDocument } = elementRef.current;
|
|
27
28
|
function handleDragStart(event) {
|
|
28
|
-
// Check the first time when the dragging starts.
|
|
29
29
|
handleDragEnter(event);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.
|
|
33
31
|
function handleDragEnd() {
|
|
34
32
|
setIsDraggingWithin(false);
|
|
35
33
|
}
|
|
36
34
|
function handleDragEnter(event) {
|
|
37
|
-
// Check if the current target is inside the item element.
|
|
38
35
|
if (elementRef.current.contains(event.target)) {
|
|
39
36
|
setIsDraggingWithin(true);
|
|
40
37
|
} else {
|
|
41
38
|
setIsDraggingWithin(false);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ownerDocument.addEventListener('dragstart', handleDragStart);
|
|
48
|
-
ownerDocument.addEventListener('dragend', handleDragEnd);
|
|
49
|
-
ownerDocument.addEventListener('dragenter', handleDragEnter);
|
|
41
|
+
ownerDocument.addEventListener("dragstart", handleDragStart);
|
|
42
|
+
ownerDocument.addEventListener("dragend", handleDragEnd);
|
|
43
|
+
ownerDocument.addEventListener("dragenter", handleDragEnter);
|
|
50
44
|
return () => {
|
|
51
|
-
ownerDocument.removeEventListener(
|
|
52
|
-
ownerDocument.removeEventListener(
|
|
53
|
-
ownerDocument.removeEventListener(
|
|
45
|
+
ownerDocument.removeEventListener("dragstart", handleDragStart);
|
|
46
|
+
ownerDocument.removeEventListener("dragend", handleDragEnd);
|
|
47
|
+
ownerDocument.removeEventListener("dragenter", handleDragEnter);
|
|
54
48
|
};
|
|
55
49
|
}, []);
|
|
56
50
|
return isDraggingWithin;
|
|
57
51
|
};
|
|
58
|
-
var
|
|
59
|
-
//# sourceMappingURL=use-is-dragging-within.js.map
|
|
52
|
+
var use_is_dragging_within_default = useIsDraggingWithin;
|
|
53
|
+
//# sourceMappingURL=use-is-dragging-within.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/blocks/widget-area/edit/use-is-dragging-within.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nexport default useIsDraggingWithin;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoC;AAWpC,MAAM,sBAAsB,CAAE,eAAgB;AAC7C,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAU,KAAM;AAElE,gCAAW,MAAM;AAChB,UAAM,EAAE,cAAc,IAAI,WAAW;AAErC,aAAS,gBAAiB,OAAQ;AAEjC,sBAAiB,KAAM;AAAA,IACxB;AAGA,aAAS,gBAAgB;AACxB,0BAAqB,KAAM;AAAA,IAC5B;AAEA,aAAS,gBAAiB,OAAQ;AAEjC,UAAK,WAAW,QAAQ,SAAU,MAAM,MAAO,GAAI;AAClD,4BAAqB,IAAK;AAAA,MAC3B,OAAO;AACN,4BAAqB,KAAM;AAAA,MAC5B;AAAA,IACD;AAIA,kBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAc,iBAAkB,WAAW,aAAc;AACzD,kBAAc,iBAAkB,aAAa,eAAgB;AAE7D,WAAO,MAAM;AACZ,oBAAc,oBAAqB,aAAa,eAAgB;AAChE,oBAAc,oBAAqB,WAAW,aAAc;AAC5D,oBAAc,oBAAqB,aAAa,eAAgB;AAAA,IACjE;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;AAEA,IAAO,iCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,54 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
apiVersion: 3,
|
|
19
|
-
name: "core/widget-area",
|
|
20
|
-
title: "Widget Area",
|
|
21
|
-
category: "widgets",
|
|
22
|
-
attributes: {
|
|
23
|
-
id: {
|
|
24
|
-
type: "string"
|
|
25
|
-
},
|
|
26
|
-
name: {
|
|
27
|
-
type: "string"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
supports: {
|
|
31
|
-
html: false,
|
|
32
|
-
inserter: false,
|
|
33
|
-
customClassName: false,
|
|
34
|
-
reusable: false,
|
|
35
|
-
__experimentalToolbar: false,
|
|
36
|
-
__experimentalParentSelector: false,
|
|
37
|
-
__experimentalDisableBlockOverlay: true
|
|
38
|
-
},
|
|
39
|
-
editorStyle: "wp-block-widget-area-editor",
|
|
40
|
-
style: "wp-block-widget-area"
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name2 in all)
|
|
9
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
41
18
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var widget_area_exports = {};
|
|
29
|
+
__export(widget_area_exports, {
|
|
30
|
+
metadata: () => import_block.default,
|
|
31
|
+
name: () => name,
|
|
32
|
+
settings: () => settings
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(widget_area_exports);
|
|
35
|
+
var import_i18n = require("@wordpress/i18n");
|
|
36
|
+
var import_block = __toESM(require("./block.json"));
|
|
37
|
+
var import_edit = __toESM(require("./edit"));
|
|
38
|
+
const { name } = import_block.default;
|
|
39
|
+
const settings = {
|
|
40
|
+
title: (0, import_i18n.__)("Widget Area"),
|
|
41
|
+
description: (0, import_i18n.__)("A widget area container."),
|
|
42
|
+
__experimentalLabel: ({ name: label }) => label,
|
|
43
|
+
edit: import_edit.default
|
|
53
44
|
};
|
|
54
|
-
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
metadata,
|
|
48
|
+
name,
|
|
49
|
+
settings
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.js.map
|