@wordpress/block-library 7.15.0 → 7.15.1-next.4d3b314fd5.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/CHANGELOG.md +1 -0
- package/build/comments-pagination-numbers/index.js +7 -0
- package/build/comments-pagination-numbers/index.js.map +1 -1
- package/build/gallery/gallery.js +2 -28
- package/build/gallery/gallery.js.map +1 -1
- package/build/paragraph/drop-zone.js +99 -0
- package/build/paragraph/drop-zone.js.map +1 -0
- package/build/paragraph/edit.js +11 -3
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-content/edit.js +6 -1
- package/build/post-content/edit.js.map +1 -1
- package/build-module/comments-pagination-numbers/index.js +7 -0
- package/build-module/comments-pagination-numbers/index.js.map +1 -1
- package/build-module/gallery/gallery.js +2 -29
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/paragraph/drop-zone.js +88 -0
- package/build-module/paragraph/drop-zone.js.map +1 -0
- package/build-module/paragraph/edit.js +10 -3
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-content/edit.js +6 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-style/classic-rtl.css +85 -0
- package/build-style/classic.css +85 -0
- package/build-style/editor-rtl.css +41 -2
- package/build-style/editor.css +41 -2
- package/build-style/group/editor-rtl.css +11 -1
- package/build-style/group/editor.css +11 -1
- package/build-style/image/editor-rtl.css +3 -0
- package/build-style/image/editor.css +3 -0
- package/build-style/navigation/editor-rtl.css +11 -1
- package/build-style/navigation/editor.css +11 -1
- package/build-style/paragraph/editor-rtl.css +16 -0
- package/build-style/paragraph/editor.css +16 -0
- package/package.json +28 -28
- package/src/archives/index.php +4 -7
- package/src/classic.scss +15 -0
- package/src/comment-template/index.php +18 -8
- package/src/comments-pagination-numbers/block.json +7 -0
- package/src/gallery/gallery.js +1 -31
- package/src/image/editor.scss +4 -0
- package/src/navigation-submenu/index.php +11 -2
- package/src/page-list/index.php +1 -1
- package/src/paragraph/drop-zone.js +105 -0
- package/src/paragraph/edit.js +14 -1
- package/src/paragraph/editor.scss +20 -0
- package/src/post-content/edit.js +3 -1
- package/src/tag-cloud/index.php +1 -8
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
### New Feature
|
|
10
10
|
|
|
11
11
|
- Made it possible to import individual blocks ([#42258](https://github.com/WordPress/gutenberg/pull/42258)). Check [README](./README.md#loading-individual-blocks) for more information.
|
|
12
|
+
- Paragraph block: You can now drop files/blocks/HTML on an empty Paragraph block to transform it into relevant blocks ([#42722](https://github.com/WordPress/gutenberg/pull/42722)).
|
|
12
13
|
|
|
13
14
|
## 7.13.0 (2022-08-24)
|
|
14
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-pagination-numbers/index.js"],"names":["name","metadata","settings","icon","edit","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AAVA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-pagination-numbers/index.js"],"names":["name","metadata","settings","icon","edit","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,6BADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB;;;AAKA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEL,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { queryPaginationNumbers as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
package/build/gallery/gallery.js
CHANGED
|
@@ -59,25 +59,6 @@ const Gallery = props => {
|
|
|
59
59
|
alignments: []
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
const [captionFocused, setCaptionFocused] = (0, _element.useState)(false);
|
|
63
|
-
|
|
64
|
-
function onFocusCaption() {
|
|
65
|
-
if (!captionFocused) {
|
|
66
|
-
setCaptionFocused(true);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function removeCaptionFocus() {
|
|
71
|
-
if (captionFocused) {
|
|
72
|
-
setCaptionFocused(false);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
(0, _element.useEffect)(() => {
|
|
77
|
-
if (!isSelected) {
|
|
78
|
-
setCaptionFocused(false);
|
|
79
|
-
}
|
|
80
|
-
}, [isSelected]);
|
|
81
62
|
return (0, _element.createElement)("figure", (0, _extends2.default)({}, innerBlocksProps, {
|
|
82
63
|
className: (0, _classnames.default)(blockProps.className, 'blocks-gallery-grid', {
|
|
83
64
|
[`align${align}`]: align,
|
|
@@ -86,12 +67,9 @@ const Gallery = props => {
|
|
|
86
67
|
'is-cropped': imageCrop
|
|
87
68
|
})
|
|
88
69
|
}), children, isSelected && !children && (0, _element.createElement)(_primitives.View, {
|
|
89
|
-
className: "blocks-gallery-media-placeholder-wrapper"
|
|
90
|
-
onClick: removeCaptionFocus
|
|
70
|
+
className: "blocks-gallery-media-placeholder-wrapper"
|
|
91
71
|
}, mediaPlaceholder), (0, _element.createElement)(RichTextVisibilityHelper, {
|
|
92
72
|
isHidden: !isSelected && _blockEditor.RichText.isEmpty(caption),
|
|
93
|
-
captionFocused: captionFocused,
|
|
94
|
-
onFocusCaption: onFocusCaption,
|
|
95
73
|
tagName: "figcaption",
|
|
96
74
|
className: (0, _classnames.default)('blocks-gallery-caption', (0, _blockEditor.__experimentalGetElementClassName)('caption')),
|
|
97
75
|
"aria-label": (0, _i18n.__)('Gallery caption text'),
|
|
@@ -110,8 +88,6 @@ exports.Gallery = Gallery;
|
|
|
110
88
|
function RichTextVisibilityHelper(_ref) {
|
|
111
89
|
let {
|
|
112
90
|
isHidden,
|
|
113
|
-
captionFocused,
|
|
114
|
-
onFocusCaption,
|
|
115
91
|
className,
|
|
116
92
|
value,
|
|
117
93
|
placeholder,
|
|
@@ -131,9 +107,7 @@ function RichTextVisibilityHelper(_ref) {
|
|
|
131
107
|
value: value,
|
|
132
108
|
placeholder: placeholder,
|
|
133
109
|
className: className,
|
|
134
|
-
tagName: tagName
|
|
135
|
-
isSelected: captionFocused,
|
|
136
|
-
onClick: onFocusCaption
|
|
110
|
+
tagName: tagName
|
|
137
111
|
}, richTextProps));
|
|
138
112
|
}
|
|
139
113
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/gallery.js"],"names":["allowedBlocks","Gallery","props","attributes","isSelected","setAttributes","mediaPlaceholder","insertBlocksAfter","blockProps","align","columns","caption","imageCrop","children","innerBlocksProps","orientation","renderAppender","__experimentalLayout","type","alignments","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/gallery/gallery.js"],"names":["allowedBlocks","Gallery","props","attributes","isSelected","setAttributes","mediaPlaceholder","insertBlocksAfter","blockProps","align","columns","caption","imageCrop","children","innerBlocksProps","orientation","renderAppender","__experimentalLayout","type","alignments","className","undefined","RichText","isEmpty","value","RichTextVisibilityHelper","isHidden","placeholder","tagName","captionRef","richTextProps"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;AAWA,MAAMA,aAAa,GAAG,CAAE,YAAF,CAAtB;;AAEO,MAAMC,OAAO,GAAKC,KAAF,IAAa;AACnC,QAAM;AACLC,IAAAA,UADK;AAELC,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AAQ,EAAKa,KAAF,IAAanB,aAAa,CAAE;AAAEM,MAAAA,OAAO,EAAEa;AAAX,KAAF,CAVtC;AAWC,IAAA,aAAa,MAXd;AAYC,IAAA,sBAAsB,EAAG,MACxBjB,iBAAiB,CAAE,yBAAa,kCAAb,CAAF;AAbnB,IAnBD,CADD;AAsCA,CAzDM;;;;AA2DP,SAASkB,wBAAT,OAQI;AAAA,MAR+B;AAClCC,IAAAA,QADkC;AAElCN,IAAAA,SAFkC;AAGlCI,IAAAA,KAHkC;AAIlCG,IAAAA,WAJkC;AAKlCC,IAAAA,OALkC;AAMlCC,IAAAA,UANkC;AAOlC,OAAGC;AAP+B,GAQ/B;;AACH,MAAKJ,QAAL,EAAgB;AACf,WAAO,4BAAC,0BAAD;AAAgB,MAAA,EAAE,EAAGJ;AAArB,OAAqCQ,aAArC,EAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,GAAG,EAAGD,UADP;AAEC,IAAA,KAAK,EAAGL,KAFT;AAGC,IAAA,WAAW,EAAGG,WAHf;AAIC,IAAA,SAAS,EAAGP,SAJb;AAKC,IAAA,OAAO,EAAGQ;AALX,KAMME,aANN,EADD;AAUA;;eAEc7B,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseInnerBlocksProps,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { View } from '@wordpress/primitives';\n\nconst allowedBlocks = [ 'core/image' ];\n\nexport const Gallery = ( props ) => {\n\tconst {\n\t\tattributes,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tmediaPlaceholder,\n\t\tinsertBlocksAfter,\n\t\tblockProps,\n\t} = props;\n\n\tconst { align, columns, caption, imageCrop } = attributes;\n\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks,\n\t\torientation: 'horizontal',\n\t\trenderAppender: false,\n\t\t__experimentalLayout: { type: 'default', alignments: [] },\n\t} );\n\n\treturn (\n\t\t<figure\n\t\t\t{ ...innerBlocksProps }\n\t\t\tclassName={ classnames(\n\t\t\t\tblockProps.className,\n\t\t\t\t'blocks-gallery-grid',\n\t\t\t\t{\n\t\t\t\t\t[ `align${ align }` ]: align,\n\t\t\t\t\t[ `columns-${ columns }` ]: columns !== undefined,\n\t\t\t\t\t[ `columns-default` ]: columns === undefined,\n\t\t\t\t\t'is-cropped': imageCrop,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t\t{ isSelected && ! children && (\n\t\t\t\t<View className=\"blocks-gallery-media-placeholder-wrapper\">\n\t\t\t\t\t{ mediaPlaceholder }\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t<RichTextVisibilityHelper\n\t\t\t\tisHidden={ ! isSelected && RichText.isEmpty( caption ) }\n\t\t\t\ttagName=\"figcaption\"\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'blocks-gallery-caption',\n\t\t\t\t\t__experimentalGetElementClassName( 'caption' )\n\t\t\t\t) }\n\t\t\t\taria-label={ __( 'Gallery caption text' ) }\n\t\t\t\tplaceholder={ __( 'Write gallery caption…' ) }\n\t\t\t\tvalue={ caption }\n\t\t\t\tonChange={ ( value ) => setAttributes( { caption: value } ) }\n\t\t\t\tinlineToolbar\n\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) )\n\t\t\t\t}\n\t\t\t/>\n\t\t</figure>\n\t);\n};\n\nfunction RichTextVisibilityHelper( {\n\tisHidden,\n\tclassName,\n\tvalue,\n\tplaceholder,\n\ttagName,\n\tcaptionRef,\n\t...richTextProps\n} ) {\n\tif ( isHidden ) {\n\t\treturn <VisuallyHidden as={ RichText } { ...richTextProps } />;\n\t}\n\n\treturn (\n\t\t<RichText\n\t\t\tref={ captionRef }\n\t\t\tvalue={ value }\n\t\t\tplaceholder={ placeholder }\n\t\t\tclassName={ className }\n\t\t\ttagName={ tagName }\n\t\t\t{ ...richTextProps }\n\t\t/>\n\t);\n}\n\nexport default Gallery;\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DropZone;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
|
|
12
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
+
|
|
14
|
+
var _compose = require("@wordpress/compose");
|
|
15
|
+
|
|
16
|
+
var _components = require("@wordpress/components");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
const animateVariants = {
|
|
22
|
+
hide: {
|
|
23
|
+
opacity: 0,
|
|
24
|
+
scaleY: 0.75
|
|
25
|
+
},
|
|
26
|
+
show: {
|
|
27
|
+
opacity: 1,
|
|
28
|
+
scaleY: 1
|
|
29
|
+
},
|
|
30
|
+
exit: {
|
|
31
|
+
opacity: 0,
|
|
32
|
+
scaleY: 0.9
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function DropZone(_ref) {
|
|
37
|
+
let {
|
|
38
|
+
paragraphElement,
|
|
39
|
+
clientId
|
|
40
|
+
} = _ref;
|
|
41
|
+
const {
|
|
42
|
+
rootClientId,
|
|
43
|
+
blockIndex
|
|
44
|
+
} = (0, _data.useSelect)(select => {
|
|
45
|
+
const selectors = select(_blockEditor.store);
|
|
46
|
+
return {
|
|
47
|
+
rootClientId: selectors.getBlockRootClientId(clientId),
|
|
48
|
+
blockIndex: selectors.getBlockIndex(clientId)
|
|
49
|
+
};
|
|
50
|
+
}, [clientId]);
|
|
51
|
+
const onBlockDrop = (0, _blockEditor.__experimentalUseOnBlockDrop)(rootClientId, blockIndex, {
|
|
52
|
+
action: 'replace'
|
|
53
|
+
});
|
|
54
|
+
const [isDragging, setIsDragging] = (0, _element.useState)(false);
|
|
55
|
+
const [isVisible, setIsVisible] = (0, _element.useState)(false);
|
|
56
|
+
const popoverRef = (0, _compose.__experimentalUseDropZone)({
|
|
57
|
+
onDragStart: () => {
|
|
58
|
+
setIsDragging(true);
|
|
59
|
+
},
|
|
60
|
+
onDragEnd: () => {
|
|
61
|
+
setIsDragging(false);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const dropZoneRef = (0, _compose.__experimentalUseDropZone)({
|
|
65
|
+
onDrop: onBlockDrop,
|
|
66
|
+
onDragEnter: () => {
|
|
67
|
+
setIsVisible(true);
|
|
68
|
+
},
|
|
69
|
+
onDragLeave: () => {
|
|
70
|
+
setIsVisible(false);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const reducedMotion = (0, _compose.useReducedMotion)();
|
|
74
|
+
return (0, _element.createElement)(_components.Popover, {
|
|
75
|
+
anchor: paragraphElement,
|
|
76
|
+
animate: false,
|
|
77
|
+
placement: "top-start",
|
|
78
|
+
focusOnMount: false,
|
|
79
|
+
flip: false,
|
|
80
|
+
resize: false,
|
|
81
|
+
className: "wp-block-paragraph__drop-zone",
|
|
82
|
+
ref: popoverRef
|
|
83
|
+
}, isDragging ? (0, _element.createElement)("div", {
|
|
84
|
+
className: "wp-block-paragraph__drop-zone-backdrop",
|
|
85
|
+
ref: dropZoneRef,
|
|
86
|
+
style: {
|
|
87
|
+
width: paragraphElement === null || paragraphElement === void 0 ? void 0 : paragraphElement.offsetWidth,
|
|
88
|
+
height: paragraphElement === null || paragraphElement === void 0 ? void 0 : paragraphElement.offsetHeight
|
|
89
|
+
}
|
|
90
|
+
}, (0, _element.createElement)(_components.__unstableAnimatePresence, null, isVisible ? (0, _element.createElement)(_components.__unstableMotion.div, {
|
|
91
|
+
key: "drop-zone-foreground",
|
|
92
|
+
"data-testid": "empty-paragraph-drop-zone",
|
|
93
|
+
initial: reducedMotion ? animateVariants.show : animateVariants.hide,
|
|
94
|
+
animate: animateVariants.show,
|
|
95
|
+
exit: reducedMotion ? animateVariants.show : animateVariants.exit,
|
|
96
|
+
className: "wp-block-paragraph__drop-zone-foreground"
|
|
97
|
+
}) : null)) : null);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=drop-zone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/paragraph/drop-zone.js"],"names":["animateVariants","hide","opacity","scaleY","show","exit","DropZone","paragraphElement","clientId","rootClientId","blockIndex","select","selectors","blockEditorStore","getBlockRootClientId","getBlockIndex","onBlockDrop","action","isDragging","setIsDragging","isVisible","setIsVisible","popoverRef","onDragStart","onDragEnd","dropZoneRef","onDrop","onDragEnter","onDragLeave","reducedMotion","width","offsetWidth","height","offsetHeight"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAIA;;AAIA;;AAbA;AACA;AACA;AAiBA,MAAMA,eAAe,GAAG;AACvBC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB,GADiB;AAEvBC,EAAAA,IAAI,EAAE;AAAEF,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB,GAFiB;AAGvBE,EAAAA,IAAI,EAAE;AAAEH,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB;AAHiB,CAAxB;;AAMe,SAASG,QAAT,OAAoD;AAAA,MAAjC;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAiC;AAClE,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA+B,qBAClCC,MAAF,IAAc;AACb,UAAMC,SAAS,GAAGD,MAAM,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,UAAU,GACX;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,GAAG,EAAGO,WAFP;AAGC,IAAA,KAAK,EAAG;AACPK,MAAAA,KAAK,EAAEvB,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAEwB,WADlB;AAEPC,MAAAA,MAAM,EAAEzB,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAE0B;AAFnB;AAHT,KAQC,4BAAC,qCAAD,QACGb,SAAS,GACV,4BAAC,4BAAD,CAAQ,GAAR;AACC,IAAA,GAAG,EAAC,sBADL;AAEC,mBAAY,2BAFb;AAGC,IAAA,OAAO,EACNS,aAAa,GACV7B,eAAe,CAACI,IADN,GAEVJ,eAAe,CAACC,IANrB;AAQC,IAAA,OAAO,EAAGD,eAAe,CAACI,IAR3B;AASC,IAAA,IAAI,EACHyB,aAAa,GACV7B,eAAe,CAACI,IADN,GAEVJ,eAAe,CAACK,IAZrB;AAcC,IAAA,SAAS,EAAC;AAdX,IADU,GAiBP,IAlBL,CARD,CADW,GA8BR,IAxCL,CADD;AA4CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalUseOnBlockDrop as useOnBlockDrop,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalUseDropZone as useDropZone,\n\tuseReducedMotion,\n} from '@wordpress/compose';\nimport {\n\tPopover,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\n\nconst animateVariants = {\n\thide: { opacity: 0, scaleY: 0.75 },\n\tshow: { opacity: 1, scaleY: 1 },\n\texit: { opacity: 0, scaleY: 0.9 },\n};\n\nexport default function DropZone( { paragraphElement, clientId } ) {\n\tconst { rootClientId, blockIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst selectors = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\trootClientId: selectors.getBlockRootClientId( clientId ),\n\t\t\t\tblockIndex: selectors.getBlockIndex( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst onBlockDrop = useOnBlockDrop( rootClientId, blockIndex, {\n\t\taction: 'replace',\n\t} );\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst [ isVisible, setIsVisible ] = useState( false );\n\tconst popoverRef = useDropZone( {\n\t\tonDragStart: () => {\n\t\t\tsetIsDragging( true );\n\t\t},\n\t\tonDragEnd: () => {\n\t\t\tsetIsDragging( false );\n\t\t},\n\t} );\n\tconst dropZoneRef = useDropZone( {\n\t\tonDrop: onBlockDrop,\n\t\tonDragEnter: () => {\n\t\t\tsetIsVisible( true );\n\t\t},\n\t\tonDragLeave: () => {\n\t\t\tsetIsVisible( false );\n\t\t},\n\t} );\n\tconst reducedMotion = useReducedMotion();\n\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ paragraphElement }\n\t\t\tanimate={ false }\n\t\t\tplacement=\"top-start\"\n\t\t\tfocusOnMount={ false }\n\t\t\tflip={ false }\n\t\t\tresize={ false }\n\t\t\tclassName=\"wp-block-paragraph__drop-zone\"\n\t\t\tref={ popoverRef }\n\t\t>\n\t\t\t{ isDragging ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-block-paragraph__drop-zone-backdrop\"\n\t\t\t\t\tref={ dropZoneRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: paragraphElement?.offsetWidth,\n\t\t\t\t\t\theight: paragraphElement?.offsetHeight,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t{ isVisible ? (\n\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\tkey=\"drop-zone-foreground\"\n\t\t\t\t\t\t\t\tdata-testid=\"empty-paragraph-drop-zone\"\n\t\t\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\t\t\treducedMotion\n\t\t\t\t\t\t\t\t\t\t? animateVariants.show\n\t\t\t\t\t\t\t\t\t\t: animateVariants.hide\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tanimate={ animateVariants.show }\n\t\t\t\t\t\t\t\texit={\n\t\t\t\t\t\t\t\t\treducedMotion\n\t\t\t\t\t\t\t\t\t\t? animateVariants.show\n\t\t\t\t\t\t\t\t\t\t: animateVariants.exit\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tclassName=\"wp-block-paragraph__drop-zone-foreground\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t</AnimatePresence>\n\t\t\t\t</div>\n\t\t\t) : null }\n\t\t</Popover>\n\t);\n}\n"]}
|
package/build/paragraph/edit.js
CHANGED
|
@@ -19,12 +19,16 @@ var _components = require("@wordpress/components");
|
|
|
19
19
|
|
|
20
20
|
var _blockEditor = require("@wordpress/block-editor");
|
|
21
21
|
|
|
22
|
+
var _compose = require("@wordpress/compose");
|
|
23
|
+
|
|
22
24
|
var _blocks = require("@wordpress/blocks");
|
|
23
25
|
|
|
24
26
|
var _icons = require("@wordpress/icons");
|
|
25
27
|
|
|
26
28
|
var _useEnter = require("./use-enter");
|
|
27
29
|
|
|
30
|
+
var _dropZone = _interopRequireDefault(require("./drop-zone"));
|
|
31
|
+
|
|
28
32
|
/**
|
|
29
33
|
* External dependencies
|
|
30
34
|
*/
|
|
@@ -70,11 +74,12 @@ function ParagraphBlock(_ref2) {
|
|
|
70
74
|
placeholder
|
|
71
75
|
} = attributes;
|
|
72
76
|
const isDropCapFeatureEnabled = (0, _blockEditor.useSetting)('typography.dropCap');
|
|
77
|
+
const [paragraphElement, setParagraphElement] = (0, _element.useState)(null);
|
|
73
78
|
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
74
|
-
ref: (0, _useEnter.useOnEnter)({
|
|
79
|
+
ref: (0, _compose.useMergeRefs)([(0, _useEnter.useOnEnter)({
|
|
75
80
|
clientId,
|
|
76
81
|
content
|
|
77
|
-
}),
|
|
82
|
+
}), setParagraphElement]),
|
|
78
83
|
className: (0, _classnames.default)({
|
|
79
84
|
'has-drop-cap': dropCap,
|
|
80
85
|
[`has-text-align-${align}`]: align
|
|
@@ -114,7 +119,10 @@ function ParagraphBlock(_ref2) {
|
|
|
114
119
|
dropCap: !dropCap
|
|
115
120
|
}),
|
|
116
121
|
help: dropCap ? (0, _i18n.__)('Showing large initial letter.') : (0, _i18n.__)('Toggle to show a large initial letter.')
|
|
117
|
-
}))), (0, _element.createElement)(
|
|
122
|
+
}))), !content && (0, _element.createElement)(_dropZone.default, {
|
|
123
|
+
clientId: clientId,
|
|
124
|
+
paragraphElement: paragraphElement
|
|
125
|
+
}), (0, _element.createElement)(_blockEditor.RichText, (0, _extends2.default)({
|
|
118
126
|
identifier: "content",
|
|
119
127
|
tagName: "p"
|
|
120
128
|
}, blockProps, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/paragraph/edit.js"],"names":["name","ParagraphRTLControl","direction","setDirection","formatLtr","undefined","ParagraphBlock","attributes","mergeBlocks","onReplace","onRemove","setAttributes","clientId","align","content","dropCap","placeholder","isDropCapFeatureEnabled","blockProps","ref","className","style","newAlign","newDirection","newContent","value","isOriginal","newAttributes","block"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/paragraph/edit.js"],"names":["name","ParagraphRTLControl","direction","setDirection","formatLtr","undefined","ParagraphBlock","attributes","mergeBlocks","onReplace","onRemove","setAttributes","clientId","align","content","dropCap","placeholder","isDropCapFeatureEnabled","paragraphElement","setParagraphElement","blockProps","ref","className","style","newAlign","newDirection","newContent","value","isOriginal","newAttributes","block"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AAKA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,gBAAb;;AAEA,SAASC,mBAAT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Aa,CAAE;AAAEG,MAAAA,OAAO,EAAEY;AAAX,KAAF,CANf;AAQC,IAAA,OAAO,EAAG,CAAEC,KAAF,EAASC,UAAT,KAAyB;AAClC,UAAIC,aAAJ;;AAEA,UAAKD,UAAU,IAAID,KAAnB,EAA2B;AAC1BE,QAAAA,aAAa,GAAG,EACf,GAAGtB,UADY;AAEfO,UAAAA,OAAO,EAAEa;AAFM,SAAhB;AAIA;;AAED,YAAMG,KAAK,GAAG,yBAAa9B,IAAb,EAAmB6B,aAAnB,CAAd;;AAEA,UAAKD,UAAL,EAAkB;AACjBE,QAAAA,KAAK,CAAClB,QAAN,GAAiBA,QAAjB;AACA;;AAED,aAAOkB,KAAP;AACA,KAzBF;AA0BC,IAAA,OAAO,EAAGtB,WA1BX;AA2BC,IAAA,SAAS,EAAGC,SA3Bb;AA4BC,IAAA,QAAQ,EAAGC,QA5BZ;AA6BC,kBACCI,OAAO,GACJ,cAAI,iBAAJ,CADI,GAEJ,cACA,oEADA,CAhCL;AAoCC,kBAAaA,OAAO,GAAG,KAAH,GAAW,IApChC;AAqCC,IAAA,WAAW,EAAGE,WAAW,IAAI,cAAI,0BAAJ,CArC9B;AAsCC,+BAA0BA,WAAW,GAAG,IAAH,GAAUX,SAtChD;AAuCC,IAAA,yBAAyB,MAvC1B;AAwCC,IAAA,oCAAoC;AAxCrC,KAjDD,CADD;AA8FA;;eAEcC,c","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSetting,\n} from '@wordpress/block-editor';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { createBlock } from '@wordpress/blocks';\nimport { formatLtr } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\nimport DropZone from './drop-zone';\n\nconst name = 'core/paragraph';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLtr }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { align, content, direction, dropCap, placeholder } = attributes;\n\tconst isDropCapFeatureEnabled = useSetting( 'typography.dropCap' );\n\tconst [ paragraphElement, setParagraphElement ] = useState( null );\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [\n\t\t\tuseOnEnter( { clientId, content } ),\n\t\t\tsetParagraphElement,\n\t\t] ),\n\t\tclassName: classnames( {\n\t\t\t'has-drop-cap': dropCap,\n\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ align }\n\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\tsetAttributes( { align: newAlign } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\tdirection={ direction }\n\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t{ isDropCapFeatureEnabled && (\n\t\t\t\t<InspectorControls __experimentalGroup=\"typography\">\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { dropCap: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresetAllFilter={ () => ( { dropCap: undefined } ) }\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { dropCap: ! dropCap } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tdropCap\n\t\t\t\t\t\t\t\t\t? __( 'Showing large initial letter.' )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Toggle to show a large initial letter.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! content && (\n\t\t\t\t<DropZone\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tparagraphElement={ paragraphElement }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonSplit={ ( value, isOriginal ) => {\n\t\t\t\t\tlet newAttributes;\n\n\t\t\t\t\tif ( isOriginal || value ) {\n\t\t\t\t\t\tnewAttributes = {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst block = createBlock( name, newAttributes );\n\n\t\t\t\t\tif ( isOriginal ) {\n\t\t\t\t\t\tblock.clientId = clientId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn block;\n\t\t\t\t} }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tcontent\n\t\t\t\t\t\t? __( 'Paragraph block' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t\tdata-empty={ content ? false : true }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"]}
|
|
@@ -61,7 +61,12 @@ function EditableContent(_ref2) {
|
|
|
61
61
|
return (_getSettings = getSettings()) === null || _getSettings === void 0 ? void 0 : _getSettings.supportsLayout;
|
|
62
62
|
}, []);
|
|
63
63
|
const defaultLayout = (0, _blockEditor.useSetting)('layout') || {};
|
|
64
|
-
const usedLayout =
|
|
64
|
+
const usedLayout = !(layout !== null && layout !== void 0 && layout.type) ? { ...defaultLayout,
|
|
65
|
+
...layout,
|
|
66
|
+
type: 'default'
|
|
67
|
+
} : { ...defaultLayout,
|
|
68
|
+
...layout
|
|
69
|
+
};
|
|
65
70
|
const [blocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('postType', postType, {
|
|
66
71
|
id: postId
|
|
67
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","type","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uBAAuB,EAAG;AAAEE,MAAAA,MAAM,EAAEH,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI;AAAnB;AAF3B,KALD;AAUA;;AAED,SAASC,eAAT,QAAqD;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAO,GAAG;AAApB,GAA2B;AACpD,QAAM;AAAET,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuBQ,OAA7B;AACA,QAAMC,mBA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,WAAW,IAAI,CAAE8B,uBAApC;AAEA,SAAOG,UAAU,GAChB,4BAAC,eAAD,EAAsBV,KAAtB,CADgB,GAGhB,4BAAC,eAAD;AACC,IAAA,WAAW,EAAGvB,WADf;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,MAAM,EAAGC;AAHV,IAHD;AASA;;AAED,SAASgC,WAAT,GAAuB;AACtB,QAAM9B,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,uCACG,cACD,4FADC,CADH,CADD,EAMC,uCACG,cACD,mMADC,CADH,CAND,EAWC,uCACG,cACD,uIADC,CADH,CAXD,CADD;AAmBA;;AAED,SAAS+B,cAAT,GAA0B;AACzB,QAAM/B,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,oBAAD,QACG,cAAI,yCAAJ,CADH,CADD,CADD;AAOA;;AAEc,SAASgC,eAAT,QAAoD;AAAA,MAA1B;AAAE1B,IAAAA,OAAF;AAAW2B,IAAAA;AAAX,GAA0B;AAClE,QAAM;AAAEnC,IAAAA,MAAM,EAAEoC,aAAV;AAAyBrC,IAAAA,QAAQ,EAAEsC;AAAnC,MAAuD7B,OAA7D;AACA,QAAM;AAAED,IAAAA,MAAM,GAAG;AAAX,MAAkB4B,UAAxB;AACA,QAAMG,kBAAkB,GAAG,gDAAiBF,aAAjB,CAA3B;;AAEA,MAAKA,aAAa,IAAIC,eAAjB,IAAoCC,kBAAzC,EAA8D;AAC7D,WAAO,4BAAC,cAAD,OAAP;AACA;;AAED,SACC,4BAAC,4CAAD;AAAmB,IAAA,QAAQ,EAAGF;AAA9B,KACGA,aAAa,IAAIC,eAAjB,GACD,4BAAC,OAAD;AAAS,IAAA,OAAO,EAAG7B,OAAnB;AAA6B,IAAA,MAAM,EAAGD;AAAtC,IADC,GAGD,4BAAC,WAAD,OAJF,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { layout, context = {} } ) {\n\tconst { postType, postId } = context;\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Post Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( { context, attributes } ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-pagination-numbers/index.js"],"names":["queryPaginationNumbers","icon","initBlock","edit","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,IAAnC,QAA+C,kBAA/C;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-pagination-numbers/index.js"],"names":["queryPaginationNumbers","icon","initBlock","edit","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,IAAnC,QAA+C,kBAA/C;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBE,EAAAA;AAFuB,CAAjB;AAKP,OAAO,MAAMI,IAAI,GAAG,MAAML,SAAS,CAAE;AAAEE,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { queryPaginationNumbers as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -11,7 +11,6 @@ import classnames from 'classnames';
|
|
|
11
11
|
|
|
12
12
|
import { RichText, useInnerBlocksProps, __experimentalGetElementClassName } from '@wordpress/block-editor';
|
|
13
13
|
import { VisuallyHidden } from '@wordpress/components';
|
|
14
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
15
14
|
import { __ } from '@wordpress/i18n';
|
|
16
15
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
17
16
|
import { View } from '@wordpress/primitives';
|
|
@@ -43,25 +42,6 @@ export const Gallery = props => {
|
|
|
43
42
|
alignments: []
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
|
-
const [captionFocused, setCaptionFocused] = useState(false);
|
|
47
|
-
|
|
48
|
-
function onFocusCaption() {
|
|
49
|
-
if (!captionFocused) {
|
|
50
|
-
setCaptionFocused(true);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function removeCaptionFocus() {
|
|
55
|
-
if (captionFocused) {
|
|
56
|
-
setCaptionFocused(false);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (!isSelected) {
|
|
62
|
-
setCaptionFocused(false);
|
|
63
|
-
}
|
|
64
|
-
}, [isSelected]);
|
|
65
45
|
return createElement("figure", _extends({}, innerBlocksProps, {
|
|
66
46
|
className: classnames(blockProps.className, 'blocks-gallery-grid', {
|
|
67
47
|
[`align${align}`]: align,
|
|
@@ -70,12 +50,9 @@ export const Gallery = props => {
|
|
|
70
50
|
'is-cropped': imageCrop
|
|
71
51
|
})
|
|
72
52
|
}), children, isSelected && !children && createElement(View, {
|
|
73
|
-
className: "blocks-gallery-media-placeholder-wrapper"
|
|
74
|
-
onClick: removeCaptionFocus
|
|
53
|
+
className: "blocks-gallery-media-placeholder-wrapper"
|
|
75
54
|
}, mediaPlaceholder), createElement(RichTextVisibilityHelper, {
|
|
76
55
|
isHidden: !isSelected && RichText.isEmpty(caption),
|
|
77
|
-
captionFocused: captionFocused,
|
|
78
|
-
onFocusCaption: onFocusCaption,
|
|
79
56
|
tagName: "figcaption",
|
|
80
57
|
className: classnames('blocks-gallery-caption', __experimentalGetElementClassName('caption')),
|
|
81
58
|
"aria-label": __('Gallery caption text'),
|
|
@@ -92,8 +69,6 @@ export const Gallery = props => {
|
|
|
92
69
|
function RichTextVisibilityHelper(_ref) {
|
|
93
70
|
let {
|
|
94
71
|
isHidden,
|
|
95
|
-
captionFocused,
|
|
96
|
-
onFocusCaption,
|
|
97
72
|
className,
|
|
98
73
|
value,
|
|
99
74
|
placeholder,
|
|
@@ -113,9 +88,7 @@ function RichTextVisibilityHelper(_ref) {
|
|
|
113
88
|
value: value,
|
|
114
89
|
placeholder: placeholder,
|
|
115
90
|
className: className,
|
|
116
|
-
tagName: tagName
|
|
117
|
-
isSelected: captionFocused,
|
|
118
|
-
onClick: onFocusCaption
|
|
91
|
+
tagName: tagName
|
|
119
92
|
}, richTextProps));
|
|
120
93
|
}
|
|
121
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/gallery.js"],"names":["classnames","RichText","useInnerBlocksProps","__experimentalGetElementClassName","VisuallyHidden","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/gallery/gallery.js"],"names":["classnames","RichText","useInnerBlocksProps","__experimentalGetElementClassName","VisuallyHidden","__","createBlock","getDefaultBlockName","View","allowedBlocks","Gallery","props","attributes","isSelected","setAttributes","mediaPlaceholder","insertBlocksAfter","blockProps","align","columns","caption","imageCrop","children","innerBlocksProps","orientation","renderAppender","__experimentalLayout","type","alignments","className","undefined","isEmpty","value","RichTextVisibilityHelper","isHidden","placeholder","tagName","captionRef","richTextProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,mBAFD,EAGCC,iCAHD,QAIO,yBAJP;AAKA,SAASC,cAAT,QAA+B,uBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,mBAAtB,QAAiD,mBAAjD;AACA,SAASC,IAAT,QAAqB,uBAArB;AAEA,MAAMC,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iCAAiC,CAAE,SAAF,CAFZ,CAHvB;AAOC,kBAAaE,EAAE,CAAE,sBAAF,CAPhB;AAQC,IAAA,WAAW,EAAGA,EAAE,CAAE,wBAAF,CARjB;AASC,IAAA,KAAK,EAAGe,OATT;AAUC,IAAA,QAAQ,EAAKY,KAAF,IAAalB,aAAa,CAAE;AAAEM,MAAAA,OAAO,EAAEY;AAAX,KAAF,CAVtC;AAWC,IAAA,aAAa,MAXd;AAYC,IAAA,sBAAsB,EAAG,MACxBhB,iBAAiB,CAAEV,WAAW,CAAEC,mBAAmB,EAArB,CAAb;AAbnB,IAnBD,CADD;AAsCA,CAzDM;;AA2DP,SAAS0B,wBAAT,OAQI;AAAA,MAR+B;AAClCC,IAAAA,QADkC;AAElCL,IAAAA,SAFkC;AAGlCG,IAAAA,KAHkC;AAIlCG,IAAAA,WAJkC;AAKlCC,IAAAA,OALkC;AAMlCC,IAAAA,UANkC;AAOlC,OAAGC;AAP+B,GAQ/B;;AACH,MAAKJ,QAAL,EAAgB;AACf,WAAO,cAAC,cAAD;AAAgB,MAAA,EAAE,EAAGjC;AAArB,OAAqCqC,aAArC,EAAP;AACA;;AAED,SACC,cAAC,QAAD;AACC,IAAA,GAAG,EAAGD,UADP;AAEC,IAAA,KAAK,EAAGL,KAFT;AAGC,IAAA,WAAW,EAAGG,WAHf;AAIC,IAAA,SAAS,EAAGN,SAJb;AAKC,IAAA,OAAO,EAAGO;AALX,KAMME,aANN,EADD;AAUA;;AAED,eAAe5B,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseInnerBlocksProps,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { View } from '@wordpress/primitives';\n\nconst allowedBlocks = [ 'core/image' ];\n\nexport const Gallery = ( props ) => {\n\tconst {\n\t\tattributes,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tmediaPlaceholder,\n\t\tinsertBlocksAfter,\n\t\tblockProps,\n\t} = props;\n\n\tconst { align, columns, caption, imageCrop } = attributes;\n\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks,\n\t\torientation: 'horizontal',\n\t\trenderAppender: false,\n\t\t__experimentalLayout: { type: 'default', alignments: [] },\n\t} );\n\n\treturn (\n\t\t<figure\n\t\t\t{ ...innerBlocksProps }\n\t\t\tclassName={ classnames(\n\t\t\t\tblockProps.className,\n\t\t\t\t'blocks-gallery-grid',\n\t\t\t\t{\n\t\t\t\t\t[ `align${ align }` ]: align,\n\t\t\t\t\t[ `columns-${ columns }` ]: columns !== undefined,\n\t\t\t\t\t[ `columns-default` ]: columns === undefined,\n\t\t\t\t\t'is-cropped': imageCrop,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t\t{ isSelected && ! children && (\n\t\t\t\t<View className=\"blocks-gallery-media-placeholder-wrapper\">\n\t\t\t\t\t{ mediaPlaceholder }\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t<RichTextVisibilityHelper\n\t\t\t\tisHidden={ ! isSelected && RichText.isEmpty( caption ) }\n\t\t\t\ttagName=\"figcaption\"\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'blocks-gallery-caption',\n\t\t\t\t\t__experimentalGetElementClassName( 'caption' )\n\t\t\t\t) }\n\t\t\t\taria-label={ __( 'Gallery caption text' ) }\n\t\t\t\tplaceholder={ __( 'Write gallery caption…' ) }\n\t\t\t\tvalue={ caption }\n\t\t\t\tonChange={ ( value ) => setAttributes( { caption: value } ) }\n\t\t\t\tinlineToolbar\n\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) )\n\t\t\t\t}\n\t\t\t/>\n\t\t</figure>\n\t);\n};\n\nfunction RichTextVisibilityHelper( {\n\tisHidden,\n\tclassName,\n\tvalue,\n\tplaceholder,\n\ttagName,\n\tcaptionRef,\n\t...richTextProps\n} ) {\n\tif ( isHidden ) {\n\t\treturn <VisuallyHidden as={ RichText } { ...richTextProps } />;\n\t}\n\n\treturn (\n\t\t<RichText\n\t\t\tref={ captionRef }\n\t\t\tvalue={ value }\n\t\t\tplaceholder={ placeholder }\n\t\t\tclassName={ className }\n\t\t\ttagName={ tagName }\n\t\t\t{ ...richTextProps }\n\t\t/>\n\t);\n}\n\nexport default Gallery;\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { __experimentalUseOnBlockDrop as useOnBlockDrop, store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
|
+
import { __experimentalUseDropZone as useDropZone, useReducedMotion } from '@wordpress/compose';
|
|
10
|
+
import { Popover, __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence } from '@wordpress/components';
|
|
11
|
+
const animateVariants = {
|
|
12
|
+
hide: {
|
|
13
|
+
opacity: 0,
|
|
14
|
+
scaleY: 0.75
|
|
15
|
+
},
|
|
16
|
+
show: {
|
|
17
|
+
opacity: 1,
|
|
18
|
+
scaleY: 1
|
|
19
|
+
},
|
|
20
|
+
exit: {
|
|
21
|
+
opacity: 0,
|
|
22
|
+
scaleY: 0.9
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export default function DropZone(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
paragraphElement,
|
|
28
|
+
clientId
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
rootClientId,
|
|
32
|
+
blockIndex
|
|
33
|
+
} = useSelect(select => {
|
|
34
|
+
const selectors = select(blockEditorStore);
|
|
35
|
+
return {
|
|
36
|
+
rootClientId: selectors.getBlockRootClientId(clientId),
|
|
37
|
+
blockIndex: selectors.getBlockIndex(clientId)
|
|
38
|
+
};
|
|
39
|
+
}, [clientId]);
|
|
40
|
+
const onBlockDrop = useOnBlockDrop(rootClientId, blockIndex, {
|
|
41
|
+
action: 'replace'
|
|
42
|
+
});
|
|
43
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
44
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
45
|
+
const popoverRef = useDropZone({
|
|
46
|
+
onDragStart: () => {
|
|
47
|
+
setIsDragging(true);
|
|
48
|
+
},
|
|
49
|
+
onDragEnd: () => {
|
|
50
|
+
setIsDragging(false);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const dropZoneRef = useDropZone({
|
|
54
|
+
onDrop: onBlockDrop,
|
|
55
|
+
onDragEnter: () => {
|
|
56
|
+
setIsVisible(true);
|
|
57
|
+
},
|
|
58
|
+
onDragLeave: () => {
|
|
59
|
+
setIsVisible(false);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const reducedMotion = useReducedMotion();
|
|
63
|
+
return createElement(Popover, {
|
|
64
|
+
anchor: paragraphElement,
|
|
65
|
+
animate: false,
|
|
66
|
+
placement: "top-start",
|
|
67
|
+
focusOnMount: false,
|
|
68
|
+
flip: false,
|
|
69
|
+
resize: false,
|
|
70
|
+
className: "wp-block-paragraph__drop-zone",
|
|
71
|
+
ref: popoverRef
|
|
72
|
+
}, isDragging ? createElement("div", {
|
|
73
|
+
className: "wp-block-paragraph__drop-zone-backdrop",
|
|
74
|
+
ref: dropZoneRef,
|
|
75
|
+
style: {
|
|
76
|
+
width: paragraphElement === null || paragraphElement === void 0 ? void 0 : paragraphElement.offsetWidth,
|
|
77
|
+
height: paragraphElement === null || paragraphElement === void 0 ? void 0 : paragraphElement.offsetHeight
|
|
78
|
+
}
|
|
79
|
+
}, createElement(AnimatePresence, null, isVisible ? createElement(motion.div, {
|
|
80
|
+
key: "drop-zone-foreground",
|
|
81
|
+
"data-testid": "empty-paragraph-drop-zone",
|
|
82
|
+
initial: reducedMotion ? animateVariants.show : animateVariants.hide,
|
|
83
|
+
animate: animateVariants.show,
|
|
84
|
+
exit: reducedMotion ? animateVariants.show : animateVariants.exit,
|
|
85
|
+
className: "wp-block-paragraph__drop-zone-foreground"
|
|
86
|
+
}) : null)) : null);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=drop-zone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/paragraph/drop-zone.js"],"names":["useState","useSelect","__experimentalUseOnBlockDrop","useOnBlockDrop","store","blockEditorStore","__experimentalUseDropZone","useDropZone","useReducedMotion","Popover","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","animateVariants","hide","opacity","scaleY","show","exit","DropZone","paragraphElement","clientId","rootClientId","blockIndex","select","selectors","getBlockRootClientId","getBlockIndex","onBlockDrop","action","isDragging","setIsDragging","isVisible","setIsVisible","popoverRef","onDragStart","onDragEnd","dropZoneRef","onDrop","onDragEnter","onDragLeave","reducedMotion","width","offsetWidth","height","offsetHeight"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,oBAAzB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,4BAA4B,IAAIC,cADjC,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SACCC,yBAAyB,IAAIC,WAD9B,EAECC,gBAFD,QAGO,oBAHP;AAIA,SACCC,OADD,EAECC,gBAAgB,IAAIC,MAFrB,EAGCC,yBAAyB,IAAIC,eAH9B,QAIO,uBAJP;AAMA,MAAMC,eAAe,GAAG;AACvBC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB,GADiB;AAEvBC,EAAAA,IAAI,EAAE;AAAEF,IAAAA,OAAO,EAAE,CAAX;AAAc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J+B;AAKhCO,IAAAA,WAAW,EAAE,MAAM;AAClBP,MAAAA,YAAY,CAAE,KAAF,CAAZ;AACA;AAP+B,GAAF,CAA/B;AASA,QAAMQ,aAAa,GAAGlC,gBAAgB,EAAtC;AAEA,SACC,cAAC,OAAD;AACC,IAAA,MAAM,EAAGa,gBADV;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,SAAS,EAAC,WAHX;AAIC,IAAA,YAAY,EAAG,KAJhB;AAKC,IAAA,IAAI,EAAG,KALR;AAMC,IAAA,MAAM,EAAG,KANV;AAOC,IAAA,SAAS,EAAC,+BAPX;AAQC,IAAA,GAAG,EAAGc;AARP,KAUGJ,UAAU,GACX;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,GAAG,EAAGO,WAFP;AAGC,IAAA,KAAK,EAAG;AACPK,MAAAA,KAAK,EAAEtB,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAEuB,WADlB;AAEPC,MAAAA,MAAM,EAAExB,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAEyB;AAFnB;AAHT,KAQC,cAAC,eAAD,QACGb,SAAS,GACV,cAAC,MAAD,CAAQ,GAAR;AACC,IAAA,GAAG,EAAC,sBADL;AAEC,mBAAY,2BAFb;AAGC,IAAA,OAAO,EACNS,aAAa,GACV5B,eAAe,CAACI,IADN,GAEVJ,eAAe,CAACC,IANrB;AAQC,IAAA,OAAO,EAAGD,eAAe,CAACI,IAR3B;AASC,IAAA,IAAI,EACHwB,aAAa,GACV5B,eAAe,CAACI,IADN,GAEVJ,eAAe,CAACK,IAZrB;AAcC,IAAA,SAAS,EAAC;AAdX,IADU,GAiBP,IAlBL,CARD,CADW,GA8BR,IAxCL,CADD;AA4CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalUseOnBlockDrop as useOnBlockDrop,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalUseDropZone as useDropZone,\n\tuseReducedMotion,\n} from '@wordpress/compose';\nimport {\n\tPopover,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\n\nconst animateVariants = {\n\thide: { opacity: 0, scaleY: 0.75 },\n\tshow: { opacity: 1, scaleY: 1 },\n\texit: { opacity: 0, scaleY: 0.9 },\n};\n\nexport default function DropZone( { paragraphElement, clientId } ) {\n\tconst { rootClientId, blockIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst selectors = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\trootClientId: selectors.getBlockRootClientId( clientId ),\n\t\t\t\tblockIndex: selectors.getBlockIndex( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst onBlockDrop = useOnBlockDrop( rootClientId, blockIndex, {\n\t\taction: 'replace',\n\t} );\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst [ isVisible, setIsVisible ] = useState( false );\n\tconst popoverRef = useDropZone( {\n\t\tonDragStart: () => {\n\t\t\tsetIsDragging( true );\n\t\t},\n\t\tonDragEnd: () => {\n\t\t\tsetIsDragging( false );\n\t\t},\n\t} );\n\tconst dropZoneRef = useDropZone( {\n\t\tonDrop: onBlockDrop,\n\t\tonDragEnter: () => {\n\t\t\tsetIsVisible( true );\n\t\t},\n\t\tonDragLeave: () => {\n\t\t\tsetIsVisible( false );\n\t\t},\n\t} );\n\tconst reducedMotion = useReducedMotion();\n\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ paragraphElement }\n\t\t\tanimate={ false }\n\t\t\tplacement=\"top-start\"\n\t\t\tfocusOnMount={ false }\n\t\t\tflip={ false }\n\t\t\tresize={ false }\n\t\t\tclassName=\"wp-block-paragraph__drop-zone\"\n\t\t\tref={ popoverRef }\n\t\t>\n\t\t\t{ isDragging ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-block-paragraph__drop-zone-backdrop\"\n\t\t\t\t\tref={ dropZoneRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: paragraphElement?.offsetWidth,\n\t\t\t\t\t\theight: paragraphElement?.offsetHeight,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<AnimatePresence>\n\t\t\t\t\t\t{ isVisible ? (\n\t\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\t\tkey=\"drop-zone-foreground\"\n\t\t\t\t\t\t\t\tdata-testid=\"empty-paragraph-drop-zone\"\n\t\t\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\t\t\treducedMotion\n\t\t\t\t\t\t\t\t\t\t? animateVariants.show\n\t\t\t\t\t\t\t\t\t\t: animateVariants.hide\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tanimate={ animateVariants.show }\n\t\t\t\t\t\t\t\texit={\n\t\t\t\t\t\t\t\t\treducedMotion\n\t\t\t\t\t\t\t\t\t\t? animateVariants.show\n\t\t\t\t\t\t\t\t\t\t: animateVariants.exit\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tclassName=\"wp-block-paragraph__drop-zone-foreground\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t</AnimatePresence>\n\t\t\t\t</div>\n\t\t\t) : null }\n\t\t</Popover>\n\t);\n}\n"]}
|