@wordpress/editor 12.6.0 → 12.9.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 +6 -0
- package/build/components/editor-help/help-section-title.native.js +43 -0
- package/build/components/editor-help/help-section-title.native.js.map +1 -0
- package/build/components/editor-help/help-topic-row.native.js +3 -2
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/icon-move-blocks.native.js +23 -0
- package/build/components/editor-help/icon-move-blocks.native.js.map +1 -0
- package/build/components/editor-help/index.native.js +10 -11
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/move-blocks.native.js +14 -2
- package/build/components/editor-help/move-blocks.native.js.map +1 -1
- package/build/components/editor-help/view-sections.native.js +21 -5
- package/build/components/editor-help/view-sections.native.js.map +1 -1
- package/build/components/post-featured-image/index.js +84 -41
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-schedule/index.js +11 -18
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +2 -2
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +7 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-text-editor/index.js +12 -1
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/components/post-visibility/index.js +132 -167
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js +5 -22
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js +14 -13
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/provider/index.native.js +3 -1
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +15 -9
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/selectors.js +2 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-help/help-section-title.native.js +31 -0
- package/build-module/components/editor-help/help-section-title.native.js.map +1 -0
- package/build-module/components/editor-help/help-topic-row.native.js +3 -2
- package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build-module/components/editor-help/icon-move-blocks.native.js +13 -0
- package/build-module/components/editor-help/icon-move-blocks.native.js.map +1 -0
- package/build-module/components/editor-help/index.native.js +10 -12
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-help/move-blocks.native.js +15 -3
- package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/view-sections.native.js +22 -6
- package/build-module/components/editor-help/view-sections.native.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +86 -42
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-schedule/index.js +12 -19
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +2 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +7 -1
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-text-editor/index.js +13 -2
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/components/post-visibility/index.js +132 -166
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js +5 -20
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js +14 -13
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/provider/index.native.js +2 -1
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +16 -10
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/selectors.js +2 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +51 -52
- package/build-style/style.css +51 -52
- package/package.json +29 -28
- package/src/components/autosave-monitor/test/index.js +3 -0
- package/src/components/editor-help/help-section-title.native.js +29 -0
- package/src/components/editor-help/help-topic-row.native.js +2 -2
- package/src/components/editor-help/icon-move-blocks.native.js +10 -0
- package/src/components/editor-help/images/drag-and-drop-dark.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-dark@2x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-dark@3x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-light.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-light@2x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-light@3x.png +0 -0
- package/src/components/editor-help/index.native.js +20 -22
- package/src/components/editor-help/move-blocks.native.js +22 -2
- package/src/components/editor-help/style.scss +36 -4
- package/src/components/editor-help/test/index.native.js +1 -1
- package/src/components/editor-help/view-sections.native.js +23 -8
- package/src/components/post-featured-image/index.js +102 -69
- package/src/components/post-saved-state/style.scss +9 -0
- package/src/components/post-schedule/index.js +6 -13
- package/src/components/post-slug/test/index.js +4 -4
- package/src/components/post-taxonomies/flat-term-selector.js +5 -2
- package/src/components/post-taxonomies/index.js +3 -1
- package/src/components/post-text-editor/index.js +13 -1
- package/src/components/post-visibility/index.js +130 -150
- package/src/components/post-visibility/label.js +6 -15
- package/src/components/post-visibility/style.scss +25 -20
- package/src/components/post-visibility/utils.js +7 -12
- package/src/components/provider/index.native.js +2 -1
- package/src/components/provider/use-block-editor-settings.js +28 -12
- package/src/components/table-of-contents/style.scss +1 -3
- package/src/store/selectors.js +4 -2
- package/src/store/test/selectors.js +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/index.native.js"],"names":["kebabCase","Text","SafeAreaView","ScrollView","StyleSheet","View","TransitionPresets","BottomSheet","BottomSheetConsumer","PanelBody","__","helpFilled","plusCircleFilled","alignJustify","trash","cog","useSelect","store","editorStore","usePreferredColorSchemeStyle","requestContactCustomerSupport","requestGotoCustomerSupportOptions","styles","HelpDetailNavigationScreen","HelpTopicRow","HelpGetSupportButton","IntroToBlocks","AddBlocks","MoveBlocks","RemoveBlocks","CustomizeBlocks","HELP_TOPICS","label","icon","view","EditorHelpTopics","close","isVisible","onClose","postType","select","getEditedPostAttribute","sectionTitle","helpDetailSectionHeading","helpDetailSectionHeadingDark","title","contentContainer","navigationContainer","container","listProps","contentContainerStyle","flatten","paddingBottom","Math","max","safeAreaBottomInset","marginTop","map","labelSlug","gestureEnabled","DefaultTransition"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AACA,SAASC,IAAT,EAAeC,YAAf,EAA6BC,UAA7B,EAAyCC,UAAzC,EAAqDC,IAArD,QAAiE,cAAjE;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,mBAFD,EAGCC,SAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,UADD,EAECC,gBAFD,EAGCC,YAHD,EAICC,KAJD,EAKCC,GALD,QAMO,kBANP;AAOA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,4BAAT,QAA6C,oBAA7C;AACA,SACCC,6BADD,EAECC,iCAFD,QAGO,gCAHP;AAKA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,0BAAP,MAAuC,iCAAvC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AAEA,MAAMC,WAAW,GAAG,CACnB;AACCC,EAAAA,KAAK,EAAEtB,EAAE,CAAE,kBAAF,CADV;AAECuB,EAAAA,IAAI,EAAEtB,UAFP;AAGCuB,EAAAA,IAAI,EAAE,cAAC,aAAD;AAHP,CADmB,EAMnB;AACCF,EAAAA,KAAK,EAAE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AAS,CAC1BgC,KAD0B,CAA3B;AAGA,aACC,cAAC,YAAD;AACC,QAAA,GAAG,EACF0B,SAFF;AAIC,QAAA,KAAK,EAAG1B,KAJT;AAKC,QAAA,IAAI,EAAGC,IALR;AAMC,QAAA,UAAU,EACTyB;AAPF,QADD;AAYA,KAjBA,CALH,EAyBE,cAAC,IAAD;AACC,MAAA,KAAK,EAAGhB;AADT,OAGGhC,EAAE,CAAE,aAAF,CAHL,CAzBF,EAgCE,cAAC,oBAAD;AACC,MAAA,KAAK,EAAGA,EAAE,CACT,iBADS,CADX;AAIC,MAAA,OAAO,EACNU;AALF,MAhCF,EA0CE,cAAC,oBAAD;AACC,MAAA,KAAK,EAAGV,EAAE,CACT,sBADS,CADX;AAIC,MAAA,OAAO,EACNW;AALF,MA1CF,CAhBD,CADD;AAuEA,GA5EF,CAVD,CALD,CALD,EAqGGU,WAAW,CAAC0B,GAAZ,CAAiB,SAAuB;AAAA,QAArB;AAAEvB,MAAAA,IAAF;AAAQF,MAAAA;AAAR,KAAqB;AACzC,UAAM0B,SAAS,GAAG1D,SAAS,CAAEgC,KAAF,CAA3B;AACA,WACC,cAAC,0BAAD;AACC,MAAA,GAAG,EAAG0B,SADP;AAEC,MAAA,IAAI,EAAGA,SAFR;AAGC,MAAA,OAAO,EAAGxB,IAHX;AAIC,MAAA,KAAK,EAAGF,KAJT;AAKC,MAAA,OAAO,EAAG;AACT2B,QAAAA,cAAc,EAAE,KADP;AAET,WAAGrD,iBAAiB,CAACsD;AAFZ;AALX,MADD;AAYA,GAdC,CArGH,CADD,CARD,CADD;AAkIA;;AAED,eAAezB,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\nimport { Text, SafeAreaView, ScrollView, StyleSheet, View } from 'react-native';\nimport { TransitionPresets } from '@react-navigation/stack';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBottomSheet,\n\tBottomSheetConsumer,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\thelpFilled,\n\tplusCircleFilled,\n\talignJustify,\n\ttrash,\n\tcog,\n} from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport {\n\trequestContactCustomerSupport,\n\trequestGotoCustomerSupportOptions,\n} from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport HelpDetailNavigationScreen from './help-detail-navigation-screen';\nimport HelpTopicRow from './help-topic-row';\nimport HelpGetSupportButton from './help-get-support-button';\nimport IntroToBlocks from './intro-to-blocks';\nimport AddBlocks from './add-blocks';\nimport MoveBlocks from './move-blocks';\nimport RemoveBlocks from './remove-blocks';\nimport CustomizeBlocks from './customize-blocks';\n\nconst HELP_TOPICS = [\n\t{\n\t\tlabel: __( 'What is a block?' ),\n\t\ticon: helpFilled,\n\t\tview: <IntroToBlocks />,\n\t},\n\t{\n\t\tlabel: __( 'Add blocks' ),\n\t\ticon: plusCircleFilled,\n\t\tview: <AddBlocks />,\n\t},\n\t{ label: __( 'Move blocks' ), icon: alignJustify, view: <MoveBlocks /> },\n\t{ label: __( 'Remove blocks' ), icon: trash, view: <RemoveBlocks /> },\n\t{\n\t\tlabel: __( 'Customize blocks' ),\n\t\ticon: cog,\n\t\tview: <CustomizeBlocks />,\n\t},\n];\n\nfunction EditorHelpTopics( { close, isVisible, onClose } ) {\n\tconst { postType } = useSelect( ( select ) => ( {\n\t\tpostType: select( editorStore ).getEditedPostAttribute( 'type' ),\n\t} ) );\n\n\tconst sectionTitle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailSectionHeading,\n\t\tstyles.helpDetailSectionHeadingDark\n\t);\n\n\tconst title =\n\t\tpostType === 'page'\n\t\t\t? __( 'How to edit your page' )\n\t\t\t: __( 'How to edit your post' );\n\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible={ isVisible }\n\t\t\tonClose={ onClose }\n\t\t\thideHeader\n\t\t\thasNavigation\n\t\t\tcontentStyle={ styles.contentContainer }\n\t\t\ttestID=\"editor-help-modal\"\n\t\t>\n\t\t\t<SafeAreaView>\n\t\t\t\t<BottomSheet.NavigationContainer\n\t\t\t\t\tanimate\n\t\t\t\t\tmain\n\t\t\t\t\tstyle={ styles.navigationContainer }\n\t\t\t\t>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t\tname=\"help-topics\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<View style={ styles.container }>\n\t\t\t\t\t\t\t<BottomSheet.NavBar>\n\t\t\t\t\t\t\t\t<BottomSheet.NavBar.DismissButton\n\t\t\t\t\t\t\t\t\tonPress={ close }\n\t\t\t\t\t\t\t\t\tiosText={ __( 'Close' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<BottomSheet.NavBar.Heading>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</BottomSheet.NavBar.Heading>\n\t\t\t\t\t\t\t</BottomSheet.NavBar>\n\t\t\t\t\t\t\t<BottomSheetConsumer>\n\t\t\t\t\t\t\t\t{ ( { listProps } ) => {\n\t\t\t\t\t\t\t\t\tconst contentContainerStyle = StyleSheet.flatten(\n\t\t\t\t\t\t\t\t\t\tlistProps.contentContainerStyle\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\t\t\t\t{ ...listProps }\n\t\t\t\t\t\t\t\t\t\t\tcontentContainerStyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t...contentContainerStyle,\n\t\t\t\t\t\t\t\t\t\t\t\tpaddingBottom: Math.max(\n\t\t\t\t\t\t\t\t\t\t\t\t\tlistProps.safeAreaBottomInset,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontentContainerStyle.paddingBottom\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t\t\t\t * Remove margin set via `hideHeader`. Combining a header\n\t\t\t\t\t\t\t\t\t\t\t\t * and navigation in this bottom sheet is at odds with the\n\t\t\t\t\t\t\t\t\t\t\t\t * current `BottomSheet` implementation.\n\t\t\t\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\t\t\t\tmarginTop: 0,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t\t\t\t\t\t\t<Text style={ sectionTitle }>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'The basics' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t\t\t{ /* Print out help topics. */ }\n\t\t\t\t\t\t\t\t\t\t\t\t{ HELP_TOPICS.map(\n\t\t\t\t\t\t\t\t\t\t\t\t\t( { label, icon } ) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconst labelSlug = kebabCase(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpTopicRow\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabelSlug\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tscreenName={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabelSlug\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ sectionTitle }\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Get support' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpGetSupportButton\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Contact support'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonPress={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trequestContactCustomerSupport\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpGetSupportButton\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'More support options'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonPress={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trequestGotoCustomerSupportOptions\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t</BottomSheetConsumer>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t{ /* Print out help detail screens. */ }\n\t\t\t\t\t{ HELP_TOPICS.map( ( { view, label } ) => {\n\t\t\t\t\t\tconst labelSlug = kebabCase( label );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<HelpDetailNavigationScreen\n\t\t\t\t\t\t\t\tkey={ labelSlug }\n\t\t\t\t\t\t\t\tname={ labelSlug }\n\t\t\t\t\t\t\t\tcontent={ view }\n\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\toptions={ {\n\t\t\t\t\t\t\t\t\tgestureEnabled: false,\n\t\t\t\t\t\t\t\t\t...TransitionPresets.DefaultTransition,\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\t\t\t\t\t} ) }\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</SafeAreaView>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default EditorHelpTopics;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/index.native.js"],"names":["kebabCase","SafeAreaView","ScrollView","StyleSheet","View","TransitionPresets","BottomSheet","BottomSheetConsumer","PanelBody","__","helpFilled","plusCircleFilled","trash","cog","useSelect","store","editorStore","requestContactCustomerSupport","requestGotoCustomerSupportOptions","styles","HelpDetailNavigationScreen","HelpTopicRow","HelpGetSupportButton","IntroToBlocks","AddBlocks","MoveBlocks","RemoveBlocks","CustomizeBlocks","moveBlocksIcon","HelpSectionTitle","HELP_TOPICS","label","icon","view","EditorHelpTopics","close","isVisible","onClose","postType","select","getEditedPostAttribute","title","contentContainer","navigationContainer","container","listProps","contentContainerStyle","flatten","paddingBottom","Math","max","safeAreaBottomInset","marginTop","map","index","labelSlug","isLastItem","length","gestureEnabled","DefaultTransition"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,EAAmCC,UAAnC,EAA+CC,IAA/C,QAA2D,cAA3D;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,mBAFD,EAGCC,SAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,gBAArB,EAAuCC,KAAvC,EAA8CC,GAA9C,QAAyD,kBAAzD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,6BADD,EAECC,iCAFD,QAGO,gCAHP;AAKA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,0BAAP,MAAuC,iCAAvC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,WAAW,GAAG,CACnB;AACCC,EAAAA,KAAK,EAAEtB,EAAE,CAAE,kBAAF,CADV;AAECuB,EAAAA,IAAI,EAAEtB,UAFP;AAGCuB,EAAAA,IAAI,EAAE,cAAC,aAAD;AAHP,CADmB,EAMnB;AACCF,EAAAA,KAAK,EAAEtB,EAAE,CAAE,YAAF,CADV;AAECuB,EA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AA,KAAK,EAAGxB,KAJT;AAKC,QAAA,IAAI,EAAGC,IALR;AAMC,QAAA,UAAU,EACTuB,SAPF;AASC,QAAA,UAAU,EACTC;AAVF,QADD;AAeA,KA3BA,CALH,EAmCE,cAAC,gBAAD,QACG/C,EAAE,CAAE,aAAF,CADL,CAnCF,EAwCE,cAAC,oBAAD;AACC,MAAA,KAAK,EAAGA,EAAE,CACT,iBADS,CADX;AAIC,MAAA,OAAO,EACNQ;AALF,MAxCF,EAkDE,cAAC,oBAAD;AACC,MAAA,KAAK,EAAGR,EAAE,CACT,sBADS,CADX;AAIC,MAAA,OAAO,EACNS;AALF,MAlDF,CAhBD,CADD;AA+EA,GApFF,CAVD,CALD,CALD,EA6GGY,WAAW,CAACuB,GAAZ,CAAiB,SAAuB;AAAA,QAArB;AAAEpB,MAAAA,IAAF;AAAQF,MAAAA;AAAR,KAAqB;AACzC,UAAMwB,SAAS,GAAGvD,SAAS,CAAE+B,KAAF,CAA3B;AACA,WACC,cAAC,0BAAD;AACC,MAAA,GAAG,EAAGwB,SADP;AAEC,MAAA,IAAI,EAAGA,SAFR;AAGC,MAAA,OAAO,EAAGtB,IAHX;AAIC,MAAA,KAAK,EAAGF,KAJT;AAKC,MAAA,OAAO,EAAG;AACT2B,QAAAA,cAAc,EAAE,KADP;AAET,WAAGrD,iBAAiB,CAACsD;AAFZ;AALX,MADD;AAYA,GAdC,CA7GH,CADD,CARD,CADD;AA0IA;;AAED,eAAezB,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\nimport { SafeAreaView, ScrollView, StyleSheet, View } from 'react-native';\nimport { TransitionPresets } from '@react-navigation/stack';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBottomSheet,\n\tBottomSheetConsumer,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { helpFilled, plusCircleFilled, trash, cog } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport {\n\trequestContactCustomerSupport,\n\trequestGotoCustomerSupportOptions,\n} from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport HelpDetailNavigationScreen from './help-detail-navigation-screen';\nimport HelpTopicRow from './help-topic-row';\nimport HelpGetSupportButton from './help-get-support-button';\nimport IntroToBlocks from './intro-to-blocks';\nimport AddBlocks from './add-blocks';\nimport MoveBlocks from './move-blocks';\nimport RemoveBlocks from './remove-blocks';\nimport CustomizeBlocks from './customize-blocks';\nimport moveBlocksIcon from './icon-move-blocks';\nimport HelpSectionTitle from './help-section-title';\n\nconst HELP_TOPICS = [\n\t{\n\t\tlabel: __( 'What is a block?' ),\n\t\ticon: helpFilled,\n\t\tview: <IntroToBlocks />,\n\t},\n\t{\n\t\tlabel: __( 'Add blocks' ),\n\t\ticon: plusCircleFilled,\n\t\tview: <AddBlocks />,\n\t},\n\t{ label: __( 'Move blocks' ), icon: moveBlocksIcon, view: <MoveBlocks /> },\n\t{ label: __( 'Remove blocks' ), icon: trash, view: <RemoveBlocks /> },\n\t{\n\t\tlabel: __( 'Customize blocks' ),\n\t\ticon: cog,\n\t\tview: <CustomizeBlocks />,\n\t},\n];\n\nfunction EditorHelpTopics( { close, isVisible, onClose } ) {\n\tconst { postType } = useSelect( ( select ) => ( {\n\t\tpostType: select( editorStore ).getEditedPostAttribute( 'type' ),\n\t} ) );\n\n\tconst title =\n\t\tpostType === 'page'\n\t\t\t? __( 'How to edit your page' )\n\t\t\t: __( 'How to edit your post' );\n\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible={ isVisible }\n\t\t\tonClose={ onClose }\n\t\t\thideHeader\n\t\t\thasNavigation\n\t\t\tcontentStyle={ styles.contentContainer }\n\t\t\ttestID=\"editor-help-modal\"\n\t\t>\n\t\t\t<SafeAreaView>\n\t\t\t\t<BottomSheet.NavigationContainer\n\t\t\t\t\tanimate\n\t\t\t\t\tmain\n\t\t\t\t\tstyle={ styles.navigationContainer }\n\t\t\t\t>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t\tname=\"help-topics\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<View style={ styles.container }>\n\t\t\t\t\t\t\t<BottomSheet.NavBar>\n\t\t\t\t\t\t\t\t<BottomSheet.NavBar.DismissButton\n\t\t\t\t\t\t\t\t\tonPress={ close }\n\t\t\t\t\t\t\t\t\tiosText={ __( 'Close' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<BottomSheet.NavBar.Heading>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</BottomSheet.NavBar.Heading>\n\t\t\t\t\t\t\t</BottomSheet.NavBar>\n\t\t\t\t\t\t\t<BottomSheetConsumer>\n\t\t\t\t\t\t\t\t{ ( { listProps } ) => {\n\t\t\t\t\t\t\t\t\tconst contentContainerStyle = StyleSheet.flatten(\n\t\t\t\t\t\t\t\t\t\tlistProps.contentContainerStyle\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\t\t\t\t{ ...listProps }\n\t\t\t\t\t\t\t\t\t\t\tcontentContainerStyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t...contentContainerStyle,\n\t\t\t\t\t\t\t\t\t\t\t\tpaddingBottom: Math.max(\n\t\t\t\t\t\t\t\t\t\t\t\t\tlistProps.safeAreaBottomInset,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontentContainerStyle.paddingBottom\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t\t\t\t * Remove margin set via `hideHeader`. Combining a header\n\t\t\t\t\t\t\t\t\t\t\t\t * and navigation in this bottom sheet is at odds with the\n\t\t\t\t\t\t\t\t\t\t\t\t * current `BottomSheet` implementation.\n\t\t\t\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\t\t\t\tmarginTop: 0,\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t\t\t\t\t\t\t<HelpSectionTitle>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'The basics' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</HelpSectionTitle>\n\t\t\t\t\t\t\t\t\t\t\t\t{ /* Print out help topics. */ }\n\t\t\t\t\t\t\t\t\t\t\t\t{ HELP_TOPICS.map(\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ label, icon },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconst labelSlug = kebabCase(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconst isLastItem =\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tindex ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tHELP_TOPICS.length -\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpTopicRow\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabelSlug\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tscreenName={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabelSlug\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisLastItem={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisLastItem\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpSectionTitle>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Get support' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</HelpSectionTitle>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpGetSupportButton\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Contact support'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonPress={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trequestContactCustomerSupport\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t<HelpGetSupportButton\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'More support options'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonPress={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trequestGotoCustomerSupportOptions\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t</BottomSheetConsumer>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t{ /* Print out help detail screens. */ }\n\t\t\t\t\t{ HELP_TOPICS.map( ( { view, label } ) => {\n\t\t\t\t\t\tconst labelSlug = kebabCase( label );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<HelpDetailNavigationScreen\n\t\t\t\t\t\t\t\tkey={ labelSlug }\n\t\t\t\t\t\t\t\tname={ labelSlug }\n\t\t\t\t\t\t\t\tcontent={ view }\n\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\toptions={ {\n\t\t\t\t\t\t\t\t\tgestureEnabled: false,\n\t\t\t\t\t\t\t\t\t...TransitionPresets.DefaultTransition,\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\t\t\t\t\t} ) }\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</SafeAreaView>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default EditorHelpTopics;\n"]}
|
|
@@ -14,16 +14,28 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import styles from './style.scss';
|
|
17
|
-
import { HelpDetailBodyText, HelpDetailImage } from './view-sections';
|
|
17
|
+
import { HelpDetailBodyText, HelpDetailImage, HelpDetailSectionHeadingText } from './view-sections';
|
|
18
18
|
|
|
19
19
|
const MoveBlocks = () => {
|
|
20
20
|
return createElement(Fragment, null, createElement(HelpDetailImage, {
|
|
21
|
+
source: require('./images/drag-and-drop-light.png'),
|
|
22
|
+
sourceDarkMode: require('./images/drag-and-drop-dark.png')
|
|
23
|
+
}), createElement(View, {
|
|
24
|
+
style: styles.helpDetailContainer
|
|
25
|
+
}, createElement(HelpDetailSectionHeadingText, {
|
|
26
|
+
text: __('Drag & drop'),
|
|
27
|
+
badge: __('NEW')
|
|
28
|
+
}), createElement(HelpDetailBodyText, {
|
|
29
|
+
text: __('Drag & drop makes rearranging blocks a breeze. Press and hold on a block, then drag it to its new location and release.')
|
|
30
|
+
})), createElement(HelpDetailImage, {
|
|
21
31
|
source: require('./images/move-light.png'),
|
|
22
32
|
sourceDarkMode: require('./images/move-dark.png')
|
|
23
33
|
}), createElement(View, {
|
|
24
34
|
style: styles.helpDetailContainer
|
|
25
|
-
}, createElement(
|
|
26
|
-
text: __('
|
|
35
|
+
}, createElement(HelpDetailSectionHeadingText, {
|
|
36
|
+
text: __('Arrow buttons')
|
|
37
|
+
}), createElement(HelpDetailBodyText, {
|
|
38
|
+
text: __('You can also rearrange blocks by tapping a block and then tapping the up and down arrows that appear on the bottom left side of the block to move it up or down.')
|
|
27
39
|
})));
|
|
28
40
|
};
|
|
29
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/move-blocks.native.js"],"names":["View","__","styles","HelpDetailBodyText","HelpDetailImage","MoveBlocks","require","helpDetailContainer"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/move-blocks.native.js"],"names":["View","__","styles","HelpDetailBodyText","HelpDetailImage","HelpDetailSectionHeadingText","MoveBlocks","require","helpDetailContainer"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,SACCC,kBADD,EAECC,eAFD,EAGCC,4BAHD,QAIO,iBAJP;;AAMA,MAAMC,UAAU,GAAG,MAAM;AACxB,SACC,8BACC,cAAC,eAAD;AACC,IAAA,MAAM,EAAGC,OAAO,CAAE,kCAAF,CADjB;AAEC,IAAA,cAAc,EAAGA,OAAO,CAAE,iCAAF;AAFzB,IADD,EAKC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGL,MAAM,CAACM;AAArB,KACC,cAAC,4BAAD;AACC,IAAA,IAAI,EAAGP,EAAE,CAAE,aAAF,CADV;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,KAAF;AAFX,IADD,EAKC,cAAC,kBAAD;AACC,IAAA,IAAI,EAAGA,EAAE,CACR,yHADQ;AADV,IALD,CALD,EAgBC,cAAC,eAAD;AACC,IAAA,MAAM,EAAGM,OAAO,CAAE,yBAAF,CADjB;AAEC,IAAA,cAAc,EAAGA,OAAO,CAAE,wBAAF;AAFzB,IAhBD,EAoBC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGL,MAAM,CAACM;AAArB,KACC,cAAC,4BAAD;AAA8B,IAAA,IAAI,EAAGP,EAAE,CAAE,eAAF;AAAvC,IADD,EAEC,cAAC,kBAAD;AACC,IAAA,IAAI,EAAGA,EAAE,CACR,kKADQ;AADV,IAFD,CApBD,CADD;AA+BA,CAhCD;;AAkCA,eAAeK,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport {\n\tHelpDetailBodyText,\n\tHelpDetailImage,\n\tHelpDetailSectionHeadingText,\n} from './view-sections';\n\nconst MoveBlocks = () => {\n\treturn (\n\t\t<>\n\t\t\t<HelpDetailImage\n\t\t\t\tsource={ require( './images/drag-and-drop-light.png' ) }\n\t\t\t\tsourceDarkMode={ require( './images/drag-and-drop-dark.png' ) }\n\t\t\t/>\n\t\t\t<View style={ styles.helpDetailContainer }>\n\t\t\t\t<HelpDetailSectionHeadingText\n\t\t\t\t\ttext={ __( 'Drag & drop' ) }\n\t\t\t\t\tbadge={ __( 'NEW' ) }\n\t\t\t\t/>\n\t\t\t\t<HelpDetailBodyText\n\t\t\t\t\ttext={ __(\n\t\t\t\t\t\t'Drag & drop makes rearranging blocks a breeze. Press and hold on a block, then drag it to its new location and release.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t\t<HelpDetailImage\n\t\t\t\tsource={ require( './images/move-light.png' ) }\n\t\t\t\tsourceDarkMode={ require( './images/move-dark.png' ) }\n\t\t\t/>\n\t\t\t<View style={ styles.helpDetailContainer }>\n\t\t\t\t<HelpDetailSectionHeadingText text={ __( 'Arrow buttons' ) } />\n\t\t\t\t<HelpDetailBodyText\n\t\t\t\t\ttext={ __(\n\t\t\t\t\t\t'You can also rearrange blocks by tapping a block and then tapping the up and down arrows that appear on the bottom left side of the block to move it up or down.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default MoveBlocks;\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { Text, Image } from 'react-native';
|
|
6
|
+
import { Text, Image, View } from 'react-native';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
@@ -26,14 +26,19 @@ export const HelpDetailBodyText = _ref => {
|
|
|
26
26
|
};
|
|
27
27
|
export const HelpDetailSectionHeadingText = _ref2 => {
|
|
28
28
|
let {
|
|
29
|
-
text
|
|
29
|
+
text,
|
|
30
|
+
badge
|
|
30
31
|
} = _ref2;
|
|
31
|
-
const
|
|
32
|
-
return createElement(
|
|
32
|
+
const headingTextStyle = usePreferredColorSchemeStyle(styles.helpDetailSectionHeadingText, styles.helpDetailSectionHeadingTextDark);
|
|
33
|
+
return createElement(View, {
|
|
34
|
+
style: styles.helpDetailSectionHeading
|
|
35
|
+
}, badge && createElement(HelpDetailBadge, {
|
|
36
|
+
text: badge
|
|
37
|
+
}), createElement(Text, {
|
|
33
38
|
accessibilityRole: "header",
|
|
34
39
|
selectable: true,
|
|
35
|
-
style:
|
|
36
|
-
}, text);
|
|
40
|
+
style: headingTextStyle
|
|
41
|
+
}, text));
|
|
37
42
|
};
|
|
38
43
|
export const HelpDetailImage = _ref3 => {
|
|
39
44
|
let {
|
|
@@ -51,4 +56,15 @@ export const HelpDetailImage = _ref3 => {
|
|
|
51
56
|
style: imageStyle
|
|
52
57
|
});
|
|
53
58
|
};
|
|
59
|
+
|
|
60
|
+
const HelpDetailBadge = _ref4 => {
|
|
61
|
+
let {
|
|
62
|
+
text
|
|
63
|
+
} = _ref4;
|
|
64
|
+
return createElement(View, {
|
|
65
|
+
style: styles.helpDetailBadgeContainer
|
|
66
|
+
}, createElement(Text, {
|
|
67
|
+
style: styles.helpDetailBadgeText
|
|
68
|
+
}, text));
|
|
69
|
+
};
|
|
54
70
|
//# sourceMappingURL=view-sections.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/view-sections.native.js"],"names":["Text","Image","usePreferredColorScheme","usePreferredColorSchemeStyle","styles","HelpDetailBodyText","text","bodyStyle","helpDetailBody","helpDetailBodyDark","HelpDetailSectionHeadingText","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/view-sections.native.js"],"names":["Text","Image","View","usePreferredColorScheme","usePreferredColorSchemeStyle","styles","HelpDetailBodyText","text","bodyStyle","helpDetailBody","helpDetailBodyDark","HelpDetailSectionHeadingText","badge","headingTextStyle","helpDetailSectionHeadingText","helpDetailSectionHeadingTextDark","helpDetailSectionHeading","HelpDetailImage","accessible","accessibilityLabel","source","sourceDarkMode","imageStyle","helpDetailImage","helpDetailImageDark","darkModeEnabled","HelpDetailBadge","helpDetailBadgeContainer","helpDetailBadgeText"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,KAAf,EAAsBC,IAAtB,QAAkC,cAAlC;AAEA;AACA;AACA;;AACA,SACCC,uBADD,EAECC,4BAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,OAAO,MAAMC,kBAAkB,GAAG,QAAgB;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACjD,QAAMC,SAAS,GAAGJ,4BAA4B,CAC7CC,MAAM,CAACI,cADsC,EAE7CJ,MAAM,CAACK,kBAFsC,CAA9C;AAIA,SACC,cAAC,IAAD;AAAM,IAAA,UAAU,MAAhB;AAAiB,IAAA,KAAK,EAAGF;AAAzB,KACGD,IADH,CADD;AAKA,CAVM;AAYP,OAAO,MAAMI,4BAA4B,GAAG,SAAuB;AAAA,MAArB;AAAEJ,IAAAA,IAAF;AAAQK,IAAAA;AAAR,GAAqB;AAClE,QAAMC,gBAAgB,GAAGT,4BAA4B,CACpDC,MAAM,CAACS,4BAD6C,EAEpDT,MAAM,CAACU,gCAF6C,CAArD;AAIA,SACC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGV,MAAM,CAACW;AAArB,KACGJ,KAAK,IAAI,cAAC,eAAD;AAAiB,IAAA,IAAI,EAAGA;AAAxB,IADZ,EAEC,cAAC,IAAD;AACC,IAAA,iBAAiB,EAAC,QADnB;AAEC,IAAA,UAAU,MAFX;AAGC,IAAA,KAAK,EAAGC;AAHT,KAKGN,IALH,CAFD,CADD;AAYA,CAjBM;AAmBP,OAAO,MAAMU,eAAe,GAAG,SAKxB;AAAA,MAL0B;AAChCC,IAAAA,UADgC;AAEhCC,IAAAA,kBAFgC;AAGhCC,IAAAA,MAHgC;AAIhCC,IAAAA;AAJgC,GAK1B;AACN,QAAMC,UAAU,GAAGlB,4BAA4B,CAC9CC,MAAM,CAACkB,eADuC,EAE9ClB,MAAM,CAACmB,mBAFuC,CAA/C;AAIA,QAAMC,eAAe,GAAGtB,uBAAuB,OAAO,MAAtD;AACA,SACC,cAAC,KAAD;AACC,IAAA,UAAU,EAAGe,UADd;AAEC,IAAA,kBAAkB,EAAGC,kBAFtB;AAGC,IAAA,MAAM,EACLM,eAAe,IAAIJ,cAAnB,GAAoCA,cAApC,GAAqDD,MAJvD;AAMC,IAAA,KAAK,EAAGE;AANT,IADD;AAUA,CArBM;;AAuBP,MAAMI,eAAe,GAAG,SAAgB;AAAA,MAAd;AAAEnB,IAAAA;AAAF,GAAc;AACvC,SACC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGF,MAAM,CAACsB;AAArB,KACC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGtB,MAAM,CAACuB;AAArB,KAA6CrB,IAA7C,CADD,CADD;AAKA,CAND","sourcesContent":["/**\n * External dependencies\n */\nimport { Text, Image, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport const HelpDetailBodyText = ( { text } ) => {\n\tconst bodyStyle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailBody,\n\t\tstyles.helpDetailBodyDark\n\t);\n\treturn (\n\t\t<Text selectable style={ bodyStyle }>\n\t\t\t{ text }\n\t\t</Text>\n\t);\n};\n\nexport const HelpDetailSectionHeadingText = ( { text, badge } ) => {\n\tconst headingTextStyle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailSectionHeadingText,\n\t\tstyles.helpDetailSectionHeadingTextDark\n\t);\n\treturn (\n\t\t<View style={ styles.helpDetailSectionHeading }>\n\t\t\t{ badge && <HelpDetailBadge text={ badge } /> }\n\t\t\t<Text\n\t\t\t\taccessibilityRole=\"header\"\n\t\t\t\tselectable\n\t\t\t\tstyle={ headingTextStyle }\n\t\t\t>\n\t\t\t\t{ text }\n\t\t\t</Text>\n\t\t</View>\n\t);\n};\n\nexport const HelpDetailImage = ( {\n\taccessible,\n\taccessibilityLabel,\n\tsource,\n\tsourceDarkMode,\n} ) => {\n\tconst imageStyle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailImage,\n\t\tstyles.helpDetailImageDark\n\t);\n\tconst darkModeEnabled = usePreferredColorScheme() === 'dark';\n\treturn (\n\t\t<Image\n\t\t\taccessible={ accessible }\n\t\t\taccessibilityLabel={ accessibilityLabel }\n\t\t\tsource={\n\t\t\t\tdarkModeEnabled && sourceDarkMode ? sourceDarkMode : source\n\t\t\t}\n\t\t\tstyle={ imageStyle }\n\t\t/>\n\t);\n};\n\nconst HelpDetailBadge = ( { text } ) => {\n\treturn (\n\t\t<View style={ styles.helpDetailBadgeContainer }>\n\t\t\t<Text style={ styles.helpDetailBadgeText }>{ text }</Text>\n\t\t</View>\n\t);\n};\n"]}
|
|
@@ -11,8 +11,10 @@ import { has, get } from 'lodash';
|
|
|
11
11
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
12
|
import { applyFilters } from '@wordpress/hooks';
|
|
13
13
|
import { DropZone, Button, Spinner, ResponsiveWrapper, withNotices, withFilters } from '@wordpress/components';
|
|
14
|
+
import { isBlobURL } from '@wordpress/blob';
|
|
15
|
+
import { useState } from '@wordpress/element';
|
|
14
16
|
import { compose } from '@wordpress/compose';
|
|
15
|
-
import {
|
|
17
|
+
import { useSelect, withDispatch, withSelect } from '@wordpress/data';
|
|
16
18
|
import { MediaUpload, MediaUploadCheck, store as blockEditorStore } from '@wordpress/block-editor';
|
|
17
19
|
import { store as coreStore } from '@wordpress/core-data';
|
|
18
20
|
/**
|
|
@@ -29,6 +31,42 @@ const DEFAULT_SET_FEATURE_IMAGE_LABEL = __('Set featured image');
|
|
|
29
31
|
|
|
30
32
|
const DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __('Remove image');
|
|
31
33
|
|
|
34
|
+
const instructions = createElement("p", null, __('To edit the featured image, you need permission to upload media.'));
|
|
35
|
+
|
|
36
|
+
function getMediaDetails(media, postId) {
|
|
37
|
+
if (!media) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const defaultSize = applyFilters('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
|
|
42
|
+
|
|
43
|
+
if (has(media, ['media_details', 'sizes', defaultSize])) {
|
|
44
|
+
return {
|
|
45
|
+
mediaWidth: media.media_details.sizes[defaultSize].width,
|
|
46
|
+
mediaHeight: media.media_details.sizes[defaultSize].height,
|
|
47
|
+
mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
|
|
48
|
+
};
|
|
49
|
+
} // Use fallbackSize when defaultSize is not available.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const fallbackSize = applyFilters('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
|
|
53
|
+
|
|
54
|
+
if (has(media, ['media_details', 'sizes', fallbackSize])) {
|
|
55
|
+
return {
|
|
56
|
+
mediaWidth: media.media_details.sizes[fallbackSize].width,
|
|
57
|
+
mediaHeight: media.media_details.sizes[fallbackSize].height,
|
|
58
|
+
mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
|
|
59
|
+
};
|
|
60
|
+
} // Use full image size when fallbackSize and defaultSize are not available.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
mediaWidth: media.media_details.width,
|
|
65
|
+
mediaHeight: media.media_details.height,
|
|
66
|
+
mediaSourceUrl: media.source_url
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
32
70
|
function PostFeaturedImage(_ref) {
|
|
33
71
|
var _media$media_details$, _media$media_details$2;
|
|
34
72
|
|
|
@@ -36,40 +74,46 @@ function PostFeaturedImage(_ref) {
|
|
|
36
74
|
currentPostId,
|
|
37
75
|
featuredImageId,
|
|
38
76
|
onUpdateImage,
|
|
39
|
-
onDropImage,
|
|
40
77
|
onRemoveImage,
|
|
41
78
|
media,
|
|
42
79
|
postType,
|
|
43
|
-
noticeUI
|
|
80
|
+
noticeUI,
|
|
81
|
+
noticeOperations
|
|
44
82
|
} = _ref;
|
|
83
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
84
|
+
const mediaUpload = useSelect(select => {
|
|
85
|
+
return select(blockEditorStore).getSettings().mediaUpload;
|
|
86
|
+
}, []);
|
|
45
87
|
const postLabel = get(postType, ['labels'], {});
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
const {
|
|
89
|
+
mediaWidth,
|
|
90
|
+
mediaHeight,
|
|
91
|
+
mediaSourceUrl
|
|
92
|
+
} = getMediaDetails(media, currentPostId);
|
|
93
|
+
|
|
94
|
+
function onDropFiles(filesList) {
|
|
95
|
+
mediaUpload({
|
|
96
|
+
allowedTypes: ['image'],
|
|
97
|
+
filesList,
|
|
98
|
+
|
|
99
|
+
onFileChange(_ref2) {
|
|
100
|
+
let [image] = _ref2;
|
|
101
|
+
|
|
102
|
+
if (isBlobURL(image === null || image === void 0 ? void 0 : image.url)) {
|
|
103
|
+
setIsLoading(true);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onUpdateImage(image);
|
|
108
|
+
setIsLoading(false);
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
onError(message) {
|
|
112
|
+
noticeOperations.removeAllNotices();
|
|
113
|
+
noticeOperations.createErrorNotice(message);
|
|
71
114
|
}
|
|
72
|
-
|
|
115
|
+
|
|
116
|
+
});
|
|
73
117
|
}
|
|
74
118
|
|
|
75
119
|
return createElement(PostFeaturedImageCheck, null, noticeUI, createElement("div", {
|
|
@@ -87,10 +131,10 @@ function PostFeaturedImage(_ref) {
|
|
|
87
131
|
unstableFeaturedImageFlow: true,
|
|
88
132
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
89
133
|
modalClass: "editor-post-featured-image__media-modal",
|
|
90
|
-
render:
|
|
134
|
+
render: _ref3 => {
|
|
91
135
|
let {
|
|
92
136
|
open
|
|
93
|
-
} =
|
|
137
|
+
} = _ref3;
|
|
94
138
|
return createElement("div", {
|
|
95
139
|
className: "editor-post-featured-image__container"
|
|
96
140
|
}, createElement(Button, {
|
|
@@ -105,27 +149,27 @@ function PostFeaturedImage(_ref) {
|
|
|
105
149
|
}, createElement("img", {
|
|
106
150
|
src: mediaSourceUrl,
|
|
107
151
|
alt: ""
|
|
108
|
-
})),
|
|
109
|
-
onFilesDrop:
|
|
152
|
+
})), isLoading && createElement(Spinner, null), !featuredImageId && !isLoading && (postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)), createElement(DropZone, {
|
|
153
|
+
onFilesDrop: onDropFiles
|
|
110
154
|
}));
|
|
111
155
|
},
|
|
112
156
|
value: featuredImageId
|
|
113
|
-
})), !!featuredImageId &&
|
|
157
|
+
})), !!featuredImageId && createElement(MediaUploadCheck, null, media && createElement(MediaUpload, {
|
|
114
158
|
title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
|
|
115
159
|
onSelect: onUpdateImage,
|
|
116
160
|
unstableFeaturedImageFlow: true,
|
|
117
161
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
118
162
|
modalClass: "editor-post-featured-image__media-modal",
|
|
119
|
-
render:
|
|
163
|
+
render: _ref4 => {
|
|
120
164
|
let {
|
|
121
165
|
open
|
|
122
|
-
} =
|
|
166
|
+
} = _ref4;
|
|
123
167
|
return createElement(Button, {
|
|
124
168
|
onClick: open,
|
|
125
169
|
variant: "secondary"
|
|
126
170
|
}, __('Replace Image'));
|
|
127
171
|
}
|
|
128
|
-
})
|
|
172
|
+
}), createElement(Button, {
|
|
129
173
|
onClick: onRemoveImage,
|
|
130
174
|
variant: "link",
|
|
131
175
|
isDestructive: true
|
|
@@ -151,13 +195,13 @@ const applyWithSelect = withSelect(select => {
|
|
|
151
195
|
featuredImageId
|
|
152
196
|
};
|
|
153
197
|
});
|
|
154
|
-
const applyWithDispatch = withDispatch((dispatch,
|
|
198
|
+
const applyWithDispatch = withDispatch((dispatch, _ref5, _ref6) => {
|
|
155
199
|
let {
|
|
156
200
|
noticeOperations
|
|
157
|
-
} =
|
|
201
|
+
} = _ref5;
|
|
158
202
|
let {
|
|
159
203
|
select
|
|
160
|
-
} =
|
|
204
|
+
} = _ref6;
|
|
161
205
|
const {
|
|
162
206
|
editPost
|
|
163
207
|
} = dispatch(editorStore);
|
|
@@ -173,8 +217,8 @@ const applyWithDispatch = withDispatch((dispatch, _ref4, _ref5) => {
|
|
|
173
217
|
allowedTypes: ['image'],
|
|
174
218
|
filesList,
|
|
175
219
|
|
|
176
|
-
onFileChange(
|
|
177
|
-
let [image] =
|
|
220
|
+
onFileChange(_ref7) {
|
|
221
|
+
let [image] = _ref7;
|
|
178
222
|
editPost({
|
|
179
223
|
featured_media: image.id
|
|
180
224
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"names":["has","get","__","sprintf","applyFilters","DropZone","Button","Spinner","ResponsiveWrapper","withNotices","withFilters","compose","withSelect","withDispatch","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","DEFAULT_REMOVE_FEATURE_IMAGE_LABEL","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onDropImage","onRemoveImage","media","postType","noticeUI","postLabel","instructions","mediaWidth","mediaHeight","mediaSourceUrl","mediaSize","id","media_details","sizes","width","height","source_url","fallbackMediaSize","alt_text","full","file","slug","featured_image","open","set_featured_image","isLoading","remove_featured_image","applyWithSelect","select","getMedia","getPostType","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","noticeOperations","editPost","image","featured_media","filesList","getSettings","mediaUpload","allowedTypes","onFileChange","onError","message","removeAllNotices","createErrorNotice"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,OAHD,EAICC,iBAJD,EAKCC,WALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SACCC,WADD,EAECC,gBAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,SAAnC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,aAArC;AAEA,MAAMC,mBAAmB,GAAG,CAAE,OAAF,CAA5B,C,CAEA;;AACA,MAAMC,2BAA2B,GAAGpB,EAAE,CAAE,gBAAF,CAAtC;;AACA,MAAMqB,+BAA+B,GAAGrB,EAAE,CAAE,oBAAF,CAA1C;;AACA,MAAMsB,kCAAkC,GAAGtB,EAAE,CAAE,cAAF,CAA7C;;AAEA,SAASuB,iBAAT,OASI;AAAA;;AAAA,MATwB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,CAAEwC,SAAF,EAAc;AACxBZ,MAAAA,MAAM,CAAExC,gBAAF,CAAN,CACEqD,WADF,GAEEC,WAFF,CAEe;AACbC,QAAAA,YAAY,EAAE,CAAE,OAAF,CADD;AAEbH,QAAAA,SAFa;;AAGbI,QAAAA,YAAY,QAAc;AAAA,cAAZ,CAAEN,KAAF,CAAY;AACzBD,UAAAA,QAAQ,CAAE;AAAEE,YAAAA,cAAc,EAAED,KAAK,CAAC3B;AAAxB,WAAF,CAAR;AACA,SALY;;AAMbkC,QAAAA,OAAO,CAAEC,OAAF,EAAY;AAClBV,UAAAA,gBAAgB,CAACW,gBAAjB;AACAX,UAAAA,gBAAgB,CAACY,iBAAjB,CAAoCF,OAApC;AACA;;AATY,OAFf;AAaA,KAlBK;;AAmBN7C,IAAAA,aAAa,GAAG;AACfoC,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,cAAc,EAAE;AAAlB,OAAF,CAAR;AACA;;AArBK,GAAP;AAuBA,CA1BoC,CAAtC;AA6BA,eAAezD,OAAO,CACrBF,WADqB,EAErB+C,eAFqB,EAGrBO,iBAHqB,EAIrBrD,WAAW,CAAE,0BAAF,CAJU,CAAP,CAKZe,iBALY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { has, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\tResponsiveWrapper,\n\twithNotices,\n\twithFilters,\n} from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );\nconst DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove image' );\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonDropImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n} ) {\n\tconst postLabel = get( postType, [ 'labels' ], {} );\n\tconst instructions = (\n\t\t<p>\n\t\t\t{ __(\n\t\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t\t) }\n\t\t</p>\n\t);\n\n\tlet mediaWidth, mediaHeight, mediaSourceUrl;\n\tif ( media ) {\n\t\tconst mediaSize = applyFilters(\n\t\t\t'editor.PostFeaturedImage.imageSize',\n\t\t\t'post-thumbnail',\n\t\t\tmedia.id,\n\t\t\tcurrentPostId\n\t\t);\n\t\tif ( has( media, [ 'media_details', 'sizes', mediaSize ] ) ) {\n\t\t\t// Use mediaSize when available.\n\t\t\tmediaWidth = media.media_details.sizes[ mediaSize ].width;\n\t\t\tmediaHeight = media.media_details.sizes[ mediaSize ].height;\n\t\t\tmediaSourceUrl = media.media_details.sizes[ mediaSize ].source_url;\n\t\t} else {\n\t\t\t// Get fallbackMediaSize if mediaSize is not available.\n\t\t\tconst fallbackMediaSize = applyFilters(\n\t\t\t\t'editor.PostFeaturedImage.imageSize',\n\t\t\t\t'thumbnail',\n\t\t\t\tmedia.id,\n\t\t\t\tcurrentPostId\n\t\t\t);\n\t\t\tif (\n\t\t\t\thas( media, [ 'media_details', 'sizes', fallbackMediaSize ] )\n\t\t\t) {\n\t\t\t\t// Use fallbackMediaSize when mediaSize is not available.\n\t\t\t\tmediaWidth =\n\t\t\t\t\tmedia.media_details.sizes[ fallbackMediaSize ].width;\n\t\t\t\tmediaHeight =\n\t\t\t\t\tmedia.media_details.sizes[ fallbackMediaSize ].height;\n\t\t\t\tmediaSourceUrl =\n\t\t\t\t\tmedia.media_details.sizes[ fallbackMediaSize ].source_url;\n\t\t\t} else {\n\t\t\t\t// Use full image size when mediaFallbackSize and mediaSize are not available.\n\t\t\t\tmediaWidth = media.media_details.width;\n\t\t\t\tmediaHeight = media.media_details.height;\n\t\t\t\tmediaSourceUrl = media.source_url;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image filename.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmedia.media_details.sizes?.full?.file ||\n\t\t\t\t\t\t\t\t\tmedia.slug\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostLabel.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Edit or update the image' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t<ResponsiveWrapper\n\t\t\t\t\t\t\t\t\t\t\tnaturalWidth={ mediaWidth }\n\t\t\t\t\t\t\t\t\t\t\tnaturalHeight={ mediaHeight }\n\t\t\t\t\t\t\t\t\t\t\tisInline\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ResponsiveWrapper>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && ! media && (\n\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t( postLabel.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropImage } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t\t{ !! featuredImageId && media && ! media.isLoading && (\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\tpostLabel.featured_image ||\n\t\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t<Button onClick={ open } variant=\"secondary\">\n\t\t\t\t\t\t\t\t\t{ __( 'Replace Image' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t) }\n\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onRemoveImage }\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postLabel.remove_featured_image ||\n\t\t\t\t\t\t\t\tDEFAULT_REMOVE_FEATURE_IMAGE_LABEL }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType } = select( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"names":["has","get","__","sprintf","applyFilters","DropZone","Button","Spinner","ResponsiveWrapper","withNotices","withFilters","isBlobURL","useState","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","DEFAULT_REMOVE_FEATURE_IMAGE_LABEL","instructions","getMediaDetails","media","postId","defaultSize","id","mediaWidth","media_details","sizes","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isLoading","setIsLoading","mediaUpload","select","getSettings","postLabel","onDropFiles","filesList","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","alt_text","full","file","slug","featured_image","open","set_featured_image","remove_featured_image","applyWithSelect","getMedia","getPostType","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,OAHD,EAICC,iBAJD,EAKCC,WALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,UAAlC,QAAoD,iBAApD;AACA,SACCC,WADD,EAECC,gBAFD,EAGCC,KAAK,IAAIC,gBAHV,Q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F,EAAU;AACtBsB,MAAAA,QAAQ,CAAE;AAAEC,QAAAA,cAAc,EAAEvB,KAAK,CAAC5B;AAAxB,OAAF,CAAR;AACA,KAHK;;AAINoD,IAAAA,WAAW,CAAE3B,SAAF,EAAc;AACxBJ,MAAAA,MAAM,CAAElC,gBAAF,CAAN,CACEmC,WADF,GAEEF,WAFF,CAEe;AACbM,QAAAA,YAAY,EAAE,CAAE,OAAF,CADD;AAEbD,QAAAA,SAFa;;AAGbE,QAAAA,YAAY,QAAc;AAAA,cAAZ,CAAEC,KAAF,CAAY;AACzBsB,UAAAA,QAAQ,CAAE;AAAEC,YAAAA,cAAc,EAAEvB,KAAK,CAAC5B;AAAxB,WAAF,CAAR;AACA,SALY;;AAMb8B,QAAAA,OAAO,CAAEC,OAAF,EAAY;AAClBd,UAAAA,gBAAgB,CAACe,gBAAjB;AACAf,UAAAA,gBAAgB,CAACgB,iBAAjB,CAAoCF,OAApC;AACA;;AATY,OAFf;AAaA,KAlBK;;AAmBNjB,IAAAA,aAAa,GAAG;AACfoC,MAAAA,QAAQ,CAAE;AAAEC,QAAAA,cAAc,EAAE;AAAlB,OAAF,CAAR;AACA;;AArBK,GAAP;AAuBA,CA1BoC,CAAtC;AA6BA,eAAevE,OAAO,CACrBJ,WADqB,EAErBkE,eAFqB,EAGrBM,iBAHqB,EAIrBvE,WAAW,CAAE,0BAAF,CAJU,CAAP,CAKZiC,iBALY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { has, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\tResponsiveWrapper,\n\twithNotices,\n\twithFilters,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );\nconst DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = __( 'Remove image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( has( media, [ 'media_details', 'sizes', defaultSize ] ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( has( media, [ 'media_details', 'sizes', fallbackSize ] ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n} ) {\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst postLabel = get( postType, [ 'labels' ], {} );\n\tconst { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(\n\t\tmedia,\n\t\tcurrentPostId\n\t);\n\n\tfunction onDropFiles( filesList ) {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonUpdateImage( image );\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image filename.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmedia.media_details.sizes?.full?.file ||\n\t\t\t\t\t\t\t\t\tmedia.slug\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostLabel.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Edit or update the image' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t<ResponsiveWrapper\n\t\t\t\t\t\t\t\t\t\t\tnaturalWidth={ mediaWidth }\n\t\t\t\t\t\t\t\t\t\t\tnaturalHeight={ mediaHeight }\n\t\t\t\t\t\t\t\t\t\t\tisInline\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ResponsiveWrapper>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isLoading && <Spinner /> }\n\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t( postLabel.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t{ media && (\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\tpostLabel.featured_image ||\n\t\t\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Replace Image' ) }\n\t\t\t\t\t\t\t\t\t</Button>\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\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onRemoveImage }\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postLabel.remove_featured_image ||\n\t\t\t\t\t\t\t\tDEFAULT_REMOVE_FEATURE_IMAGE_LABEL }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType } = select( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"]}
|
|
@@ -5,8 +5,8 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { __experimentalGetSettings } from '@wordpress/date';
|
|
7
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';
|
|
9
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -21,7 +21,10 @@ function getDayOfTheMonth() {
|
|
|
21
21
|
return new Date(d.getFullYear(), d.getMonth() + (firstDay ? 0 : 1), firstDay ? 1 : 0).toISOString();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export default function PostSchedule() {
|
|
24
|
+
export default function PostSchedule(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
onClose
|
|
27
|
+
} = _ref;
|
|
25
28
|
const {
|
|
26
29
|
postDate,
|
|
27
30
|
postType
|
|
@@ -45,19 +48,18 @@ export default function PostSchedule() {
|
|
|
45
48
|
before: getDayOfTheMonth(previewedMonth, false),
|
|
46
49
|
exclude: [select(editorStore).getCurrentPostId()]
|
|
47
50
|
}), [previewedMonth, postType]);
|
|
48
|
-
const events = useMemo(() => (eventsByPostType || []).map(
|
|
51
|
+
const events = useMemo(() => (eventsByPostType || []).map(_ref2 => {
|
|
49
52
|
let {
|
|
50
53
|
title,
|
|
51
54
|
type,
|
|
52
55
|
date: eventDate
|
|
53
|
-
} =
|
|
56
|
+
} = _ref2;
|
|
54
57
|
return {
|
|
55
58
|
title: title === null || title === void 0 ? void 0 : title.rendered,
|
|
56
59
|
type,
|
|
57
60
|
date: new Date(eventDate)
|
|
58
61
|
};
|
|
59
62
|
}), [eventsByPostType]);
|
|
60
|
-
const ref = useRef();
|
|
61
63
|
|
|
62
64
|
const settings = __experimentalGetSettings(); // To know if the current timezone is a 12 hour time with look for "a" in the time format
|
|
63
65
|
// We also make sure this a is not escaped by a "/"
|
|
@@ -67,22 +69,13 @@ export default function PostSchedule() {
|
|
|
67
69
|
.replace(/\\\\/g, '') // Replace "//" with empty strings.
|
|
68
70
|
.split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
|
|
69
71
|
);
|
|
70
|
-
|
|
71
|
-
function onChange(newDate) {
|
|
72
|
-
onUpdateDate(newDate);
|
|
73
|
-
const {
|
|
74
|
-
ownerDocument
|
|
75
|
-
} = ref.current;
|
|
76
|
-
ownerDocument.activeElement.blur();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return createElement(DateTimePicker, {
|
|
80
|
-
ref: ref,
|
|
72
|
+
return createElement(PublishDateTimePicker, {
|
|
81
73
|
currentDate: postDate,
|
|
82
|
-
onChange:
|
|
74
|
+
onChange: onUpdateDate,
|
|
83
75
|
is12Hour: is12HourTime,
|
|
84
76
|
events: events,
|
|
85
|
-
onMonthPreviewed: setPreviewedMonth
|
|
77
|
+
onMonthPreviewed: setPreviewedMonth,
|
|
78
|
+
onClose: onClose
|
|
86
79
|
});
|
|
87
80
|
}
|
|
88
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["__experimentalGetSettings","useDispatch","useSelect","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["__experimentalGetSettings","useDispatch","useSelect","__experimentalPublishDateTimePicker","PublishDateTimePicker","useState","useMemo","store","coreStore","editorStore","getDayOfTheMonth","date","Date","firstDay","d","getFullYear","getMonth","toISOString","PostSchedule","onClose","postDate","postType","select","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","previewedMonth","setPreviewedMonth","eventsByPostType","getEntityRecords","status","after","before","exclude","getCurrentPostId","events","map","title","type","eventDate","rendered","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,yBAAT,QAA0C,iBAA1C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,mCAAmC,IAAIC,qBAAhD,QAA6E,yBAA7E;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,aAArC;;AAEA,SAASC,gBAAT,GAAgE;AAAA,MAArCC,IAAqC,uEAA9B,IAAIC,IAAJ,EAA8B;AAAA,MAAlBC,QAAkB,uEAAP,IAAO;AAC/D,QAAMC,CAAC,GAAG,IAAIF,IAAJ,CAAUD,IAAV,CAAV;AACA,SAAO,IAAIC,IAAJ,CACNE,CAAC,CAACC,WAAF,EADM,EAEND,CAAC,CAACE,QAAF,MAAiBH,QAAQ,GAAG,CAAH,GAAO,CAAhC,CAFM,EAGNA,QA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,GAA3B,CACC;AAAA,QAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,IAAT;AAAe5B,MAAAA,IAAI,EAAE6B;AAArB,KAAF;AAAA,WAA0C;AACzCF,MAAAA,KAAK,EAAEA,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAEG,QAD2B;AAEzCF,MAAAA,IAFyC;AAGzC5B,MAAAA,IAAI,EAAE,IAAIC,IAAJ,CAAU4B,SAAV;AAHmC,KAA1C;AAAA,GADD,CAFoB,EASrB,CAAEX,gBAAF,CATqB,CAAtB;;AAYA,QAAMa,QAAQ,GAAG1C,yBAAyB,EAA1C,CAxCmD,CA0CnD;AACA;;;AACA,QAAM2C,YAAY,GAAG,WAAWC,IAAX,CACpBF,QAAQ,CAACG,OAAT,CAAiBC,IAAjB,CACEC,WADF,GACgB;AADhB,GAEEC,OAFF,CAEW,OAFX,EAEoB,EAFpB,EAEyB;AAFzB,GAGEC,KAHF,CAGS,EAHT,EAIEC,OAJF,GAKEC,IALF,CAKQ,EALR,CADoB,CAMP;AANO,GAArB;AASA,SACC,cAAC,qBAAD;AACC,IAAA,WAAW,EAAG/B,QADf;AAEC,IAAA,QAAQ,EAAGM,YAFZ;AAGC,IAAA,QAAQ,EAAGiB,YAHZ;AAIC,IAAA,MAAM,EAAGP,MAJV;AAKC,IAAA,gBAAgB,EAAGR,iBALpB;AAMC,IAAA,OAAO,EAAGT;AANX,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGetSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getDayOfTheMonth( date = new Date(), firstDay = true ) {\n\tconst d = new Date( date );\n\treturn new Date(\n\t\td.getFullYear(),\n\t\td.getMonth() + ( firstDay ? 0 : 1 ),\n\t\tfirstDay ? 1 : 0\n\t).toISOString();\n}\n\nexport default function PostSchedule( { onClose } ) {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tgetDayOfTheMonth( postDate )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: getDayOfTheMonth( previewedMonth ),\n\t\t\t\tbefore: getDayOfTheMonth( previewedMonth, false ),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map(\n\t\t\t\t( { title, type, date: eventDate } ) => ( {\n\t\t\t\t\ttitle: title?.rendered,\n\t\t\t\t\ttype,\n\t\t\t\t\tdate: new Date( eventDate ),\n\t\t\t\t} )\n\t\t\t),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst settings = __experimentalGetSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\treturn (\n\t\t<PublishDateTimePicker\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onUpdateDate }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ setPreviewedMonth }\n\t\t\tonClose={ onClose }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -139,7 +139,7 @@ function FlatTermSelector(_ref) {
|
|
|
139
139
|
|
|
140
140
|
useEffect(() => {
|
|
141
141
|
if (hasResolvedTerms) {
|
|
142
|
-
const newValues = terms.map(term => unescapeString(term.name));
|
|
142
|
+
const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
|
|
143
143
|
setValues(newValues);
|
|
144
144
|
}
|
|
145
145
|
}, [terms, hasResolvedTerms]);
|
|
@@ -161,7 +161,7 @@ function FlatTermSelector(_ref) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
function onChange(termNames) {
|
|
164
|
-
const availableTerms = [...terms, ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
|
|
164
|
+
const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
|
|
165
165
|
const uniqueTerms = uniqBy(termNames, term => term.toLowerCase());
|
|
166
166
|
const newTermNames = uniqueTerms.filter(termName => !find(availableTerms, term => isSameTermName(term.name, termName))); // Optimistically update term values.
|
|
167
167
|
// The selector will always re-fetch terms later.
|