@wordpress/block-editor 15.10.1-next.v.0 → 15.11.1-next.v.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 +2 -0
- package/build/components/block-controls/index.cjs +1 -1
- package/build/components/block-controls/index.cjs.map +2 -2
- package/build/components/block-edit/context.cjs +5 -0
- package/build/components/block-edit/context.cjs.map +2 -2
- package/build/components/block-edit/index.cjs +3 -0
- package/build/components/block-edit/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +7 -27
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-list/block.cjs +3 -0
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +37 -13
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +1 -1
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +1 -1
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +2 -26
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-visibility/index.cjs +7 -9
- package/build/components/block-visibility/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs +13 -11
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +1 -1
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/block-visibility/utils.cjs +5 -1
- package/build/components/block-visibility/utils.cjs.map +2 -2
- package/build/components/block-visibility/viewport-menu-item.cjs +11 -4
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +4 -6
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +121 -0
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +7 -0
- package/build/components/button-block-appender/index.cjs +23 -19
- package/build/components/button-block-appender/index.cjs.map +2 -2
- package/build/components/color-palette/with-color-context.cjs +1 -1
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/color-style-selector/index.cjs +1 -1
- package/build/components/color-style-selector/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +5 -3
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +1 -1
- package/build/components/colors-gradients/dropdown.cjs.map +2 -2
- package/build/components/editable-text/index.cjs +5 -1
- package/build/components/editable-text/index.cjs.map +2 -2
- package/build/components/font-sizes/font-size-picker.cjs +2 -1
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs +5 -3
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +26 -13
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +1 -1
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/gradients/with-gradient.cjs +1 -1
- package/build/components/gradients/with-gradient.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -25
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/index.cjs +1 -1
- package/build/components/inspector-controls/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +1 -1
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +7 -7
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +8 -16
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +29 -34
- package/build/components/list-view/block.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +3 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/provider/index.cjs +7 -8
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/with-registry-provider.cjs +1 -1
- package/build/components/provider/with-registry-provider.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +2 -34
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +52 -86
- package/build/hooks/block-fields/index.cjs.map +3 -3
- package/build/hooks/block-fields/link/index.cjs +2 -11
- package/build/hooks/block-fields/link/index.cjs.map +2 -2
- package/build/hooks/block-fields/media/index.cjs +9 -14
- package/build/hooks/block-fields/media/index.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +1 -1
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +141 -0
- package/build/hooks/custom-css.cjs.map +7 -0
- package/build/hooks/fit-text.cjs +14 -7
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +1 -1
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/index.cjs +6 -1
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout.cjs +10 -4
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +32 -11
- package/build/hooks/list-view.cjs.map +3 -3
- package/build/hooks/utils.cjs +5 -4
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs +12 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/store/defaults.cjs +3 -0
- package/build/store/defaults.cjs.map +2 -2
- package/build/store/private-selectors.cjs +45 -37
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +7 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +5 -1
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-controls/index.mjs +1 -1
- package/build-module/components/block-controls/index.mjs.map +2 -2
- package/build-module/components/block-edit/context.mjs +4 -0
- package/build-module/components/block-edit/context.mjs.map +2 -2
- package/build-module/components/block-edit/index.mjs +4 -0
- package/build-module/components/block-edit/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +7 -27
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +3 -0
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +37 -13
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +2 -2
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +2 -26
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-visibility/index.mjs +6 -9
- package/build-module/components/block-visibility/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +13 -11
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +1 -1
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +5 -1
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +11 -4
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +4 -6
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +95 -0
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +7 -0
- package/build-module/components/button-block-appender/index.mjs +23 -19
- package/build-module/components/button-block-appender/index.mjs.map +2 -2
- package/build-module/components/color-palette/with-color-context.mjs +1 -1
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/color-style-selector/index.mjs +1 -1
- package/build-module/components/color-style-selector/index.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs +5 -3
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +1 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/editable-text/index.mjs +5 -1
- package/build-module/components/editable-text/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +2 -1
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs +5 -3
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +22 -13
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +1 -1
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +1 -1
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/gradients/with-gradient.mjs +1 -1
- package/build-module/components/gradients/with-gradient.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +16 -22
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/index.mjs +1 -1
- package/build-module/components/inspector-controls/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +7 -7
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +8 -16
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +31 -36
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs +3 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +7 -8
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/with-registry-provider.mjs +1 -1
- package/build-module/components/provider/with-registry-provider.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +3 -37
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +45 -87
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +2 -11
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +9 -14
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +1 -1
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +112 -0
- package/build-module/hooks/custom-css.mjs.map +7 -0
- package/build-module/hooks/fit-text.mjs +14 -7
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +1 -1
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/index.mjs +6 -1
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +10 -4
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +33 -12
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +7 -5
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +12 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/store/defaults.mjs +3 -0
- package/build-module/store/defaults.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +42 -40
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +7 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +5 -1
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +39 -39
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-controls/test/index.js +1 -0
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +6 -0
- package/src/components/block-edit/test/edit.js +10 -0
- package/src/components/block-inspector/index.js +16 -38
- package/src/components/block-list/block.js +3 -0
- package/src/components/block-list/block.native.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +49 -29
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-preview/test/index.js +11 -7
- package/src/components/block-settings-menu-controls/index.js +2 -2
- package/src/components/block-switcher/test/index.js +2 -0
- package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
- package/src/components/block-switcher/test/utils.js +2 -0
- package/src/components/block-toolbar/index.js +2 -2
- package/src/components/block-tools/index.js +2 -29
- package/src/components/block-visibility/index.js +3 -19
- package/src/components/block-visibility/modal.js +16 -14
- package/src/components/block-visibility/test/use-block-visibility.js +27 -25
- package/src/components/block-visibility/test/utils.js +24 -8
- package/src/components/block-visibility/use-block-visibility.js +1 -4
- package/src/components/block-visibility/utils.js +9 -1
- package/src/components/block-visibility/viewport-menu-item.js +11 -5
- package/src/components/block-visibility/viewport-toolbar.js +5 -6
- package/src/components/block-visibility/viewport-visibility-info.js +131 -0
- package/src/components/button-block-appender/index.js +2 -2
- package/src/components/color-palette/with-color-context.js +1 -1
- package/src/components/color-style-selector/index.js +2 -3
- package/src/components/colors/with-colors.js +23 -20
- package/src/components/colors-gradients/dropdown.js +2 -3
- package/src/components/editable-text/index.js +5 -1
- package/src/components/font-sizes/font-size-picker.js +1 -0
- package/src/components/font-sizes/with-font-sizes.js +13 -10
- package/src/components/global-styles/advanced-panel.js +35 -16
- package/src/components/global-styles/filters-panel.js +2 -3
- package/src/components/global-styles/shadow-panel-components.js +1 -1
- package/src/components/global-styles/style.scss +9 -5
- package/src/components/gradients/with-gradient.js +7 -4
- package/src/components/inner-blocks/test/index.js +2 -0
- package/src/components/inspector-controls/fill.js +30 -20
- package/src/components/inspector-controls/index.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +5 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -11
- package/src/components/link-control/test/index.js +6 -1
- package/src/components/list-view/block-select-button.js +16 -25
- package/src/components/list-view/block.js +38 -43
- package/src/components/list-view/utils.js +4 -2
- package/src/components/media-replace-flow/test/index.js +13 -11
- package/src/components/provider/index.js +11 -10
- package/src/components/provider/test/use-block-sync.js +1 -0
- package/src/components/provider/with-registry-provider.js +1 -1
- package/src/components/use-block-commands/index.js +0 -41
- package/src/hooks/block-fields/index.js +66 -111
- package/src/hooks/block-fields/link/index.js +2 -14
- package/src/hooks/block-fields/media/index.js +9 -21
- package/src/hooks/cross-origin-isolation.js +19 -18
- package/src/hooks/custom-css.js +176 -0
- package/src/hooks/fit-text.js +20 -5
- package/src/hooks/grid-visualizer.js +15 -14
- package/src/hooks/index.js +6 -1
- package/src/hooks/layout.js +55 -43
- package/src/hooks/list-view.js +46 -12
- package/src/hooks/test/align.js +1 -0
- package/src/hooks/test/allowed-blocks.js +8 -0
- package/src/hooks/test/auto-inspector-controls.js +4 -0
- package/src/hooks/test/font-size.js +1 -0
- package/src/hooks/test/metadata.js +4 -0
- package/src/hooks/test/text-align.js +1 -0
- package/src/hooks/utils.js +124 -116
- package/src/layouts/grid.js +19 -3
- package/src/layouts/test/grid.js +1 -1
- package/src/store/defaults.js +4 -0
- package/src/store/private-selectors.js +94 -63
- package/src/store/selectors.js +14 -6
- package/src/store/test/actions.js +7 -0
- package/src/store/test/private-selectors.js +116 -119
- package/src/store/test/reducer.js +4 -0
- package/src/store/test/registry-selectors.js +2 -0
- package/src/store/test/selectors.js +19 -0
- package/src/utils/fit-text-utils.js +12 -2
- package/build/components/block-visibility/block-visibility-info.cjs +0 -63
- package/build/components/block-visibility/block-visibility-info.cjs.map +0 -7
- package/build/components/block-visibility/menu-item.cjs +0 -109
- package/build/components/block-visibility/menu-item.cjs.map +0 -7
- package/build/components/block-visibility/toolbar.cjs +0 -92
- package/build/components/block-visibility/toolbar.cjs.map +0 -7
- package/build-module/components/block-visibility/block-visibility-info.mjs +0 -47
- package/build-module/components/block-visibility/block-visibility-info.mjs.map +0 -7
- package/build-module/components/block-visibility/menu-item.mjs +0 -88
- package/build-module/components/block-visibility/menu-item.mjs.map +0 -7
- package/build-module/components/block-visibility/toolbar.mjs +0 -71
- package/build-module/components/block-visibility/toolbar.mjs.map +0 -7
- package/src/components/block-visibility/block-visibility-info.js +0 -62
- package/src/components/block-visibility/menu-item.js +0 -96
- package/src/components/block-visibility/toolbar.js +0 -88
- /package/src/components/block-icon/stories/{index.story.js → index.story.ts} +0 -0
- /package/src/components/contrast-checker/stories/{index.story.js → index.story.ts} +0 -0
|
@@ -9,13 +9,17 @@ function findOptimalFontSize(textElement, applyFontSize) {
|
|
|
9
9
|
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
|
|
10
10
|
const range = document.createRange();
|
|
11
11
|
range.selectNodeContents(textElement);
|
|
12
|
+
let maxclientHeight = textElement.clientHeight;
|
|
12
13
|
while (minSize <= maxSize) {
|
|
13
14
|
const midSize = Math.floor((minSize + maxSize) / 2);
|
|
14
15
|
applyFontSize(midSize);
|
|
15
16
|
const rect = range.getBoundingClientRect();
|
|
16
17
|
const textWidth = rect.width;
|
|
17
18
|
const fitsWidth = textElement.scrollWidth <= textElement.clientWidth && textWidth <= textElement.clientWidth - paddingLeft - paddingRight;
|
|
18
|
-
const fitsHeight = alreadyHasScrollableHeight || textElement.scrollHeight <= textElement.clientHeight;
|
|
19
|
+
const fitsHeight = alreadyHasScrollableHeight || textElement.scrollHeight <= textElement.clientHeight || textElement.scrollHeight <= maxclientHeight;
|
|
20
|
+
if (textElement.clientHeight > maxclientHeight) {
|
|
21
|
+
maxclientHeight = textElement.clientHeight;
|
|
22
|
+
}
|
|
19
23
|
if (fitsWidth && fitsHeight) {
|
|
20
24
|
bestSize = midSize;
|
|
21
25
|
minSize = midSize + 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/fit-text-utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared utility functions for fit text functionality.\n * Uses callback-based approach for maximum code reuse between editor and frontend.\n */\n\n/**\n * Find optimal font size using simple binary search between 0-2400px.\n *\n * @param {HTMLElement} textElement The text element\n * @param {Function} applyFontSize Function that receives font size in pixels\n * @return {number} Optimal font size\n */\nfunction findOptimalFontSize( textElement, applyFontSize ) {\n\tconst alreadyHasScrollableHeight =\n\t\ttextElement.scrollHeight > textElement.clientHeight;\n\tlet minSize = 0;\n\tlet maxSize = 2400;\n\tlet bestSize = minSize;\n\n\tconst computedStyle = window.getComputedStyle( textElement );\n\tconst paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;\n\tconst paddingRight = parseFloat( computedStyle.paddingRight ) || 0;\n\tconst range = document.createRange();\n\trange.selectNodeContents( textElement );\n\n\twhile ( minSize <= maxSize ) {\n\t\tconst midSize = Math.floor( ( minSize + maxSize ) / 2 );\n\t\tapplyFontSize( midSize );\n\n\t\t// When there is padding if the text overflows to the\n\t\t// padding area, it should be considered overflowing.\n\t\t// Use Range API to measure actual text content dimensions.\n\t\tconst rect = range.getBoundingClientRect();\n\t\tconst textWidth = rect.width;\n\n\t\t// Check if text fits within the element's width and is not\n\t\t// overflowing into the padding area.\n\t\tconst fitsWidth =\n\t\t\ttextElement.scrollWidth <= textElement.clientWidth &&\n\t\t\ttextWidth <= textElement.clientWidth - paddingLeft - paddingRight;\n\t\t// Check if text fits within the element's height.\n\t\tconst fitsHeight =\n\t\t\talreadyHasScrollableHeight ||\n\t\t\ttextElement.scrollHeight <= textElement.clientHeight;\n\n\t\tif ( fitsWidth && fitsHeight ) {\n\t\t\tbestSize = midSize;\n\t\t\tminSize = midSize + 1;\n\t\t} else {\n\t\t\tmaxSize = midSize - 1;\n\t\t}\n\t}\n\trange.detach();\n\n\treturn bestSize;\n}\n\n/**\n * Complete fit text optimization for a single text element.\n * Handles the full flow using callbacks for font size application.\n *\n * @param {HTMLElement} textElement The text element (paragraph, heading, etc.)\n * @param {Function} applyFontSize Function that receives font size in pixels (0 to clear, >0 to apply)\n */\nexport function optimizeFitText( textElement, applyFontSize ) {\n\tif ( ! textElement ) {\n\t\treturn;\n\t}\n\n\tapplyFontSize( 0 );\n\n\tconst optimalSize = findOptimalFontSize( textElement, applyFontSize );\n\n\tapplyFontSize( optimalSize );\n\treturn optimalSize;\n}\n"],
|
|
5
|
-
"mappings": ";AAYA,SAAS,oBAAqB,aAAa,eAAgB;AAC1D,QAAM,6BACL,YAAY,eAAe,YAAY;AACxC,MAAI,UAAU;AACd,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,QAAM,gBAAgB,OAAO,iBAAkB,WAAY;AAC3D,QAAM,cAAc,WAAY,cAAc,WAAY,KAAK;AAC/D,QAAM,eAAe,WAAY,cAAc,YAAa,KAAK;AACjE,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,WAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * Shared utility functions for fit text functionality.\n * Uses callback-based approach for maximum code reuse between editor and frontend.\n */\n\n/**\n * Find optimal font size using simple binary search between 0-2400px.\n *\n * @param {HTMLElement} textElement The text element\n * @param {Function} applyFontSize Function that receives font size in pixels\n * @return {number} Optimal font size\n */\nfunction findOptimalFontSize( textElement, applyFontSize ) {\n\tconst alreadyHasScrollableHeight =\n\t\ttextElement.scrollHeight > textElement.clientHeight;\n\tlet minSize = 0;\n\tlet maxSize = 2400;\n\tlet bestSize = minSize;\n\n\tconst computedStyle = window.getComputedStyle( textElement );\n\tconst paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;\n\tconst paddingRight = parseFloat( computedStyle.paddingRight ) || 0;\n\tconst range = document.createRange();\n\trange.selectNodeContents( textElement );\n\tlet maxclientHeight = textElement.clientHeight;\n\twhile ( minSize <= maxSize ) {\n\t\tconst midSize = Math.floor( ( minSize + maxSize ) / 2 );\n\t\tapplyFontSize( midSize );\n\n\t\t// When there is padding if the text overflows to the\n\t\t// padding area, it should be considered overflowing.\n\t\t// Use Range API to measure actual text content dimensions.\n\t\tconst rect = range.getBoundingClientRect();\n\t\tconst textWidth = rect.width;\n\n\t\t// Check if text fits within the element's width and is not\n\t\t// overflowing into the padding area.\n\t\tconst fitsWidth =\n\t\t\ttextElement.scrollWidth <= textElement.clientWidth &&\n\t\t\ttextWidth <= textElement.clientWidth - paddingLeft - paddingRight;\n\t\t// Check if text fits within the element's height.\n\t\tconst fitsHeight =\n\t\t\talreadyHasScrollableHeight ||\n\t\t\ttextElement.scrollHeight <= textElement.clientHeight ||\n\t\t\ttextElement.scrollHeight <= maxclientHeight;\n\n\t\t// When there are calculated line heights, text may jump in height\n\t\t// the available space may decrease while the font size decreases,\n\t\t// making text not fit.\n\t\t// We store a maximum reference height: the maximum reference element height that was observed\n\t\t// during the loop to avoid issues with such jumps.\n\t\tif ( textElement.clientHeight > maxclientHeight ) {\n\t\t\tmaxclientHeight = textElement.clientHeight;\n\t\t}\n\n\t\tif ( fitsWidth && fitsHeight ) {\n\t\t\tbestSize = midSize;\n\t\t\tminSize = midSize + 1;\n\t\t} else {\n\t\t\tmaxSize = midSize - 1;\n\t\t}\n\t}\n\trange.detach();\n\n\treturn bestSize;\n}\n\n/**\n * Complete fit text optimization for a single text element.\n * Handles the full flow using callbacks for font size application.\n *\n * @param {HTMLElement} textElement The text element (paragraph, heading, etc.)\n * @param {Function} applyFontSize Function that receives font size in pixels (0 to clear, >0 to apply)\n */\nexport function optimizeFitText( textElement, applyFontSize ) {\n\tif ( ! textElement ) {\n\t\treturn;\n\t}\n\n\tapplyFontSize( 0 );\n\n\tconst optimalSize = findOptimalFontSize( textElement, applyFontSize );\n\n\tapplyFontSize( optimalSize );\n\treturn optimalSize;\n}\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,oBAAqB,aAAa,eAAgB;AAC1D,QAAM,6BACL,YAAY,eAAe,YAAY;AACxC,MAAI,UAAU;AACd,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,QAAM,gBAAgB,OAAO,iBAAkB,WAAY;AAC3D,QAAM,cAAc,WAAY,cAAc,WAAY,KAAK;AAC/D,QAAM,eAAe,WAAY,cAAc,YAAa,KAAK;AACjE,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,WAAY;AACtC,MAAI,kBAAkB,YAAY;AAClC,SAAQ,WAAW,SAAU;AAC5B,UAAM,UAAU,KAAK,OAAS,UAAU,WAAY,CAAE;AACtD,kBAAe,OAAQ;AAKvB,UAAM,OAAO,MAAM,sBAAsB;AACzC,UAAM,YAAY,KAAK;AAIvB,UAAM,YACL,YAAY,eAAe,YAAY,eACvC,aAAa,YAAY,cAAc,cAAc;AAEtD,UAAM,aACL,8BACA,YAAY,gBAAgB,YAAY,gBACxC,YAAY,gBAAgB;AAO7B,QAAK,YAAY,eAAe,iBAAkB;AACjD,wBAAkB,YAAY;AAAA,IAC/B;AAEA,QAAK,aAAa,YAAa;AAC9B,iBAAW;AACX,gBAAU,UAAU;AAAA,IACrB,OAAO;AACN,gBAAU,UAAU;AAAA,IACrB;AAAA,EACD;AACA,QAAM,OAAO;AAEb,SAAO;AACR;AASO,SAAS,gBAAiB,aAAa,eAAgB;AAC7D,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,gBAAe,CAAE;AAEjB,QAAM,cAAc,oBAAqB,aAAa,aAAc;AAEpE,gBAAe,WAAY;AAC3B,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1760,6 +1760,9 @@ iframe[name=editor-canvas] {
|
|
|
1760
1760
|
background: linear-gradient(45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
|
|
1761
1761
|
}
|
|
1762
1762
|
|
|
1763
|
+
.block-editor-global-styles-advanced-panel__custom-css-input {
|
|
1764
|
+
margin-bottom: 16px;
|
|
1765
|
+
}
|
|
1763
1766
|
.block-editor-global-styles-advanced-panel__custom-css-input textarea {
|
|
1764
1767
|
font-family: Menlo, Consolas, monaco, monospace;
|
|
1765
1768
|
direction: ltr;
|
package/build-style/style.css
CHANGED
|
@@ -1760,6 +1760,9 @@ iframe[name=editor-canvas] {
|
|
|
1760
1760
|
background: linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
|
|
1761
1761
|
}
|
|
1762
1762
|
|
|
1763
|
+
.block-editor-global-styles-advanced-panel__custom-css-input {
|
|
1764
|
+
margin-bottom: 16px;
|
|
1765
|
+
}
|
|
1763
1766
|
.block-editor-global-styles-advanced-panel__custom-css-input textarea {
|
|
1764
1767
|
font-family: Menlo, Consolas, monaco, monospace;
|
|
1765
1768
|
/*rtl:ignore*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.11.1-next.v.0+b8934fcf9",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -61,43 +61,43 @@
|
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@react-spring/web": "^9.4.5",
|
|
64
|
-
"@wordpress/a11y": "^4.
|
|
65
|
-
"@wordpress/api-fetch": "^7.
|
|
66
|
-
"@wordpress/base-styles": "^6.
|
|
67
|
-
"@wordpress/blob": "^4.
|
|
68
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
69
|
-
"@wordpress/blocks": "^15.
|
|
70
|
-
"@wordpress/commands": "^1.
|
|
71
|
-
"@wordpress/components": "^32.0.
|
|
72
|
-
"@wordpress/compose": "^7.
|
|
73
|
-
"@wordpress/data": "^10.
|
|
74
|
-
"@wordpress/dataviews": "^11.
|
|
75
|
-
"@wordpress/date": "^5.
|
|
76
|
-
"@wordpress/deprecated": "^4.
|
|
77
|
-
"@wordpress/dom": "^4.
|
|
78
|
-
"@wordpress/element": "^6.
|
|
79
|
-
"@wordpress/escape-html": "^3.
|
|
80
|
-
"@wordpress/global-styles-engine": "^1.
|
|
81
|
-
"@wordpress/hooks": "^4.
|
|
82
|
-
"@wordpress/html-entities": "^4.
|
|
83
|
-
"@wordpress/i18n": "^6.
|
|
84
|
-
"@wordpress/icons": "^11.
|
|
85
|
-
"@wordpress/image-cropper": "^1.
|
|
86
|
-
"@wordpress/interactivity": "^6.
|
|
87
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
88
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
89
|
-
"@wordpress/keycodes": "^4.38.1-next.v.0+
|
|
90
|
-
"@wordpress/notices": "^5.38.1-next.v.0+
|
|
91
|
-
"@wordpress/preferences": "^4.
|
|
92
|
-
"@wordpress/priority-queue": "^3.
|
|
93
|
-
"@wordpress/private-apis": "^1.
|
|
94
|
-
"@wordpress/rich-text": "^7.
|
|
95
|
-
"@wordpress/style-engine": "^2.
|
|
96
|
-
"@wordpress/token-list": "^3.
|
|
97
|
-
"@wordpress/upload-media": "^0.
|
|
98
|
-
"@wordpress/url": "^4.
|
|
99
|
-
"@wordpress/warning": "^3.
|
|
100
|
-
"@wordpress/wordcount": "^4.
|
|
64
|
+
"@wordpress/a11y": "^4.38.1-next.v.0+b8934fcf9",
|
|
65
|
+
"@wordpress/api-fetch": "^7.38.1-next.v.0+b8934fcf9",
|
|
66
|
+
"@wordpress/base-styles": "^6.14.1-next.v.0+b8934fcf9",
|
|
67
|
+
"@wordpress/blob": "^4.38.1-next.v.0+b8934fcf9",
|
|
68
|
+
"@wordpress/block-serialization-default-parser": "^5.38.1-next.v.0+b8934fcf9",
|
|
69
|
+
"@wordpress/blocks": "^15.11.1-next.v.0+b8934fcf9",
|
|
70
|
+
"@wordpress/commands": "^1.38.1-next.v.0+b8934fcf9",
|
|
71
|
+
"@wordpress/components": "^32.0.2-next.v.0+b8934fcf9",
|
|
72
|
+
"@wordpress/compose": "^7.38.1-next.v.0+b8934fcf9",
|
|
73
|
+
"@wordpress/data": "^10.38.1-next.v.0+b8934fcf9",
|
|
74
|
+
"@wordpress/dataviews": "^11.3.1-next.v.0+b8934fcf9",
|
|
75
|
+
"@wordpress/date": "^5.38.1-next.v.0+b8934fcf9",
|
|
76
|
+
"@wordpress/deprecated": "^4.38.1-next.v.0+b8934fcf9",
|
|
77
|
+
"@wordpress/dom": "^4.38.1-next.v.0+b8934fcf9",
|
|
78
|
+
"@wordpress/element": "^6.38.1-next.v.0+b8934fcf9",
|
|
79
|
+
"@wordpress/escape-html": "^3.38.1-next.v.0+b8934fcf9",
|
|
80
|
+
"@wordpress/global-styles-engine": "^1.5.1-next.v.0+b8934fcf9",
|
|
81
|
+
"@wordpress/hooks": "^4.38.1-next.v.0+b8934fcf9",
|
|
82
|
+
"@wordpress/html-entities": "^4.38.1-next.v.0+b8934fcf9",
|
|
83
|
+
"@wordpress/i18n": "^6.11.1-next.v.0+b8934fcf9",
|
|
84
|
+
"@wordpress/icons": "^11.5.1-next.v.0+b8934fcf9",
|
|
85
|
+
"@wordpress/image-cropper": "^1.2.1-next.v.0+b8934fcf9",
|
|
86
|
+
"@wordpress/interactivity": "^6.38.1-next.v.0+b8934fcf9",
|
|
87
|
+
"@wordpress/is-shallow-equal": "^5.38.1-next.v.0+b8934fcf9",
|
|
88
|
+
"@wordpress/keyboard-shortcuts": "^5.38.1-next.v.0+b8934fcf9",
|
|
89
|
+
"@wordpress/keycodes": "^4.38.1-next.v.0+b8934fcf9",
|
|
90
|
+
"@wordpress/notices": "^5.38.1-next.v.0+b8934fcf9",
|
|
91
|
+
"@wordpress/preferences": "^4.38.1-next.v.0+b8934fcf9",
|
|
92
|
+
"@wordpress/priority-queue": "^3.38.1-next.v.0+b8934fcf9",
|
|
93
|
+
"@wordpress/private-apis": "^1.38.1-next.v.0+b8934fcf9",
|
|
94
|
+
"@wordpress/rich-text": "^7.38.1-next.v.0+b8934fcf9",
|
|
95
|
+
"@wordpress/style-engine": "^2.38.1-next.v.0+b8934fcf9",
|
|
96
|
+
"@wordpress/token-list": "^3.38.1-next.v.0+b8934fcf9",
|
|
97
|
+
"@wordpress/upload-media": "^0.23.1-next.v.0+b8934fcf9",
|
|
98
|
+
"@wordpress/url": "^4.38.1-next.v.0+b8934fcf9",
|
|
99
|
+
"@wordpress/warning": "^3.38.1-next.v.0+b8934fcf9",
|
|
100
|
+
"@wordpress/wordcount": "^4.38.1-next.v.0+b8934fcf9",
|
|
101
101
|
"change-case": "^4.1.2",
|
|
102
102
|
"clsx": "^2.1.1",
|
|
103
103
|
"colord": "^2.7.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"publishConfig": {
|
|
125
125
|
"access": "public"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "17529010285784fd2e735348a28391c79de87c88"
|
|
128
128
|
}
|
|
@@ -12,7 +12,7 @@ BlockControls.Slot = BlockControlsSlot;
|
|
|
12
12
|
export const BlockFormatControls = ( props ) => {
|
|
13
13
|
return <BlockControlsFill group="inline" { ...props } />;
|
|
14
14
|
};
|
|
15
|
-
BlockFormatControls.Slot = ( props )
|
|
15
|
+
BlockFormatControls.Slot = function Slot( props ) {
|
|
16
16
|
return <BlockControlsSlot group="inline" { ...props } />;
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -5,6 +5,9 @@ import { createContext, useContext } from '@wordpress/element';
|
|
|
5
5
|
|
|
6
6
|
export const mayDisplayControlsKey = Symbol( 'mayDisplayControls' );
|
|
7
7
|
export const mayDisplayParentControlsKey = Symbol( 'mayDisplayParentControls' );
|
|
8
|
+
export const mayDisplayPatternEditingControlsKey = Symbol(
|
|
9
|
+
'mayDisplayPatternEditingControls'
|
|
10
|
+
);
|
|
8
11
|
export const blockEditingModeKey = Symbol( 'blockEditingMode' );
|
|
9
12
|
export const blockBindingsKey = Symbol( 'blockBindings' );
|
|
10
13
|
export const isPreviewModeKey = Symbol( 'isPreviewMode' );
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useBlockEditContext,
|
|
14
14
|
mayDisplayControlsKey,
|
|
15
15
|
mayDisplayParentControlsKey,
|
|
16
|
+
mayDisplayPatternEditingControlsKey,
|
|
16
17
|
blockEditingModeKey,
|
|
17
18
|
blockBindingsKey,
|
|
18
19
|
isPreviewModeKey,
|
|
@@ -33,6 +34,7 @@ export { useBlockEditContext };
|
|
|
33
34
|
export default function BlockEdit( {
|
|
34
35
|
mayDisplayControls,
|
|
35
36
|
mayDisplayParentControls,
|
|
37
|
+
mayDisplayPatternEditingControls,
|
|
36
38
|
blockEditingMode,
|
|
37
39
|
isPreviewMode,
|
|
38
40
|
// The remaining props are passed through the BlockEdit filters and are thus
|
|
@@ -69,6 +71,9 @@ export default function BlockEdit( {
|
|
|
69
71
|
// usage outside of the package (this context is exposed).
|
|
70
72
|
[ mayDisplayControlsKey ]: mayDisplayControls,
|
|
71
73
|
[ mayDisplayParentControlsKey ]: mayDisplayParentControls,
|
|
74
|
+
[ mayDisplayPatternEditingControlsKey ]:
|
|
75
|
+
mayDisplayPatternEditingControls &&
|
|
76
|
+
blockEditingMode !== 'disabled',
|
|
72
77
|
[ blockEditingModeKey ]: blockEditingMode,
|
|
73
78
|
[ blockBindingsKey ]: bindings,
|
|
74
79
|
[ isPreviewModeKey ]: isPreviewMode,
|
|
@@ -82,6 +87,7 @@ export default function BlockEdit( {
|
|
|
82
87
|
__unstableLayoutClassNames,
|
|
83
88
|
mayDisplayControls,
|
|
84
89
|
mayDisplayParentControls,
|
|
90
|
+
mayDisplayPatternEditingControls,
|
|
85
91
|
blockEditingMode,
|
|
86
92
|
bindings,
|
|
87
93
|
isPreviewMode,
|
|
@@ -37,6 +37,7 @@ describe( 'Edit', () => {
|
|
|
37
37
|
const edit = () => <div data-testid="foo-bar" />;
|
|
38
38
|
|
|
39
39
|
registerBlockType( 'core/test-block', {
|
|
40
|
+
apiVersion: 3,
|
|
40
41
|
save: noop,
|
|
41
42
|
category: 'text',
|
|
42
43
|
title: 'block title',
|
|
@@ -52,6 +53,7 @@ describe( 'Edit', () => {
|
|
|
52
53
|
const save = () => <div data-testid="foo-bar" />;
|
|
53
54
|
|
|
54
55
|
registerBlockType( 'core/test-block', {
|
|
56
|
+
apiVersion: 3,
|
|
55
57
|
save,
|
|
56
58
|
category: 'text',
|
|
57
59
|
title: 'block title',
|
|
@@ -79,6 +81,13 @@ describe( 'Edit', () => {
|
|
|
79
81
|
|
|
80
82
|
render( <Edit name="core/test-block" attributes={ attributes } /> );
|
|
81
83
|
|
|
84
|
+
// This test is for API version 1 blocks, so the console warning is intentional.
|
|
85
|
+
// API version 1 blocks automatically receive the default block class name,
|
|
86
|
+
// while API version 2+ blocks require useBlockProps() to be used explicitly.
|
|
87
|
+
expect( console ).toHaveWarnedWith(
|
|
88
|
+
'Block with API version 2 or lower is deprecated since version 6.9. See: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/ Note: The block "core/test-block" is registered with API version 1. This means that the post editor may work as a non-iframe editor. Since all editors are planned to work as iframes in the future, set the `apiVersion` field to 3 and test the block inside the iframe editor.'
|
|
89
|
+
);
|
|
90
|
+
|
|
82
91
|
const editElement = screen.getByTestId( 'foo-bar' );
|
|
83
92
|
expect( editElement ).toHaveClass( 'wp-block-test-block' );
|
|
84
93
|
expect( editElement ).toHaveClass( 'my-class' );
|
|
@@ -87,6 +96,7 @@ describe( 'Edit', () => {
|
|
|
87
96
|
it( 'should assign context', () => {
|
|
88
97
|
const edit = ( { context } ) => context.value;
|
|
89
98
|
registerBlockType( 'core/test-block', {
|
|
99
|
+
apiVersion: 3,
|
|
90
100
|
category: 'text',
|
|
91
101
|
title: 'block title',
|
|
92
102
|
usesContext: [ 'value' ],
|
|
@@ -29,21 +29,19 @@ import PositionControls from '../inspector-controls-tabs/position-controls-panel
|
|
|
29
29
|
import useBlockInspectorAnimationSettings from './useBlockInspectorAnimationSettings';
|
|
30
30
|
import { useBorderPanelLabel } from '../../hooks/border';
|
|
31
31
|
import ContentTab from '../inspector-controls-tabs/content-tab';
|
|
32
|
-
import
|
|
32
|
+
import ViewportVisibilityInfo from '../block-visibility/viewport-visibility-info';
|
|
33
33
|
import { unlock } from '../../lock-unlock';
|
|
34
34
|
|
|
35
35
|
function StyleInspectorSlots( {
|
|
36
36
|
blockName,
|
|
37
37
|
showAdvancedControls = true,
|
|
38
38
|
showPositionControls = true,
|
|
39
|
-
showListControls = false,
|
|
40
39
|
showBindingsControls = true,
|
|
41
40
|
} ) {
|
|
42
41
|
const borderPanelLabel = useBorderPanelLabel( { blockName } );
|
|
43
42
|
return (
|
|
44
43
|
<>
|
|
45
44
|
<InspectorControls.Slot />
|
|
46
|
-
{ showListControls && <InspectorControls.Slot group="list" /> }
|
|
47
45
|
<InspectorControls.Slot
|
|
48
46
|
group="color"
|
|
49
47
|
label={ __( 'Color' ) }
|
|
@@ -79,7 +77,6 @@ function StyleInspectorSlots( {
|
|
|
79
77
|
function BlockInspector() {
|
|
80
78
|
const {
|
|
81
79
|
selectedBlockCount,
|
|
82
|
-
selectedBlockClientId,
|
|
83
80
|
renderedBlockName,
|
|
84
81
|
renderedBlockClientId,
|
|
85
82
|
blockType,
|
|
@@ -121,7 +118,6 @@ function BlockInspector() {
|
|
|
121
118
|
|
|
122
119
|
return {
|
|
123
120
|
selectedBlockCount: getSelectedBlockCount(),
|
|
124
|
-
selectedBlockClientId: _selectedBlockClientId,
|
|
125
121
|
renderedBlockClientId: _renderedBlockClientId,
|
|
126
122
|
renderedBlockName: _renderedBlockName,
|
|
127
123
|
blockType: _blockType,
|
|
@@ -259,7 +255,6 @@ function BlockInspector() {
|
|
|
259
255
|
>
|
|
260
256
|
<BlockInspectorSingleBlock
|
|
261
257
|
renderedBlockClientId={ renderedBlockClientId }
|
|
262
|
-
selectedBlockClientId={ selectedBlockClientId }
|
|
263
258
|
blockName={ blockType.name }
|
|
264
259
|
isSectionBlock={ isSectionBlock }
|
|
265
260
|
availableTabs={ availableTabs }
|
|
@@ -311,10 +306,6 @@ const BlockInspectorSingleBlock = ( {
|
|
|
311
306
|
// The block that is displayed in the inspector. This is the block whose
|
|
312
307
|
// controls and information are shown to the user.
|
|
313
308
|
renderedBlockClientId,
|
|
314
|
-
// The actual block that is selected in the editor. This may or may not
|
|
315
|
-
// be the same as the rendered block (e.g., when a child block is selected
|
|
316
|
-
// but its parent section block is the main one rendered in the inspector).
|
|
317
|
-
selectedBlockClientId,
|
|
318
309
|
blockName,
|
|
319
310
|
isSectionBlock,
|
|
320
311
|
availableTabs,
|
|
@@ -334,10 +325,6 @@ const BlockInspectorSingleBlock = ( {
|
|
|
334
325
|
renderedBlockClientId
|
|
335
326
|
);
|
|
336
327
|
const isBlockSynced = blockInformation.isSynced;
|
|
337
|
-
const shouldShowTabs = ! isBlockSynced && hasMultipleTabs;
|
|
338
|
-
const isSectionBlockSelected =
|
|
339
|
-
window?.__experimentalContentOnlyPatternInsertion &&
|
|
340
|
-
selectedBlockClientId === renderedBlockClientId;
|
|
341
328
|
|
|
342
329
|
return (
|
|
343
330
|
<div className="block-editor-block-inspector">
|
|
@@ -355,43 +342,34 @@ const BlockInspectorSingleBlock = ( {
|
|
|
355
342
|
isChild={ hasParentChildBlockCards }
|
|
356
343
|
clientId={ renderedBlockClientId }
|
|
357
344
|
/>
|
|
358
|
-
<
|
|
345
|
+
<ViewportVisibilityInfo clientId={ renderedBlockClientId } />
|
|
359
346
|
{ window?.__experimentalContentOnlyPatternInsertion && (
|
|
360
347
|
<EditContents clientId={ renderedBlockClientId } />
|
|
361
348
|
) }
|
|
362
349
|
<BlockVariationTransforms blockClientId={ renderedBlockClientId } />
|
|
363
|
-
{
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
350
|
+
{ hasMultipleTabs && (
|
|
351
|
+
<>
|
|
352
|
+
<InspectorControlsTabs
|
|
353
|
+
hasBlockStyles={ hasBlockStyles }
|
|
354
|
+
clientId={ renderedBlockClientId }
|
|
355
|
+
blockName={ blockName }
|
|
356
|
+
tabs={ availableTabs }
|
|
357
|
+
isSectionBlock={ isSectionBlock }
|
|
358
|
+
contentClientIds={ contentClientIds }
|
|
359
|
+
/>
|
|
360
|
+
</>
|
|
372
361
|
) }
|
|
373
|
-
{ !
|
|
362
|
+
{ ! hasMultipleTabs && (
|
|
374
363
|
<>
|
|
375
364
|
{ hasBlockStyles && (
|
|
376
365
|
<BlockStyles clientId={ renderedBlockClientId } />
|
|
377
366
|
) }
|
|
378
367
|
<ContentTab contentClientIds={ contentClientIds } />
|
|
379
368
|
<InspectorControls.Slot group="content" />
|
|
369
|
+
<InspectorControls.Slot group="list" />
|
|
380
370
|
{ ! isSectionBlock && (
|
|
381
|
-
<StyleInspectorSlots
|
|
382
|
-
blockName={ blockName }
|
|
383
|
-
showListControls
|
|
384
|
-
/>
|
|
371
|
+
<StyleInspectorSlots blockName={ blockName } />
|
|
385
372
|
) }
|
|
386
|
-
{ isSectionBlock &&
|
|
387
|
-
isBlockSynced &&
|
|
388
|
-
isSectionBlockSelected && (
|
|
389
|
-
<>
|
|
390
|
-
<InspectorControls.Slot />
|
|
391
|
-
{ /* Allow AdvancedControls so users can adjust local attributes (e.g. additional CSS classes, HTML element). */ }
|
|
392
|
-
<AdvancedControls />
|
|
393
|
-
</>
|
|
394
|
-
) }
|
|
395
373
|
</>
|
|
396
374
|
) }
|
|
397
375
|
<SkipToSelectedBlock key="back" />
|
|
@@ -106,6 +106,7 @@ function BlockListBlock( {
|
|
|
106
106
|
const {
|
|
107
107
|
mayDisplayControls,
|
|
108
108
|
mayDisplayParentControls,
|
|
109
|
+
isSelectionWithinCurrentSection,
|
|
109
110
|
themeSupportsLayout,
|
|
110
111
|
...context
|
|
111
112
|
} = useContext( PrivateBlockContext );
|
|
@@ -135,6 +136,7 @@ function BlockListBlock( {
|
|
|
135
136
|
}
|
|
136
137
|
mayDisplayControls={ mayDisplayControls }
|
|
137
138
|
mayDisplayParentControls={ mayDisplayParentControls }
|
|
139
|
+
mayDisplayPatternEditingControls={ isSelectionWithinCurrentSection }
|
|
138
140
|
blockEditingMode={ context.blockEditingMode }
|
|
139
141
|
isPreviewMode={ context.isPreviewMode }
|
|
140
142
|
/>
|
|
@@ -231,6 +233,7 @@ function BlockListBlock( {
|
|
|
231
233
|
value={ {
|
|
232
234
|
wrapperProps: updatedWrapperProps,
|
|
233
235
|
isAligned,
|
|
236
|
+
isSelectionWithinCurrentSection,
|
|
234
237
|
...context,
|
|
235
238
|
} }
|
|
236
239
|
>
|
|
@@ -195,6 +195,7 @@ function BlockListBlock( {
|
|
|
195
195
|
isParentSelected,
|
|
196
196
|
order,
|
|
197
197
|
mayDisplayControls,
|
|
198
|
+
mayDisplayPatternEditingControls,
|
|
198
199
|
blockEditingMode,
|
|
199
200
|
} = useSelect(
|
|
200
201
|
( select ) => {
|
|
@@ -263,6 +264,7 @@ function BlockListBlock( {
|
|
|
263
264
|
getMultiSelectedBlockClientIds().every(
|
|
264
265
|
( id ) => getBlockName( id ) === name
|
|
265
266
|
) ),
|
|
267
|
+
mayDisplayPatternEditingControls: false, // Section/pattern editing not yet supported on native
|
|
266
268
|
blockEditingMode: getBlockEditingMode( clientId ),
|
|
267
269
|
};
|
|
268
270
|
},
|
|
@@ -403,6 +405,9 @@ function BlockListBlock( {
|
|
|
403
405
|
}
|
|
404
406
|
wrapperProps={ wrapperProps }
|
|
405
407
|
mayDisplayControls={ mayDisplayControls }
|
|
408
|
+
mayDisplayPatternEditingControls={
|
|
409
|
+
mayDisplayPatternEditingControls
|
|
410
|
+
}
|
|
406
411
|
blockEditingMode={ blockEditingMode }
|
|
407
412
|
/>
|
|
408
413
|
<View onLayout={ onLayout } />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { isReusableBlock, isTemplatePart } from '@wordpress/blocks';
|
|
4
5
|
import { isTextField } from '@wordpress/dom';
|
|
5
6
|
import { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
|
|
6
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -31,6 +32,7 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
31
32
|
hasMultiSelection,
|
|
32
33
|
isSectionBlock,
|
|
33
34
|
editedContentOnlySection,
|
|
35
|
+
getBlock,
|
|
34
36
|
} = unlock( useSelect( blockEditorStore ) );
|
|
35
37
|
const {
|
|
36
38
|
insertAfterBlock,
|
|
@@ -128,15 +130,13 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
128
130
|
|
|
129
131
|
const rect = node.getBoundingClientRect();
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// Maybe remove the clone now that it's relative?
|
|
134
|
-
clone.style.display = 'none';
|
|
135
|
-
|
|
136
|
-
// Remove the id and leave it on the clone so that drop target
|
|
137
|
-
// calculations are correct.
|
|
133
|
+
// Remove the id and leave it on a shallow clone so that drop
|
|
134
|
+
// target calculations are correct.
|
|
138
135
|
const id = node.id;
|
|
136
|
+
const clone = node.cloneNode();
|
|
137
|
+
clone.style.display = 'none';
|
|
139
138
|
node.id = null;
|
|
139
|
+
node.after( clone );
|
|
140
140
|
|
|
141
141
|
let _scale = 1;
|
|
142
142
|
|
|
@@ -154,8 +154,6 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
154
154
|
|
|
155
155
|
const inverted = 1 / _scale;
|
|
156
156
|
|
|
157
|
-
node.after( clone );
|
|
158
|
-
|
|
159
157
|
const originalNodeProperties = {};
|
|
160
158
|
for ( const property of [
|
|
161
159
|
'transform',
|
|
@@ -225,32 +223,41 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
225
223
|
}
|
|
226
224
|
|
|
227
225
|
let hasStarted = false;
|
|
226
|
+
let lastClientX = originClientX;
|
|
227
|
+
let lastClientY = originClientY;
|
|
228
|
+
|
|
229
|
+
function dragOver( e ) {
|
|
230
|
+
// Only trigger `over` if the mouse has moved.
|
|
231
|
+
if (
|
|
232
|
+
e.clientX === lastClientX &&
|
|
233
|
+
e.clientY === lastClientY
|
|
234
|
+
) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
lastClientX = e.clientX;
|
|
238
|
+
lastClientY = e.clientY;
|
|
239
|
+
over();
|
|
240
|
+
}
|
|
228
241
|
|
|
229
|
-
function over(
|
|
242
|
+
function over() {
|
|
230
243
|
if ( ! hasStarted ) {
|
|
231
244
|
hasStarted = true;
|
|
232
245
|
node.style.pointerEvents = 'none';
|
|
233
246
|
}
|
|
247
|
+
const pointerYDelta = lastClientY - originClientY;
|
|
248
|
+
const pointerXDelta = lastClientX - originClientX;
|
|
234
249
|
const scrollTop = defaultView.scrollY;
|
|
235
250
|
const scrollLeft = defaultView.scrollX;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}px`;
|
|
243
|
-
node.style.left = `${
|
|
244
|
-
( e.clientX -
|
|
245
|
-
originClientX +
|
|
246
|
-
scrollLeft -
|
|
247
|
-
originScrollLeft ) *
|
|
248
|
-
inverted
|
|
249
|
-
}px`;
|
|
251
|
+
const scrollTopDelta = scrollTop - originScrollTop;
|
|
252
|
+
const scrollLeftDelta = scrollLeft - originScrollLeft;
|
|
253
|
+
const topDelta = pointerYDelta + scrollTopDelta;
|
|
254
|
+
const leftDelta = pointerXDelta + scrollLeftDelta;
|
|
255
|
+
node.style.top = `${ topDelta * inverted }px`;
|
|
256
|
+
node.style.left = `${ leftDelta * inverted }px`;
|
|
250
257
|
}
|
|
251
258
|
|
|
252
259
|
function end() {
|
|
253
|
-
ownerDocument.removeEventListener( 'dragover',
|
|
260
|
+
ownerDocument.removeEventListener( 'dragover', dragOver );
|
|
254
261
|
ownerDocument.removeEventListener( 'dragend', end );
|
|
255
262
|
ownerDocument.removeEventListener( 'drop', end );
|
|
256
263
|
ownerDocument.removeEventListener( 'scroll', over );
|
|
@@ -271,7 +278,7 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
271
278
|
);
|
|
272
279
|
}
|
|
273
280
|
|
|
274
|
-
ownerDocument.addEventListener( 'dragover',
|
|
281
|
+
ownerDocument.addEventListener( 'dragover', dragOver );
|
|
275
282
|
ownerDocument.addEventListener( 'dragend', end );
|
|
276
283
|
ownerDocument.addEventListener( 'drop', end );
|
|
277
284
|
ownerDocument.addEventListener( 'scroll', over );
|
|
@@ -294,12 +301,22 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
294
301
|
*/
|
|
295
302
|
function onDoubleClick( event ) {
|
|
296
303
|
const isSection = isSectionBlock( clientId );
|
|
304
|
+
const block = getBlock( clientId );
|
|
305
|
+
const isSyncedPattern = isReusableBlock( block );
|
|
306
|
+
const isTemplatePartBlock = isTemplatePart( block );
|
|
297
307
|
const isAlreadyEditing = editedContentOnlySection === clientId;
|
|
298
308
|
|
|
299
|
-
if (
|
|
300
|
-
|
|
301
|
-
|
|
309
|
+
if (
|
|
310
|
+
! isSection ||
|
|
311
|
+
isAlreadyEditing ||
|
|
312
|
+
isSyncedPattern ||
|
|
313
|
+
isTemplatePartBlock
|
|
314
|
+
) {
|
|
315
|
+
return;
|
|
302
316
|
}
|
|
317
|
+
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
editContentOnlySection( clientId );
|
|
303
320
|
}
|
|
304
321
|
|
|
305
322
|
// Only add double-click listener if experimental flag is enabled
|
|
@@ -319,6 +336,9 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
319
336
|
clientId,
|
|
320
337
|
isSelected,
|
|
321
338
|
getBlockRootClientId,
|
|
339
|
+
getBlock,
|
|
340
|
+
isReusableBlock,
|
|
341
|
+
isTemplatePart,
|
|
322
342
|
insertAfterBlock,
|
|
323
343
|
removeBlock,
|
|
324
344
|
isZoomOut,
|
|
@@ -9,7 +9,7 @@ import { fn } from 'storybook/test';
|
|
|
9
9
|
import BlockPatternsList from '../';
|
|
10
10
|
import { ExperimentalBlockEditorProvider } from '../../provider';
|
|
11
11
|
import patterns from './fixtures';
|
|
12
|
-
import blockLibraryStyles from '
|
|
12
|
+
import blockLibraryStyles from '../../../../../block-library/build-style/style.css?raw';
|
|
13
13
|
|
|
14
14
|
const blockEditorSettings = {
|
|
15
15
|
styles: [ { css: blockLibraryStyles } ],
|
|
@@ -16,22 +16,26 @@ import {
|
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
import { useBlockPreview } from '../';
|
|
19
|
+
import { useBlockProps } from '../../block-list/use-block-props';
|
|
19
20
|
|
|
20
21
|
describe( 'useBlockPreview', () => {
|
|
21
22
|
beforeAll( () => {
|
|
22
23
|
registerBlockType( 'core/test-block', {
|
|
24
|
+
apiVersion: 3,
|
|
23
25
|
save: () => (
|
|
24
|
-
<div>
|
|
26
|
+
<div { ...useBlockProps.save() }>
|
|
25
27
|
Test block save view
|
|
26
28
|
<button>Button</button>
|
|
27
29
|
</div>
|
|
28
30
|
),
|
|
29
|
-
edit: ()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
edit: function Edit() {
|
|
32
|
+
return (
|
|
33
|
+
<div { ...useBlockProps() }>
|
|
34
|
+
Test block edit view
|
|
35
|
+
<button>Button</button>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
35
39
|
category: 'text',
|
|
36
40
|
title: 'test block',
|
|
37
41
|
} );
|
|
@@ -21,7 +21,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
21
21
|
import BlockModeToggle from '../block-settings-menu/block-mode-toggle';
|
|
22
22
|
import { ModifyContentOnlySectionMenuItem } from '../content-lock';
|
|
23
23
|
import { BlockRenameControl, useBlockRename } from '../block-rename';
|
|
24
|
-
import {
|
|
24
|
+
import { BlockVisibilityViewportMenuItem } from '../block-visibility';
|
|
25
25
|
import { EditSectionMenuItem } from './edit-section-menu-item';
|
|
26
26
|
|
|
27
27
|
const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );
|
|
@@ -116,7 +116,7 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
|
|
|
116
116
|
/>
|
|
117
117
|
) }
|
|
118
118
|
{ showVisibilityButton && (
|
|
119
|
-
<
|
|
119
|
+
<BlockVisibilityViewportMenuItem
|
|
120
120
|
clientIds={ selectedClientIds }
|
|
121
121
|
/>
|
|
122
122
|
) }
|