@wordpress/block-editor 10.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/autocomplete/index.js +2 -2
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-compact.native.js +2 -1
- package/build/components/block-list/block-list-compact.native.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +1 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-popover/inbetween.js +37 -49
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +28 -5
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +5 -6
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +8 -3
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/inner-blocks/index.js +7 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +27 -16
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +28 -4
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/list-view/branch.js +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +30 -28
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +9 -9
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +4 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/linked-button.js +2 -3
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -4
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/text-decoration-control/index.js +19 -15
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +25 -17
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +6 -4
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +1 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/hooks/content-lock-ui.js +3 -3
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/typography.js +10 -11
- package/build/hooks/typography.js.map +1 -1
- package/build/layouts/constrained.js +1 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/store/reducer.js +4 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +2 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -2
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-compact.native.js +2 -1
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
- package/build-module/components/block-list/block.js +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +1 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +38 -50
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +28 -5
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +5 -6
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +8 -3
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +7 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +27 -16
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +28 -4
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +30 -28
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +10 -10
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/linked-button.js +2 -3
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -4
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/text-decoration-control/index.js +21 -16
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +28 -20
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +6 -4
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +1 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +3 -3
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/typography.js +10 -11
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/layouts/constrained.js +1 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/store/reducer.js +4 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +2 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +49 -3
- package/build-style/style.css +49 -3
- package/package.json +11 -11
- package/src/components/autocomplete/index.js +2 -5
- package/src/components/block-inspector/index.js +1 -1
- package/src/components/block-list/block-list-compact.native.js +1 -1
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/style.scss +22 -3
- package/src/components/block-lock/use-block-lock.js +1 -1
- package/src/components/block-popover/inbetween.js +50 -52
- package/src/components/block-popover/index.js +44 -6
- package/src/components/border-radius-control/linked-button.js +12 -11
- package/src/components/convert-to-group-buttons/toolbar.js +6 -2
- package/src/components/inner-blocks/README.md +2 -2
- package/src/components/inner-blocks/index.js +7 -0
- package/src/components/inner-blocks/use-inner-block-template-sync.js +39 -28
- package/src/components/inner-blocks/use-nested-settings-update.js +30 -3
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/drop-indicator.js +33 -32
- package/src/components/rich-text/format-toolbar-container.js +18 -10
- package/src/components/rich-text/index.js +2 -2
- package/src/components/spacing-sizes-control/linked-button.js +2 -3
- package/src/components/spacing-sizes-control/style.scss +4 -1
- package/src/components/spacing-sizes-control/utils.js +1 -8
- package/src/components/text-decoration-control/index.js +31 -23
- package/src/components/text-decoration-control/style.scss +18 -0
- package/src/components/text-transform-control/index.js +42 -26
- package/src/components/text-transform-control/style.scss +18 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -3
- package/src/components/use-block-drop-zone/index.js +1 -1
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/typography.js +13 -14
- package/src/layouts/constrained.js +1 -1
- package/src/store/reducer.js +3 -0
- package/src/store/selectors.js +2 -2
- package/src/store/test/selectors.js +4 -4
- package/src/style.scss +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/linked-button.js"],"names":["LinkedButton","isLinked","props","label","link","linkOff"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,YAAT,OAAgD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAAyB;AAC9D,QAAMC,KAAK,GAAGF,QAAQ,GAAG,cAAI,cAAJ,CAAH,GAA0B,cAAI,YAAJ,CAAhD
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/linked-button.js"],"names":["LinkedButton","isLinked","props","label","link","linkOff"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,YAAT,OAAgD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAAyB;AAC9D,QAAMC,KAAK,GAAGF,QAAQ,GAAG,cAAI,cAAJ,CAAH,GAA0B,cAAI,YAAJ,CAAhD,CAD8D,CAG9D;;AACA,SACC,4BAAC,mBAAD;AAAS,IAAA,IAAI,EAAGE;AAAhB,KACC,0CACC,4BAAC,kBAAD,6BACMD,KADN;AAEC,IAAA,SAAS,EAAC,gDAFX;AAGC,IAAA,OAAO,MAHR;AAIC,IAAA,IAAI,EAAGD,QAAQ,GAAGG,WAAH,GAAUC,cAJ1B;AAKC,IAAA,QAAQ,EAAG,EALZ;AAMC,kBAAaF;AANd,KADD,CADD,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Tooltip } from '@wordpress/components';\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function LinkedButton( { isLinked, ...props } ) {\n\tconst label = isLinked ? __( 'Unlink radii' ) : __( 'Link radii' );\n\n\t// TODO: Remove span after merging https://github.com/WordPress/gutenberg/pull/44198\n\treturn (\n\t\t<Tooltip text={ label }>\n\t\t\t<span>\n\t\t\t\t<Button\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName=\"component-border-radius-control__linked-button\"\n\t\t\t\t\tisSmall\n\t\t\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\taria-label={ label }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Tooltip>\n\t);\n}\n"]}
|
|
@@ -29,7 +29,9 @@ var _store = require("../../store");
|
|
|
29
29
|
* Internal dependencies
|
|
30
30
|
*/
|
|
31
31
|
const layouts = {
|
|
32
|
-
group:
|
|
32
|
+
group: {
|
|
33
|
+
type: 'constrained'
|
|
34
|
+
},
|
|
33
35
|
row: {
|
|
34
36
|
type: 'flex',
|
|
35
37
|
flexWrap: 'nowrap'
|
|
@@ -66,10 +68,13 @@ function BlockGroupToolbar() {
|
|
|
66
68
|
};
|
|
67
69
|
}, [clientIds, groupingBlockName]);
|
|
68
70
|
|
|
69
|
-
const onConvertToGroup =
|
|
70
|
-
let layout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'group';
|
|
71
|
+
const onConvertToGroup = layout => {
|
|
71
72
|
const newBlocks = (0, _blocks.switchToBlockType)(blocksSelection, groupingBlockName);
|
|
72
73
|
|
|
74
|
+
if (typeof layout !== 'string') {
|
|
75
|
+
layout = 'group';
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
if (newBlocks && newBlocks.length > 0) {
|
|
74
79
|
// Because the block is not in the store yet we can't use
|
|
75
80
|
// updateBlockAttributes so need to manually update attributes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/convert-to-group-buttons/toolbar.js"],"names":["layouts","group","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/convert-to-group-buttons/toolbar.js"],"names":["layouts","group","type","row","flexWrap","stack","orientation","BlockGroupToolbar","blocksSelection","clientIds","groupingBlockName","isGroupable","replaceBlocks","blockEditorStore","canRemove","variations","select","canRemoveBlocks","getBlockVariations","blocksStore","onConvertToGroup","layout","newBlocks","length","attributes","onConvertToRow","onConvertToStack","canInsertRow","find","name","canInsertStack"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAMA,OAAO,GAAG;AACfC,EAAAA,KAAK,EAAE;AAAEC,IAAAA,IAAI,EAAE;AAAR,GADQ;AAEfC,EAAAA,GAAG,EAAE;AAAED,IAAAA,IAAI,EAAE,MAAR;AAAgBE,IAAAA,Q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B,CAAE,KAAF,CAA7C;;AACA,QAAMM,gBAAgB,GAAG,MAAMN,gBAAgB,CAAE,OAAF,CAA/C,CAxC4B,CA0C5B;AACA;AACA;AACA;;;AACA,MAAK,CAAET,WAAF,IAAiB,CAAEG,SAAxB,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,QAAMa,YAAY,GAAG,CAAC,CAAEZ,UAAU,CAACa,IAAX,CACvB;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAK,WAAzB;AAAA,GADuB,CAAxB;AAGA,QAAMC,cAAc,GAAG,CAAC,CAAEf,UAAU,CAACa,IAAX,CACzB;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAK,aAAzB;AAAA,GADyB,CAA1B;AAIA,SACC,4BAAC,wBAAD,QACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAG5B,YADR;AAEC,IAAA,KAAK,EAAG,cAAI,OAAJ,EAAa,MAAb,CAFT;AAGC,IAAA,OAAO,EAAGmB;AAHX,IADD,EAMGO,YAAY,IACb,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGxB,UADR;AAEC,IAAA,KAAK,EAAG,cAAI,KAAJ,EAAW,wBAAX,CAFT;AAGC,IAAA,OAAO,EAAGsB;AAHX,IAPF,EAaGK,cAAc,IACf,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGzB,YADR;AAEC,IAAA,KAAK,EAAG,cAAI,OAAJ,EAAa,MAAb,CAFT;AAGC,IAAA,OAAO,EAAGqB;AAHX,IAdF,CADD;AAuBA;;eAEcnB,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { switchToBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { group, row, stack } from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useConvertToGroupButtonProps } from '../convert-to-group-buttons';\nimport { store as blockEditorStore } from '../../store';\n\nconst layouts = {\n\tgroup: { type: 'constrained' },\n\trow: { type: 'flex', flexWrap: 'nowrap' },\n\tstack: { type: 'flex', orientation: 'vertical' },\n};\n\nfunction BlockGroupToolbar() {\n\tconst { blocksSelection, clientIds, groupingBlockName, isGroupable } =\n\t\tuseConvertToGroupButtonProps();\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\tconst { canRemove, variations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds ),\n\t\t\t\tvariations: getBlockVariations(\n\t\t\t\t\tgroupingBlockName,\n\t\t\t\t\t'transform'\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, groupingBlockName ]\n\t);\n\n\tconst onConvertToGroup = ( layout ) => {\n\t\tconst newBlocks = switchToBlockType(\n\t\t\tblocksSelection,\n\t\t\tgroupingBlockName\n\t\t);\n\n\t\tif ( typeof layout !== 'string' ) {\n\t\t\tlayout = 'group';\n\t\t}\n\n\t\tif ( newBlocks && newBlocks.length > 0 ) {\n\t\t\t// Because the block is not in the store yet we can't use\n\t\t\t// updateBlockAttributes so need to manually update attributes.\n\t\t\tnewBlocks[ 0 ].attributes.layout = layouts[ layout ];\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t}\n\t};\n\n\tconst onConvertToRow = () => onConvertToGroup( 'row' );\n\tconst onConvertToStack = () => onConvertToGroup( 'stack' );\n\n\t// Don't render the button if the current selection cannot be grouped.\n\t// A good example is selecting multiple button blocks within a Buttons block:\n\t// The group block is not a valid child of Buttons, so we should not show the button.\n\t// Any blocks that are locked against removal also cannot be grouped.\n\tif ( ! isGroupable || ! canRemove ) {\n\t\treturn null;\n\t}\n\n\tconst canInsertRow = !! variations.find(\n\t\t( { name } ) => name === 'group-row'\n\t);\n\tconst canInsertStack = !! variations.find(\n\t\t( { name } ) => name === 'group-stack'\n\t);\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ group }\n\t\t\t\tlabel={ _x( 'Group', 'verb' ) }\n\t\t\t\tonClick={ onConvertToGroup }\n\t\t\t/>\n\t\t\t{ canInsertRow && (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={ row }\n\t\t\t\t\tlabel={ _x( 'Row', 'single horizontal line' ) }\n\t\t\t\t\tonClick={ onConvertToRow }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canInsertStack && (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={ stack }\n\t\t\t\t\tlabel={ _x( 'Stack', 'verb' ) }\n\t\t\t\t\tonClick={ onConvertToStack }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default BlockGroupToolbar;\n"]}
|
|
@@ -82,7 +82,13 @@ function UncontrolledInnerBlocks(props) {
|
|
|
82
82
|
(0, _useNestedSettingsUpdate.default)(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, __experimentalLayout);
|
|
83
83
|
(0, _useInnerBlockTemplateSync.default)(clientId, template, templateLock, templateInsertUpdatesSelection);
|
|
84
84
|
const context = (0, _data.useSelect)(select => {
|
|
85
|
-
const block = select(_store.store).getBlock(clientId);
|
|
85
|
+
const block = select(_store.store).getBlock(clientId); // This check is here to avoid the Redux zombie bug where a child subscription
|
|
86
|
+
// is called before a parent, causing potential JS errors when the child has been removed.
|
|
87
|
+
|
|
88
|
+
if (!block) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
const blockType = (0, _blocks.getBlockType)(block.name);
|
|
87
93
|
|
|
88
94
|
if (!blockType || !blockType.providesContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","select","block","blockEditorStore","getBlock","blockType","name","providesContext","attributes","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","blocksStore","hasBlockSupport","rootClientId","InnerBlocks","value","onChange","className","children","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,8BARK;AASLC,IAAAA,6BAA6B,EAAEC,eAT1B;AAULC,IAAAA,6BAVK;AAWLC,IAAAA,cAXK;AAYLC,IAAAA,WAZK;AAaLC,IAAAA,WAbK;AAcLC,IAAAA;AAdK,MAeFf,KAfJ;AAiBA,wCACCC,QADD,EAECC,aAFD,EAGCC,0BAHD,EAICC,0BAJD,EAKCE,YALD,EAMCI,eAND,EAOCG,WAPD,EAQCE,oBARD;AAWA,0CACCd,QADD,EAECI,QAFD,EAGCC,YAHD,EAICE,8BAJD;AAOA,QAAMQ,OAAO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GAAGC,KADG;AAEN2B,IAAAA,GAFM;AAGNkB,IAAAA,SAAS,EAAE,yBACV7C,KAAK,CAAC6C,SADI,EAEV,iCAFU,EAGV;AACC,qBAAeb;AADhB,KAHU,CAHL;AAUNc,IAAAA,QAAQ,EAAE7C,QAAQ,GACjB,4BAAC,WAAD,6BAAkB2B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG3B;AAAhD,OADiB,GAGjB,4BAAC,yBAAD,EAAqB6B,OAArB;AAbK,GAAP;AAgBA;;AAEDD,mBAAmB,CAACkB,IAApB,GAA2BC,qCAA3B,C,CAEA;;AACAtB,oBAAoB,CAACuB,oBAArB,GAA4CA,6BAA5C;AACAvB,oBAAoB,CAACwB,mBAArB,GAA2CA,4BAA3C;;AAEAxB,oBAAoB,CAACyB,OAArB,GAA+B,MAAMtB,mBAAmB,CAACkB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;eACepB,oB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { clientId } = useBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseBlockDropZone( {\n\t\t\trootClientId: clientId,\n\t\t} ),\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","select","block","blockEditorStore","getBlock","blockType","name","providesContext","attributes","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","blocksStore","hasBlockSupport","rootClientId","InnerBlocks","value","onChange","className","children","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,8BARK;AASLC,IAAAA,6BAA6B,EAAEC,eAT1B;AAULC,IAAAA,6BAVK;AAWLC,IAAAA,cAXK;AAYLC,IAAAA,WAZK;AAaLC,IAAAA,WAbK;AAcLC,IAAAA;AAdK,MAeFf,KAfJ;AAiBA,wCACCC,QADD,EAECC,aAFD,EAGCC,0BAHD,EAICC,0BAJD,EAKCE,YALD,EAMCI,eAND,EAOCG,WAPD,EAQCE,oBARD;AAWA,0CACCd,QADD,EAECI,QAFD,EAGCC,YAHD,EAICE,8BAJD;AAOA,QAAMQ,OAAO,GAAG,qBACbC,MAAF,IAAc;AACb,UAAMC,KAAK,GAAGD,MAAM,CAAEE,YAAF,CAAN,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N2B,IAAAA,GAFM;AAGNkB,IAAAA,SAAS,EAAE,yBACV7C,KAAK,CAAC6C,SADI,EAEV,iCAFU,EAGV;AACC,qBAAeb;AADhB,KAHU,CAHL;AAUNc,IAAAA,QAAQ,EAAE7C,QAAQ,GACjB,4BAAC,WAAD,6BAAkB2B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG3B;AAAhD,OADiB,GAGjB,4BAAC,yBAAD,EAAqB6B,OAArB;AAbK,GAAP;AAgBA;;AAEDD,mBAAmB,CAACkB,IAApB,GAA2BC,qCAA3B,C,CAEA;;AACAtB,oBAAoB,CAACuB,oBAArB,GAA4CA,6BAA5C;AACAvB,oBAAoB,CAACwB,mBAArB,GAA2CA,4BAA3C;;AAEAxB,oBAAoB,CAACyB,OAArB,GAA+B,MAAMtB,mBAAmB,CAACkB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;eACepB,oB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { clientId } = useBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseBlockDropZone( {\n\t\t\trootClientId: clientId,\n\t\t} ),\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
|
|
@@ -31,7 +31,7 @@ var _store = require("../../store");
|
|
|
31
31
|
* This hook makes sure that a block's inner blocks stay in sync with the given
|
|
32
32
|
* block "template". The template is a block hierarchy to which inner blocks must
|
|
33
33
|
* conform. If the blocks get "out of sync" with the template and the template
|
|
34
|
-
* is meant to be locked (e.g. templateLock = "all" or templateLock = "
|
|
34
|
+
* is meant to be locked (e.g. templateLock = "all" or templateLock = "contentOnly"),
|
|
35
35
|
* then we replace the inner blocks with the correct value after synchronizing it with the template.
|
|
36
36
|
*
|
|
37
37
|
* @param {string} clientId The block client ID.
|
|
@@ -53,28 +53,39 @@ function useInnerBlockTemplateSync(clientId, template, templateLock, templateIns
|
|
|
53
53
|
const {
|
|
54
54
|
replaceInnerBlocks
|
|
55
55
|
} = (0, _data.useDispatch)(_store.store);
|
|
56
|
-
const innerBlocks = (0, _data.useSelect)(select => select(_store.store).getBlocks(clientId), [clientId]);
|
|
56
|
+
const innerBlocks = (0, _data.useSelect)(select => select(_store.store).getBlocks(clientId), [clientId]);
|
|
57
|
+
const {
|
|
58
|
+
getBlocks
|
|
59
|
+
} = (0, _data.useSelect)(_store.store); // Maintain a reference to the previous value so we can do a deep equality check.
|
|
57
60
|
|
|
58
61
|
const existingTemplate = (0, _element.useRef)(null);
|
|
59
62
|
(0, _element.useLayoutEffect)(() => {
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
+
// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
|
|
64
|
+
// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),
|
|
65
|
+
// we need to schedule this one in a microtask as well.
|
|
66
|
+
// Exemple: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.
|
|
67
|
+
window.queueMicrotask(() => {
|
|
68
|
+
// Only synchronize innerBlocks with template if innerBlocks are empty
|
|
69
|
+
// or a locking "all" or "contentOnly" exists directly on the block.
|
|
70
|
+
const currentInnerBlocks = getBlocks(clientId);
|
|
71
|
+
const shouldApplyTemplate = currentInnerBlocks.length === 0 || templateLock === 'all' || templateLock === 'contentOnly';
|
|
63
72
|
const hasTemplateChanged = !(0, _lodash.isEqual)(template, existingTemplate.current);
|
|
64
73
|
|
|
65
|
-
if (hasTemplateChanged) {
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
if (!shouldApplyTemplate || !hasTemplateChanged) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
existingTemplate.current = template;
|
|
79
|
+
const nextBlocks = (0, _blocks.synchronizeBlocksWithTemplate)(currentInnerBlocks, template);
|
|
68
80
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
81
|
+
if (!(0, _lodash.isEqual)(nextBlocks, currentInnerBlocks)) {
|
|
82
|
+
replaceInnerBlocks(clientId, nextBlocks, currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template
|
|
83
|
+
// If we're supposed to focus the block, we'll focus the first inner block
|
|
84
|
+
// otherwise, we won't apply any auto-focus.
|
|
85
|
+
// This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
|
|
86
|
+
getSelectedBlocksInitialCaretPosition());
|
|
76
87
|
}
|
|
77
|
-
}
|
|
88
|
+
});
|
|
78
89
|
}, [innerBlocks, template, templateLock, clientId]);
|
|
79
90
|
}
|
|
80
91
|
//# sourceMappingURL=use-inner-block-template-sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getSelectedBlocksInitialCaretPosition","blockEditorStore","replaceInnerBlocks","innerBlocks","select","getBlocks","existingTemplate","length","hasTemplateChanged","current","nextBlocks"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,yBAAT,CACdC,QADc,EAEdC,QAFc,EAGdC,YAHc,EAIdC,8BAJc,EAKb;AACD,QAAM;AAAEC,IAAAA;AAAF,MACL,qBAAWC,YAAX,CADD;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaD,YAAb,CAA/B;AACA,QAAME,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEH,YAAF,CAAN,CAA2BI,SAA3B,CAAsCT,QAAtC,CADK,EAEnB,CAAEA,QAAF,CAFmB,CAApB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getSelectedBlocksInitialCaretPosition","blockEditorStore","replaceInnerBlocks","innerBlocks","select","getBlocks","existingTemplate","window","queueMicrotask","currentInnerBlocks","shouldApplyTemplate","length","hasTemplateChanged","current","nextBlocks"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,yBAAT,CACdC,QADc,EAEdC,QAFc,EAGdC,YAHc,EAIdC,8BAJc,EAKb;AACD,QAAM;AAAEC,IAAAA;AAAF,MACL,qBAAWC,YAAX,CADD;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaD,YAAb,CAA/B;AACA,QAAME,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEH,YAAF,CAAN,CAA2BI,SAA3B,CAAsCT,QAAtC,CADK,EAEnB,CAAEA,QAAF,CAFmB,CAApB;AAIA,QAAM;AAAES,IAAAA;AAAF,MAAgB,qBAAWJ,YAAX,CAAtB,CARC,CAUD;;AACA,QAAMK,gBAAgB,GAAG,qBAAQ,IAAR,CAAzB;AACA,gCAAiB,MAAM;AACtB;AACA;AACA;AACA;AACAC,IAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5B;AACA;AACA,YAAMC,kBAAkB,GAAGJ,SAAS,CAAET,QAAF,CAApC;AACA,YAAMc,mBAAmB,GACxBD,kBAAkB,CAACE,MAAnB,KAA8B,CAA9B,IACAb,YAAY,KAAK,KADjB,IAEAA,YAAY,KAAK,aAHlB;AAKA,YAAMc,kBAAkB,GAAG,CAAE,qBAC5Bf,QAD4B,EAE5BS,gBAAgB,CAACO,OAFW,CAA7B;;AAKA,UAAK,CAAEH,mBAAF,IAAyB,CAAEE,kBAAhC,EAAqD;AACpD;AACA;;AAEDN,MAAAA,gBAAgB,CAACO,OAAjB,GAA2BhB,QAA3B;AACA,YAAMiB,UAAU,GAAG,2CAClBL,kBADkB,EAElBZ,QAFkB,CAAnB;;AAKA,UAAK,CAAE,qBAASiB,UAAT,EAAqBL,kBAArB,CAAP,EAAmD;AAClDP,QAAAA,kBAAkB,CACjBN,QADiB,EAEjBkB,UAFiB,EAGjBL,kBAAkB,CAACE,MAAnB,KAA8B,CAA9B,IACCZ,8BADD,IAECe,UAAU,CAACH,MAAX,KAAsB,CALN,EAMjB;AACA;AACA;AACA;AACAX,QAAAA,qCAAqC,EAVpB,CAAlB;AAYA;AACD,KAtCD;AAuCA,GA5CD,EA4CG,CAAEG,WAAF,EAAeN,QAAf,EAAyBC,YAAzB,EAAuCF,QAAvC,CA5CH;AA6CA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { synchronizeBlocksWithTemplate } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * This hook makes sure that a block's inner blocks stay in sync with the given\n * block \"template\". The template is a block hierarchy to which inner blocks must\n * conform. If the blocks get \"out of sync\" with the template and the template\n * is meant to be locked (e.g. templateLock = \"all\" or templateLock = \"contentOnly\"),\n * then we replace the inner blocks with the correct value after synchronizing it with the template.\n *\n * @param {string} clientId The block client ID.\n * @param {Object} template The template to match.\n * @param {string} templateLock The template lock state for the inner blocks. For\n * example, if the template lock is set to \"all\",\n * then the inner blocks will stay in sync with the\n * template. If not defined or set to false, then\n * the inner blocks will not be synchronized with\n * the given template.\n * @param {boolean} templateInsertUpdatesSelection Whether or not to update the\n * block-editor selection state when inner blocks\n * are replaced after template synchronization.\n */\nexport default function useInnerBlockTemplateSync(\n\tclientId,\n\ttemplate,\n\ttemplateLock,\n\ttemplateInsertUpdatesSelection\n) {\n\tconst { getSelectedBlocksInitialCaretPosition } =\n\t\tuseSelect( blockEditorStore );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst innerBlocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// Maintain a reference to the previous value so we can do a deep equality check.\n\tconst existingTemplate = useRef( null );\n\tuseLayoutEffect( () => {\n\t\t// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate\n\t\t// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),\n\t\t// we need to schedule this one in a microtask as well.\n\t\t// Exemple: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.\n\t\twindow.queueMicrotask( () => {\n\t\t\t// Only synchronize innerBlocks with template if innerBlocks are empty\n\t\t\t// or a locking \"all\" or \"contentOnly\" exists directly on the block.\n\t\t\tconst currentInnerBlocks = getBlocks( clientId );\n\t\t\tconst shouldApplyTemplate =\n\t\t\t\tcurrentInnerBlocks.length === 0 ||\n\t\t\t\ttemplateLock === 'all' ||\n\t\t\t\ttemplateLock === 'contentOnly';\n\n\t\t\tconst hasTemplateChanged = ! isEqual(\n\t\t\t\ttemplate,\n\t\t\t\texistingTemplate.current\n\t\t\t);\n\n\t\t\tif ( ! shouldApplyTemplate || ! hasTemplateChanged ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\texistingTemplate.current = template;\n\t\t\tconst nextBlocks = synchronizeBlocksWithTemplate(\n\t\t\t\tcurrentInnerBlocks,\n\t\t\t\ttemplate\n\t\t\t);\n\n\t\t\tif ( ! isEqual( nextBlocks, currentInnerBlocks ) ) {\n\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\tclientId,\n\t\t\t\t\tnextBlocks,\n\t\t\t\t\tcurrentInnerBlocks.length === 0 &&\n\t\t\t\t\t\ttemplateInsertUpdatesSelection &&\n\t\t\t\t\t\tnextBlocks.length !== 0,\n\t\t\t\t\t// This ensures the \"initialPosition\" doesn't change when applying the template\n\t\t\t\t\t// If we're supposed to focus the block, we'll focus the first inner block\n\t\t\t\t\t// otherwise, we won't apply any auto-focus.\n\t\t\t\t\t// This ensures for instance that the focus stays in the inserter when inserting the \"buttons\" block.\n\t\t\t\t\tgetSelectedBlocksInitialCaretPosition()\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}, [ innerBlocks, template, templateLock, clientId ] );\n}\n"]}
|
|
@@ -26,7 +26,7 @@ var _layouts = require("../../layouts");
|
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */
|
|
29
|
-
|
|
29
|
+
const pendingSettingsUpdates = new WeakMap();
|
|
30
30
|
/**
|
|
31
31
|
* This hook is a side effect which updates the block-editor store when changes
|
|
32
32
|
* happen to inner block settings. The given props are transformed into a
|
|
@@ -49,10 +49,12 @@ var _layouts = require("../../layouts");
|
|
|
49
49
|
* should face.
|
|
50
50
|
* @param {Object} layout The layout object for the block container.
|
|
51
51
|
*/
|
|
52
|
+
|
|
52
53
|
function useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
|
|
53
54
|
const {
|
|
54
55
|
updateBlockListSettings
|
|
55
56
|
} = (0, _data.useDispatch)(_store.store);
|
|
57
|
+
const registry = (0, _data.useRegistry)();
|
|
56
58
|
const {
|
|
57
59
|
blockListSettings,
|
|
58
60
|
parentLock
|
|
@@ -70,7 +72,7 @@ function useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultB
|
|
|
70
72
|
(0, _element.useLayoutEffect)(() => {
|
|
71
73
|
const newSettings = {
|
|
72
74
|
allowedBlocks: _allowedBlocks,
|
|
73
|
-
templateLock: templateLock === undefined || parentLock === '
|
|
75
|
+
templateLock: templateLock === undefined || parentLock === 'contentOnly' ? parentLock : templateLock
|
|
74
76
|
}; // These values are not defined for RN, so only include them if they
|
|
75
77
|
// are defined.
|
|
76
78
|
|
|
@@ -96,8 +98,30 @@ function useNestedSettingsUpdate(clientId, allowedBlocks, __experimentalDefaultB
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
if (!(0, _isShallowEqual.default)(blockListSettings, newSettings)) {
|
|
99
|
-
|
|
101
|
+
// Batch updates to block list settings to avoid triggering cascading renders
|
|
102
|
+
// for each container block included in a tree and optimize initial render.
|
|
103
|
+
// To avoid triggering updateBlockListSettings for each container block
|
|
104
|
+
// causing X re-renderings for X container blocks,
|
|
105
|
+
// we batch all the updatedBlockListSettings in a single "data" batch
|
|
106
|
+
// which results in a single re-render.
|
|
107
|
+
if (!pendingSettingsUpdates.get(registry)) {
|
|
108
|
+
pendingSettingsUpdates.set(registry, []);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
pendingSettingsUpdates.get(registry).push([clientId, newSettings]);
|
|
112
|
+
window.queueMicrotask(() => {
|
|
113
|
+
var _pendingSettingsUpdat;
|
|
114
|
+
|
|
115
|
+
if ((_pendingSettingsUpdat = pendingSettingsUpdates.get(registry)) !== null && _pendingSettingsUpdat !== void 0 && _pendingSettingsUpdat.length) {
|
|
116
|
+
registry.batch(() => {
|
|
117
|
+
pendingSettingsUpdates.get(registry).forEach(args => {
|
|
118
|
+
updateBlockListSettings(...args);
|
|
119
|
+
});
|
|
120
|
+
pendingSettingsUpdates.set(registry, []);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
100
124
|
}
|
|
101
|
-
}, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout]);
|
|
125
|
+
}, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout, registry]);
|
|
102
126
|
}
|
|
103
127
|
//# sourceMappingURL=use-nested-settings-update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"names":["useNestedSettingsUpdate","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","blockEditorStore","blockListSettings","parentLock","select","rootClientId","getBlockRootClientId","getBlockListSettings","getTemplateLock","_allowedBlocks","newSettings","undefined","__experimentalCaptureToolbars","layoutType","type","getOrientation"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AAIA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"names":["pendingSettingsUpdates","WeakMap","useNestedSettingsUpdate","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","blockEditorStore","registry","blockListSettings","parentLock","select","rootClientId","getBlockRootClientId","getBlockListSettings","getTemplateLock","_allowedBlocks","newSettings","undefined","__experimentalCaptureToolbars","layoutType","type","getOrientation","get","set","push","window","queueMicrotask","length","batch","forEach","args"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AAEA,MAAMA,sBAAsB,GAAG,IAAIC,OAAJ,EAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,uBAAT,CACdC,QADc,EAEdC,aAFc,EAGdC,0BAHc,EAIdC,0BAJc,EAKdC,YALc,EAMdC,eANc,EAOdC,WAPc,EAQdC,MARc,EASb;AACD,QAAM;AAAEC,IAAAA;AAAF,MAA8B,uBAAaC,YAAb,CAApC;AACA,QAAMC,QAAQ,GAAG,wBAAjB;AAEA,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAoC,qBACvCC,MAAF,IAAc;AACb,UAAMC,YAAY,GACjBD,MAAM,CAAEJ,YAAF,CAAN,CAA2BM,oBAA3B,CAAiDf,QAAjD,CADD;AAEA,WAAO;AACNW,MAAAA,iBAAiB,EAChBE,MAAM,CAAEJ,YAAF,CAAN,CAA2BO,oBAA3B,CAAiDhB,QAAjD,CAFK;AAGNY,MAAAA,UAAU,EACTC,MAAM,CAAEJ,YAAF,CAAN,CAA2BQ,eAA3B,CAA4CH,YAA5C;AAJK,KAAP;AAMA,GAVwC,EAWzC,CAAEd,QAAF,CAXyC,CAA1C,CAJC,CAkBD;AACA;;AACA,QAAMkB,cAAc,GAAG,sBAAS,MAAMjB,aAAf,EAA8BA,aAA9B,CAAvB;;AAEA,gCAAiB,MAAM;AACtB,UAAMkB,WAAW,GAAG;AACnBlB,MAAAA,aAAa,EAAEiB,cADI;AAEnBd,MAAAA,YAAY,EACXA,YAAY,KAAKgB,SAAjB,IAA8BR,UAAU,KAAK,a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,CACpB4B,GADF,CACOf,QADP,EAEEsB,OAFF,CAEaC,IAAF,IAAY;AACrBzB,cAAAA,uBAAuB,CAAE,GAAGyB,IAAL,CAAvB;AACA,aAJF;AAKApC,YAAAA,sBAAsB,CAAC6B,GAAvB,CAA4BhB,QAA5B,EAAsC,EAAtC;AACA,WAPD;AAQA;AACD,OAXD;AAYA;AACD,GA1DD,EA0DG,CACFV,QADE,EAEFW,iBAFE,EAGFO,cAHE,EAIFhB,0BAJE,EAKFC,0BALE,EAMFC,YANE,EAOFQ,UAPE,EAQFP,eARE,EASFC,WATE,EAUFE,uBAVE,EAWFD,MAXE,EAYFG,QAZE,CA1DH;AAwEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getLayoutType } from '../../layouts';\n\n/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */\n\nconst pendingSettingsUpdates = new WeakMap();\n\n/**\n * This hook is a side effect which updates the block-editor store when changes\n * happen to inner block settings. The given props are transformed into a\n * settings object, and if that is different from the current settings object in\n * the block-editor store, then the store is updated with the new settings which\n * came from props.\n *\n * @param {string} clientId The client ID of the block to update.\n * @param {string[]} allowedBlocks An array of block names which are permitted\n * in inner blocks.\n * @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ].\n * @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the\n * appender.\n * @param {string} [templateLock] The template lock specified for the inner\n * blocks component. (e.g. \"all\")\n * @param {boolean} captureToolbars Whether or children toolbars should be shown\n * in the inner blocks component rather than on\n * the child block.\n * @param {string} orientation The direction in which the block\n * should face.\n * @param {Object} layout The layout object for the block container.\n */\nexport default function useNestedSettingsUpdate(\n\tclientId,\n\tallowedBlocks,\n\t__experimentalDefaultBlock,\n\t__experimentalDirectInsert,\n\ttemplateLock,\n\tcaptureToolbars,\n\torientation,\n\tlayout\n) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst { blockListSettings, parentLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst rootClientId =\n\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tblockListSettings:\n\t\t\t\t\tselect( blockEditorStore ).getBlockListSettings( clientId ),\n\t\t\t\tparentLock:\n\t\t\t\t\tselect( blockEditorStore ).getTemplateLock( rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Memoize as inner blocks implementors often pass a new array on every\n\t// render.\n\tconst _allowedBlocks = useMemo( () => allowedBlocks, allowedBlocks );\n\n\tuseLayoutEffect( () => {\n\t\tconst newSettings = {\n\t\t\tallowedBlocks: _allowedBlocks,\n\t\t\ttemplateLock:\n\t\t\t\ttemplateLock === undefined || parentLock === 'contentOnly'\n\t\t\t\t\t? parentLock\n\t\t\t\t\t: templateLock,\n\t\t};\n\n\t\t// These values are not defined for RN, so only include them if they\n\t\t// are defined.\n\t\tif ( captureToolbars !== undefined ) {\n\t\t\tnewSettings.__experimentalCaptureToolbars = captureToolbars;\n\t\t}\n\n\t\t// Orientation depends on layout,\n\t\t// ideally the separate orientation prop should be deprecated.\n\t\tif ( orientation !== undefined ) {\n\t\t\tnewSettings.orientation = orientation;\n\t\t} else {\n\t\t\tconst layoutType = getLayoutType( layout?.type );\n\t\t\tnewSettings.orientation = layoutType.getOrientation( layout );\n\t\t}\n\n\t\tif ( __experimentalDefaultBlock !== undefined ) {\n\t\t\tnewSettings.__experimentalDefaultBlock = __experimentalDefaultBlock;\n\t\t}\n\n\t\tif ( __experimentalDirectInsert !== undefined ) {\n\t\t\tnewSettings.__experimentalDirectInsert = __experimentalDirectInsert;\n\t\t}\n\n\t\tif ( ! isShallowEqual( blockListSettings, newSettings ) ) {\n\t\t\t// Batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// To avoid triggering updateBlockListSettings for each container block\n\t\t\t// causing X re-renderings for X container blocks,\n\t\t\t// we batch all the updatedBlockListSettings in a single \"data\" batch\n\t\t\t// which results in a single re-render.\n\t\t\tif ( ! pendingSettingsUpdates.get( registry ) ) {\n\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t}\n\t\t\tpendingSettingsUpdates\n\t\t\t\t.get( registry )\n\t\t\t\t.push( [ clientId, newSettings ] );\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tif ( pendingSettingsUpdates.get( registry )?.length ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tpendingSettingsUpdates\n\t\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t\t.forEach( ( args ) => {\n\t\t\t\t\t\t\t\tupdateBlockListSettings( ...args );\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tblockListSettings,\n\t\t_allowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tparentLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tupdateBlockListSettings,\n\t\tlayout,\n\t\tregistry,\n\t] );\n}\n"]}
|
|
@@ -96,7 +96,7 @@ function ListViewBranch(props) {
|
|
|
96
96
|
shouldShowInnerBlocks = true
|
|
97
97
|
} = props;
|
|
98
98
|
const isContentLocked = (0, _data.useSelect)(select => {
|
|
99
|
-
return !!(parentId && select(_store.store).getTemplateLock(parentId) === '
|
|
99
|
+
return !!(parentId && select(_store.store).getTemplateLock(parentId) === 'contentOnly');
|
|
100
100
|
}, [parentId]);
|
|
101
101
|
const {
|
|
102
102
|
expandedState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","parentId","shouldShowInnerBlocks","isContentLocked","select","blockEditorStore","getTemplateLock","filteredBlocks","filter","Boolean","blockCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","defaultProps"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CACCC,KADD,EAECC,aAFD,EAGCC,gBAHD,EAICC,mBAJD,EAKE;AAAA;;AACD,QAAMC,SAAS,GAAGF,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEG,QAAlB,CAA4BL,KAAK,CAACM,QAAlC,CAAlB;;AACA,MAAKF,SAAL,EAAiB;AAChB,WAAO,CAAP;AACA;;AACD,QAAMG,UAAU,4BAAGN,aAAa,CAAED,KAAK,CAACM,QAAR,CAAhB,yEAAsCH,mBAAtD;;AAEA,MAAKI,UAAL,EAAkB;AACjB,WACC,IACAP,KAAK,CAACQ,WAAN,CAAkBC,MAAlB,CACCC,YAAY,CACXT,aADW,EAEXC,gBAFW,EAGXC,mBAHW,CADb,EAMC,CAND,CAFD;AAWA;;AACD,SAAO,CAAP;AACA;;AACD,MAAMO,YAAY,GACjB,CAAET,aAAF,EAAiBC,gBAAjB,EAAmCC,mBAAnC,KACA,CAAEQ,KAAF,EAASX,KAAT,KAAoB;AAAA;;AACnB,QAAMI,SAAS,GAAGF,gBAAH,aAAG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esContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer =\n\t( expandedState, draggedClientIds, isExpandedByDefault ) =>\n\t( count, block ) => {\n\t\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\t\tif ( isDragged ) {\n\t\t\treturn count;\n\t\t}\n\t\tconst isExpanded =\n\t\t\texpandedState[ block.clientId ] ?? isExpandedByDefault;\n\t\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\t\treturn (\n\t\t\t\tcount +\n\t\t\t\tcountBlocks(\n\t\t\t\t\tblock,\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn count + 1;\n\t};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tshouldShowInnerBlocks = true,\n\t} = props;\n\n\tconst isContentLocked = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! (\n\t\t\t\tparentId &&\n\t\t\t\tselect( blockEditorStore ).getTemplateLock( parentId ) ===\n\t\t\t\t\t'noContent'\n\t\t\t);\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tif ( isContentLocked ) {\n\t\treturn null;\n\t}\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand =\n\t\t\t\t\thasNestedBlocks && shouldShowInnerBlocks\n\t\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","parentId","shouldShowInnerBlocks","isContentLocked","select","blockEditorStore","getTemplateLock","filteredBlocks","filter","Boolean","blockCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","defaultProps"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CACCC,KADD,EAECC,aAFD,EAGC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D,CApBF,EAwBGH,eAAe,IAAIC,YAAnB,IAAmC,CAAEtC,SAArC,IACD,4BAAC,cAAD;AACC,MAAA,QAAQ,EAAGE,QADZ;AAEC,MAAA,MAAM,EAAGE,WAFV;AAGC,MAAA,WAAW,EAAGQ,WAHf;AAIC,MAAA,eAAe,EAAGC,eAJnB;AAKC,MAAA,KAAK,EAAGE,KAAK,GAAG,CALjB;AAMC,MAAA,IAAI,EAAGqB,WANR;AAOC,MAAA,YAAY,EAAGN,YAAY,GAAG,CAP/B;AAQC,MAAA,eAAe,EAAGX,eARnB;AASC,MAAA,gBAAgB,EAAGuB,gBATpB;AAUC,MAAA,iBAAiB,EAAG5B,iBAVrB;AAWC,MAAA,UAAU,EAAGX;AAXd,MAzBF,CADD;AA0CA,GAjFC,CADH,CADD;AAsFA;;AAEDM,cAAc,CAACkC,YAAf,GAA8B;AAC7B/B,EAAAA,WAAW,EAAE,MAAM,CAAE;AADQ,CAA9B;;eAIe,mBAAMH,cAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer =\n\t( expandedState, draggedClientIds, isExpandedByDefault ) =>\n\t( count, block ) => {\n\t\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\t\tif ( isDragged ) {\n\t\t\treturn count;\n\t\t}\n\t\tconst isExpanded =\n\t\t\texpandedState[ block.clientId ] ?? isExpandedByDefault;\n\t\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\t\treturn (\n\t\t\t\tcount +\n\t\t\t\tcountBlocks(\n\t\t\t\t\tblock,\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn count + 1;\n\t};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tshouldShowInnerBlocks = true,\n\t} = props;\n\n\tconst isContentLocked = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! (\n\t\t\t\tparentId &&\n\t\t\t\tselect( blockEditorStore ).getTemplateLock( parentId ) ===\n\t\t\t\t\t'contentOnly'\n\t\t\t);\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tif ( isContentLocked ) {\n\t\treturn null;\n\t}\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand =\n\t\t\t\t\thasNestedBlocks && shouldShowInnerBlocks\n\t\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}
|
|
@@ -65,37 +65,39 @@ function ListViewDropIndicator(_ref) {
|
|
|
65
65
|
width: targetElement.offsetWidth - indent
|
|
66
66
|
};
|
|
67
67
|
}, [getDropIndicatorIndent, targetElement]);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
68
|
+
const popoverAnchor = (0, _element.useMemo)(() => {
|
|
69
|
+
const isValidDropPosition = dropPosition === 'top' || dropPosition === 'bottom' || dropPosition === 'inside';
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const indent = getDropIndicatorIndent();
|
|
76
|
-
const anchorRect = {
|
|
77
|
-
left: rect.left + indent,
|
|
78
|
-
right: rect.right,
|
|
79
|
-
width: 0,
|
|
80
|
-
height: 0,
|
|
81
|
-
ownerDocument
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
if (dropPosition === 'top') {
|
|
85
|
-
return { ...anchorRect,
|
|
86
|
-
top: rect.top,
|
|
87
|
-
bottom: rect.top
|
|
88
|
-
};
|
|
71
|
+
if (!targetElement || !isValidDropPosition) {
|
|
72
|
+
return undefined;
|
|
89
73
|
}
|
|
90
74
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
return {
|
|
76
|
+
ownerDocument: targetElement.ownerDocument,
|
|
77
|
+
|
|
78
|
+
getBoundingClientRect() {
|
|
79
|
+
const rect = targetElement.getBoundingClientRect();
|
|
80
|
+
const indent = getDropIndicatorIndent();
|
|
81
|
+
const left = rect.left + indent;
|
|
82
|
+
const right = rect.right;
|
|
83
|
+
let top = 0;
|
|
84
|
+
let bottom = 0;
|
|
85
|
+
|
|
86
|
+
if (dropPosition === 'top') {
|
|
87
|
+
top = rect.top;
|
|
88
|
+
bottom = rect.top;
|
|
89
|
+
} else {
|
|
90
|
+
// `dropPosition` is either `bottom` or `inside`
|
|
91
|
+
top = rect.bottom;
|
|
92
|
+
bottom = rect.bottom;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const width = right - left;
|
|
96
|
+
const height = bottom - top;
|
|
97
|
+
return new window.DOMRect(left, top, width, height);
|
|
98
|
+
}
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
};
|
|
99
101
|
}, [targetElement, dropPosition, getDropIndicatorIndent]);
|
|
100
102
|
|
|
101
103
|
if (!targetElement) {
|
|
@@ -104,7 +106,7 @@ function ListViewDropIndicator(_ref) {
|
|
|
104
106
|
|
|
105
107
|
return (0, _element.createElement)(_components.Popover, {
|
|
106
108
|
animate: false,
|
|
107
|
-
|
|
109
|
+
anchor: popoverAnchor,
|
|
108
110
|
focusOnMount: false,
|
|
109
111
|
className: "block-editor-list-view-drop-indicator"
|
|
110
112
|
}, (0, _element.createElement)("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/drop-indicator.js"],"names":["ListViewDropIndicator","listViewRef","blockDropTarget","rootClientId","clientId","dropPosition","rootBlockElement","blockElement","current","_rootBlockElement","querySelector","undefined","_blockElement","targetElement","getDropIndicatorIndent","targetElementRect","getBoundingClientRect","rootBlockIconElement","rootBlockIconRect","right","left","style","indent","width","offsetWidth","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/drop-indicator.js"],"names":["ListViewDropIndicator","listViewRef","blockDropTarget","rootClientId","clientId","dropPosition","rootBlockElement","blockElement","current","_rootBlockElement","querySelector","undefined","_blockElement","targetElement","getDropIndicatorIndent","targetElementRect","getBoundingClientRect","rootBlockIconElement","rootBlockIconRect","right","left","style","indent","width","offsetWidth","popoverAnchor","isValidDropPosition","ownerDocument","rect","top","bottom","height","window","DOMRect"],"mappings":";;;;;;;AAIA;;AADA;;AAHA;AACA;AACA;AAIe,SAASA,qBAAT,OAGX;AAAA,MAH2C;AAC9CC,IAAAA,WAD8C;AAE9CC,IAAAA;AAF8C,GAG3C;AACH,QA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EAmCnB,CAAElB,aAAF,EAAiBR,YAAjB,EAA+BS,sBAA/B,CAnCmB,CAAtB;;AAqCA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,mBAAD;AACC,IAAA,OAAO,EAAG,KADX;AAEC,IAAA,MAAM,EAAGY,aAFV;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,SAAS,EAAC;AAJX,KAMC;AACC,IAAA,KAAK,EAAGJ,KADT;AAEC,IAAA,SAAS,EAAC;AAFX,IAND,CADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\nexport default function ListViewDropIndicator( {\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst getDropIndicatorIndent = useCallback( () => {\n\t\tif ( ! rootBlockElement ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Calculate the indent using the block icon of the root block.\n\t\t// Using a classname selector here might be flaky and could be\n\t\t// improved.\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\t\tconst rootBlockIconElement = rootBlockElement.querySelector(\n\t\t\t'.block-editor-block-icon'\n\t\t);\n\t\tconst rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();\n\t\treturn rootBlockIconRect.right - targetElementRect.left;\n\t}, [ rootBlockElement, targetElement ] );\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst indent = getDropIndicatorIndent();\n\n\t\treturn {\n\t\t\twidth: targetElement.offsetWidth - indent,\n\t\t};\n\t}, [ getDropIndicatorIndent, targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\townerDocument: targetElement.ownerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\tconst indent = getDropIndicatorIndent();\n\n\t\t\t\tconst left = rect.left + indent;\n\t\t\t\tconst right = rect.right;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet bottom = 0;\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t\tbottom = rect.top;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.bottom;\n\t\t\t\t\tbottom = rect.bottom;\n\t\t\t\t}\n\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [ targetElement, dropPosition, getDropIndicatorIndent ] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator\"\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName=\"block-editor-list-view-drop-indicator__line\"\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
|
|
@@ -31,30 +31,30 @@ var _store = require("../../store");
|
|
|
31
31
|
function InlineSelectionToolbar(_ref) {
|
|
32
32
|
let {
|
|
33
33
|
value,
|
|
34
|
-
|
|
34
|
+
editableContentElement,
|
|
35
35
|
activeFormats
|
|
36
36
|
} = _ref;
|
|
37
37
|
const lastFormat = activeFormats[activeFormats.length - 1];
|
|
38
38
|
const lastFormatType = lastFormat === null || lastFormat === void 0 ? void 0 : lastFormat.type;
|
|
39
39
|
const settings = (0, _data.useSelect)(select => select(_richText.store).getFormatType(lastFormatType), [lastFormatType]);
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const popoverAnchor = (0, _richText.useAnchor)({
|
|
41
|
+
editableContentElement,
|
|
42
42
|
value,
|
|
43
43
|
settings
|
|
44
44
|
});
|
|
45
45
|
return (0, _element.createElement)(InlineToolbar, {
|
|
46
|
-
|
|
46
|
+
popoverAnchor: popoverAnchor
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function InlineToolbar(_ref2) {
|
|
51
51
|
let {
|
|
52
|
-
|
|
52
|
+
popoverAnchor
|
|
53
53
|
} = _ref2;
|
|
54
54
|
return (0, _element.createElement)(_components.Popover, {
|
|
55
55
|
position: "top center",
|
|
56
56
|
focusOnMount: false,
|
|
57
|
-
|
|
57
|
+
anchor: popoverAnchor,
|
|
58
58
|
className: "block-editor-rich-text__inline-format-toolbar",
|
|
59
59
|
__unstableSlotName: "block-toolbar"
|
|
60
60
|
}, (0, _element.createElement)("div", {
|
|
@@ -65,14 +65,14 @@ function InlineToolbar(_ref2) {
|
|
|
65
65
|
const FormatToolbarContainer = _ref3 => {
|
|
66
66
|
let {
|
|
67
67
|
inline,
|
|
68
|
-
|
|
68
|
+
editableContentElement,
|
|
69
69
|
value
|
|
70
70
|
} = _ref3;
|
|
71
71
|
const hasInlineToolbar = (0, _data.useSelect)(select => select(_store.store).getSettings().hasInlineToolbar, []);
|
|
72
72
|
|
|
73
73
|
if (inline) {
|
|
74
74
|
return (0, _element.createElement)(InlineToolbar, {
|
|
75
|
-
|
|
75
|
+
popoverAnchor: editableContentElement
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -84,7 +84,7 @@ const FormatToolbarContainer = _ref3 => {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
return (0, _element.createElement)(InlineSelectionToolbar, {
|
|
87
|
-
|
|
87
|
+
editableContentElement: editableContentElement,
|
|
88
88
|
value: value,
|
|
89
89
|
activeFormats: activeFormats
|
|
90
90
|
});
|