@wordpress/block-editor 16.2.0 → 17.0.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 +39 -0
- package/build/components/block-inspector/index.cjs +9 -6
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
- package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
- package/build/components/block-list/block.cjs +10 -3
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/index.cjs +6 -1
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-parent-selector/index.cjs +98 -29
- package/build/components/block-parent-selector/index.cjs.map +3 -3
- package/build/components/block-popover/inbetween.cjs +2 -2
- package/build/components/block-popover/inbetween.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +0 -4
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-styles/index.cjs +77 -33
- package/build/components/block-styles/index.cjs.map +3 -3
- package/build/components/block-visibility/constants.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +55 -71
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +18 -16
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/utils.cjs +61 -0
- package/build/components/dimensions-tool/utils.cjs.map +7 -0
- package/build/components/duotone-control/index.cjs +2 -0
- package/build/components/duotone-control/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +2 -5
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +14 -2
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +9 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +12 -8
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +16 -11
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/utils.cjs +9 -0
- package/build/components/global-styles/utils.cjs.map +2 -2
- package/build/components/inner-blocks/index.cjs +5 -3
- package/build/components/inner-blocks/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
- package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
- package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
- package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +18 -7
- package/build/components/inserter/menu.cjs.map +2 -2
- package/build/components/inserter/quick-inserter.cjs +30 -27
- package/build/components/inserter/quick-inserter.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/list-view/index.cjs +31 -5
- package/build/components/list-view/index.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +13 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +1 -1
- package/build/components/media-placeholder/index.cjs.map +3 -3
- package/build/components/provider/index.cjs +5 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/publish-date-time-picker/index.cjs +3 -2
- package/build/components/publish-date-time-picker/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +46 -39
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +7 -5
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/multiline.cjs +105 -70
- package/build/components/rich-text/multiline.cjs.map +3 -3
- package/build/components/url-input/index.cjs.map +2 -2
- package/build/components/writing-flow/use-input.cjs +65 -13
- package/build/components/writing-flow/use-input.cjs.map +3 -3
- package/build/hooks/border.cjs +25 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +9 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +4 -3
- package/build/hooks/duotone.cjs.map +2 -2
- package/build/hooks/gap.cjs +8 -2
- package/build/hooks/gap.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +35 -13
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +23 -1
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +7 -4
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +8 -1
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +9 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/flow.cjs +4 -1
- package/build/layouts/flow.cjs.map +2 -2
- package/build/layouts/grid.cjs +5 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +3 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +1 -1
- package/build/store/actions.cjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +9 -6
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
- package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
- package/build-module/components/block-list/block.mjs +10 -3
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/index.mjs +6 -1
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-parent-selector/index.mjs +101 -32
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-popover/inbetween.mjs +2 -2
- package/build-module/components/block-popover/inbetween.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +0 -4
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-styles/index.mjs +79 -35
- package/build-module/components/block-styles/index.mjs.map +2 -2
- package/build-module/components/block-visibility/constants.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +5 -5
- package/build-module/components/child-layout-control/index.mjs.map +1 -1
- package/build-module/components/colors/with-colors.mjs +56 -72
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +19 -17
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/utils.mjs +35 -0
- package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
- package/build-module/components/duotone-control/index.mjs +2 -0
- package/build-module/components/duotone-control/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +5 -2
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -5
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +14 -2
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +16 -9
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/utils.mjs +8 -0
- package/build-module/components/global-styles/utils.mjs.map +2 -2
- package/build-module/components/inner-blocks/index.mjs +5 -3
- package/build-module/components/inner-blocks/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
- package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
- package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +19 -8
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/quick-inserter.mjs +30 -27
- package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs +32 -5
- package/build-module/components/list-view/index.mjs.map +3 -3
- package/build-module/components/list-view/utils.mjs +13 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +3 -3
- package/build-module/components/media-placeholder/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +6 -2
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/publish-date-time-picker/index.mjs +3 -2
- package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +7 -5
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/multiline.mjs +112 -72
- package/build-module/components/rich-text/multiline.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +2 -2
- package/build-module/components/url-input/index.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +66 -14
- package/build-module/components/writing-flow/use-input.mjs.map +3 -3
- package/build-module/hooks/border.mjs +26 -8
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +9 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +8 -4
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/gap.mjs +6 -1
- package/build-module/hooks/gap.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +36 -13
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +22 -1
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +8 -5
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +8 -1
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +9 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/flow.mjs +4 -1
- package/build-module/layouts/flow.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +5 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +3 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -1
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/style-rtl.css +108 -71
- package/build-style/style.css +108 -71
- package/build-types/components/block-visibility/constants.d.ts +4 -3
- package/build-types/components/block-visibility/constants.d.ts.map +1 -1
- package/package.json +43 -43
- package/src/components/background-image-control/README.md +122 -0
- package/src/components/block-edit-visually-button/README.md +39 -0
- package/src/components/block-editing-mode/README.md +72 -0
- package/src/components/block-inspector/index.js +6 -6
- package/src/components/block-keyboard-shortcuts/index.js +256 -0
- package/src/components/block-list/block.js +7 -0
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
- package/src/components/block-parent-selector/index.js +111 -30
- package/src/components/block-popover/README.md +10 -3
- package/src/components/block-popover/inbetween.js +8 -2
- package/src/components/block-popover/stories/index.story.jsx +143 -0
- package/src/components/block-preview/index.js +0 -2
- package/src/components/block-styles/index.js +95 -43
- package/src/components/block-styles/style.scss +5 -34
- package/src/components/block-tools/style.scss +94 -0
- package/src/components/block-visibility/constants.ts +4 -3
- package/src/components/child-layout-control/index.js +5 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
- package/src/components/colors/test/with-colors.js +6 -7
- package/src/components/colors/with-colors.js +79 -105
- package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
- package/src/components/dimensions-tool/index.js +34 -22
- package/src/components/dimensions-tool/test/index.js +166 -2
- package/src/components/dimensions-tool/test/utils.js +51 -0
- package/src/components/dimensions-tool/utils.js +67 -0
- package/src/components/duotone-control/index.js +2 -0
- package/src/components/duotone-control/test/index.js +100 -0
- package/src/components/global-styles/advanced-panel.js +5 -2
- package/src/components/global-styles/border-panel.js +11 -9
- package/src/components/global-styles/color-panel.js +13 -1
- package/src/components/global-styles/dimensions-panel.js +17 -5
- package/src/components/global-styles/filters-panel.js +24 -10
- package/src/components/global-styles/shadow-panel-components.js +38 -11
- package/src/components/global-styles/test/border-panel.js +230 -0
- package/src/components/global-styles/test/color-panel.js +24 -0
- package/src/components/global-styles/test/dimensions-panel.js +98 -7
- package/src/components/global-styles/test/filters-panel.js +84 -0
- package/src/components/global-styles/test/utils.js +30 -0
- package/src/components/global-styles/utils.js +23 -0
- package/src/components/inner-blocks/index.js +11 -2
- package/src/components/inner-blocks/stories/index.story.jsx +246 -0
- package/src/components/inserter/block-patterns-explorer/index.js +24 -11
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
- package/src/components/inserter/hooks/use-insertion-point.js +9 -4
- package/src/components/inserter/menu.js +23 -10
- package/src/components/inserter/quick-inserter.js +15 -13
- package/src/components/inserter/style.scss +44 -62
- package/src/components/inspector-controls-tabs/README.md +92 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/src/components/link-control/test/index.js +5 -0
- package/src/components/list-view/index.js +50 -7
- package/src/components/list-view/utils.js +16 -1
- package/src/components/media-placeholder/index.js +9 -4
- package/src/components/plain-text/stories/index.story.jsx +3 -0
- package/src/components/provider/index.js +7 -1
- package/src/components/publish-date-time-picker/README.md +10 -0
- package/src/components/publish-date-time-picker/index.js +17 -14
- package/src/components/rich-text/event-listeners/enter.js +58 -45
- package/src/components/rich-text/index.js +9 -4
- package/src/components/rich-text/multiline.js +126 -86
- package/src/components/url-input/index.js +2 -2
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
- package/src/components/url-input/test/index.js +5 -0
- package/src/components/url-popover/README.md +7 -0
- package/src/components/url-popover/stories/index.story.jsx +133 -47
- package/src/components/writing-flow/use-input.js +105 -15
- package/src/hooks/border.js +27 -8
- package/src/hooks/dimensions.js +8 -1
- package/src/hooks/duotone.js +23 -7
- package/src/hooks/gap.js +16 -0
- package/src/hooks/layout-child.js +41 -9
- package/src/hooks/layout.js +117 -71
- package/src/hooks/states.js +8 -5
- package/src/hooks/test/gap.js +31 -1
- package/src/hooks/test/layout-child.js +60 -1
- package/src/hooks/test/layout.js +27 -0
- package/src/layouts/constrained.js +9 -1
- package/src/layouts/flex.js +15 -0
- package/src/layouts/flow.js +4 -1
- package/src/layouts/grid.js +9 -1
- package/src/layouts/test/constrained.js +26 -0
- package/src/layouts/test/flow.js +26 -0
- package/src/layouts/test/grid.js +46 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +14 -1
- package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
- package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
- package/build/components/gradients/with-gradient.cjs +0 -36
- package/build/components/gradients/with-gradient.cjs.map +0 -7
- package/build/components/inserter-button/sparkles.cjs +0 -36
- package/build/components/inserter-button/sparkles.cjs.map +0 -7
- package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
- package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
- package/build-module/components/gradients/with-gradient.mjs +0 -11
- package/build-module/components/gradients/with-gradient.mjs.map +0 -7
- package/build-module/components/inserter-button/sparkles.mjs +0 -15
- package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
- package/build-style/default-editor-styles-rtl.css +0 -68
- package/build-style/default-editor-styles.css +0 -68
- package/src/components/floating-toolbar/nav-up-icon.js +0 -22
- package/src/components/gradients/with-gradient.js +0 -9
- package/src/components/inserter-button/README.md +0 -62
- package/src/components/inserter-button/sparkles.js +0 -12
- package/src/default-editor-styles.scss +0 -25
|
@@ -369,89 +369,71 @@ $block-inserter-tabs-height: 44px;
|
|
|
369
369
|
padding: 0;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
.block-editor-inserter__quick-inserter-expand
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
color: $white;
|
|
376
|
-
width: 100%;
|
|
377
|
-
border-radius: 0;
|
|
378
|
-
|
|
379
|
-
&:hover {
|
|
380
|
-
color: $white;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
&:active {
|
|
384
|
-
color: $gray-400;
|
|
385
|
-
}
|
|
372
|
+
.block-editor-inserter__quick-inserter-expand {
|
|
373
|
+
padding: 0 $grid-unit-20 $grid-unit-20;
|
|
374
|
+
}
|
|
386
375
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
background: var(--wp-admin-theme-color);
|
|
391
|
-
border-color: var(--wp-admin-theme-color);
|
|
392
|
-
}
|
|
376
|
+
.block-editor-inserter__quick-inserter-expand-toggle {
|
|
377
|
+
width: 100%;
|
|
378
|
+
justify-content: center;
|
|
393
379
|
}
|
|
394
380
|
|
|
395
|
-
.block-editor-block-patterns-
|
|
396
|
-
|
|
381
|
+
.block-editor-block-patterns-explorer__sidebar {
|
|
382
|
+
padding-bottom: $grid-unit-30;
|
|
383
|
+
|
|
384
|
+
@include break-medium() {
|
|
397
385
|
position: absolute;
|
|
398
386
|
top: $header-height + $grid-unit-10;
|
|
399
387
|
left: 0;
|
|
400
388
|
bottom: 0;
|
|
401
389
|
width: $sidebar-width;
|
|
402
|
-
padding: $grid-unit-30
|
|
390
|
+
padding: $grid-unit-30;
|
|
403
391
|
overflow-x: visible;
|
|
404
392
|
overflow-y: auto;
|
|
405
|
-
|
|
406
|
-
&__categories-list__item {
|
|
407
|
-
display: block;
|
|
408
|
-
width: 100%;
|
|
409
|
-
height: 48px;
|
|
410
|
-
text-align: left;
|
|
411
|
-
}
|
|
412
393
|
}
|
|
394
|
+
}
|
|
413
395
|
|
|
414
|
-
|
|
415
|
-
|
|
396
|
+
.block-editor-block-patterns-explorer__panel {
|
|
397
|
+
@include break-medium() {
|
|
398
|
+
margin-inline-start: $sidebar-width;
|
|
416
399
|
}
|
|
400
|
+
}
|
|
417
401
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
402
|
+
.block-editor-block-patterns-explorer__no-results {
|
|
403
|
+
padding: $grid-unit-40;
|
|
404
|
+
text-align: center;
|
|
405
|
+
}
|
|
421
406
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
width: 380px;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
407
|
+
.block-editor-block-patterns-explorer__list {
|
|
408
|
+
padding: $grid-unit-30 0 $grid-unit-40;
|
|
409
|
+
|
|
410
|
+
.block-editor-patterns__sync-status-filter .components-input-control__container {
|
|
411
|
+
width: 380px;
|
|
430
412
|
}
|
|
413
|
+
}
|
|
431
414
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
415
|
+
.block-editor-block-patterns-explorer .block-editor-block-patterns-list {
|
|
416
|
+
display: grid;
|
|
417
|
+
grid-gap: $grid-unit-40;
|
|
418
|
+
grid-template-columns: repeat(1, 1fr);
|
|
419
|
+
margin-bottom: $grid-unit-20;
|
|
437
420
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
421
|
+
@include break-xlarge() {
|
|
422
|
+
grid-template-columns: repeat(2, 1fr);
|
|
423
|
+
}
|
|
441
424
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
425
|
+
@include break-huge() {
|
|
426
|
+
grid-template-columns: repeat(3, 1fr);
|
|
427
|
+
}
|
|
445
428
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
429
|
+
.block-editor-block-patterns-list__list-item {
|
|
430
|
+
min-height: 240px;
|
|
431
|
+
}
|
|
449
432
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
433
|
+
.block-editor-inserter__media-list__list-item {
|
|
434
|
+
height: inherit;
|
|
435
|
+
min-height: 100px;
|
|
436
|
+
max-height: 800px;
|
|
455
437
|
}
|
|
456
438
|
}
|
|
457
439
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Inspector Controls Tabs
|
|
2
|
+
|
|
3
|
+
The `InspectorControlsTabs` component splits the block inspector sidebar into tabs, so a block's content, list view, settings and styles are grouped instead of being stacked in a single scrolling column.
|
|
4
|
+
|
|
5
|
+
_Note:_ This component is internal to the `@wordpress/block-editor` package. It is not exported from the package and is not part of the public API. It is rendered by [`BlockInspector`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md), which decides whether tabs are shown at all.
|
|
6
|
+
|
|
7
|
+
## Development guidelines
|
|
8
|
+
|
|
9
|
+
The tabs are not authored by the block. Each tab renders [`InspectorControls`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md) slots, so a block populates a tab simply by rendering `InspectorControls` with the matching `group`. There are four tabs, rendered in this order when available: Content (the `content` group), List View (the `list` group), Settings (the default and `bindings` groups, plus the Advanced panel) and Styles (the `typography`, `color`, `background`, `filter`, `layout`, `dimensions`, `border`, `elements`, `position` and `styles` groups).
|
|
10
|
+
|
|
11
|
+
Which tabs exist is determined by the `useInspectorControlsTabs` hook, which returns a tab when fills have been rendered into its groups. `BlockInspector` renders this component only when the hook returns more than one tab; with a single tab the sections are rendered flat instead. The hook also honors the `blockInspectorTabs` block editor setting, which can disable tabs globally or per block name.
|
|
12
|
+
|
|
13
|
+
Tab labels are rendered as icons with a tooltip. When the `showIconLabels` preference from `@wordpress/preferences` is enabled, the tab title is rendered as text instead.
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import InspectorControlsTabs from '../inspector-controls-tabs';
|
|
19
|
+
import useInspectorControlsTabs from '../inspector-controls-tabs/use-inspector-controls-tabs';
|
|
20
|
+
|
|
21
|
+
function MyBlockInspector( {
|
|
22
|
+
blockName,
|
|
23
|
+
clientId,
|
|
24
|
+
hasBlockStyles,
|
|
25
|
+
isSectionBlock,
|
|
26
|
+
contentClientIds,
|
|
27
|
+
} ) {
|
|
28
|
+
const availableTabs = useInspectorControlsTabs(
|
|
29
|
+
blockName,
|
|
30
|
+
contentClientIds,
|
|
31
|
+
isSectionBlock,
|
|
32
|
+
hasBlockStyles
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if ( availableTabs.length <= 1 ) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<InspectorControlsTabs
|
|
41
|
+
blockName={ blockName }
|
|
42
|
+
clientId={ clientId }
|
|
43
|
+
hasBlockStyles={ hasBlockStyles }
|
|
44
|
+
tabs={ availableTabs }
|
|
45
|
+
isSectionBlock={ isSectionBlock }
|
|
46
|
+
contentClientIds={ contentClientIds }
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Props
|
|
53
|
+
|
|
54
|
+
#### `blockName`
|
|
55
|
+
|
|
56
|
+
- **Type:** `String`
|
|
57
|
+
|
|
58
|
+
The name of the block being inspected, for example `core/group`. It is used to resolve the border panel label, and `core/template-part` is excluded from the curated section styles described under `isSectionBlock`. When omitted, the Advanced panel is not rendered in the Settings tab.
|
|
59
|
+
|
|
60
|
+
#### `clientId`
|
|
61
|
+
|
|
62
|
+
- **Type:** `String`
|
|
63
|
+
|
|
64
|
+
The client ID of the block being inspected. It is used as the key of the tabs panel so that selecting a different block resets the selected tab, and it is passed to the block styles preview in the Styles tab.
|
|
65
|
+
|
|
66
|
+
#### `hasBlockStyles`
|
|
67
|
+
|
|
68
|
+
- **Type:** `Boolean`
|
|
69
|
+
|
|
70
|
+
Whether the block has registered block styles. When `true`, the Styles tab renders the block style previews above the block support panels.
|
|
71
|
+
|
|
72
|
+
#### `tabs`
|
|
73
|
+
|
|
74
|
+
- **Type:** `Array`
|
|
75
|
+
|
|
76
|
+
The tabs to render in the tab list, in display order. Each entry is an object with `name`, `title` and `icon`. Pass the value returned by `useInspectorControlsTabs`; only tabs matching the `content`, `list`, `settings` and `styles` names have a corresponding panel.
|
|
77
|
+
|
|
78
|
+
#### `isSectionBlock`
|
|
79
|
+
|
|
80
|
+
- **Type:** `Boolean`
|
|
81
|
+
|
|
82
|
+
Whether the block being inspected is a section. When `true`, the Styles tab replaces the full set of block support panels with a curated subset — typography, background and elements — restricted to the supports a section should expose. Template parts are excluded and keep the full panel set.
|
|
83
|
+
|
|
84
|
+
#### `contentClientIds`
|
|
85
|
+
|
|
86
|
+
- **Type:** `Array`
|
|
87
|
+
|
|
88
|
+
The client IDs of the content blocks within a section. The Content tab lists them as quick navigation links to select a nested block, and the Styles tab uses them to decide which element color controls to show by default.
|
|
89
|
+
|
|
90
|
+
## Related components
|
|
91
|
+
|
|
92
|
+
Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
fetchFauxEntitySuggestions,
|
|
16
16
|
uniqueId,
|
|
17
17
|
} from './fixtures';
|
|
18
|
+
import { expectValidatedInputControlDeprecationIfCalled } from '../../url-input/test/fixtures/validated-input-control-deprecation';
|
|
18
19
|
|
|
19
20
|
const mockFetchSearchSuggestions = jest.fn();
|
|
20
21
|
|
|
@@ -3255,6 +3256,10 @@ describe( 'URL validation', () => {
|
|
|
3255
3256
|
mockOnChange.mockClear();
|
|
3256
3257
|
} );
|
|
3257
3258
|
|
|
3259
|
+
afterEach( () => {
|
|
3260
|
+
expectValidatedInputControlDeprecationIfCalled();
|
|
3261
|
+
} );
|
|
3262
|
+
|
|
3258
3263
|
it.each( [
|
|
3259
3264
|
{
|
|
3260
3265
|
description: 'URLs with spaces',
|
|
@@ -2,6 +2,7 @@ import clsx from 'clsx';
|
|
|
2
2
|
import {
|
|
3
3
|
useInstanceId,
|
|
4
4
|
useMergeRefs,
|
|
5
|
+
useRefEffect,
|
|
5
6
|
__experimentalUseFixedWindowList as useFixedWindowList,
|
|
6
7
|
} from '@wordpress/compose';
|
|
7
8
|
import { isShallowEqual } from '@wordpress/is-shallow-equal';
|
|
@@ -80,6 +81,7 @@ const expansion = ( state, action ) => {
|
|
|
80
81
|
* @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.
|
|
81
82
|
* @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.
|
|
82
83
|
* @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.
|
|
84
|
+
* @param {?boolean} props.focusOnMount Flag to move focus into the list when it mounts. Defaults to `false`.
|
|
83
85
|
* @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.
|
|
84
86
|
* @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.
|
|
85
87
|
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
@@ -95,6 +97,7 @@ function ListViewComponent(
|
|
|
95
97
|
showBlockMovers = false,
|
|
96
98
|
isExpanded = false,
|
|
97
99
|
showAppender = false,
|
|
100
|
+
focusOnMount = false,
|
|
98
101
|
blockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,
|
|
99
102
|
rootClientId,
|
|
100
103
|
description,
|
|
@@ -174,21 +177,61 @@ function ListViewComponent(
|
|
|
174
177
|
selectBlock: selectEditorBlock,
|
|
175
178
|
} );
|
|
176
179
|
|
|
177
|
-
const
|
|
180
|
+
const focusOnMountRef = useRefEffect(
|
|
178
181
|
( node ) => {
|
|
182
|
+
// A list that mounts as a side effect of selecting a block, the
|
|
183
|
+
// block inspector's for one, would pull focus out of whatever the
|
|
184
|
+
// user is editing, so taking focus is opt-in.
|
|
185
|
+
if ( ! focusOnMount ) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const controller = new window.AbortController();
|
|
190
|
+
const focusRow = ( clientId ) =>
|
|
191
|
+
focusListItem( clientId, node, controller.signal ).then( () =>
|
|
192
|
+
controller.abort()
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// Anything that takes focus first has a better claim to it. The row
|
|
196
|
+
// is not always there yet either, because a nested block waits on
|
|
197
|
+
// its ancestors expanding.
|
|
198
|
+
node.ownerDocument.addEventListener(
|
|
199
|
+
'focusin',
|
|
200
|
+
() => controller.abort(),
|
|
201
|
+
{ once: true, signal: controller.signal }
|
|
202
|
+
);
|
|
203
|
+
|
|
179
204
|
const [ firstSelectedClientId ] = getSelectedBlockClientIds();
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
205
|
+
|
|
206
|
+
if ( firstSelectedClientId ) {
|
|
207
|
+
focusRow( firstSelectedClientId );
|
|
208
|
+
return () => controller.abort();
|
|
184
209
|
}
|
|
210
|
+
|
|
211
|
+
// With nothing selected the top of the list gets focus, but only
|
|
212
|
+
// once the click that opened the list is over. Focusing a row costs
|
|
213
|
+
// a style and layout pass, and inside that commit it lands on a
|
|
214
|
+
// document that is still dirty.
|
|
215
|
+
const timerId = setTimeout( () => {
|
|
216
|
+
const firstClientId = node.querySelector(
|
|
217
|
+
'[role=row][data-block]'
|
|
218
|
+
)?.dataset.block;
|
|
219
|
+
if ( firstClientId ) {
|
|
220
|
+
focusRow( firstClientId );
|
|
221
|
+
}
|
|
222
|
+
}, 0 );
|
|
223
|
+
|
|
224
|
+
return () => {
|
|
225
|
+
clearTimeout( timerId );
|
|
226
|
+
controller.abort();
|
|
227
|
+
};
|
|
185
228
|
},
|
|
186
|
-
[ getSelectedBlockClientIds ]
|
|
229
|
+
[ focusOnMount, getSelectedBlockClientIds ]
|
|
187
230
|
);
|
|
188
231
|
|
|
189
232
|
const treeGridRef = useMergeRefs( [
|
|
190
233
|
clipBoardRef,
|
|
191
|
-
|
|
234
|
+
focusOnMountRef,
|
|
192
235
|
elementRef,
|
|
193
236
|
dropZoneRef,
|
|
194
237
|
ref,
|
|
@@ -80,8 +80,9 @@ export function getCommonDepthClientIds(
|
|
|
80
80
|
*
|
|
81
81
|
* @param {string} focusClientId The client ID of the block to focus.
|
|
82
82
|
* @param {?HTMLElement} treeGridElement The container element to search within.
|
|
83
|
+
* @param {?AbortSignal} signal Optional signal to stop waiting for the row and leave focus alone.
|
|
83
84
|
*/
|
|
84
|
-
export function focusListItem( focusClientId, treeGridElement ) {
|
|
85
|
+
export function focusListItem( focusClientId, treeGridElement, signal ) {
|
|
85
86
|
if ( ! treeGridElement ) {
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
@@ -108,12 +109,26 @@ export function focusListItem( focusClientId, treeGridElement ) {
|
|
|
108
109
|
subtree: true,
|
|
109
110
|
} );
|
|
110
111
|
|
|
112
|
+
signal?.addEventListener(
|
|
113
|
+
'abort',
|
|
114
|
+
() => {
|
|
115
|
+
clearTimeout( timer );
|
|
116
|
+
observer.disconnect();
|
|
117
|
+
resolve( null );
|
|
118
|
+
},
|
|
119
|
+
{ once: true }
|
|
120
|
+
);
|
|
121
|
+
|
|
111
122
|
// Stop trying after 3 seconds.
|
|
112
123
|
timer = setTimeout( () => {
|
|
113
124
|
observer.disconnect();
|
|
114
125
|
resolve( null );
|
|
115
126
|
}, 3000 );
|
|
116
127
|
} ).then( ( element ) => {
|
|
128
|
+
if ( signal?.aborted ) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
117
132
|
if ( element && element.isConnected ) {
|
|
118
133
|
// Focus the first focusable in the row, which is the ListViewBlockSelectButton.
|
|
119
134
|
focus.focusable.find( element )?.[ 0 ]?.focus();
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
FormFileUpload,
|
|
5
5
|
Placeholder,
|
|
6
6
|
DropZone,
|
|
7
|
-
__experimentalInputControl as
|
|
7
|
+
__experimentalInputControl as WCInputControl,
|
|
8
8
|
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
|
|
9
9
|
withFilters,
|
|
10
10
|
} from '@wordpress/components';
|
|
@@ -19,7 +19,6 @@ import URLPopover from '../url-popover';
|
|
|
19
19
|
import { store as blockEditorStore } from '../../store';
|
|
20
20
|
import { parseDropEvent } from '../use-on-block-drop';
|
|
21
21
|
import { getComputedAcceptAttribute } from './utils';
|
|
22
|
-
|
|
23
22
|
const noop = () => {};
|
|
24
23
|
|
|
25
24
|
const InsertFromURLPopover = ( {
|
|
@@ -34,7 +33,7 @@ const InsertFromURLPopover = ( {
|
|
|
34
33
|
className="block-editor-media-placeholder__url-input-form"
|
|
35
34
|
onSubmit={ onSubmit }
|
|
36
35
|
>
|
|
37
|
-
<
|
|
36
|
+
<WCInputControl
|
|
38
37
|
label={ __( 'URL' ) }
|
|
39
38
|
type="text" // Use text instead of URL to allow relative paths (e.g., /image/image.jpg)
|
|
40
39
|
hideLabelFromVision
|
|
@@ -373,6 +372,10 @@ export function MediaPlaceholder( {
|
|
|
373
372
|
onFilesDrop={ onFilesUpload }
|
|
374
373
|
onDrop={ handleBlocksDrop }
|
|
375
374
|
isEligible={ ( dataTransfer ) => {
|
|
375
|
+
// This dropzone only accepts block drags from the inserter, not
|
|
376
|
+
// canvas block drags. Only the inserter publishes the dragged
|
|
377
|
+
// blocks' names, as wp-block:core/{name}, so no matches means it
|
|
378
|
+
// isn't an inserter drag.
|
|
376
379
|
const prefix = 'wp-block:core/';
|
|
377
380
|
const types = [];
|
|
378
381
|
for ( const type of dataTransfer.types ) {
|
|
@@ -381,9 +384,11 @@ export function MediaPlaceholder( {
|
|
|
381
384
|
}
|
|
382
385
|
}
|
|
383
386
|
return (
|
|
387
|
+
types.length > 0 &&
|
|
384
388
|
types.every( ( type ) =>
|
|
385
389
|
allowedTypes.includes( type )
|
|
386
|
-
) &&
|
|
390
|
+
) &&
|
|
391
|
+
( multiple ? true : types.length === 1 )
|
|
387
392
|
);
|
|
388
393
|
} }
|
|
389
394
|
/>
|
|
@@ -5,6 +5,9 @@ const meta = {
|
|
|
5
5
|
title: 'BlockEditor/PlainText',
|
|
6
6
|
component: PlainText,
|
|
7
7
|
parameters: {
|
|
8
|
+
// FIXME: Story renders PlainText without a label (label).
|
|
9
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
10
|
+
a11y: { test: 'todo' },
|
|
8
11
|
docs: {
|
|
9
12
|
canvas: { sourceState: 'shown' },
|
|
10
13
|
description: {
|
|
@@ -13,6 +13,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
13
13
|
import { BlockRefsProvider } from './block-refs-provider';
|
|
14
14
|
import { unlock } from '../../lock-unlock';
|
|
15
15
|
import KeyboardShortcuts from '../keyboard-shortcuts';
|
|
16
|
+
import BlockKeyboardShortcuts from '../block-keyboard-shortcuts';
|
|
16
17
|
import useMediaUploadSettings from './use-media-upload-settings';
|
|
17
18
|
import { mediaUploadOnSuccessKey } from '../../store/private-keys';
|
|
18
19
|
import { SelectionContext } from './selection-context';
|
|
@@ -361,7 +362,12 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(
|
|
|
361
362
|
|
|
362
363
|
const children = (
|
|
363
364
|
<SlotFillProvider passthrough>
|
|
364
|
-
{ ! settings?.isPreviewMode &&
|
|
365
|
+
{ ! settings?.isPreviewMode && (
|
|
366
|
+
<>
|
|
367
|
+
<KeyboardShortcuts.Register />
|
|
368
|
+
<BlockKeyboardShortcuts />
|
|
369
|
+
</>
|
|
370
|
+
) }
|
|
365
371
|
<BlockRefsProvider>{ props.children }</BlockRefsProvider>
|
|
366
372
|
</SlotFillProvider>
|
|
367
373
|
);
|
|
@@ -59,3 +59,13 @@ Called when the user presses the close button.
|
|
|
59
59
|
|
|
60
60
|
- Type: `Function`
|
|
61
61
|
- Required: No
|
|
62
|
+
|
|
63
|
+
### showPopoverHeader
|
|
64
|
+
|
|
65
|
+
Whether to render the popover header, which holds the title, the close button
|
|
66
|
+
and a "Reset" action. Set it to `false` when the picker is rendered inline,
|
|
67
|
+
where the surrounding UI already provides a heading.
|
|
68
|
+
|
|
69
|
+
- Type: `Boolean`
|
|
70
|
+
- Required: No
|
|
71
|
+
- Default: `true`
|
|
@@ -8,6 +8,7 @@ export function PublishDateTimePicker(
|
|
|
8
8
|
{
|
|
9
9
|
onClose,
|
|
10
10
|
onChange,
|
|
11
|
+
showPopoverHeader = true,
|
|
11
12
|
showPopoverHeaderActions,
|
|
12
13
|
isCompact,
|
|
13
14
|
currentDate,
|
|
@@ -26,20 +27,22 @@ export function PublishDateTimePicker(
|
|
|
26
27
|
const DatePickerComponent = isCompact ? TimePicker : DateTimePicker;
|
|
27
28
|
return (
|
|
28
29
|
<div ref={ ref } className="block-editor-publish-date-time-picker">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
{ showPopoverHeader && (
|
|
31
|
+
<InspectorPopoverHeader
|
|
32
|
+
title={ title || __( 'Publish' ) }
|
|
33
|
+
actions={
|
|
34
|
+
showPopoverHeaderActions
|
|
35
|
+
? [
|
|
36
|
+
{
|
|
37
|
+
label: __( 'Reset' ),
|
|
38
|
+
onClick: () => onChange?.( null ),
|
|
39
|
+
},
|
|
40
|
+
]
|
|
41
|
+
: undefined
|
|
42
|
+
}
|
|
43
|
+
onClose={ onClose }
|
|
44
|
+
/>
|
|
45
|
+
) }
|
|
43
46
|
<DatePickerComponent { ...datePickerProps } />
|
|
44
47
|
</div>
|
|
45
48
|
);
|
|
@@ -11,19 +11,66 @@ const { subscribeOwnedListener, ownsSelection } = unlock( richTextPrivateApis );
|
|
|
11
11
|
const { subscribeDelegatedListener } = unlock( composePrivateApis );
|
|
12
12
|
|
|
13
13
|
export default ( props ) => ( element ) => {
|
|
14
|
-
function
|
|
14
|
+
function onKeyDown( event ) {
|
|
15
15
|
if ( event.keyCode !== ENTER ) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
onReplace,
|
|
21
|
+
onSplit,
|
|
22
|
+
supportsSplitting,
|
|
23
|
+
disableLineBreaks,
|
|
24
|
+
onChange,
|
|
25
|
+
getValue,
|
|
26
|
+
onSplitAtDoubleLineEnd,
|
|
27
|
+
registry,
|
|
28
|
+
onSplitAtEnd,
|
|
29
|
+
} = props.current;
|
|
30
|
+
// The rendered value can lag the record: the capture phase listener
|
|
31
|
+
// that syncs the selection runs on this event, and a re-render with
|
|
32
|
+
// the new selection has not happened yet.
|
|
33
|
+
const value = getValue();
|
|
34
|
+
const { text, start, end } = value;
|
|
20
35
|
|
|
21
|
-
if (
|
|
36
|
+
if ( event.shiftKey ) {
|
|
37
|
+
if ( ! disableLineBreaks ) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
onChange( insert( value, '\n' ) );
|
|
40
|
+
}
|
|
41
|
+
} else if ( onSplitAtEnd && start === end && end === text.length ) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
onSplitAtEnd();
|
|
44
|
+
} else if ( onReplace && onSplit ) {
|
|
22
45
|
event.__deprecatedOnSplit = true;
|
|
46
|
+
} else if (
|
|
47
|
+
! supportsSplitting &&
|
|
48
|
+
! disableLineBreaks &&
|
|
49
|
+
! event.defaultPrevented
|
|
50
|
+
) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
if (
|
|
53
|
+
// For some blocks it's desirable to split at the end of the
|
|
54
|
+
// block when there are two line breaks at the end of the
|
|
55
|
+
// block, so triple Enter exits the block.
|
|
56
|
+
onSplitAtDoubleLineEnd &&
|
|
57
|
+
start === end &&
|
|
58
|
+
end === text.length &&
|
|
59
|
+
text.slice( -2 ) === '\n\n'
|
|
60
|
+
) {
|
|
61
|
+
registry.batch( () => {
|
|
62
|
+
const _value = { ...value };
|
|
63
|
+
_value.start = _value.end - 2;
|
|
64
|
+
onChange( remove( _value ) );
|
|
65
|
+
onSplitAtDoubleLineEnd();
|
|
66
|
+
} );
|
|
67
|
+
} else {
|
|
68
|
+
onChange( insert( value, '\n' ) );
|
|
69
|
+
}
|
|
23
70
|
}
|
|
24
71
|
}
|
|
25
72
|
|
|
26
|
-
function
|
|
73
|
+
function onDefaultKeyDown( event ) {
|
|
27
74
|
if ( event.defaultPrevented ) {
|
|
28
75
|
return;
|
|
29
76
|
}
|
|
@@ -39,64 +86,30 @@ export default ( props ) => ( element ) => {
|
|
|
39
86
|
return;
|
|
40
87
|
}
|
|
41
88
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onChange,
|
|
45
|
-
disableLineBreaks,
|
|
46
|
-
onSplitAtEnd,
|
|
47
|
-
onSplitAtDoubleLineEnd,
|
|
48
|
-
registry,
|
|
49
|
-
} = props.current;
|
|
50
|
-
|
|
89
|
+
// On ENTER, we ALWAYS want to prevent the default browser behaviour
|
|
90
|
+
// at this last interception point.
|
|
51
91
|
event.preventDefault();
|
|
52
|
-
|
|
53
|
-
const { text, start, end } = value;
|
|
54
|
-
|
|
55
|
-
if ( event.shiftKey ) {
|
|
56
|
-
if ( ! disableLineBreaks ) {
|
|
57
|
-
onChange( insert( value, '\n' ) );
|
|
58
|
-
}
|
|
59
|
-
} else if ( onSplitAtEnd && start === end && end === text.length ) {
|
|
60
|
-
onSplitAtEnd();
|
|
61
|
-
} else if (
|
|
62
|
-
// For some blocks it's desirable to split at the end of the
|
|
63
|
-
// block when there are two line breaks at the end of the
|
|
64
|
-
// block, so triple Enter exits the block.
|
|
65
|
-
onSplitAtDoubleLineEnd &&
|
|
66
|
-
start === end &&
|
|
67
|
-
end === text.length &&
|
|
68
|
-
text.slice( -2 ) === '\n\n'
|
|
69
|
-
) {
|
|
70
|
-
registry.batch( () => {
|
|
71
|
-
const _value = { ...value };
|
|
72
|
-
_value.start = _value.end - 2;
|
|
73
|
-
onChange( remove( _value ) );
|
|
74
|
-
onSplitAtDoubleLineEnd();
|
|
75
|
-
} );
|
|
76
|
-
} else if ( ! disableLineBreaks ) {
|
|
77
|
-
onChange( insert( value, '\n' ) );
|
|
78
|
-
}
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
const { defaultView } = element.ownerDocument;
|
|
82
95
|
|
|
83
96
|
// Attach the listener to the window so parent elements have the chance to
|
|
84
97
|
// prevent the default behavior.
|
|
85
|
-
const
|
|
98
|
+
const unsubscribeDefaultKeyDown = subscribeDelegatedListener(
|
|
86
99
|
defaultView,
|
|
87
100
|
'keydown',
|
|
88
|
-
|
|
101
|
+
onDefaultKeyDown
|
|
89
102
|
);
|
|
90
103
|
// Capture phase so this runs before ancestor (writing flow) bubble
|
|
91
104
|
// handlers, matching the timing of the previous raw element listener.
|
|
92
|
-
const
|
|
105
|
+
const unsubscribeKeyDown = subscribeOwnedListener(
|
|
93
106
|
element,
|
|
94
107
|
'keydown',
|
|
95
|
-
|
|
108
|
+
onKeyDown,
|
|
96
109
|
true
|
|
97
110
|
);
|
|
98
111
|
return () => {
|
|
112
|
+
unsubscribeDefaultKeyDown();
|
|
99
113
|
unsubscribeKeyDown();
|
|
100
|
-
unsubscribeKeyDownDeprecated();
|
|
101
114
|
};
|
|
102
115
|
};
|