@wordpress/block-editor 12.4.0 → 12.5.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/README.md +5 -0
- package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
- package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-lock/toolbar.js +25 -6
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -6
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +8 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +18 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +8 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +7 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js +99 -0
- package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
- package/build/components/dimensions-tool/index.js +207 -0
- package/build/components/dimensions-tool/index.js.map +1 -0
- package/build/components/dimensions-tool/scale-tool.js +111 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -0
- package/build/components/dimensions-tool/width-height-tool.js +125 -0
- package/build/components/dimensions-tool/width-height-tool.js.map +1 -0
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +1 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +34 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +1 -2
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +19 -1
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +7 -35
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +3 -4
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +9 -3
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +2 -21
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +62 -0
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build/components/inserter/reusable-blocks-tab.js +6 -2
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/tabs.native.js +1 -1
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +9 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/index.js +17 -15
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-input.js +4 -4
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +2 -3
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/appender.js +2 -6
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/provider/index.js +5 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +21 -0
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/resolution-tool/index.js +55 -0
- package/build/components/resolution-tool/index.js.map +1 -0
- package/build/components/url-input/index.js +4 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +10 -27
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-mode-control/index.js +70 -0
- package/build/components/writing-mode-control/index.js.map +1 -0
- package/build/hooks/behaviors.js +25 -20
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +4 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +3 -0
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +195 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +10 -1
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +46 -40
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +33 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +25 -7
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -5
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +20 -24
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -5
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js +87 -0
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
- package/build-module/components/dimensions-tool/index.js +195 -0
- package/build-module/components/dimensions-tool/index.js.map +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js +103 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -0
- package/build-module/components/dimensions-tool/width-height-tool.js +122 -0
- package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +33 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +1 -2
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +5 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +6 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +7 -33
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +3 -4
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +9 -3
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +2 -21
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build-module/components/inserter/reusable-blocks-tab.js +5 -2
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +1 -1
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +9 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -15
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-input.js +4 -4
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +4 -5
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/appender.js +2 -6
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/provider/index.js +5 -2
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +21 -0
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +45 -0
- package/build-module/components/resolution-tool/index.js.map +1 -0
- package/build-module/components/url-input/index.js +4 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +8 -26
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +57 -0
- package/build-module/components/writing-mode-control/index.js.map +1 -0
- package/build-module/hooks/behaviors.js +26 -20
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +4 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +2 -0
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +191 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +10 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +45 -36
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +22 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +33 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +131 -129
- package/build-style/style.css +131 -129
- package/package.json +32 -31
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -6
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -5
- package/src/components/block-draggable/style.scss +1 -0
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
- package/src/components/block-heading-level-dropdown/index.native.js +8 -4
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-lock/toolbar.js +34 -6
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -8
- package/src/components/block-parent-selector/index.js +13 -8
- package/src/components/block-removal-warning-modal/index.js +20 -33
- package/src/components/block-toolbar/index.js +9 -6
- package/src/components/block-tools/block-contextual-toolbar.js +5 -11
- package/src/components/block-tools/style.scss +73 -26
- package/src/components/default-block-appender/content.scss +11 -0
- package/src/components/dimensions-tool/aspect-ratio-tool.js +124 -0
- package/src/components/dimensions-tool/index.js +212 -0
- package/src/components/dimensions-tool/scale-tool.js +124 -0
- package/src/components/dimensions-tool/stories/aspect-ratio-tool.js +52 -0
- package/src/components/dimensions-tool/stories/index.js +54 -0
- package/src/components/dimensions-tool/stories/scale-tool.js +48 -0
- package/src/components/dimensions-tool/stories/width-height-tool.js +54 -0
- package/src/components/dimensions-tool/test/index.js +641 -0
- package/src/components/dimensions-tool/width-height-tool.js +113 -0
- package/src/components/font-family/README.md +71 -0
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/filters-panel.js +2 -2
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +40 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/src/components/image-editor/use-save-image.js +0 -1
- package/src/components/image-size-control/index.js +6 -0
- package/src/components/index.js +6 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +8 -2
- package/src/components/inserter/block-patterns-tab.js +8 -56
- package/src/components/inserter/hooks/use-block-types-state.js +3 -4
- package/src/components/inserter/hooks/use-patterns-state.js +35 -19
- package/src/components/inserter/media-tab/hooks.js +2 -22
- package/src/components/inserter/reusable-block-rename-hint.js +52 -0
- package/src/components/inserter/reusable-blocks-tab.js +5 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/src/components/inserter/style.scss +28 -0
- package/src/components/inserter/tabs.native.js +5 -1
- package/src/components/inserter-draggable-blocks/index.js +13 -2
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/index.js +32 -28
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-input.js +4 -3
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/settings-drawer.js +6 -5
- package/src/components/link-control/style.scss +51 -123
- package/src/components/link-control/test/index.js +135 -123
- package/src/components/list-view/appender.js +5 -6
- package/src/components/list-view/style.scss +1 -2
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/panel-color-settings/README.md +98 -0
- package/src/components/provider/index.js +9 -2
- package/src/components/provider/test/use-block-sync.js +21 -6
- package/src/components/provider/use-block-sync.js +19 -0
- package/src/components/recursion-provider/README.md +101 -0
- package/src/components/resolution-tool/index.js +56 -0
- package/src/components/resolution-tool/stories/index.js +48 -0
- package/src/components/url-input/index.js +2 -0
- package/src/components/writing-flow/use-tab-nav.js +10 -33
- package/src/components/writing-mode-control/index.js +68 -0
- package/src/components/writing-mode-control/style.scss +18 -0
- package/src/hooks/behaviors.js +25 -16
- package/src/hooks/supports.js +7 -0
- package/src/hooks/typography.js +2 -0
- package/src/hooks/utils.js +3 -0
- package/src/private-apis.js +6 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +194 -1
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +10 -0
- package/src/store/private-actions.js +39 -39
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +22 -8
- package/src/store/selectors.js +54 -20
- package/src/store/test/actions.js +111 -0
- package/src/store/test/private-actions.js +56 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-toolbar/index.js"],"names":["BlockToolbar","hideDragHandle","blockClientIds","blockClientId","blockType","hasFixedToolbar","isDistractionFree","isValid","isVisual","blockEditingMode","select","getBlockName","getBlockMode","getSelectedBlockClientIds","isBlockValid","getBlockRootClientId","getSettings","getBlockEditingMode","blockEditorStore","selectedBlockClientIds","selectedBlockClientId","blockRootClientId","settings","rootClientId","every","id","toggleBlockHighlight","nodeRef","showMovers","gestures","showMoversGestures","ref","onChange","isFocused","displayHeaderToolbar","isLargeViewport","shouldShowMovers","length","shouldShowVisualToolbar","isMultiToolbar","isSynced","classes","name"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;AAeA,MAAMA,YAAY,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAA0B;AAC9C,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,SAHK;AAILC,IAAAA,eAJK;AAKLC,IAAAA,iBALK;AAMLC,IAAAA,OANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA;AARK,MASF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA,yBAHK;AAILC,MAAAA,YAJK;AAKLC,MAAAA,oBALK;AAMLC,MAAAA,WANK;AAOLC,MAAAA;AAPK,QAQF,wBAAQP,MAAM,CAAEQ,YAAF,CAAd,CARJ;AASA,UAAMC,sBAAsB,GAAGN,yBAAyB,EAAxD;AACA,UAAMO,qBAAqB,GAAGD,sBAAsB,CAAE,CAAF,CAApD;AACA,UAAME,iBAAiB,GAAGN,oBAAoB,CAAEK,qBAAF,CAA9C;AACA,UAAME,QAAQ,GAAGN,WAAW,EAA5B;AA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AAA,SAAS,EAAC;AAFX,IADD,EAKC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,OADP;AAEC,IAAA,SAAS,EAAC;AAFX,IALD,EASC,4BAAC,sBAAD,CAAe,IAAf;AAAoB,IAAA,SAAS,EAAC;AAA9B,IATD,EAUC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,QADP;AAEC,IAAA,SAAS,EAAC;AAFX,IAVD,EAcC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,OADP;AAEC,IAAA,SAAS,EAAC;AAFX,IAdD,EAkBC,4BAAC,yBAAD,CAA4B,QAA5B;AACC,IAAA,KAAK,EAAGlC,SAAS,EAAEsC;AADpB,KAGC,4BAAC,6BAAD,CAAgC,IAAhC,OAHD,CAlBD,CAzBF,EAkDC,4BAAC,gCAAD;AAAyB,IAAA,SAAS,EAAGxC;AAArC,IAlDD,EAmDGO,gBAAgB,KAAK,SAArB,IACD,4BAAC,0BAAD;AAAmB,IAAA,SAAS,EAAGP;AAA/B,IApDF,CADD;AAyDA,CAjJD;AAmJA;AACA;AACA;;;eACeF,Y","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockSwitcher from '../block-switcher';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowMoversGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport __unstableBlockNameContext from './block-name-context';\nimport { unlock } from '../../lock-unlock';\n\nconst BlockToolbar = ( { hideDragHandle } ) => {\n\tconst {\n\t\tblockClientIds,\n\t\tblockClientId,\n\t\tblockType,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tisValid,\n\t\tisVisual,\n\t\tblockEditingMode,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t\tgetBlockEditingMode,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst blockRootClientId = getBlockRootClientId( selectedBlockClientId );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\tselectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( selectedBlockClientId ) ),\n\t\t\thasFixedToolbar: settings.hasFixedToolbar,\n\t\t\tisDistractionFree: settings.isDistractionFree,\n\t\t\trootClientId: blockRootClientId,\n\t\t\tisValid: selectedBlockClientIds.every( ( id ) =>\n\t\t\t\tisBlockValid( id )\n\t\t\t),\n\t\t\tisVisual: selectedBlockClientIds.every(\n\t\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t\t),\n\t\t\tblockEditingMode: getBlockEditingMode( selectedBlockClientId ),\n\t\t};\n\t}, [] );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\tconst nodeRef = useRef();\n\tconst { showMovers, gestures: showMoversGestures } = useShowMoversGestures(\n\t\t{\n\t\t\tref: nodeRef,\n\t\t\tonChange( isFocused ) {\n\t\t\t\tif ( isFocused && isDistractionFree ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttoggleBlockHighlight( blockClientId, isFocused );\n\t\t\t},\n\t\t}\n\t);\n\n\t// Account for the cases where the block toolbar is rendered within the\n\t// header area and not contextually to the block.\n\tconst displayHeaderToolbar =\n\t\tuseViewportMatch( 'medium', '<' ) || hasFixedToolbar;\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tif ( blockType ) {\n\t\tif ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst shouldShowMovers = displayHeaderToolbar || showMovers;\n\n\tif ( blockClientIds.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst shouldShowVisualToolbar = isValid && isVisual;\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\tconst classes = classnames( 'block-editor-block-toolbar', {\n\t\t'is-showing-movers': shouldShowMovers,\n\t\t'is-synced': isSynced,\n\t} );\n\n\treturn (\n\t\t<div className={ classes }>\n\t\t\t{ ! isMultiToolbar &&\n\t\t\t\tisLargeViewport &&\n\t\t\t\tblockEditingMode === 'default' && <BlockParentSelector /> }\n\t\t\t<div ref={ nodeRef } { ...showMoversGestures }>\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) &&\n\t\t\t\t\tblockEditingMode === 'default' && (\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockSwitcher clientIds={ blockClientIds } />\n\t\t\t\t\t\t\t{ ! isMultiToolbar && (\n\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\tclientId={ blockClientIds[ 0 ] }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ shouldShowVisualToolbar && isMultiToolbar && (\n\t\t\t\t<BlockGroupToolbar />\n\t\t\t) }\n\t\t\t{ shouldShowVisualToolbar && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<__unstableBlockNameContext.Provider\n\t\t\t\t\t\tvalue={ blockType?.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t</__unstableBlockNameContext.Provider>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n */\nexport default BlockToolbar;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-toolbar/index.js"],"names":["BlockToolbar","hideDragHandle","blockClientIds","blockClientId","blockType","hasFixedToolbar","isDistractionFree","isValid","isVisual","blockEditingMode","select","getBlockName","getBlockMode","getSelectedBlockClientIds","isBlockValid","getBlockRootClientId","getSettings","getBlockEditingMode","blockEditorStore","selectedBlockClientIds","selectedBlockClientId","blockRootClientId","settings","rootClientId","every","id","toolbarWrapperRef","toggleBlockHighlight","nodeRef","showMovers","gestures","showMoversGestures","ref","onChange","isFocused","displayHeaderToolbar","isLargeViewport","shouldShowMovers","length","shouldShowVisualToolbar","isMultiToolbar","isSynced","classes","name"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;AAeA,MAAMA,YAAY,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAA0B;AAC9C,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,SAHK;AAILC,IAAAA,eAJK;AAKLC,IAAAA,iBALK;AAMLC,IAAAA,OANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA;AARK,MASF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA,yBAHK;AAILC,MAAAA,YAJK;AAKLC,MAAAA,oBALK;AAMLC,MAAAA,WANK;AAOLC,MAAAA;AAPK,QAQF,wBAAQP,MAAM,CAAEQ,YAAF,CAAd,CARJ;AASA,UAAMC,sBAAsB,GAAGN,yBAAyB,EAAxD;AACA,UAAMO,qBAAqB,GAAGD,sBAAsB,CAAE,CAAF,CAApD;AACA,UAAME,iBAAiB,GAAGN,oBAAo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Ac,EAAGD;AAFlB,IARD,CADD,CANH,EAsBGsC,uBAAuB,IAAIC,cAA3B,IACD,4BAAC,wCAAD,OAvBF,EAyBGD,uBAAuB,IACxB,qDACC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,QADP;AAEC,IAAA,SAAS,EAAC;AAFX,IADD,EAKC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,OADP;AAEC,IAAA,SAAS,EAAC;AAFX,IALD,EASC,4BAAC,sBAAD,CAAe,IAAf;AAAoB,IAAA,SAAS,EAAC;AAA9B,IATD,EAUC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,QADP;AAEC,IAAA,SAAS,EAAC;AAFX,IAVD,EAcC,4BAAC,sBAAD,CAAe,IAAf;AACC,IAAA,KAAK,EAAC,OADP;AAEC,IAAA,SAAS,EAAC;AAFX,IAdD,EAkBC,4BAAC,yBAAD,CAA4B,QAA5B;AACC,IAAA,KAAK,EAAGnC,SAAS,EAAEuC;AADpB,KAGC,4BAAC,6BAAD,CAAgC,IAAhC,OAHD,CAlBD,CA1BF,EAmDC,4BAAC,gCAAD;AAAyB,IAAA,SAAS,EAAGzC;AAArC,IAnDD,EAoDGO,gBAAgB,KAAK,SAArB,IACD,4BAAC,0BAAD;AAAmB,IAAA,SAAS,EAAGP;AAA/B,IArDF,CADD;AA0DA,CApJD;AAsJA;AACA;AACA;;;eACeF,Y","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockSwitcher from '../block-switcher';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowMoversGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport __unstableBlockNameContext from './block-name-context';\nimport { unlock } from '../../lock-unlock';\n\nconst BlockToolbar = ( { hideDragHandle } ) => {\n\tconst {\n\t\tblockClientIds,\n\t\tblockClientId,\n\t\tblockType,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tisValid,\n\t\tisVisual,\n\t\tblockEditingMode,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t\tgetBlockEditingMode,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst blockRootClientId = getBlockRootClientId( selectedBlockClientId );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\tselectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( selectedBlockClientId ) ),\n\t\t\thasFixedToolbar: settings.hasFixedToolbar,\n\t\t\tisDistractionFree: settings.isDistractionFree,\n\t\t\trootClientId: blockRootClientId,\n\t\t\tisValid: selectedBlockClientIds.every( ( id ) =>\n\t\t\t\tisBlockValid( id )\n\t\t\t),\n\t\t\tisVisual: selectedBlockClientIds.every(\n\t\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t\t),\n\t\t\tblockEditingMode: getBlockEditingMode( selectedBlockClientId ),\n\t\t};\n\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\tconst nodeRef = useRef();\n\tconst { showMovers, gestures: showMoversGestures } = useShowMoversGestures(\n\t\t{\n\t\t\tref: nodeRef,\n\t\t\tonChange( isFocused ) {\n\t\t\t\tif ( isFocused && isDistractionFree ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttoggleBlockHighlight( blockClientId, isFocused );\n\t\t\t},\n\t\t}\n\t);\n\n\t// Account for the cases where the block toolbar is rendered within the\n\t// header area and not contextually to the block.\n\tconst displayHeaderToolbar =\n\t\tuseViewportMatch( 'medium', '<' ) || hasFixedToolbar;\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tif ( blockType ) {\n\t\tif ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst shouldShowMovers = displayHeaderToolbar || showMovers;\n\n\tif ( blockClientIds.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst shouldShowVisualToolbar = isValid && isVisual;\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\tconst classes = classnames( 'block-editor-block-toolbar', {\n\t\t'is-showing-movers': shouldShowMovers,\n\t\t'is-synced': isSynced,\n\t} );\n\n\treturn (\n\t\t<div className={ classes } ref={ toolbarWrapperRef }>\n\t\t\t{ ! isMultiToolbar &&\n\t\t\t\tisLargeViewport &&\n\t\t\t\tblockEditingMode === 'default' && <BlockParentSelector /> }\n\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) &&\n\t\t\t\tblockEditingMode === 'default' && (\n\t\t\t\t\t<div ref={ nodeRef } { ...showMoversGestures }>\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockSwitcher clientIds={ blockClientIds } />\n\t\t\t\t\t\t\t{ ! isMultiToolbar && (\n\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\tclientId={ blockClientIds[ 0 ] }\n\t\t\t\t\t\t\t\t\twrapperRef={ toolbarWrapperRef }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t{ shouldShowVisualToolbar && isMultiToolbar && (\n\t\t\t\t<BlockGroupToolbar />\n\t\t\t) }\n\t\t\t{ shouldShowVisualToolbar && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<__unstableBlockNameContext.Provider\n\t\t\t\t\t\tvalue={ blockType?.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t</__unstableBlockNameContext.Provider>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n */\nexport default BlockToolbar;\n"]}
|
|
@@ -29,8 +29,6 @@ var _blockToolbar = _interopRequireDefault(require("../block-toolbar"));
|
|
|
29
29
|
|
|
30
30
|
var _store = require("../../store");
|
|
31
31
|
|
|
32
|
-
var _blockIcon = _interopRequireDefault(require("../block-icon"));
|
|
33
|
-
|
|
34
32
|
var _lockUnlock = require("../../lock-unlock");
|
|
35
33
|
|
|
36
34
|
/**
|
|
@@ -78,7 +76,7 @@ function BlockContextualToolbar({
|
|
|
78
76
|
selectedBlockClientId: _selectedBlockClientId,
|
|
79
77
|
blockType: _selectedBlockClientId && getBlockType(getBlockName(_selectedBlockClientId)),
|
|
80
78
|
hasParents: parents.length,
|
|
81
|
-
showParentSelector: parentBlockType && (0, _blocks.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1 && getBlockEditingMode(_selectedBlockClientId) === 'default'
|
|
79
|
+
showParentSelector: parentBlockType && getBlockEditingMode(firstParentClientId) === 'default' && (0, _blocks.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1 && getBlockEditingMode(_selectedBlockClientId) === 'default'
|
|
82
80
|
};
|
|
83
81
|
}, []);
|
|
84
82
|
(0, _element.useEffect)(() => {
|
|
@@ -102,22 +100,20 @@ function BlockContextualToolbar({
|
|
|
102
100
|
,
|
|
103
101
|
"aria-label": (0, _i18n.__)('Block tools'),
|
|
104
102
|
...props
|
|
105
|
-
},
|
|
103
|
+
}, !isCollapsed && (0, _element.createElement)(_blockToolbar.default, {
|
|
104
|
+
hideDragHandle: isFixed
|
|
105
|
+
}), isFixed && isLargeViewport && blockType && (0, _element.createElement)(_components.ToolbarGroup, {
|
|
106
106
|
className: isCollapsed ? 'block-editor-block-toolbar__group-expand-fixed-toolbar' : 'block-editor-block-toolbar__group-collapse-fixed-toolbar'
|
|
107
107
|
}, (0, _element.createElement)(_components.ToolbarItem, {
|
|
108
108
|
as: _components.ToolbarButton,
|
|
109
109
|
ref: toolbarButtonRef,
|
|
110
|
-
icon: isCollapsed ?
|
|
111
|
-
icon: blockType.icon
|
|
112
|
-
}) : _icons.levelUp,
|
|
110
|
+
icon: isCollapsed ? _icons.next : _icons.previous,
|
|
113
111
|
onClick: () => {
|
|
114
112
|
setIsCollapsed(collapsed => !collapsed);
|
|
115
113
|
toolbarButtonRef.current.focus();
|
|
116
114
|
},
|
|
117
|
-
label: isCollapsed ? (0, _i18n.__)('Show block tools') : (0, _i18n.__)('
|
|
118
|
-
}))
|
|
119
|
-
hideDragHandle: isFixed
|
|
120
|
-
}));
|
|
115
|
+
label: isCollapsed ? (0, _i18n.__)('Show block tools') : (0, _i18n.__)('Hide block tools')
|
|
116
|
+
})));
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
var _default = BlockContextualToolbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"names":["BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","toolbarButtonRef","isLargeViewport","blockType","hasParents","showParentSelector","selectedBlockClientId","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","blockEditorStore","getBlockType","blocksStore","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","classes","ToolbarButton","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"names":["BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","toolbarButtonRef","isLargeViewport","blockType","hasParents","showParentSelector","selectedBlockClientId","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","blockEditorStore","getBlockType","blocksStore","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","classes","ToolbarButton","next","previous","collapsed","current","focus"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAMA,SAASA,sBAAT,CAAiC;AAAEC,EAAAA,YAAF;AAAgBC,EAAAA,OAAhB;AAAyB,KAAGC;AAA5B,CAAjC,EAAuE;AACtE;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAMC,gBAAgB,GAAG,sBAAzB;AAEA,QAAMC,eAAe,GAAG,+BAAkB,QAAlB,CAAxB;AACA,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,UAAb;AAAyBC,IAAAA,kBAAzB;AAA6CC,IAAAA;AAA7C,MACL,qBAAaC,MAAF,IAAc;AACxB,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,eAFK;AAGLC,MAAAA,yBAHK;AAILC,MAAAA;AAJK,QAKF,wBAAQJ,MAAM,CAAEK,YAAF,CAAd,CALJ;AAMA,UAAM;AAAEC,MAAAA;AAAF,QAAmBN,MAAM,CAAEO,aAAF,CAA/B;AACA,UAAMC,sBAAsB,GAAGL,yBAAyB,EAAxD;AACA,UAAMM,sBAAsB,GAAGD,sBAAsB,CAAE,CAAF,CAArD;AACA,UAAME,OAAO,GAAGR,eAAe,CAAEO,sBAAF,CAA/B;AACA,UAAME,mBAAmB,GAAGD,OAAO,CAAEA,OAAO,CAACE,MAAR,GAAiB,CAAnB,CAAnC;AACA,UAAMC,eAAe,GAAGZ,YAAY,CAAEU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C,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGwB,yBADN;AAEC,IAAA,GAAG,EAAGtB,gBAFP;AAGC,IAAA,IAAI,EAAGF,WAAW,GAAGyB,WAAH,GAAUC,eAH7B;AAIC,IAAA,OAAO,EAAG,MAAM;AACfzB,MAAAA,cAAc,CAAI0B,SAAF,IAAiB,CAAEA,SAArB,CAAd;AACAzB,MAAAA,gBAAgB,CAAC0B,OAAjB,CAAyBC,KAAzB;AACA,KAPF;AAQC,IAAA,KAAK,EACJ7B,WAAW,GACR,cAAI,kBAAJ,CADQ,GAER,cAAI,kBAAJ;AAXL,IAPD,CATF,CADD;AAmCA;;eAEcJ,sB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tToolbarItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { next, previous } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {\n\t// When the toolbar is fixed it can be collapsed\n\tconst [ isCollapsed, setIsCollapsed ] = useState( false );\n\tconst toolbarButtonRef = useRef();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { blockType, hasParents, showParentSelector, selectedBlockClientId } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\t\treturn {\n\t\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\t\tblockType:\n\t\t\t\t\t_selectedBlockClientId &&\n\t\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\t\thasParents: parents.length,\n\t\t\t\tshowParentSelector:\n\t\t\t\t\tparentBlockType &&\n\t\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tparentBlockType,\n\t\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\t\ttrue\n\t\t\t\t\t) &&\n\t\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t\t};\n\t\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsCollapsed( false );\n\t}, [ selectedBlockClientId ] );\n\n\tif (\n\t\tblockType &&\n\t\t! hasBlockSupport( blockType, '__experimentalToolbar', true )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t\t'is-collapsed': isCollapsed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }\n\t\t\t{ isFixed && isLargeViewport && blockType && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t? 'block-editor-block-toolbar__group-expand-fixed-toolbar'\n\t\t\t\t\t\t\t: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ ToolbarButton }\n\t\t\t\t\t\tref={ toolbarButtonRef }\n\t\t\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsCollapsed( ( collapsed ) => ! collapsed );\n\t\t\t\t\t\t\ttoolbarButtonRef.current.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default BlockContextualToolbar;\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_ASPECT_RATIO_OPTIONS = void 0;
|
|
7
|
+
exports.default = AspectRatioTool;
|
|
8
|
+
|
|
9
|
+
var _element = require("@wordpress/element");
|
|
10
|
+
|
|
11
|
+
var _components = require("@wordpress/components");
|
|
12
|
+
|
|
13
|
+
var _i18n = require("@wordpress/i18n");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* WordPress dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @type {SelectControlProps[]}
|
|
25
|
+
*/
|
|
26
|
+
const DEFAULT_ASPECT_RATIO_OPTIONS = [{
|
|
27
|
+
label: (0, _i18n._x)('Original', 'Aspect ratio option for dimensions control'),
|
|
28
|
+
value: 'auto'
|
|
29
|
+
}, {
|
|
30
|
+
label: (0, _i18n._x)('Square - 1:1', 'Aspect ratio option for dimensions control'),
|
|
31
|
+
value: '1'
|
|
32
|
+
}, {
|
|
33
|
+
label: (0, _i18n._x)('Standard - 4:3', 'Aspect ratio option for dimensions control'),
|
|
34
|
+
value: '4/3'
|
|
35
|
+
}, {
|
|
36
|
+
label: (0, _i18n._x)('Portrait - 3:4', 'Aspect ratio option for dimensions control'),
|
|
37
|
+
value: '3/4'
|
|
38
|
+
}, {
|
|
39
|
+
label: (0, _i18n._x)('Classic - 3:2', 'Aspect ratio option for dimensions control'),
|
|
40
|
+
value: '3/2'
|
|
41
|
+
}, {
|
|
42
|
+
label: (0, _i18n._x)('Classic Portrait - 2:3', 'Aspect ratio option for dimensions control'),
|
|
43
|
+
value: '2/3'
|
|
44
|
+
}, {
|
|
45
|
+
label: (0, _i18n._x)('Wide - 16:9', 'Aspect ratio option for dimensions control'),
|
|
46
|
+
value: '16/9'
|
|
47
|
+
}, {
|
|
48
|
+
label: (0, _i18n._x)('Tall - 9:16', 'Aspect ratio option for dimensions control'),
|
|
49
|
+
value: '9/16'
|
|
50
|
+
}, {
|
|
51
|
+
label: (0, _i18n._x)('Custom', 'Aspect ratio option for dimensions control'),
|
|
52
|
+
value: 'custom',
|
|
53
|
+
disabled: true,
|
|
54
|
+
hidden: true
|
|
55
|
+
}];
|
|
56
|
+
/**
|
|
57
|
+
* @callback AspectRatioToolPropsOnChange
|
|
58
|
+
* @param {string} [value] New aspect ratio value.
|
|
59
|
+
* @return {void} No return.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {Object} AspectRatioToolProps
|
|
64
|
+
* @property {string} [panelId] ID of the panel this tool is associated with.
|
|
65
|
+
* @property {string} [value] Current aspect ratio value.
|
|
66
|
+
* @property {AspectRatioToolPropsOnChange} [onChange] Callback to update the aspect ratio value.
|
|
67
|
+
* @property {SelectControlProps[]} [options] Aspect ratio options.
|
|
68
|
+
* @property {string} [defaultValue] Default aspect ratio value.
|
|
69
|
+
* @property {boolean} [isShownByDefault] Whether the tool is shown by default.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
exports.DEFAULT_ASPECT_RATIO_OPTIONS = DEFAULT_ASPECT_RATIO_OPTIONS;
|
|
73
|
+
|
|
74
|
+
function AspectRatioTool({
|
|
75
|
+
panelId,
|
|
76
|
+
value,
|
|
77
|
+
onChange = () => {},
|
|
78
|
+
options = DEFAULT_ASPECT_RATIO_OPTIONS,
|
|
79
|
+
defaultValue = DEFAULT_ASPECT_RATIO_OPTIONS[0].value,
|
|
80
|
+
isShownByDefault = true
|
|
81
|
+
}) {
|
|
82
|
+
// Match the CSS default so if the value is used directly in CSS it will look correct in the control.
|
|
83
|
+
const displayValue = value !== null && value !== void 0 ? value : 'auto';
|
|
84
|
+
return (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
85
|
+
hasValue: () => displayValue !== defaultValue,
|
|
86
|
+
label: (0, _i18n.__)('Aspect ratio'),
|
|
87
|
+
onDeselect: () => onChange(undefined),
|
|
88
|
+
isShownByDefault: isShownByDefault,
|
|
89
|
+
panelId: panelId
|
|
90
|
+
}, (0, _element.createElement)(_components.SelectControl, {
|
|
91
|
+
label: (0, _i18n.__)('Aspect ratio'),
|
|
92
|
+
value: displayValue,
|
|
93
|
+
options: options,
|
|
94
|
+
onChange: onChange,
|
|
95
|
+
size: '__unstable-large',
|
|
96
|
+
__nextHasNoMarginBottom: true
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=aspect-ratio-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/dimensions-tool/aspect-ratio-tool.js"],"names":["DEFAULT_ASPECT_RATIO_OPTIONS","label","value","disabled","hidden","AspectRatioTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","undefined"],"mappings":";;;;;;;;;;AAGA;;AAIA;;AAPA;AACA;AACA;;AAOA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,4BAA4B,GAAG,CAC3C;AACCC,EAAAA,KAAK,EAAE,cAAI,UAAJ,EAAgB,4CAAhB,CADR;AAECC,EAAAA,KAAK,EAAE;AAFR,CAD2C,EAK3C;AACCD,EAAAA,KAAK,EAAE,cACN,cADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CAL2C,EAY3C;AACCD,EAAAA,KAAK,EAAE,cACN,gBADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CAZ2C,EAmB3C;AACCD,EAAAA,KAAK,EAAE,cACN,gBADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CAnB2C,EA0B3C;AACCD,EAAAA,KAAK,EAAE,cACN,eADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CA1B2C,EAiC3C;AACCD,EAAAA,KAAK,EAAE,cACN,wBADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CAjC2C,EAwC3C;AACCD,EAAAA,KAAK,EAAE,cACN,aADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CAxC2C,EA+C3C;AACCD,EAAAA,KAAK,EAAE,cACN,aADM,EAEN,4CAFM,CADR;AAKCC,EAAAA,KAAK,EAAE;AALR,CA/C2C,EAsD3C;AACCD,EAAAA,KAAK,EAAE,cAAI,QAAJ,EAAc,4CAAd,CADR;AAECC,EAAAA,KAAK,EAAE,QAFR;AAGCC,EAAAA,QAAQ,EAAE,IAHX;AAICC,EAAAA,MAAM,EAAE;AAJT,CAtD2C,CAArC;AA8DP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AAEe,SAASC,eAAT,CAA0B;AACxCC,EAAAA,OADwC;AAExCJ,EAAAA,KAFwC;AAGxCK,EAAAA,QAAQ,GAAG,MAAM,CAAE,CAHqB;AAIxCC,EAAAA,OAAO,GAAGR,4BAJ8B;AAKxCS,EAAAA,YAAY,GAAGT,4BAA4B,CAAE,CAAF,CAA5B,CAAkCE,KALT;AAMxCQ,EAAAA,gBAAgB,GAAG;AANqB,CAA1B,EAOX;AACH;AACA,QAAMC,YAAY,GAAGT,KAAH,aAAGA,KAAH,cAAGA,KAAH,GAAY,MAA9B;AAEA,SACC,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAG,MAAMS,YAAY,KAAKF,YADnC;AAEC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMF,QAAQ,CAAEK,SAAF,CAH5B;AAIC,IAAA,gBAAgB,EAAGF,gBAJpB;AAKC,IAAA,OAAO,EAAGJ;AALX,KAOC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,cAAJ,CADT;AAEC,IAAA,KAAK,EAAGK,YAFT;AAGC,IAAA,OAAO,EAAGH,OAHX;AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,IAAI,EAAG,kBALR;AAMC,IAAA,uBAAuB;AANxB,IAPD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tSelectControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @type {SelectControlProps[]}\n */\nexport const DEFAULT_ASPECT_RATIO_OPTIONS = [\n\t{\n\t\tlabel: _x( 'Original', 'Aspect ratio option for dimensions control' ),\n\t\tvalue: 'auto',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Square - 1:1',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '1',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Standard - 4:3',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '4/3',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Portrait - 3:4',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '3/4',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Classic - 3:2',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '3/2',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Classic Portrait - 2:3',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '2/3',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Wide - 16:9',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '16/9',\n\t},\n\t{\n\t\tlabel: _x(\n\t\t\t'Tall - 9:16',\n\t\t\t'Aspect ratio option for dimensions control'\n\t\t),\n\t\tvalue: '9/16',\n\t},\n\t{\n\t\tlabel: _x( 'Custom', 'Aspect ratio option for dimensions control' ),\n\t\tvalue: 'custom',\n\t\tdisabled: true,\n\t\thidden: true,\n\t},\n];\n\n/**\n * @callback AspectRatioToolPropsOnChange\n * @param {string} [value] New aspect ratio value.\n * @return {void} No return.\n */\n\n/**\n * @typedef {Object} AspectRatioToolProps\n * @property {string} [panelId] ID of the panel this tool is associated with.\n * @property {string} [value] Current aspect ratio value.\n * @property {AspectRatioToolPropsOnChange} [onChange] Callback to update the aspect ratio value.\n * @property {SelectControlProps[]} [options] Aspect ratio options.\n * @property {string} [defaultValue] Default aspect ratio value.\n * @property {boolean} [isShownByDefault] Whether the tool is shown by default.\n */\n\nexport default function AspectRatioTool( {\n\tpanelId,\n\tvalue,\n\tonChange = () => {},\n\toptions = DEFAULT_ASPECT_RATIO_OPTIONS,\n\tdefaultValue = DEFAULT_ASPECT_RATIO_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n} ) {\n\t// Match the CSS default so if the value is used directly in CSS it will look correct in the control.\n\tconst displayValue = value ?? 'auto';\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\tonDeselect={ () => onChange( undefined ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\toptions={ options }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _aspectRatioTool = _interopRequireDefault(require("./aspect-ratio-tool"));
|
|
13
|
+
|
|
14
|
+
var _scaleTool = _interopRequireDefault(require("./scale-tool"));
|
|
15
|
+
|
|
16
|
+
var _widthHeightTool = _interopRequireDefault(require("./width-height-tool"));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {Object} Dimensions
|
|
36
|
+
* @property {string} [width] CSS width property.
|
|
37
|
+
* @property {string} [height] CSS height property.
|
|
38
|
+
* @property {string} [scale] CSS object-fit property.
|
|
39
|
+
* @property {string} [aspectRatio] CSS aspect-ratio property.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @callback DimensionsControlsOnChange
|
|
44
|
+
* @param {Dimensions} nextValue
|
|
45
|
+
* @return {void}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {Object} DimensionsControlsProps
|
|
50
|
+
* @property {string} [panelId] ID of the panel that contains the controls.
|
|
51
|
+
* @property {Dimensions} [value] Current dimensions values.
|
|
52
|
+
* @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.
|
|
53
|
+
* @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.
|
|
54
|
+
* @property {SelectControlProps[]} [scaleOptions] Scale options.
|
|
55
|
+
* @property {WPUnitControlUnit[]} [unitsOptions] Units options.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Component that renders controls to edit the dimensions of an image or container.
|
|
60
|
+
*
|
|
61
|
+
* @param {DimensionsControlsProps} props The component props.
|
|
62
|
+
*
|
|
63
|
+
* @return {WPElement} The dimensions controls.
|
|
64
|
+
*/
|
|
65
|
+
function DimensionsTool({
|
|
66
|
+
panelId,
|
|
67
|
+
value = {},
|
|
68
|
+
onChange = () => {},
|
|
69
|
+
aspectRatioOptions,
|
|
70
|
+
// Default options handled by AspectRatioTool.
|
|
71
|
+
defaultAspectRatio = 'auto',
|
|
72
|
+
// Match CSS default value for aspect-ratio.
|
|
73
|
+
scaleOptions,
|
|
74
|
+
// Default options handled by ScaleTool.
|
|
75
|
+
defaultScale = 'fill',
|
|
76
|
+
// Match CSS default value for object-fit.
|
|
77
|
+
unitsOptions // Default options handled by UnitControl.
|
|
78
|
+
|
|
79
|
+
}) {
|
|
80
|
+
// Coerce undefined and CSS default values to be null.
|
|
81
|
+
const width = value.width === undefined || value.width === 'auto' ? null : value.width;
|
|
82
|
+
const height = value.height === undefined || value.height === 'auto' ? null : value.height;
|
|
83
|
+
const aspectRatio = value.aspectRatio === undefined || value.aspectRatio === 'auto' ? null : value.aspectRatio;
|
|
84
|
+
const scale = value.scale === undefined || value.scale === 'fill' ? null : value.scale; // Keep track of state internally, so when the value is cleared by means
|
|
85
|
+
// other than directly editing that field, it's easier to restore the
|
|
86
|
+
// previous value.
|
|
87
|
+
|
|
88
|
+
const [lastScale, setLastScale] = (0, _element.useState)(scale);
|
|
89
|
+
const [lastAspectRatio, setLastAspectRatio] = (0, _element.useState)(aspectRatio); // 'custom' is not a valid value for CSS aspect-ratio, but it is used in the
|
|
90
|
+
// dropdown to indicate that setting both the width and height is the same
|
|
91
|
+
// as a custom aspect ratio.
|
|
92
|
+
|
|
93
|
+
const aspectRatioValue = width && height ? 'custom' : lastAspectRatio;
|
|
94
|
+
const showScaleControl = aspectRatio || width && height;
|
|
95
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_aspectRatioTool.default, {
|
|
96
|
+
panelId: panelId,
|
|
97
|
+
options: aspectRatioOptions,
|
|
98
|
+
defaultValue: defaultAspectRatio,
|
|
99
|
+
value: aspectRatioValue,
|
|
100
|
+
onChange: nextAspectRatio => {
|
|
101
|
+
const nextValue = { ...value
|
|
102
|
+
}; // 'auto' is CSS default, so it gets treated as null.
|
|
103
|
+
|
|
104
|
+
nextAspectRatio = nextAspectRatio === 'auto' ? null : nextAspectRatio;
|
|
105
|
+
setLastAspectRatio(nextAspectRatio); // Update aspectRatio.
|
|
106
|
+
|
|
107
|
+
if (!nextAspectRatio) {
|
|
108
|
+
delete nextValue.aspectRatio;
|
|
109
|
+
} else {
|
|
110
|
+
nextValue.aspectRatio = nextAspectRatio;
|
|
111
|
+
} // Auto-update scale.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if (!nextAspectRatio) {
|
|
115
|
+
delete nextValue.scale;
|
|
116
|
+
} else if (lastScale) {
|
|
117
|
+
nextValue.scale = lastScale;
|
|
118
|
+
} else {
|
|
119
|
+
nextValue.scale = defaultScale;
|
|
120
|
+
setLastScale(defaultScale);
|
|
121
|
+
} // Auto-update width and height.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if (nextAspectRatio && width && height) {
|
|
125
|
+
delete nextValue.height;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
onChange(nextValue);
|
|
129
|
+
}
|
|
130
|
+
}), showScaleControl && (0, _element.createElement)(_scaleTool.default, {
|
|
131
|
+
panelId: panelId,
|
|
132
|
+
options: scaleOptions,
|
|
133
|
+
defaultValue: defaultScale,
|
|
134
|
+
value: lastScale,
|
|
135
|
+
onChange: nextScale => {
|
|
136
|
+
const nextValue = { ...value
|
|
137
|
+
}; // 'fill' is CSS default, so it gets treated as null.
|
|
138
|
+
|
|
139
|
+
nextScale = nextScale === 'fill' ? null : nextScale;
|
|
140
|
+
setLastScale(nextScale); // Update scale.
|
|
141
|
+
|
|
142
|
+
if (!nextScale) {
|
|
143
|
+
delete nextValue.scale;
|
|
144
|
+
} else {
|
|
145
|
+
nextValue.scale = nextScale;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
onChange(nextValue);
|
|
149
|
+
}
|
|
150
|
+
}), (0, _element.createElement)(_widthHeightTool.default, {
|
|
151
|
+
panelId: panelId,
|
|
152
|
+
units: unitsOptions,
|
|
153
|
+
value: {
|
|
154
|
+
width,
|
|
155
|
+
height
|
|
156
|
+
},
|
|
157
|
+
onChange: ({
|
|
158
|
+
width: nextWidth,
|
|
159
|
+
height: nextHeight
|
|
160
|
+
}) => {
|
|
161
|
+
const nextValue = { ...value
|
|
162
|
+
}; // 'auto' is CSS default, so it gets treated as null.
|
|
163
|
+
|
|
164
|
+
nextWidth = nextWidth === 'auto' ? null : nextWidth;
|
|
165
|
+
nextHeight = nextHeight === 'auto' ? null : nextHeight; // Update width.
|
|
166
|
+
|
|
167
|
+
if (!nextWidth) {
|
|
168
|
+
delete nextValue.width;
|
|
169
|
+
} else {
|
|
170
|
+
nextValue.width = nextWidth;
|
|
171
|
+
} // Update height.
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
if (!nextHeight) {
|
|
175
|
+
delete nextValue.height;
|
|
176
|
+
} else {
|
|
177
|
+
nextValue.height = nextHeight;
|
|
178
|
+
} // Auto-update aspectRatio.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if (nextWidth && nextHeight) {
|
|
182
|
+
delete nextValue.aspectRatio;
|
|
183
|
+
} else if (lastAspectRatio) {
|
|
184
|
+
nextValue.aspectRatio = lastAspectRatio;
|
|
185
|
+
} else {// No setting defaultAspectRatio here, because
|
|
186
|
+
// aspectRatio is optional in this scenario,
|
|
187
|
+
// unlike scale.
|
|
188
|
+
} // Auto-update scale.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if (!lastAspectRatio && !!nextWidth !== !!nextHeight) {
|
|
192
|
+
delete nextValue.scale;
|
|
193
|
+
} else if (lastScale) {
|
|
194
|
+
nextValue.scale = lastScale;
|
|
195
|
+
} else {
|
|
196
|
+
nextValue.scale = defaultScale;
|
|
197
|
+
setLastScale(defaultScale);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
onChange(nextValue);
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var _default = DimensionsTool;
|
|
206
|
+
exports.default = _default;
|
|
207
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"names":["DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","nextAspectRatio","nextValue","nextScale","nextWidth","nextHeight"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAT,CAAyB;AACxBC,EAAAA,OADwB;AAExBC,EAAAA,KAAK,GAAG,EAFgB;AAGxBC,EAAAA,QAAQ,GAAG,MAAM,CAAE,CAHK;AAIxBC,EAAAA,kBAJwB;AAIJ;AACpBC,EAAAA,kBAAkB,GAAG,MALG;AAKK;AAC7BC,EAAAA,YANwB;AAMV;AACdC,EAAAA,YAAY,GAAG,MAPS;AAOD;AACvBC,EAAAA,YARwB,CAQV;;AARU,CAAzB,EASI;AACH;AACA,QAAMC,KAAK,GACVP,KAAK,CAACO,KAAN,KAAgBC,SAAhB,IAA6BR,KAAK,CAACO,KAAN,KAAgB,MAA7C,GACG,IADH,GAEGP,KAAK,CAACO,KAHV;AAIA,QAAME,MAAM,GACXT,KAAK,CAACS,MAAN,KAAiBD,SAAjB,IAA8BR,KAAK,CAACS,MAAN,KAAiB,MAA/C,GACG,IADH,GAEGT,KAAK,CAACS,MAHV;AAIA,QAAMC,WAAW,GAChBV,KAAK,CAACU,WAAN,KAAsBF,SAAtB,IAAmCR,KAAK,CAACU,WAAN,KAAsB,MAAzD,GACG,IADH,GAEG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,SAA1C;AACAC,MAAAA,UAAU,GAAGA,UAAU,KAAK,MAAf,GAAwB,IAAxB,GAA+BA,UAA5C,CAL0D,CAO1D;;AACA,UAAK,CAAED,SAAP,EAAmB;AAClB,eAAOF,SAAS,CAACZ,KAAjB;AACA,OAFD,MAEO;AACNY,QAAAA,SAAS,CAACZ,KAAV,GAAkBc,SAAlB;AACA,OAZyD,CAc1D;;;AACA,UAAK,CAAEC,UAAP,EAAoB;AACnB,eAAOH,SAAS,CAACV,MAAjB;AACA,OAFD,MAEO;AACNU,QAAAA,SAAS,CAACV,MAAV,GAAmBa,UAAnB;AACA,OAnByD,CAqB1D;;;AACA,UAAKD,SAAS,IAAIC,UAAlB,EAA+B;AAC9B,eAAOH,SAAS,CAACT,WAAjB;AACA,OAFD,MAEO,IAAKI,eAAL,EAAuB;AAC7BK,QAAAA,SAAS,CAACT,WAAV,GAAwBI,eAAxB;AACA,OAFM,MAEA,CACN;AACA;AACA;AACA,OA9ByD,CAgC1D;;;AACA,UAAK,CAAEA,eAAF,IAAqB,CAAC,CAAEO,SAAH,KAAiB,CAAC,CAAEC,UAA9C,EAA2D;AAC1D,eAAOH,SAAS,CAACR,KAAjB;AACA,OAFD,MAEO,IAAKC,SAAL,EAAiB;AACvBO,QAAAA,SAAS,CAACR,KAAV,GAAkBC,SAAlB;AACA,OAFM,MAEA;AACNO,QAAAA,SAAS,CAACR,KAAV,GAAkBN,YAAlB;AACAQ,QAAAA,YAAY,CAAER,YAAF,CAAZ;AACA;;AAEDJ,MAAAA,QAAQ,CAAEkB,SAAF,CAAR;AACA;AA/CF,IAjED,CADD;AAqHA;;eAEcrB,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {WPElement} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ScaleTool;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The descriptions are purposely made generic as object-fit could be used for
|
|
24
|
+
* any replaced element. Provide your own set of options if you need different
|
|
25
|
+
* help text or labels.
|
|
26
|
+
*
|
|
27
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element
|
|
28
|
+
*
|
|
29
|
+
* @type {SelectControlProps[]}
|
|
30
|
+
*/
|
|
31
|
+
const DEFAULT_SCALE_OPTIONS = [{
|
|
32
|
+
value: 'fill',
|
|
33
|
+
label: (0, _i18n._x)('Fill', 'Scale option for dimensions control'),
|
|
34
|
+
help: (0, _i18n.__)('Fill the space by stretching the content.')
|
|
35
|
+
}, {
|
|
36
|
+
value: 'contain',
|
|
37
|
+
label: (0, _i18n._x)('Contain', 'Scale option for dimensions control'),
|
|
38
|
+
help: (0, _i18n.__)('Fit the content to the space without clipping.')
|
|
39
|
+
}, {
|
|
40
|
+
value: 'cover',
|
|
41
|
+
label: (0, _i18n._x)('Cover', 'Scale option for dimensions control'),
|
|
42
|
+
help: (0, _i18n.__)("Fill the space by clipping what doesn't fit.")
|
|
43
|
+
}, {
|
|
44
|
+
value: 'none',
|
|
45
|
+
label: (0, _i18n._x)('None', 'Scale option for dimensions control'),
|
|
46
|
+
help: (0, _i18n.__)('Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding.')
|
|
47
|
+
}, {
|
|
48
|
+
value: 'scale-down',
|
|
49
|
+
label: (0, _i18n._x)('Scale down', 'Scale option for dimensions control'),
|
|
50
|
+
help: (0, _i18n.__)('Scale down the content to fit the space if it is too big. Content that is too small will have additional padding.')
|
|
51
|
+
}];
|
|
52
|
+
/**
|
|
53
|
+
* @callback ScaleToolPropsOnChange
|
|
54
|
+
* @param {string} nextValue New scale value.
|
|
55
|
+
* @return {void}
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @typedef {Object} ScaleToolProps
|
|
60
|
+
* @property {string} [panelId] ID of the panel that contains the controls.
|
|
61
|
+
* @property {string} [value] Current scale value.
|
|
62
|
+
* @property {ScaleToolPropsOnChange} [onChange] Callback to update the scale value.
|
|
63
|
+
* @property {SelectControlProps[]} [options] Scale options.
|
|
64
|
+
* @property {string} [defaultValue] Default scale value.
|
|
65
|
+
* @property {boolean} [showControl=true] Whether to show the control.
|
|
66
|
+
* @property {boolean} [isShownByDefault=true] Whether the tool panel is shown by default.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A tool to select the CSS object-fit property for the image.
|
|
71
|
+
*
|
|
72
|
+
* @param {ScaleToolProps} props
|
|
73
|
+
*
|
|
74
|
+
* @return {import('@wordpress/element').WPElement} The scale tool.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
function ScaleTool({
|
|
78
|
+
panelId,
|
|
79
|
+
value,
|
|
80
|
+
onChange,
|
|
81
|
+
options = DEFAULT_SCALE_OPTIONS,
|
|
82
|
+
defaultValue = DEFAULT_SCALE_OPTIONS[0].value,
|
|
83
|
+
isShownByDefault = true
|
|
84
|
+
}) {
|
|
85
|
+
// Match the CSS default so if the value is used directly in CSS it will look correct in the control.
|
|
86
|
+
const displayValue = value !== null && value !== void 0 ? value : 'fill';
|
|
87
|
+
const scaleHelp = (0, _element.useMemo)(() => {
|
|
88
|
+
return options.reduce((acc, option) => {
|
|
89
|
+
acc[option.value] = option.help;
|
|
90
|
+
return acc;
|
|
91
|
+
}, {});
|
|
92
|
+
}, [options]);
|
|
93
|
+
return (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
94
|
+
label: (0, _i18n.__)('Scale'),
|
|
95
|
+
isShownByDefault: isShownByDefault,
|
|
96
|
+
hasValue: () => displayValue !== defaultValue,
|
|
97
|
+
onDeselect: () => onChange(defaultValue),
|
|
98
|
+
panelId: panelId
|
|
99
|
+
}, (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
|
|
100
|
+
label: (0, _i18n.__)('Scale'),
|
|
101
|
+
isBlock: true,
|
|
102
|
+
help: scaleHelp[displayValue],
|
|
103
|
+
value: displayValue,
|
|
104
|
+
onChange: onChange,
|
|
105
|
+
__nextHasNoMarginBottom: true
|
|
106
|
+
}, options.map(option => (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
107
|
+
key: option.value,
|
|
108
|
+
...option
|
|
109
|
+
}))));
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=scale-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/dimensions-tool/scale-tool.js"],"names":["DEFAULT_SCALE_OPTIONS","value","label","help","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","reduce","acc","option","map"],"mappings":";;;;;;;AAQA;;AALA;;AAMA;;AATA;AACA;AACA;;AASA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAC7B;AACCC,EAAAA,KAAK,EAAE,MADR;AAECC,EAAAA,KAAK,EAAE,cAAI,MAAJ,EAAY,qCAAZ,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,2CAAJ;AAHP,CAD6B,EAM7B;AACCF,EAAAA,KAAK,EAAE,SADR;AAECC,EAAAA,KAAK,EAAE,cAAI,SAAJ,EAAe,qCAAf,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,gDAAJ;AAHP,CAN6B,EAW7B;AACCF,EAAAA,KAAK,EAAE,OADR;AAECC,EAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,qCAAb,CAFR;AAGCC,EAAAA,IAAI,EAAE,cAAI,8CAAJ;AAHP,CAX6B,EAgB7B;AACCF,EAAAA,KAAK,EAAE,MADR;AAECC,EAAAA,KAAK,EAAE,cAAI,MAAJ,EAAY,qCAAZ,CAFR;AAGCC,EAAAA,IAAI,EAAE,cACL,iJADK;AAHP,CAhB6B,EAuB7B;AACCF,EAAAA,KAAK,EAAE,YADR;AAECC,EAAAA,KAAK,EAAE,cAAI,YAAJ,EAAkB,qCAAlB,CAFR;AAGCC,EAAAA,IAAI,EAAE,cACL,mHADK;AAHP,CAvB6B,CAA9B;AAgCA;AACA;AACA;AACA;AACA;;A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GAAG,EAAGA,MAAM,CAACb,KADd;AAAA,OAEMa;AAFN,IADC,CARH,CAPD,CADD;AAyBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * The descriptions are purposely made generic as object-fit could be used for\n * any replaced element. Provide your own set of options if you need different\n * help text or labels.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element\n *\n * @type {SelectControlProps[]}\n */\nconst DEFAULT_SCALE_OPTIONS = [\n\t{\n\t\tvalue: 'fill',\n\t\tlabel: _x( 'Fill', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fill the space by stretching the content.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fit the content to the space without clipping.' ),\n\t},\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( \"Fill the space by clipping what doesn't fit.\" ),\n\t},\n\t{\n\t\tvalue: 'none',\n\t\tlabel: _x( 'None', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding.'\n\t\t),\n\t},\n\t{\n\t\tvalue: 'scale-down',\n\t\tlabel: _x( 'Scale down', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Scale down the content to fit the space if it is too big. Content that is too small will have additional padding.'\n\t\t),\n\t},\n];\n\n/**\n * @callback ScaleToolPropsOnChange\n * @param {string} nextValue New scale value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} ScaleToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {string} [value] Current scale value.\n * @property {ScaleToolPropsOnChange} [onChange] Callback to update the scale value.\n * @property {SelectControlProps[]} [options] Scale options.\n * @property {string} [defaultValue] Default scale value.\n * @property {boolean} [showControl=true] Whether to show the control.\n * @property {boolean} [isShownByDefault=true] Whether the tool panel is shown by default.\n */\n\n/**\n * A tool to select the CSS object-fit property for the image.\n *\n * @param {ScaleToolProps} props\n *\n * @return {import('@wordpress/element').WPElement} The scale tool.\n */\nexport default function ScaleTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SCALE_OPTIONS,\n\tdefaultValue = DEFAULT_SCALE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n} ) {\n\t// Match the CSS default so if the value is used directly in CSS it will look correct in the control.\n\tconst displayValue = value ?? 'fill';\n\n\tconst scaleHelp = useMemo( () => {\n\t\treturn options.reduce( ( acc, option ) => {\n\t\t\tacc[ option.value ] = option.help;\n\t\t\treturn acc;\n\t\t}, {} );\n\t}, [ options ] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Scale' ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Scale' ) }\n\t\t\t\tisBlock\n\t\t\t\thelp={ scaleHelp[ displayValue ] }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\tonChange={ onChange }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t>\n\t\t\t\t{ options.map( ( option ) => (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\t{ ...option }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ToggleGroupControl>\n\t\t</ToolsPanelItem>\n\t);\n}\n"]}
|