@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/inserter-draggable-blocks/index.js"],"names":["InserterDraggableBlocks","isEnabled","blocks","icon","children","isPattern","transferData","type","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter-draggable-blocks/index.js"],"names":["InserterDraggableBlocks","isEnabled","blocks","icon","children","isPattern","transferData","type","blockTypeIcon","select","getBlockType","blocksStore","length","name","event","dataTransfer","setData","onDraggableStart","onDraggableEnd","draggable","onDragStart","undefined","onDragEnd"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,uBAAuB,GAAG,CAAE;AACjCC,EAAAA,SADiC;AAEjCC,EAAAA,MAFiC;AAGjCC,EAAAA,IAHiC;AAIjCC,EAAAA,QAJiC;AAKjCC,EAAAA;AALiC,CAAF,KAMzB;AACN,QAAMC,YAAY,GAAG;AACpBC,IAAAA,IAAI,EAAE,UADc;AAEpBL,IAAAA;AAFoB,GAArB;AAKA,QAAMM,aAAa,GAAG,qBACnBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAmBD,MAAM,CAAEE,aAAF,CAA/B;AACA,WACCT,MAAM,CAACU,MAAP,KAAkB,CAAlB,IAAuBF,YAAY,CAAER,MAAM,CAAE,CAAF,CAAN,CAAYW,IAAd,CAAZ,EAAkCV,IAD1D;AAGA,GANoB,EAOrB,CAAED,MAAF,CAPqB,CAAtB;AAUA,SACC,4BAAC,qBAAD;AACC,IAAA,8BAA8B,EAAC,WADhC;AAEC,IAAA,YAAY,EAAGI,YAFhB;AAGC,IAAA,WAAW,EAAKQ,KAAF,IAAa;AAC1BA,MAAAA,KAAK,CAACC,YAAN,CAAmBC,OAAnB,CAA4B,WAA5B,EAAyC,uBAAWd,MAAX,CAAzC;AACA,KALF;AAMC,IAAA,2BAA2B,EAC1B,4BAAC,sBAAD;AACC,MAAA,KAAK,EAAGA,MAAM,CAACU,MADhB;AAEC,MAAA,IAAI,EAAGT,IAAI,IAAM,CAAEE,SAAF,IAAeG,aAFjC;AAGC,MAAA,SAAS,EAAGH;AAHb;AAPF,KAcG,CAAE;AAAEY,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAF,KAA4C;AAC7C,WAAOd,QAAQ,CAAE;AAChBe,MAAAA,SAAS,EAAElB,SADK;AAEhBmB,MAAAA,WAAW,EAAEnB,SAAS,GAAGgB,gBAAH,GAAsBI,SAF5B;AAGhBC,MAAAA,SAAS,EAAErB,SAAS,GAAGiB,cAAH,GAAoBG;AAHxB,KAAF,CAAf;AAKA,GApBF,CADD;AAwBA,CA9CD;;eAgDerB,uB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Draggable } from '@wordpress/components';\nimport { serialize, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from '../block-draggable/draggable-chip';\n\nconst InserterDraggableBlocks = ( {\n\tisEnabled,\n\tblocks,\n\ticon,\n\tchildren,\n\tisPattern,\n} ) => {\n\tconst transferData = {\n\t\ttype: 'inserter',\n\t\tblocks,\n\t};\n\n\tconst blockTypeIcon = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\treturn (\n\t\t\t\tblocks.length === 1 && getBlockType( blocks[ 0 ].name )?.icon\n\t\t\t);\n\t\t},\n\t\t[ blocks ]\n\t);\n\n\treturn (\n\t\t<Draggable\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\tevent.dataTransfer.setData( 'text/html', serialize( blocks ) );\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip\n\t\t\t\t\tcount={ blocks.length }\n\t\t\t\t\ticon={ icon || ( ! isPattern && blockTypeIcon ) }\n\t\t\t\t\tisPattern={ isPattern }\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: isEnabled,\n\t\t\t\t\tonDragStart: isEnabled ? onDraggableStart : undefined,\n\t\t\t\t\tonDragEnd: isEnabled ? onDraggableEnd : undefined,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default InserterDraggableBlocks;\n"]}
|
|
@@ -17,7 +17,7 @@ const CREATE_TYPE = '__CREATE__';
|
|
|
17
17
|
exports.CREATE_TYPE = CREATE_TYPE;
|
|
18
18
|
const TEL_TYPE = 'tel';
|
|
19
19
|
exports.TEL_TYPE = TEL_TYPE;
|
|
20
|
-
const URL_TYPE = '
|
|
20
|
+
const URL_TYPE = 'link';
|
|
21
21
|
exports.URL_TYPE = URL_TYPE;
|
|
22
22
|
const MAILTO_TYPE = 'mailto';
|
|
23
23
|
exports.MAILTO_TYPE = MAILTO_TYPE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,YAApB;;AACA,MAAMC,QAAQ,GAAG,KAAjB;;AACA,MAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,YAApB;;AACA,MAAMC,QAAQ,GAAG,KAAjB;;AACA,MAAMC,QAAQ,GAAG,MAAjB;;AACA,MAAMC,WAAW,GAAG,QAApB;;AACA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;;AAOA,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAE,cAAI,iBAAJ;AAFR,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'link';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
|
|
@@ -282,7 +282,8 @@ function LinkControl({
|
|
|
282
282
|
const currentUrlInputValue = propInputValue || internalControlValue?.url || '';
|
|
283
283
|
const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length;
|
|
284
284
|
const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
|
|
285
|
-
const showSettings = !!settings?.length
|
|
285
|
+
const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
|
|
286
|
+
const showActions = isEditingLink && hasLinkValue; // Only show text control once a URL value has been committed
|
|
286
287
|
// and it isn't just empty whitespace.
|
|
287
288
|
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
|
|
288
289
|
|
|
@@ -300,7 +301,16 @@ function LinkControl({
|
|
|
300
301
|
'block-editor-link-control__search-input-wrapper': true,
|
|
301
302
|
'has-text-control': showTextControl
|
|
302
303
|
})
|
|
303
|
-
}, (0, _element.createElement)(
|
|
304
|
+
}, showTextControl && (0, _element.createElement)(_components.TextControl, {
|
|
305
|
+
__nextHasNoMarginBottom: true,
|
|
306
|
+
ref: textInputRef,
|
|
307
|
+
className: "block-editor-link-control__field block-editor-link-control__text-content",
|
|
308
|
+
label: (0, _i18n.__)('Text'),
|
|
309
|
+
value: internalControlValue?.title,
|
|
310
|
+
onChange: setInternalTextInputValue,
|
|
311
|
+
onKeyDown: handleSubmitWithEnter,
|
|
312
|
+
size: "__unstable-large"
|
|
313
|
+
}), (0, _element.createElement)(_searchInput.default, {
|
|
304
314
|
currentLink: value,
|
|
305
315
|
className: "block-editor-link-control__field block-editor-link-control__search-input",
|
|
306
316
|
placeholder: searchInputPlaceholder,
|
|
@@ -315,15 +325,7 @@ function LinkControl({
|
|
|
315
325
|
suggestionsQuery: suggestionsQuery,
|
|
316
326
|
withURLSuggestion: !noURLSuggestion,
|
|
317
327
|
createSuggestionButtonText: createSuggestionButtonText,
|
|
318
|
-
|
|
319
|
-
}), showTextControl && (0, _element.createElement)(_components.TextControl, {
|
|
320
|
-
__nextHasNoMarginBottom: true,
|
|
321
|
-
ref: textInputRef,
|
|
322
|
-
className: "block-editor-link-control__field block-editor-link-control__text-content",
|
|
323
|
-
label: (0, _i18n.__)('Text'),
|
|
324
|
-
value: internalControlValue?.title,
|
|
325
|
-
onChange: setInternalTextInputValue,
|
|
326
|
-
onKeyDown: handleSubmitWithEnter
|
|
328
|
+
hideLabelFromVision: !showTextControl
|
|
327
329
|
})), errorMessage && (0, _element.createElement)(_components.Notice, {
|
|
328
330
|
className: "block-editor-link-control__search-error",
|
|
329
331
|
status: "error",
|
|
@@ -336,16 +338,16 @@ function LinkControl({
|
|
|
336
338
|
hasRichPreviews: hasRichPreviews,
|
|
337
339
|
hasUnlinkControl: shownUnlinkControl,
|
|
338
340
|
onRemove: onRemove
|
|
339
|
-
}),
|
|
341
|
+
}), showSettings && (0, _element.createElement)("div", {
|
|
340
342
|
className: "block-editor-link-control__tools"
|
|
341
|
-
},
|
|
343
|
+
}, !currentInputIsEmpty && (0, _element.createElement)(_settingsDrawer.default, {
|
|
342
344
|
settingsOpen: settingsOpen,
|
|
343
345
|
setSettingsOpen: setSettingsOpen
|
|
344
346
|
}, (0, _element.createElement)(_settings.default, {
|
|
345
347
|
value: internalControlValue,
|
|
346
348
|
settings: settings,
|
|
347
349
|
onChange: createSetInternalSettingValueHandler(settingsKeys)
|
|
348
|
-
})), (0, _element.createElement)("div", {
|
|
350
|
+
}))), showActions && (0, _element.createElement)("div", {
|
|
349
351
|
className: "block-editor-link-control__search-actions"
|
|
350
352
|
}, (0, _element.createElement)(_components.Button, {
|
|
351
353
|
variant: "primary",
|
|
@@ -355,7 +357,7 @@ function LinkControl({
|
|
|
355
357
|
}, (0, _i18n.__)('Save')), (0, _element.createElement)(_components.Button, {
|
|
356
358
|
variant: "tertiary",
|
|
357
359
|
onClick: handleCancel
|
|
358
|
-
}, (0, _i18n.__)('Cancel')))
|
|
360
|
+
}, (0, _i18n.__)('Cancel'))), renderControlBottom && renderControlBottom());
|
|
359
361
|
}
|
|
360
362
|
|
|
361
363
|
LinkControl.ViewerFill = _viewerSlot.ViewerFill;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","LinkControl","searchInputPlaceholder","value","settings","DEFAULT_LINK_SETTINGS","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focus","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","ENTER","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showTextControl","isEditing","isDisabled","ViewerFill"],"mappings":";;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,WAAT,CAAsB;AACrBC,EAAAA,sBADqB;AAErBC,EAAAA,KAFqB;AAGrBC,EAAAA,QAAQ,GAAGC,gCAHU;AAIrBC,EAAAA,QAAQ,GAAGN,IAJU;AAKrBO,EAAAA,QALqB;AAMrBC,EAAAA,QANqB;AAOrBC,EAAAA,aAAa,GAAG,KAPK;AAQrBC,EAAAA,eAAe,GAAG,IARG;AASrBC,EAAAA,sBATqB;AAUrBC,EAAAA,kBAVqB;AAWrBC,EAAAA,gBAXqB;AA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IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGsD,UAAU,GAAGlF,IAAH,GAAUmE,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBe;AAJjB,KAMG,cAAI,MAAJ,CANH,CADD,EASC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGN;AAArC,KACG,cAAI,QAAJ,CADH,CATD,CAhBD,CA1EF,EA0GGtD,mBAAmB,IAAIA,mBAAmB,EA1G7C,CADD;AA8GA;;AAEDrB,WAAW,CAACkF,UAAZ,GAAyBA,sBAAzB;eAEelF,W","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ showSettings && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","LinkControl","searchInputPlaceholder","value","settings","DEFAULT_LINK_SETTINGS","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focus","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","ENTER","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showActions","showTextControl","isEditing","isDisabled","ViewerFill"],"mappings":";;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,WAAT,CAAsB;AACrBC,EAAAA,sBADqB;AAErBC,EAAAA,KAFqB;AAGrBC,EAAAA,QAAQ,GAAGC,gCAHU;AAIrBC,EAAAA,QAAQ,GAAGN,IAJU;AAKrBO,EAAAA,QALqB;AAMrBC,EAAAA,QANqB;AAOrBC,EAAAA,aAAa,GAAG,KAPK;AAQrBC,EAAAA,eAAe,GAAG,IARG;AASrBC,EAAAA,sBATqB;AAUrBC,EAAAA,kBAVqB;AAWrBC,EAAAA,gBAXqB;AAYrBC,EAAAA,oBAZqB;AAarBC,EAAAA,UAAU,EAAEC,cAAc,GAAG,EAbR;AAcrBC,EAAAA,gBAAgB,GAAG,EAdE;AAerBC,EAAAA,eAAe,GAAG,KAfG;AAgBrBC,EAAAA,0BAhBqB;AAiBrBC,EAAAA,eAAe,GAAG,KAjBG;AAkBrBC,E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AH,GAAUmE,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBgB;AAJjB,KAMG,cAAI,MAAJ,CANH,CADD,EASC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGP;AAArC,KACG,cAAI,QAAJ,CADH,CATD,CA9FF,EA6GGtD,mBAAmB,IAAIA,mBAAmB,EA7G7C,CADD;AAiHA;;AAEDrB,WAAW,CAACmF,UAAZ,GAAyBA,sBAAzB;eAEenF,W","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,18 +7,12 @@ exports.default = exports.LinkControlSearchCreate = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
9
|
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _i18n = require("@wordpress/i18n");
|
|
15
11
|
|
|
16
12
|
var _components = require("@wordpress/components");
|
|
17
13
|
|
|
18
14
|
var _icons = require("@wordpress/icons");
|
|
19
15
|
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
16
|
/**
|
|
25
17
|
* WordPress dependencies
|
|
26
18
|
*/
|
|
@@ -28,7 +20,6 @@ const LinkControlSearchCreate = ({
|
|
|
28
20
|
searchTerm,
|
|
29
21
|
onClick,
|
|
30
22
|
itemProps,
|
|
31
|
-
isSelected,
|
|
32
23
|
buttonText
|
|
33
24
|
}) => {
|
|
34
25
|
if (!searchTerm) {
|
|
@@ -47,19 +38,12 @@ const LinkControlSearchCreate = ({
|
|
|
47
38
|
});
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
return (0, _element.createElement)(_components.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
return (0, _element.createElement)(_components.MenuItem, { ...itemProps,
|
|
42
|
+
iconPosition: "left",
|
|
43
|
+
icon: _icons.plus,
|
|
44
|
+
className: "block-editor-link-control__search-item",
|
|
54
45
|
onClick: onClick
|
|
55
|
-
},
|
|
56
|
-
className: "block-editor-link-control__search-item-icon",
|
|
57
|
-
icon: _icons.plus
|
|
58
|
-
}), (0, _element.createElement)("span", {
|
|
59
|
-
className: "block-editor-link-control__search-item-header"
|
|
60
|
-
}, (0, _element.createElement)("span", {
|
|
61
|
-
className: "block-editor-link-control__search-item-title"
|
|
62
|
-
}, text)));
|
|
46
|
+
}, text);
|
|
63
47
|
};
|
|
64
48
|
|
|
65
49
|
exports.LinkControlSearchCreate = LinkControlSearchCreate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["LinkControlSearchCreate","searchTerm","onClick","itemProps","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["LinkControlSearchCreate","searchTerm","onClick","itemProps","buttonText","text","mark","plus"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AANA;AACA;AACA;AAMO,MAAMA,uBAAuB,GAAG,CAAE;AACxCC,EAAAA,UADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA;AAJwC,CAAF,KAKhC;AACN,MAAK,CAAEH,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAII,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEH,UAAF,CADb,GAEGG,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAG,uCACN;AACC;AACA,kBAAI,yBAAJ,CAFD,EAGCJ,UAHD,CADM,EAMN;AAAEK,MAAAA,IAAI,EAAE;AAAR,KANM,CAAP;AAQA;;AAED,SACC,4BAAC,oBAAD,OACMH,SADN;AAEC,IAAA,YAAY,EAAC,MAFd;AAGC,IAAA,IAAI,EAAGI,WAHR;AAIC,IAAA,SAAS,EAAC,wCAJX;AAKC,IAAA,OAAO,EAAGL;AALX,KAOGG,IAPH,CADD;AAWA,CAtCM;;;eAwCQL,uB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext =\n\t\t\ttypeof buttonText === 'function'\n\t\t\t\t? buttonText( searchTerm )\n\t\t\t\t: buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={ plus }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ text }\n\t\t</MenuItem>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
|
|
@@ -60,7 +60,7 @@ const LinkControlSearchInput = (0, _element.forwardRef)(({
|
|
|
60
60
|
suggestionsQuery = {},
|
|
61
61
|
withURLSuggestion = true,
|
|
62
62
|
createSuggestionButtonText,
|
|
63
|
-
|
|
63
|
+
hideLabelFromVision = false
|
|
64
64
|
}, ref) => {
|
|
65
65
|
const genericSearchHandler = (0, _useSearchHandler.default)(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
|
|
66
66
|
const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
|
|
@@ -122,15 +122,15 @@ const LinkControlSearchInput = (0, _element.forwardRef)(({
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
const inputClasses = (0, _classnames.default)(className, {
|
|
126
|
-
'has-no-label': !useLabel
|
|
125
|
+
const inputClasses = (0, _classnames.default)(className, {// 'has-no-label': ! hideLabelFromVision,
|
|
127
126
|
});
|
|
128
127
|
return (0, _element.createElement)("div", {
|
|
129
128
|
className: "block-editor-link-control__search-input-container"
|
|
130
129
|
}, (0, _element.createElement)(_.URLInput, {
|
|
131
130
|
disableSuggestions: currentLink?.url === value,
|
|
132
131
|
__nextHasNoMarginBottom: true,
|
|
133
|
-
label:
|
|
132
|
+
label: (0, _i18n.__)('Link'),
|
|
133
|
+
hideLabelFromVision: hideLabelFromVision,
|
|
134
134
|
className: inputClasses,
|
|
135
135
|
value: value,
|
|
136
136
|
onChange: onInputChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","ref","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","CREATE_TYPE","type","title","url","e","Object","keys","length","id","restLinkProps","inputClasses","event","hasSuggestion","trim","preventDefault"],"mappings":";;;;;;;;;AAQA;;AALA;;AAIA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAEA;AACA;AACA;;AAKA;AACA;AACA;AAMA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAhC;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,sBAAsB,GAAG,yBAC9B,CACC;AACCC,EAAAA,KADD;AAECC,EAAAA,QAFD;AAGCC,EAAAA,WAAW,GAAG,EAHf;AAICC,EAAAA,SAAS,GAAG,IAJb;AAKCC,EAAAA,WAAW,GAAG,IALf;AAMCC,EAAAA,oBAAoB,GAAG,KANxB;AAOCC,EAAAA,kBAAkB,GAAGR,IAPtB;AAQCS,EAAAA,QAAQ,GAAGT,IARZ;AASCU,EAAAA,QAAQ,GAAGV,IATZ;AAUCW,EAAAA,eAAe,GAAG,IAVnB;AAWCC,EAAAA,iBAAiB,GAAKC,KAAF,IACnB,4BAAC,sBAAD,OAA+BA;AAA/B,IAZF;AAcCC,EAAAA,gBAAgB,GAAG,IAdpB;AAeCC,EAAA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CAAoC,EACnCP,sBAfF;AAiBC,IAAA,QAAQ,EAAG,CAAEa,UAAF,EAAcgB,KAAd,KAAyB;AACnC,YAAMC,aAAa,GAAGjB,UAAU,IAAIJ,iBAApC,CADmC,CAGnC;AACA;;AACA,UAAK,CAAEqB,aAAF,IAAmB,CAAE5C,KAAK,EAAE6C,IAAP,IAAeN,MAAzC,EAAkD;AACjDI,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNhB,QAAAA,oBAAoB,CACnBc,aAAa,IAAI;AAAET,UAAAA,GAAG,EAAEnC;AAAP,SADE,CAApB;AAGA;AACD,KA7BF;AA8BC,IAAA,GAAG,EAAGmB;AA9BP,IADD,EAiCGlB,QAjCH,CADD;AAqCA,CAxI6B,CAA/B;eA2IeF,sB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst inputClasses = classnames( className, {\n\t\t\t// 'has-no-label': ! hideLabelFromVision,\n\t\t} );\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ inputClasses }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type url' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions={ true }\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tref={ ref }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,10 +7,6 @@ exports.default = exports.LinkControlSearchItem = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
9
|
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _url = require("@wordpress/url");
|
|
15
|
-
|
|
16
10
|
var _i18n = require("@wordpress/i18n");
|
|
17
11
|
|
|
18
12
|
var _components = require("@wordpress/components");
|
|
@@ -21,9 +15,7 @@ var _icons = require("@wordpress/icons");
|
|
|
21
15
|
|
|
22
16
|
var _dom = require("@wordpress/dom");
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
* External dependencies
|
|
26
|
-
*/
|
|
18
|
+
var _url = require("@wordpress/url");
|
|
27
19
|
|
|
28
20
|
/**
|
|
29
21
|
* WordPress dependencies
|
|
@@ -61,36 +53,27 @@ function SearchItemIcon({
|
|
|
61
53
|
const LinkControlSearchItem = ({
|
|
62
54
|
itemProps,
|
|
63
55
|
suggestion,
|
|
64
|
-
|
|
56
|
+
searchTerm,
|
|
65
57
|
onClick,
|
|
66
58
|
isURL = false,
|
|
67
|
-
searchTerm = '',
|
|
68
59
|
shouldShowType = false
|
|
69
60
|
}) => {
|
|
70
|
-
|
|
61
|
+
const info = isURL ? (0, _i18n.__)('Press ENTER to add this link') : (0, _url.filterURLForDisplay)((0, _url.safeDecodeURI)(suggestion?.url));
|
|
62
|
+
return (0, _element.createElement)(_components.MenuItem, { ...itemProps,
|
|
63
|
+
info: info,
|
|
64
|
+
iconPosition: "left",
|
|
65
|
+
icon: (0, _element.createElement)(SearchItemIcon, {
|
|
66
|
+
suggestion: suggestion,
|
|
67
|
+
isURL: isURL
|
|
68
|
+
}),
|
|
71
69
|
onClick: onClick,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'is-url': isURL,
|
|
75
|
-
'is-entity': !isURL
|
|
76
|
-
})
|
|
77
|
-
}, (0, _element.createElement)(SearchItemIcon, {
|
|
78
|
-
suggestion: suggestion,
|
|
79
|
-
isURL: isURL
|
|
80
|
-
}), (0, _element.createElement)("span", {
|
|
81
|
-
className: "block-editor-link-control__search-item-header"
|
|
82
|
-
}, (0, _element.createElement)("span", {
|
|
83
|
-
className: "block-editor-link-control__search-item-title"
|
|
70
|
+
shortcut: shouldShowType && getVisualTypeName(suggestion),
|
|
71
|
+
className: "block-editor-link-control__search-item"
|
|
84
72
|
}, (0, _element.createElement)(_components.TextHighlight // The component expects a plain text string.
|
|
85
73
|
, {
|
|
86
74
|
text: (0, _dom.__unstableStripHTML)(suggestion.title),
|
|
87
75
|
highlight: searchTerm
|
|
88
|
-
}))
|
|
89
|
-
"aria-hidden": !isURL,
|
|
90
|
-
className: "block-editor-link-control__search-item-info"
|
|
91
|
-
}, !isURL && ((0, _url.filterURLForDisplay)((0, _url.safeDecodeURI)(suggestion.url)) || ''), isURL && (0, _i18n.__)('Press ENTER to add this link'))), shouldShowType && suggestion.type && (0, _element.createElement)("span", {
|
|
92
|
-
className: "block-editor-link-control__search-item-type"
|
|
93
|
-
}, getVisualTypeName(suggestion)));
|
|
76
|
+
}));
|
|
94
77
|
};
|
|
95
78
|
|
|
96
79
|
exports.LinkControlSearchItem = LinkControlSearchItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"names":["ICONS_MAP","post","postList","page","post_tag","tag","category","attachment","file","SearchItemIcon","isURL","suggestion","icon","globe","type","LinkControlSearchItem","itemProps","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"names":["ICONS_MAP","post","postList","page","post_tag","tag","category","attachment","file","SearchItemIcon","isURL","suggestion","icon","globe","type","LinkControlSearchItem","itemProps","searchTerm","onClick","shouldShowType","info","url","getVisualTypeName","title","isFrontPage"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AACA;;AAfA;AACA;AACA;AAeA,MAAMA,SAAS,GAAG;AACjBC,EAAAA,IAAI,EAAEC,eADW;AAEjBC,EAAAA,IAAI,EAAJA,WAFiB;AAGjBC,EAAAA,QAAQ,EAAEC,UAHO;AAIjBC,EAAAA,QAAQ,EAARA,eAJiB;AAKjBC,EAAAA,UAAU,EAAEC;AALK,CAAlB;;AAQA,SAASC,cAAT,CAAyB;AAAEC,EAAAA,KAAF;AAASC,EAAAA;AAAT,CAAzB,EAAiD;AAChD,MAAIC,IAAI,GAAG,IAAX;;AAEA,MAAKF,KAAL,EAAa;AACZE,IAAAA,IAAI,GAAGC,YAAP;AACA,GAFD,MAEO,IAAKF,UAAU,CAACG,IAAX,IAAmBd,SAAxB,EAAoC;AAC1CY,IAAAA,IAAI,GAAGZ,SAAS,CAAEW,UAAU,CAACG,IAAb,CAAhB;AACA;;AAED,MAAKF,IAAL,EAAY;AACX,WACC,4BAAC,WAAD;AACC,MAAA,SAAS,EAAC,6CADX;AAEC,MAAA,IAAI,EAAGA;AAFR,MADD;AAMA;;AAED,SAAO,IAAP;AACA;;AAEM,MAAMG,qBAAqB,GAAG,CAAE;AACtCC,EAAAA,SADsC;AAEtCL,EAAAA,UAFsC;AAGtCM,EAAAA,UAHsC;AAItCC,EAAAA,OAJsC;AAKtCR,EAAAA,KAAK,GAAG,KAL8B;AAMtCS,EAAAA,cAAc,GAAG;AANqB,CAAF,KAO9B;AACN,QAAMC,IAAI,GAAGV,KAAK,GACf,cAAI,8BAAJ,CADe,GAEf,8BAAqB,wBAAeC,UAAU,EAAEU,GAA3B,CAArB,CAFH;AAIA,SACC,4BAAC,oBAAD,OACML,SADN;AAEC,IAAA,IAAI,EAAGI,IAFR;AAGC,IAAA,YAAY,EAAC,MAHd;AAIC,IAAA,IAAI,EACH,4BAAC,cAAD;AAAgB,MAAA,UAAU,EAAGT,UAA7B;AAA0C,MAAA,KAAK,EAAGD;AAAlD,MALF;AAOC,IAAA,OAAO,EAAGQ,OAPX;AAQC,IAAA,QAAQ,EAAGC,cAAc,IAAIG,iBAAiB,CAAEX,UAAF,CAR/C;AASC,IAAA,SAAS,EAAC;AATX,KAWC,4BAAC,yBAAD,CACC;AADD;AAEC,IAAA,IAAI,EAAG,8BAAWA,UAAU,CAACY,KAAtB,CAFR;AAGC,IAAA,SAAS,EAAGN;AAHb,IAXD,CADD;AAmBA,CA/BM;;;;AAiCP,SAASK,iBAAT,CAA4BX,UAA5B,EAAyC;AACxC,MAAKA,UAAU,CAACa,WAAhB,EAA8B;AAC7B,WAAO,YAAP;AACA,GAHuC,CAKxC;;;AACA,SAAOb,UAAU,CAACG,IAAX,KAAoB,UAApB,GAAiC,KAAjC,GAAyCH,UAAU,CAACG,IAA3D;AACA;;eAEcC,qB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem, TextHighlight } from '@wordpress/components';\nimport {\n\tIcon,\n\tglobe,\n\tpage,\n\ttag,\n\tpostList,\n\tcategory,\n\tfile,\n} from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';\n\nconst ICONS_MAP = {\n\tpost: postList,\n\tpage,\n\tpost_tag: tag,\n\tcategory,\n\tattachment: file,\n};\n\nfunction SearchItemIcon( { isURL, suggestion } ) {\n\tlet icon = null;\n\n\tif ( isURL ) {\n\t\ticon = globe;\n\t} else if ( suggestion.type in ICONS_MAP ) {\n\t\ticon = ICONS_MAP[ suggestion.type ];\n\t}\n\n\tif ( icon ) {\n\t\treturn (\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ icon }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nexport const LinkControlSearchItem = ( {\n\titemProps,\n\tsuggestion,\n\tsearchTerm,\n\tonClick,\n\tisURL = false,\n\tshouldShowType = false,\n} ) => {\n\tconst info = isURL\n\t\t? __( 'Press ENTER to add this link' )\n\t\t: filterURLForDisplay( safeDecodeURI( suggestion?.url ) );\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\tinfo={ info }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={\n\t\t\t\t<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t\tshortcut={ shouldShowType && getVisualTypeName( suggestion ) }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t>\n\t\t\t<TextHighlight\n\t\t\t\t// The component expects a plain text string.\n\t\t\t\ttext={ stripHTML( suggestion.title ) }\n\t\t\t\thighlight={ searchTerm }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n\nfunction getVisualTypeName( suggestion ) {\n\tif ( suggestion.isFrontPage ) {\n\t\treturn 'front page';\n\t}\n\n\t// Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.\n\treturn suggestion.type === 'post_tag' ? 'tag' : suggestion.type;\n}\n\nexport default LinkControlSearchItem;\n"]}
|
|
@@ -70,7 +70,7 @@ function LinkControlSearchResults({
|
|
|
70
70
|
}, searchResultsLabel, (0, _element.createElement)("div", { ...suggestionsListProps,
|
|
71
71
|
className: resultsListClasses,
|
|
72
72
|
"aria-labelledby": searchResultsLabelId
|
|
73
|
-
}, suggestions.map((suggestion, index) => {
|
|
73
|
+
}, (0, _element.createElement)(_components.MenuGroup, null, suggestions.map((suggestion, index) => {
|
|
74
74
|
if (shouldShowCreateSuggestion && _constants.CREATE_TYPE === suggestion.type) {
|
|
75
75
|
return (0, _element.createElement)(_searchCreateButton.default, {
|
|
76
76
|
searchTerm: currentInputValue,
|
|
@@ -105,6 +105,6 @@ function LinkControlSearchResults({
|
|
|
105
105
|
shouldShowType: shouldShowSuggestionsTypes,
|
|
106
106
|
isFrontPage: suggestion?.isFrontPage
|
|
107
107
|
});
|
|
108
|
-
})));
|
|
108
|
+
}))));
|
|
109
109
|
}
|
|
110
110
|
//# sourceMappingURL=search-results.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","isSingleDirectEntryResult","length","LINK_ENTRY_TYPES","includes","type","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","CREATE_TYPE","id","isFrontPage"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AAKe,SAASA,wBAAT,CAAmC;AACjDC,EAAAA,UADiD;AAEjDC,EAAAA,oBAFiD;AAGjDC,EAAAA,iBAHiD;AAIjDC,EAAAA,qBAJiD;AAKjDC,EAAAA,oBALiD;AAMjDC,EAAAA,wBANiD;AAOjDC,EAAAA,WAPiD;AAQjDC,EAAAA,kBARiD;AASjDC,EAAAA,SATiD;AAUjDC,EAAAA,oBAViD;AAWjDC,EAAAA,0BAXiD;AAYjDC,EAAAA;AAZiD,CAAnC,EAaX;AACH,QAAMC,kBAAkB,GAAG,yBAC1B,2CAD0B,EAE1B;AACC,kBAAcJ;AADf,GAF0B,CAA3B;;AAOA,QAAMK,yBAAyB,GAC9BP,WAAW,CAACQ,MAAZ,KAAuB,CAAvB,IACAC,4BAAiBC,QAAjB,CAA2BV,WAAW,CAAE,CAAF,CAAX,CAAiBW,IAA5C,CAFD;;AAGA,QAAMC,0BAA0B,GAC/BjB,oBAAoB,IACpB,CAAEY,yBADF,IAEA,CAAEJ,oBAHH,CAXG,CAeH;;AACA,QAAMU,0BAA0B,GAAG,CAAER,gBAAgB,EAAEM,IAAvD,CAhBG,CAkBH;AACA;AACA;;AACA,QAAMG,oBAAoB,GAAI,kDAAkDpB,UAAY,EAA5F;AACA,QAAMqB,SAAS,GAAGZ,oBAAoB,GACnC,cAAI,aAAJ,CADmC,GAEnC;AACA;AACA,gBAAI,yBAAJ,CAFA,EAGAP,iBAHA,CAFH;AAOA,QAAMoB,kBAAkB,GACvB,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAGF;AAArB,KACGC,SADH,CADD;AAMA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,kBADH,EAEC,wCACMlB,oBADN;AAEC,IAAA,SAAS,EAAGQ,kBAFb;AAGC,uBAAkBQ;AAHnB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","isSingleDirectEntryResult","length","LINK_ENTRY_TYPES","includes","type","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","CREATE_TYPE","id","isFrontPage"],"mappings":";;;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i18n';\nimport { VisuallyHidden, MenuGroup } from '@wordpress/components';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';\n\nexport default function LinkControlSearchResults( {\n\tinstanceId,\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = classnames(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tLINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\t// According to guidelines aria-label should be added if the label\n\t// itself is not visible.\n\t// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\tconst searchResultsLabelId = `block-editor-link-control-search-results-label-${ instanceId }`;\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Suggestions' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t );\n\tconst searchResultsLabel = (\n\t\t<VisuallyHidden id={ searchResultsLabelId }>\n\t\t\t{ labelText }\n\t\t</VisuallyHidden>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-link-control__search-results-wrapper\">\n\t\t\t{ searchResultsLabel }\n\t\t\t<div\n\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\tclassName={ resultsListClasses }\n\t\t\t\taria-labelledby={ searchResultsLabelId }\n\t\t\t>\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldShowCreateSuggestion &&\n\t\t\t\t\t\t\tCREATE_TYPE === suggestion.type\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkControlSearchCreate\n\t\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\t\tbuttonText={ createSuggestionButtonText }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Intentionally only using `type` here as\n\t\t\t\t\t\t\t\t\t// the constant is enough to uniquely\n\t\t\t\t\t\t\t\t\t// identify the single \"CREATE\" suggestion.\n\t\t\t\t\t\t\t\t\tkey={ suggestion.type }\n\t\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If we're not handling \"Create\" suggestions above then\n\t\t\t\t\t\t// we don't want them in the main results so exit early.\n\t\t\t\t\t\tif ( CREATE_TYPE === suggestion.type ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<LinkControlSearchItem\n\t\t\t\t\t\t\t\tkey={ `${ suggestion.id }-${ suggestion.type }` }\n\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t\tisURL={ LINK_ENTRY_TYPES.includes(\n\t\t\t\t\t\t\t\t\tsuggestion.type\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\tshouldShowType={ shouldShowSuggestionsTypes }\n\t\t\t\t\t\t\t\tisFrontPage={ suggestion?.isFrontPage }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -32,10 +32,9 @@ function LinkSettingsDrawer({
|
|
|
32
32
|
className: "block-editor-link-control__drawer-toggle",
|
|
33
33
|
"aria-expanded": settingsOpen,
|
|
34
34
|
onClick: () => setSettingsOpen(!settingsOpen),
|
|
35
|
-
icon: _icons.
|
|
36
|
-
label: (0, _i18n.__)('Link Settings'),
|
|
35
|
+
icon: (0, _i18n.isRTL)() ? _icons.chevronLeftSmall : _icons.chevronRightSmall,
|
|
37
36
|
"aria-controls": settingsDrawerId
|
|
38
|
-
}), (0, _element.createElement)(MaybeAnimatePresence, null, settingsOpen && (0, _element.createElement)(MaybeMotionDiv, {
|
|
37
|
+
}, (0, _i18n._x)('Advanced', 'Additional link settings')), (0, _element.createElement)(MaybeAnimatePresence, null, settingsOpen && (0, _element.createElement)(MaybeMotionDiv, {
|
|
39
38
|
className: "block-editor-link-control__drawer",
|
|
40
39
|
hidden: !settingsOpen,
|
|
41
40
|
id: settingsDrawerId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["LinkSettingsDrawer","children","settingsOpen","setSettingsOpen","prefersReducedMotion","MaybeAnimatePresence","Fragment","AnimatePresence","MaybeMotionDiv","motion","div","id","settingsDrawerId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["LinkSettingsDrawer","children","settingsOpen","setSettingsOpen","prefersReducedMotion","MaybeAnimatePresence","Fragment","AnimatePresence","MaybeMotionDiv","motion","div","id","settingsDrawerId","chevronLeftSmall","chevronRightSmall","open","opacity","height","collapsed","duration"],"mappings":";;;;;;;AAWA;;AARA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;AAWA,SAASA,kBAAT,CAA6B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,YAAZ;AAA0BC,EAAAA;AAA1B,CAA7B,EAA2E;AAC1E,QAAMC,oBAAoB,GAAG,gCAA7B;AACA,QAAMC,oBAAoB,GAAGD,oBAAoB,GAC9CE,iBAD8C,GAE9CC,qCAFH;AAGA,QAAMC,cAAc,GAAGJ,oBAAoB,GAAG,KAAH,GAAWK,6BAAOC,GAA7D;AAEA,QAAMC,EAAE,GAAG,4BAAeX,kBAAf,CAAX;AAEA,QAAMY,gBAAgB,GAAI,gCAAgCD,EAAI,EAA9D;AAEA,SACC,qDACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,qBAAgBT,YAFjB;AAGC,IAAA,OAAO,EAAG,MAAMC,eAAe,CAAE,CAAED,YAAJ,CAHhC;AAIC,IAAA,IAAI,EAAG,qBAAUW,uBAAV,GAA6BC,wBAJrC;AAKC,qBAAgBF;AALjB,KAOG,cAAI,UAAJ,EAAgB,0BAAhB,CAPH,CADD,EAUC,4BAAC,oBAAD,QACGV,YAAY,IACb,4BAAC,cAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,MAAM,EAAG,CAAEA,YAFZ;AAGC,IAAA,EAAE,EAAGU,gBAHN;AAIC,IAAA,OAAO,EAAC,WAJT;AAKC,IAAA,OAAO,EAAC,MALT;AAMC,IAAA,IAAI,EAAC,WANN;AAOC,IAAA,QAAQ,EAAG;AACVG,MAAAA,IAAI,EAAE;AAAEC,QAAAA,OAAO,EAAE,CAAX;AAAcC,QAAAA,MAAM,EAAE;AAAtB,OADI;AAEVC,MAAAA,SAAS,EAAE;AAAEF,QAAAA,OAAO,EAAE,CAAX;AAAcC,QAAAA,MAAM,EAAE;AAAtB;AAFD,KAPZ;AAWC,IAAA,UAAU,EAAG;AACZE,MAAAA,QAAQ,EAAE;AADE;AAXd,KAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGlB,QADH,CAfD,CAFF,CAVD,CADD;AAoCA;;eAEcD,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { useReducedMotion, useInstanceId } from '@wordpress/compose';\nimport { _x, isRTL } from '@wordpress/i18n';\nimport { Fragment } from '@wordpress/element';\n\nfunction LinkSettingsDrawer( { children, settingsOpen, setSettingsOpen } ) {\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst MaybeAnimatePresence = prefersReducedMotion\n\t\t? Fragment\n\t\t: AnimatePresence;\n\tconst MaybeMotionDiv = prefersReducedMotion ? 'div' : motion.div;\n\n\tconst id = useInstanceId( LinkSettingsDrawer );\n\n\tconst settingsDrawerId = `link-control-settings-drawer-${ id }`;\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-link-control__drawer-toggle\"\n\t\t\t\taria-expanded={ settingsOpen }\n\t\t\t\tonClick={ () => setSettingsOpen( ! settingsOpen ) }\n\t\t\t\ticon={ isRTL() ? chevronLeftSmall : chevronRightSmall }\n\t\t\t\taria-controls={ settingsDrawerId }\n\t\t\t>\n\t\t\t\t{ _x( 'Advanced', 'Additional link settings' ) }\n\t\t\t</Button>\n\t\t\t<MaybeAnimatePresence>\n\t\t\t\t{ settingsOpen && (\n\t\t\t\t\t<MaybeMotionDiv\n\t\t\t\t\t\tclassName=\"block-editor-link-control__drawer\"\n\t\t\t\t\t\thidden={ ! settingsOpen }\n\t\t\t\t\t\tid={ settingsDrawerId }\n\t\t\t\t\t\tinitial=\"collapsed\"\n\t\t\t\t\t\tanimate=\"open\"\n\t\t\t\t\t\texit=\"collapsed\"\n\t\t\t\t\t\tvariants={ {\n\t\t\t\t\t\t\topen: { opacity: 1, height: 'auto' },\n\t\t\t\t\t\t\tcollapsed: { opacity: 0, height: 0 },\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\tduration: 0.1,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-editor-link-control__drawer-inner\">\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MaybeMotionDiv>\n\t\t\t\t) }\n\t\t\t</MaybeAnimatePresence>\n\t\t</>\n\t);\n}\n\nexport default LinkSettingsDrawer;\n"]}
|
|
@@ -45,16 +45,12 @@ const Appender = (0, _element.forwardRef)(({
|
|
|
45
45
|
setInsertedBlock
|
|
46
46
|
} = (0, _context.useListViewContext)();
|
|
47
47
|
const instanceId = (0, _compose.useInstanceId)(Appender);
|
|
48
|
-
const {
|
|
49
|
-
hideInserter
|
|
50
|
-
} = (0, _data.useSelect)(select => {
|
|
48
|
+
const hideInserter = (0, _data.useSelect)(select => {
|
|
51
49
|
const {
|
|
52
50
|
getTemplateLock,
|
|
53
51
|
__unstableGetEditorMode
|
|
54
52
|
} = select(_store.store);
|
|
55
|
-
return
|
|
56
|
-
hideInserter: !!getTemplateLock(clientId) || __unstableGetEditorMode() === 'zoom-out'
|
|
57
|
-
};
|
|
53
|
+
return !!getTemplateLock(clientId) || __unstableGetEditorMode() === 'zoom-out';
|
|
58
54
|
}, [clientId]);
|
|
59
55
|
const blockTitle = (0, _useBlockDisplayTitle.default)({
|
|
60
56
|
clientId,
|