@wordpress/edit-post 6.5.0 → 6.8.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/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +12 -4
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/device-preview/index.js +26 -7
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +6 -5
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +6 -4
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/header/template-title/index.js.map +1 -1
- package/build/components/header/template-title/template-description.js +3 -1
- package/build/components/header/template-title/template-description.js.map +1 -1
- package/build/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +10 -6
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build/components/sidebar/featured-image/index.js.map +1 -1
- package/build/components/sidebar/page-attributes/index.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +9 -2
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/template/actions.js +7 -2
- package/build/components/sidebar/template/actions.js.map +1 -1
- package/build/components/sidebar/template/index.js.map +1 -1
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/text-editor/index.js +11 -24
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/block-inspector-button.js +3 -7
- package/build/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +8 -0
- package/build/editor.native.js.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/plugins/copy-content-menu-item/index.js +1 -1
- package/build/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +13 -5
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/device-preview/index.js +24 -7
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +6 -5
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +6 -4
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/header/template-title/index.js.map +1 -1
- package/build-module/components/header/template-title/template-description.js +4 -2
- package/build-module/components/header/template-title/template-description.js.map +1 -1
- package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +10 -6
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build-module/components/sidebar/featured-image/index.js.map +1 -1
- package/build-module/components/sidebar/page-attributes/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +9 -2
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/template/actions.js +8 -3
- package/build-module/components/sidebar/template/actions.js.map +1 -1
- package/build-module/components/sidebar/template/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +11 -22
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/block-inspector-button.js +3 -5
- package/build-module/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +8 -0
- package/build-module/editor.native.js.map +1 -1
- package/build-module/index.js +7 -1
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +32 -18
- package/build-style/style.css +32 -18
- package/package.json +28 -28
- package/src/components/block-manager/category.js +2 -2
- package/src/components/block-manager/index.js +15 -4
- package/src/components/device-preview/index.js +40 -29
- package/src/components/editor-initialization/listener-hooks.js +2 -3
- package/src/components/header/fullscreen-mode-close/index.js +2 -3
- package/src/components/header/header-toolbar/index.js +6 -11
- package/src/components/header/index.js +6 -9
- package/src/components/header/mode-switcher/index.js +4 -4
- package/src/components/header/post-publish-button-or-toggle.js +4 -6
- package/src/components/header/style.scss +2 -4
- package/src/components/header/template-title/delete-template.js +13 -7
- package/src/components/header/template-title/edit-template-title.js +29 -26
- package/src/components/header/template-title/index.js +2 -3
- package/src/components/header/template-title/style.scss +26 -5
- package/src/components/header/template-title/template-description.js +3 -2
- package/src/components/header/tools-more-menu-group/index.js +2 -3
- package/src/components/keyboard-shortcut-help-modal/test/index.js +2 -1
- package/src/components/keyboard-shortcuts/index.js +4 -8
- package/src/components/layout/actions-panel.js +6 -9
- package/src/components/layout/index.js +13 -21
- package/src/components/layout/index.native.js +4 -5
- package/src/components/preferences-modal/index.js +18 -9
- package/src/components/preferences-modal/options/enable-custom-fields.js +2 -2
- package/src/components/preferences-modal/options/enable-panel.js +2 -3
- package/src/components/preferences-modal/options/enable-publish-sidebar.js +2 -3
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +24 -14
- package/src/components/secondary-sidebar/inserter-sidebar.js +2 -3
- package/src/components/sidebar/discussion-panel/index.js +2 -3
- package/src/components/sidebar/featured-image/index.js +2 -3
- package/src/components/sidebar/page-attributes/index.js +2 -3
- package/src/components/sidebar/plugin-document-setting-panel/index.js +2 -3
- package/src/components/sidebar/plugin-sidebar/index.js +2 -3
- package/src/components/sidebar/post-excerpt/index.js +2 -3
- package/src/components/sidebar/post-link/index.js +2 -3
- package/src/components/sidebar/post-schedule/index.js +4 -2
- package/src/components/sidebar/post-schedule/style.scss +3 -5
- package/src/components/sidebar/post-status/index.js +2 -3
- package/src/components/sidebar/post-visibility/style.scss +2 -1
- package/src/components/sidebar/settings-header/style.scss +1 -1
- package/src/components/sidebar/template/actions.js +11 -8
- package/src/components/sidebar/template/index.js +2 -6
- package/src/components/start-page-options/index.js +8 -12
- package/src/components/text-editor/index.js +9 -19
- package/src/components/visual-editor/block-inspector-button.js +4 -8
- package/src/components/visual-editor/test/index.native.js +93 -0
- package/src/editor.js +6 -8
- package/src/editor.native.js +11 -4
- package/src/index.js +7 -0
- package/src/plugins/copy-content-menu-item/index.js +1 -1
- package/src/store/actions.js +322 -295
- package/src/store/selectors.js +20 -20
|
@@ -14,7 +14,7 @@ export function PostSchedule() {
|
|
|
14
14
|
ref: anchorRef
|
|
15
15
|
}, createElement("span", null, __('Publish')), createElement(Dropdown, {
|
|
16
16
|
popoverProps: {
|
|
17
|
-
anchorRef
|
|
17
|
+
anchorRef
|
|
18
18
|
},
|
|
19
19
|
position: "bottom left",
|
|
20
20
|
contentClassName: "edit-post-post-schedule__dialog",
|
|
@@ -30,7 +30,14 @@ export function PostSchedule() {
|
|
|
30
30
|
variant: "tertiary"
|
|
31
31
|
}, createElement(PostScheduleLabel, null)));
|
|
32
32
|
},
|
|
33
|
-
renderContent:
|
|
33
|
+
renderContent: _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
onClose
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return createElement(PostScheduleForm, {
|
|
38
|
+
onClose: onClose
|
|
39
|
+
});
|
|
40
|
+
}
|
|
34
41
|
})));
|
|
35
42
|
}
|
|
36
43
|
export default PostSchedule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-schedule/index.js"],"names":["__","PanelRow","Dropdown","Button","useRef","PostSchedule","PostScheduleForm","PostScheduleLabel","PostScheduleCheck","anchorRef","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-schedule/index.js"],"names":["__","PanelRow","Dropdown","Button","useRef","PostSchedule","PostScheduleForm","PostScheduleLabel","PostScheduleCheck","anchorRef","onToggle","isOpen","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SACCC,YAAY,IAAIC,gBADjB,EAECC,iBAFD,EAGCC,iBAHD,QAIO,mBAJP;AAMA,OAAO,SAASH,YAAT,GAAwB;AAC9B,QAAMI,SAAS,GAAGL,MAAM,EAAxB;AAEA,SACC,cAAC,iBAAD,QACC,cAAC,QAAD;AAAU,IAAA,SAAS,EAAC,yBAApB;AAA8C,IAAA,GAAG,EAAGK;AAApD,KACC,4BAAQT,EAAE,CAAE,SAAF,CAAV,CADD,EAEC,cAAC,QAAD;AACC,IAAA,YAAY,EAAG;AAAES,MAAAA;AAAF,KADhB;AAEC,IAAA,QAAQ,EAAC,aAFV;AAGC,IAAA,gBAAgB,EAAC,iCAHlB;AAIC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,QAAF;AAAYC,QAAAA;AAAZ,OAAF;AAAA,aACd,8BACC,cAAC,MAAD;AACC,QAAA,SAAS,EAAC,iCADX;AAEC,QAAA,OAAO,EAAGD,QAFX;AAGC,yBAAgBC,MAHjB;AAIC,QAAA,OAAO,EAAC;AAJT,SAMC,cAAC,iBAAD,OAND,CADD,CADc;AAAA,KAJhB;AAgBC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACf,cAAC,gBAAD;AAAkB,QAAA,OAAO,EAAGA;AAA5B,QADe;AAAA;AAhBjB,IAFD,CADD,CADD;AA2BA;AAED,eAAeP,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelRow, Dropdown, Button } from '@wordpress/components';\nimport { useRef } from '@wordpress/element';\nimport {\n\tPostSchedule as PostScheduleForm,\n\tPostScheduleLabel,\n\tPostScheduleCheck,\n} from '@wordpress/editor';\n\nexport function PostSchedule() {\n\tconst anchorRef = useRef();\n\n\treturn (\n\t\t<PostScheduleCheck>\n\t\t\t<PanelRow className=\"edit-post-post-schedule\" ref={ anchorRef }>\n\t\t\t\t<span>{ __( 'Publish' ) }</span>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ { anchorRef } }\n\t\t\t\t\tposition=\"bottom left\"\n\t\t\t\t\tcontentClassName=\"edit-post-post-schedule__dialog\"\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-post-post-schedule__toggle\"\n\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostScheduleLabel />\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostScheduleForm onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PanelRow>\n\t\t</PostScheduleCheck>\n\t);\n}\n\nexport default PostSchedule;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-status/index.js"],"names":["__","PanelBody","withSelect","withDispatch","compose","ifCondition","PostVisibility","PostTrash","PostSchedule","PostSticky","PostAuthor","PostSlug","PostFormat","PostPendingStatus","PluginPostStatusInfo","store","editPostStore","PANEL_NAME","PostStatus","isOpened","onTogglePanel","fills","select","isEditorPanelRemoved","isEditorPanelOpened","isR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AAM;AAAEC,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-status/index.js"],"names":["__","PanelBody","withSelect","withDispatch","compose","ifCondition","PostVisibility","PostTrash","PostSchedule","PostSticky","PostAuthor","PostSlug","PostFormat","PostPendingStatus","PluginPostStatusInfo","store","editPostStore","PANEL_NAME","PostStatus","isOpened","onTogglePanel","fills","select","isEditorPanelRemoved","isEditorPanelOpened","isRemoved","dispatch","toggleEditorPanelOpened"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,uBAA1B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG,aAAnB;;AAEA,SAASC,UAAT,OAAmD;AAAA,MAA9B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA8B;AAClD,SACC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,uBADX;AAEC,IAAA,KAAK,EAAGpB,EAAE,CAAE,qBAAF,CAFX;AAGC,IAAA,MAAM,EAAGmB,QAHV;AAIC,IAAA,QAAQ,EAAGC;AAJZ,KAMC,cAAC,oBAAD,CAAsB,IAAtB,QACKC,KAAF,IACD,8BACC,cAAC,cAAD,OADD,EAEC,cAAC,YAAD,OAFD,EAGC,cAAC,UAAD,OAHD,EAIC,cAAC,UAAD,OAJD,EAKC,cAAC,iBAAD,OALD,EAMC,cAAC,QAAD,OAND,EAOC,cAAC,UAAD,OAPD,EAQGA,KARH,EASC,cAAC,SAAD,OATD,CAFF,CAND,CADD;AAwBA;;AAED,eAAejB,OAAO,CAAE,CACvBF,UAAU,CAAIoB,MAAF,IAAc;AACzB;AACA;AACA,QAAM;AAAEC,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MACLF,MAAM,CAAEN,aAAF,CADP;AAEA,SAAO;AACNS,IAAAA,SAAS,EAAEF,oBAAoB,CAAEN,UAAF,CADzB;AAENE,IAAAA,QAAQ,EAAEK,mBAAmB,CAAEP,UAAF;AAFvB,GAAP;AAIA,CATS,CADa,EAWvBZ,WAAW,CAAE;AAAA,MAAE;AAAEoB,IAAAA;AAAF,GAAF;AAAA,SAAqB,CAAEA,SAAvB;AAAA,CAAF,CAXY,EAYvBtB,YAAY,CAAIuB,QAAF,KAAkB;AAC/BN,EAAAA,aAAa,GAAG;AACf,WAAOM,QAAQ,CAAEV,aAAF,CAAR,CAA0BW,uBAA1B,CACNV,UADM,CAAP;AAGA;;AAL8B,CAAlB,CAAF,CAZW,CAAF,CAAP,CAmBVC,UAnBU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostVisibility from '../post-visibility';\nimport PostTrash from '../post-trash';\nimport PostSchedule from '../post-schedule';\nimport PostSticky from '../post-sticky';\nimport PostAuthor from '../post-author';\nimport PostSlug from '../post-slug';\nimport PostFormat from '../post-format';\nimport PostPendingStatus from '../post-pending-status';\nimport PluginPostStatusInfo from '../plugin-post-status-info';\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-status';\n\nfunction PostStatus( { isOpened, onTogglePanel } ) {\n\treturn (\n\t\t<PanelBody\n\t\t\tclassName=\"edit-post-post-status\"\n\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t<PluginPostStatusInfo.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PostVisibility />\n\t\t\t\t\t\t<PostSchedule />\n\t\t\t\t\t\t<PostFormat />\n\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t<PostPendingStatus />\n\t\t\t\t\t\t<PostSlug />\n\t\t\t\t\t\t<PostAuthor />\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t<PostTrash />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PluginPostStatusInfo.Slot>\n\t\t</PanelBody>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\t// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do\n\t\t// not use isEditorPanelEnabled since this panel should not be disabled through the UI.\n\t\tconst { isEditorPanelRemoved, isEditorPanelOpened } =\n\t\t\tselect( editPostStore );\n\t\treturn {\n\t\t\tisRemoved: isEditorPanelRemoved( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t};\n\t} ),\n\tifCondition( ( { isRemoved } ) => ! isRemoved ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonTogglePanel() {\n\t\t\treturn dispatch( editPostStore ).toggleEditorPanelOpened(\n\t\t\t\tPANEL_NAME\n\t\t\t);\n\t\t},\n\t} ) ),\n] )( PostStatus );\n"]}
|
|
@@ -8,7 +8,7 @@ import { kebabCase } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { __, _x } from '@wordpress/i18n';
|
|
11
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
12
12
|
import { Button, Modal, TextControl, Flex, FlexItem } from '@wordpress/components';
|
|
13
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
14
|
import { useState } from '@wordpress/element';
|
|
@@ -22,6 +22,8 @@ import { store as editPostStore } from '../../../store';
|
|
|
22
22
|
import { createBlock, serialize } from '@wordpress/blocks';
|
|
23
23
|
|
|
24
24
|
function PostTemplateActions(_ref) {
|
|
25
|
+
var _template$title$toLow;
|
|
26
|
+
|
|
25
27
|
let {
|
|
26
28
|
isPostsPage
|
|
27
29
|
} = _ref;
|
|
@@ -105,10 +107,13 @@ function PostTemplateActions(_ref) {
|
|
|
105
107
|
className: "edit-post-template__actions"
|
|
106
108
|
}, !!template && createElement(Button, {
|
|
107
109
|
variant: "link",
|
|
108
|
-
onClick: () => __unstableSwitchToTemplateMode()
|
|
110
|
+
onClick: () => __unstableSwitchToTemplateMode(),
|
|
111
|
+
label: sprintf( // Translators: 1: The title or the slug of the currently selected template.
|
|
112
|
+
__('Edit template: %s'), (_template$title$toLow = template === null || template === void 0 ? void 0 : template.title.toLowerCase()) !== null && _template$title$toLow !== void 0 ? _template$title$toLow : template.slug)
|
|
109
113
|
}, __('Edit')), !isPostsPage && createElement(Button, {
|
|
110
114
|
variant: "link",
|
|
111
|
-
onClick: () => setIsModalOpen(true)
|
|
115
|
+
onClick: () => setIsModalOpen(true),
|
|
116
|
+
label: _x('New template', 'action')
|
|
112
117
|
},
|
|
113
118
|
/* translators: button to create a new template */
|
|
114
119
|
_x('New', 'action'))), isModalOpen && createElement(Modal, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/template/actions.js"],"names":["kebabCase","__","_x","Button","Modal","TextControl","Flex","FlexItem","useSelect","useDispatch","useState","store","editorStore","coreStore","editPostStore","createBlock","serialize","PostTemplateActions","isPostsPage","isModalOpen","setIsModalOpen","isBusy","setIsBusy","title","setTitle","template","supportsTemplateMode","defaultTemplate","select","getCurrentPostType","getEditorSettings","getPostType","getEditedPostTemplate","isViewable","viewable","_supportsTemplateMode","defaultBlockTemplate","__unstableCreateTemplate","__unstableSwitchToTemplateMode","defaultTitle","onCreateTemplate","event","preventDefault","newTemplateContent","tagName","layout","inherit","slug","content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SACCC,MADD,EAECC,KAFD,EAGCC,WAHD,EAICC,IAJD,EAKCC,QALD,QAMO,uBANP;AAOA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,gBAAvC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,mBAAvC;;AAEA,SAASC,mBAAT,OAAgD;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AAC/C,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkCV,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM,CAAEW,MAAF,EAAUC,SAAV,IAAwBZ,QAAQ,CAAE,KAAF,CAAtC;AACA,QAAM,CAAEa,KAAF,EAASC,QAAT,IAAsBd,QAAQ,CAAE,EAAF,CAApC;AACA,QAAM;AAAEe,IAAAA,QAAF;AAAYC,IAAAA,oBAAZ;AAAkCC,IAAAA;AAAlC,MAAsDnB,SAAS,CAClEoB,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,kBAAF;AAAsBC,MAAAA;AAAtB,QAA4CF,MAAM,CACvDhB,WADuD,CAAxD;AAGA,UAAM;AAAEmB,MAAAA;AAAF,QAAkBH,M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A,KANF;AAOC,IAAA,gBAAgB,EAAC;AAPlB,KASC;AAAM,IAAA,QAAQ,EAAGgB;AAAjB,KACC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAC,YAAZ;AAAyB,IAAA,GAAG,EAAG;AAA/B,KACC,cAAC,QAAD,QACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGvC,EAAE,CAAE,MAAF,CADX;AAEC,IAAA,KAAK,EAAGsB,KAFT;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,WAAW,EAAGe,YAJf;AAKC,IAAA,QAAQ,EAAGlB,MALZ;AAMC,IAAA,IAAI,EAAGpB,EAAE,CACR,+GADQ;AANV,IADD,CADD,CADD,EAgBC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfmB,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAI,MAAAA,QAAQ,CAAE,EAAF,CAAR;AACA;AALF,KAOGvB,EAAE,CAAE,QAAF,CAPL,CADD,CALD,EAgBC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,MAAM,EAAGoB,MAHV;AAIC,qBAAgBA;AAJjB,KAMGpB,EAAE,CAAE,QAAF,CANL,CADD,CAhBD,CAhBD,CATD,CAvBF,CADD;AAiFA;;AAED,eAAegB,mBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { createBlock, serialize } from '@wordpress/blocks';\n\nfunction PostTemplateActions( { isPostsPage } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\tconst { template, supportsTemplateMode, defaultTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getEditorSettings } = select(\n\t\t\t\teditorStore\n\t\t\t);\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( getCurrentPostType() )?.viewable ?? false;\n\t\t\tconst _supportsTemplateMode =\n\t\t\t\tgetEditorSettings().supportsTemplateMode && isViewable;\n\n\t\t\treturn {\n\t\t\t\ttemplate: _supportsTemplateMode && getEditedPostTemplate(),\n\t\t\t\tsupportsTemplateMode: _supportsTemplateMode,\n\t\t\t\tdefaultTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst {\n\t\t__unstableCreateTemplate,\n\t\t__unstableSwitchToTemplateMode,\n\t} = useDispatch( editPostStore );\n\n\tif ( ! supportsTemplateMode ) {\n\t\treturn null;\n\t}\n\n\tconst defaultTitle = __( 'Custom Template' );\n\n\tasync function onCreateTemplate( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tawait __unstableCreateTemplate( {\n\t\t\tslug: 'wp-custom-template-' + kebabCase( title || defaultTitle ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || defaultTitle,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tsetIsModalOpen( false );\n\n\t\t__unstableSwitchToTemplateMode( true );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-post-template__actions\">\n\t\t\t\t{ !! template && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => __unstableSwitchToTemplateMode() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! isPostsPage && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* translators: button to create a new template */\n\t\t\t\t\t\t\t_x( 'New', 'action' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tsetTitle( '' );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-post-template__modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onCreateTemplate }>\n\t\t\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\t\tplaceholder={ defaultTitle }\n\t\t\t\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the template, e.g. \"Full Width\". Custom templates can be applied to any post or page.'\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</FlexItem>\n\t\t\t\t\t\t</Flex>\n\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"edit-post-template__modal-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t\tsetTitle( '' );\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{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default PostTemplateActions;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/template/actions.js"],"names":["kebabCase","__","_x","sprintf","Button","Modal","TextControl","Flex","FlexItem","useSelect","useDispatch","useState","store","editorStore","coreStore","editPostStore","createBlock","serialize","PostTemplateActions","isPostsPage","isModalOpen","setIsModalOpen","isBusy","setIsBusy","title","setTitle","template","supportsTemplateMode","defaultTemplate","select","getCurrentPostType","getEditorSettings","getPostType","getEditedPostTemplate","isViewable","viewable","_supportsTemplateMode","defaultBlockTemplate","__unstableCreateTemplate","__unstableSwitchToTemplateMode","defaultTitle","onCreateTemplate","event","preventDefault","newTemplateContent","tagName","layout","inherit","slug","content","toLowerCase"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,MADD,EAECC,KAFD,EAGCC,WAHD,EAICC,IAJD,EAKCC,QALD,QAMO,uBANP;AAOA,SAASC,SAAT,EAAoBC,WAAp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,QAAD,QACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGxC,EAAE,CAAE,MAAF,CADX;AAEC,IAAA,KAAK,EAAGuB,KAFT;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,WAAW,EAAGe,YAJf;AAKC,IAAA,QAAQ,EAAGlB,MALZ;AAMC,IAAA,IAAI,EAAGrB,EAAE,CACR,+GADQ;AANV,IADD,CADD,CADD,EAgBC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfoB,MAAAA,cAAc,CAAE,KAAF,CAAd;AACAI,MAAAA,QAAQ,CAAE,EAAF,CAAR;AACA;AALF,KAOGxB,EAAE,CAAE,QAAF,CAPL,CADD,CALD,EAgBC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,MAAM,EAAGqB,MAHV;AAIC,qBAAgBA;AAJjB,KAMGrB,EAAE,CAAE,QAAF,CANL,CADD,CAhBD,CAhBD,CATD,CA7BF,CADD;AAuFA;;AAED,eAAeiB,mBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { createBlock, serialize } from '@wordpress/blocks';\n\nfunction PostTemplateActions( { isPostsPage } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\tconst { template, supportsTemplateMode, defaultTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getEditorSettings } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( getCurrentPostType() )?.viewable ?? false;\n\t\t\tconst _supportsTemplateMode =\n\t\t\t\tgetEditorSettings().supportsTemplateMode && isViewable;\n\n\t\t\treturn {\n\t\t\t\ttemplate: _supportsTemplateMode && getEditedPostTemplate(),\n\t\t\t\tsupportsTemplateMode: _supportsTemplateMode,\n\t\t\t\tdefaultTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { __unstableCreateTemplate, __unstableSwitchToTemplateMode } =\n\t\tuseDispatch( editPostStore );\n\n\tif ( ! supportsTemplateMode ) {\n\t\treturn null;\n\t}\n\n\tconst defaultTitle = __( 'Custom Template' );\n\n\tasync function onCreateTemplate( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tawait __unstableCreateTemplate( {\n\t\t\tslug: 'wp-custom-template-' + kebabCase( title || defaultTitle ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || defaultTitle,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tsetIsModalOpen( false );\n\n\t\t__unstableSwitchToTemplateMode( true );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-post-template__actions\">\n\t\t\t\t{ !! template && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => __unstableSwitchToTemplateMode() }\n\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t// Translators: 1: The title or the slug of the currently selected template.\n\t\t\t\t\t\t\t__( 'Edit template: %s' ),\n\t\t\t\t\t\t\ttemplate?.title.toLowerCase() ?? template.slug\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! isPostsPage && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t\t\t\tlabel={ _x( 'New template', 'action' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* translators: button to create a new template */\n\t\t\t\t\t\t\t_x( 'New', 'action' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tsetTitle( '' );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"edit-post-template__modal\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ onCreateTemplate }>\n\t\t\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\t\t\tplaceholder={ defaultTitle }\n\t\t\t\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the template, e.g. \"Full Width\". Custom templates can be applied to any post or page.'\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</FlexItem>\n\t\t\t\t\t\t</Flex>\n\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"edit-post-template__modal-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\t\t\t\tsetTitle( '' );\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{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default PostTemplateActions;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/template/index.js"],"names":["partial","isEmpty","map","fromPairs","__","sprintf","useMemo","Notice","PanelBody","SelectControl","store","editorStore","useSelect","useDispatch","coreStore","PostTemplateActions","editPostStore","PANEL_NAME","TemplatePanel","isEnabled","isOpened","isPostsPage","selectedTemplate","availableTemplates","fetchedTemplates","isViewable","template","supportsTemplateMode","canUserCreate","select","isEditorPanelEnabled","isEditorPanelOpened","getEditedPostTemplate","getEditedPostAttribute","getEditorSettings","getCurrentPostId","getCurrentPostType","getPostType","getEntityRecord","getEntityRecords","canUser","currentPostId","currentPostType","settings","_isViewable","viewable","_supportsTemplateMode","templateRecords","post_type","per_page","page_for_posts","templates","slug","title","rendered","toggleEditorPanelOpened","editPost","onTogglePanel","panelTitle","Object","keys","includes","templateSlug","templateName","value","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,OAAlB,EAA2BC,GAA3B,EAAgCC,SAAhC,QAAiD,QAAjD;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,aAA5B,QAAiD,uBAAjD;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASH,KAAK,IAAII,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,WAAhC;AACA,SAASL,KAAK,IAAIM,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG,UAAnB;AAEA,OAAO,SAASC,aAAT,GAAyB;AAC/B,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,WAHK;AAILC,IAAAA,gBAJK;AAKLC,IAAAA,kBALK;AAMLC,IAAAA,gBANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,QARK;AASLC,IAAAA,oBATK;AAULC,IAAAA;AAVK,MAWFhB,SAAS,CAAIiB,MAAF,IAAc;AAAA;;AAC5B,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,mBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEb,aAAF,CAJV;AAKA,UAAM;AACLiB,MAAAA,sBADK;AAELC,MAAAA,iBAFK;AAGLC,MAAAA,gBAHK;AAILC,MAAAA;AAJK,QAKFP,MAAM,CAAElB,WAAF,CALV;AAMA,UAAM;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/template/index.js"],"names":["partial","isEmpty","map","fromPairs","__","sprintf","useMemo","Notice","PanelBody","SelectControl","store","editorStore","useSelect","useDispatch","coreStore","PostTemplateActions","editPostStore","PANEL_NAME","TemplatePanel","isEnabled","isOpened","isPostsPage","selectedTemplate","availableTemplates","fetchedTemplates","isViewable","template","supportsTemplateMode","canUserCreate","select","isEditorPanelEnabled","isEditorPanelOpened","getEditedPostTemplate","getEditedPostAttribute","getEditorSettings","getCurrentPostId","getCurrentPostType","getPostType","getEntityRecord","getEntityRecords","canUser","currentPostId","currentPostType","settings","_isViewable","viewable","_supportsTemplateMode","templateRecords","post_type","per_page","page_for_posts","templates","slug","title","rendered","toggleEditorPanelOpened","editPost","onTogglePanel","panelTitle","Object","keys","includes","templateSlug","templateName","value","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,OAAlB,EAA2BC,GAA3B,EAAgCC,SAAhC,QAAiD,QAAjD;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,aAA5B,QAAiD,uBAAjD;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASH,KAAK,IAAII,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,WAAhC;AACA,SAASL,KAAK,IAAIM,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG,UAAnB;AAEA,OAAO,SAASC,aAAT,GAAyB;AAC/B,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,WAHK;AAILC,IAAAA,gBAJK;AAKLC,IAAAA,kBALK;AAMLC,IAAAA,gBANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,QARK;AASLC,IAAAA,oBATK;AAULC,IAAAA;AAVK,MAWFhB,SAAS,CAAIiB,MAAF,IAAc;AAAA;;AAC5B,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,mBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEb,aAAF,CAJV;AAKA,UA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,UADT;AAEC,IAAA,MAAM,EAAGtC,QAFV;AAGC,IAAA,QAAQ,EAAGqC;AAHZ,KAKGpC,WAAW,GACZ,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,MAAM,EAAC,SAFR;AAGC,IAAA,aAAa,EAAG;AAHjB,KAKGjB,EAAE,CAAE,4CAAF,CALL,CADY,GASZ,cAAC,aAAD;AACC,IAAA,mBAAmB,MADpB;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,WAAF,CAFX;AAGC,IAAA,KAAK,EACJuD,MAAM,CAACC,IAAP,CAAaT,SAAb,EAAyBU,QAAzB,CAAmCvC,gBAAnC,IACGA,gBADH,GAEG,EANL;AAQC,IAAA,QAAQ,EAAKwC,YAAF,IAAoB;AAC9BN,MAAAA,QAAQ,CAAE;AACT9B,QAAAA,QAAQ,EAAEoC,YAAY,IAAI;AADjB,OAAF,CAAR;AAGA,KAZF;AAaC,IAAA,OAAO,EAAG5D,GAAG,CACZiD,SADY,EAEZ,CAAEY,YAAF,EAAgBD,YAAhB,MAAoC;AACnCE,MAAAA,KAAK,EAAEF,YAD4B;AAEnCG,MAAAA,KAAK,EAAEF;AAF4B,KAApC,CAFY;AAbd,IAdF,EAoCGnC,aAAa,IACd,cAAC,mBAAD;AAAqB,IAAA,WAAW,EAAGP;AAAnC,IArCF,CADD;AA0CA;AAED,eAAeH,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { partial, isEmpty, map, fromPairs } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { Notice, PanelBody, SelectControl } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTemplateActions from './actions';\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'template';\n\nexport function TemplatePanel() {\n\tconst {\n\t\tisEnabled,\n\t\tisOpened,\n\t\tisPostsPage,\n\t\tselectedTemplate,\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tisViewable,\n\t\ttemplate,\n\t\tsupportsTemplateMode,\n\t\tcanUserCreate,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditorPanelEnabled,\n\t\t\tisEditorPanelOpened,\n\t\t\tgetEditedPostTemplate,\n\t\t} = select( editPostStore );\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditorSettings,\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, getEntityRecord, getEntityRecords, canUser } =\n\t\t\tselect( coreStore );\n\n\t\tconst currentPostId = getCurrentPostId();\n\t\tconst currentPostType = getCurrentPostType();\n\t\tconst settings = getEntityRecord( 'root', 'site' );\n\t\tconst _isViewable = getPostType( currentPostType )?.viewable ?? false;\n\t\tconst _supportsTemplateMode =\n\t\t\tselect( editorStore ).getEditorSettings().supportsTemplateMode &&\n\t\t\t_isViewable;\n\n\t\tconst templateRecords = getEntityRecords( 'postType', 'wp_template', {\n\t\t\tpost_type: currentPostType,\n\t\t\tper_page: -1,\n\t\t} );\n\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisPostsPage: currentPostId === settings?.page_for_posts,\n\t\t\tselectedTemplate: getEditedPostAttribute( 'template' ),\n\t\t\tavailableTemplates: getEditorSettings().availableTemplates,\n\t\t\tfetchedTemplates: templateRecords,\n\t\t\ttemplate: _supportsTemplateMode && getEditedPostTemplate(),\n\t\t\tisViewable: _isViewable,\n\t\t\tsupportsTemplateMode: _supportsTemplateMode,\n\t\t\tcanUserCreate: canUser( 'create', 'templates' ),\n\t\t};\n\t}, [] );\n\n\tconst templates = useMemo( () => {\n\t\treturn {\n\t\t\t...availableTemplates,\n\t\t\t...fromPairs(\n\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\tslug,\n\t\t\t\t\ttitle.rendered,\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}, [ availableTemplates, fetchedTemplates ] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editPostStore );\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif (\n\t\t! isEnabled ||\n\t\t! isViewable ||\n\t\t( isEmpty( availableTemplates ) &&\n\t\t\t( ! supportsTemplateMode || ! canUserCreate ) )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onTogglePanel = partial( toggleEditorPanelOpened, PANEL_NAME );\n\n\tlet panelTitle = __( 'Template' );\n\tif ( !! template ) {\n\t\tpanelTitle = sprintf(\n\t\t\t/* translators: %s: template title */\n\t\t\t__( 'Template: %s' ),\n\t\t\ttemplate?.title ?? template.slug\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ panelTitle }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t{ isPostsPage ? (\n\t\t\t\t<Notice\n\t\t\t\t\tclassName=\"edit-post-template__notice\"\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template:' ) }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\tObject.keys( templates ).includes( selectedTemplate )\n\t\t\t\t\t\t\t? selectedTemplate\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( templateSlug ) => {\n\t\t\t\t\t\teditPost( {\n\t\t\t\t\t\t\ttemplate: templateSlug || '',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\toptions={ map(\n\t\t\t\t\t\ttemplates,\n\t\t\t\t\t\t( templateName, templateSlug ) => ( {\n\t\t\t\t\t\t\tvalue: templateSlug,\n\t\t\t\t\t\t\tlabel: templateName,\n\t\t\t\t\t\t} )\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canUserCreate && (\n\t\t\t\t<PostTemplateActions isPostsPage={ isPostsPage } />\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n\nexport default TemplatePanel;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"names":["Modal","__","useState","useEffect","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","PatternSelection","onChoosePattern","blockPatterns","select","__experimentalGetPatternsByBlockTypes","shownBlockPatterns","resetEditorBlocks","_pattern","blocks","START_PAGE_MODAL_STATES","INITIAL","PATTERN","CLOSED","StartPageOptions","modalState","setModalState","shouldOpenModel","getCurrentPostType","getEditedPostContent","isEditedPostSaveable","isEditingTemplate","isFeatureActive","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SACCC,KAAK,IAAIC,gBADV,EAECC,+BAA+B,IAAIC,iBAFpC,QAGO,yBAHP;AAIA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASN,KAAK,IAAIO,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASP,KAAK,IAAIQ,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,gBAAT,OAAiD;AAAA,MAAtB;AAAEC,IAAAA;AAAF,GAAsB;AAChD,QAAM;AAAEC,IAAAA;AAAF,MAAoBP,SAAS,CAAIQ,MAAF,IAAc;AAClD,UAAM;AAAEC,MAAAA;AAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"names":["Modal","__","useState","useEffect","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","PatternSelection","onChoosePattern","blockPatterns","select","__experimentalGetPatternsByBlockTypes","shownBlockPatterns","resetEditorBlocks","_pattern","blocks","START_PAGE_MODAL_STATES","INITIAL","PATTERN","CLOSED","StartPageOptions","modalState","setModalState","shouldOpenModel","getCurrentPostType","getEditedPostContent","isEditedPostSaveable","isEditingTemplate","isFeatureActive","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SACCC,KAAK,IAAIC,gBADV,EAECC,+BAA+B,IAAIC,iBAFpC,QAGO,yBAHP;AAIA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASN,KAAK,IAAIO,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASP,KAAK,IAAIQ,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,gBAAT,OAAiD;AAAA,MAAtB;AAAEC,IAAAA;AAAF,GAAsB;AAChD,QAAM;AAAEC,IAAAA;AAAF,MAAoBP,SAAS,CAAIQ,MAAF,IAAc;AAClD,UAAM;AAAEC,MAAAA;AAAF,QACLD,MAAM,CAAEX,gBAAF,CADP;AAEA,WAAO;AACNU,MAAAA,aAAa,EACZE,qCAAqC,CAAE,mBAAF;AAFhC,KAAP;AAIA,GAPkC,EAOhC,EAPgC,CAAnC;AAQA,QAAMC,kBAAkB,GAAGR,YAAY,CAAEK,aAAF,CAAvC;AACA,QAAM;AAAEI,IAAA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AChB,QAAK0B,eAAL,EAAuB;AACtBD,MAAAA,aAAa,CAAEN,uBAAuB,CAACE,OAA1B,CAAb;AACA;AACD,GAJQ,EAIN,CAAEK,eAAF,CAJM,CAAT;;AAMA,MACCF,UAAU,KAAKL,uBAAuB,CAACC,OAAvC,IACAI,UAAU,KAAKL,uBAAuB,CAACG,MAFxC,EAGE;AACD,WAAO,IAAP;AACA;;AACD,SACC,cAAC,KAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,KAAK,EAAGxB,EAAE,CAAE,kBAAF,CAFX;AAGC,IAAA,UAAU,EAAGA,EAAE,CAAE,QAAF,CAHhB;AAIC,IAAA,cAAc,EAAG,MAAM;AACtB2B,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AANF,KAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGE,UAAU,KAAKL,uBAAuB,CAACE,OAAvC,IACD,cAAC,gBAAD;AACC,IAAA,eAAe,EAAG,MAAM;AACvBI,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AAHF,IAFF,CARD,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction PatternSelection( { onChoosePattern } ) {\n\tconst { blockPatterns } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetPatternsByBlockTypes } =\n\t\t\tselect( blockEditorStore );\n\t\treturn {\n\t\t\tblockPatterns:\n\t\t\t\t__experimentalGetPatternsByBlockTypes( 'core/post-content' ),\n\t\t};\n\t}, [] );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst START_PAGE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tPATTERN: 'PATTERN',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartPageOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_PAGE_MODAL_STATES.INITIAL\n\t);\n\tconst shouldOpenModel = useSelect(\n\t\t( select ) => {\n\t\t\tif ( modalState !== START_PAGE_MODAL_STATES.INITIAL ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { __experimentalGetPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetEditedPostContent,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t} = select( editorStore );\n\t\t\tconst { isEditingTemplate, isFeatureActive } =\n\t\t\t\tselect( editPostStore );\n\t\t\treturn (\n\t\t\t\tgetCurrentPostType() === 'page' &&\n\t\t\t\t! isEditedPostSaveable() &&\n\t\t\t\t'' === getEditedPostContent() &&\n\t\t\t\t! isEditingTemplate() &&\n\t\t\t\t! isFeatureActive( 'welcomeGuide' ) &&\n\t\t\t\t__experimentalGetPatternsByBlockTypes( 'core/post-content' )\n\t\t\t\t\t.length >= 1\n\t\t\t);\n\t\t},\n\t\t[ modalState ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldOpenModel ) {\n\t\t\tsetModalState( START_PAGE_MODAL_STATES.PATTERN );\n\t\t}\n\t}, [ shouldOpenModel ] );\n\n\tif (\n\t\tmodalState === START_PAGE_MODAL_STATES.INITIAL ||\n\t\tmodalState === START_PAGE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tonRequestClose={ () => {\n\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t{ modalState === START_PAGE_MODAL_STATES.PATTERN && (\n\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -5,42 +5,31 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { PostTextEditor, PostTitle, TextEditorGlobalKeyboardShortcuts, store as editorStore } from '@wordpress/editor';
|
|
7
7
|
import { Button } from '@wordpress/components';
|
|
8
|
-
import {
|
|
8
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
11
|
-
import { compose } from '@wordpress/compose';
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
15
|
import { store as editPostStore } from '../../store';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
export default function TextEditor() {
|
|
17
|
+
const isRichEditingEnabled = useSelect(select => {
|
|
18
|
+
return select(editorStore).getEditorSettings().richEditingEnabled;
|
|
19
|
+
}, []);
|
|
20
|
+
const {
|
|
21
|
+
switchEditorMode
|
|
22
|
+
} = useDispatch(editPostStore);
|
|
23
23
|
return createElement("div", {
|
|
24
24
|
className: "edit-post-text-editor"
|
|
25
|
-
}, isRichEditingEnabled && createElement("div", {
|
|
25
|
+
}, createElement(TextEditorGlobalKeyboardShortcuts, null), isRichEditingEnabled && createElement("div", {
|
|
26
26
|
className: "edit-post-text-editor__toolbar"
|
|
27
27
|
}, createElement("h2", null, __('Editing code')), createElement(Button, {
|
|
28
28
|
variant: "tertiary",
|
|
29
|
-
onClick:
|
|
29
|
+
onClick: () => switchEditorMode('visual'),
|
|
30
30
|
shortcut: displayShortcut.secondary('m')
|
|
31
|
-
}, __('Exit code editor'))
|
|
31
|
+
}, __('Exit code editor'))), createElement("div", {
|
|
32
32
|
className: "edit-post-text-editor__body"
|
|
33
33
|
}, createElement(PostTitle, null), createElement(PostTextEditor, null)));
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
export default compose(withSelect(select => ({
|
|
37
|
-
isRichEditingEnabled: select(editorStore).getEditorSettings().richEditingEnabled
|
|
38
|
-
})), withDispatch(dispatch => {
|
|
39
|
-
return {
|
|
40
|
-
onExit() {
|
|
41
|
-
dispatch(editPostStore).switchEditorMode('visual');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
}))(TextEditor);
|
|
46
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/text-editor/index.js"],"names":["PostTextEditor","PostTitle","TextEditorGlobalKeyboardShortcuts","store","editorStore","Button","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/text-editor/index.js"],"names":["PostTextEditor","PostTitle","TextEditorGlobalKeyboardShortcuts","store","editorStore","Button","useDispatch","useSelect","__","displayShortcut","editPostStore","TextEditor","isRichEditingEnabled","select","getEditorSettings","richEditingEnabled","switchEditorMode","secondary"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,SAFD,EAGCC,iCAHD,EAICC,KAAK,IAAIC,WAJV,QAKO,mBALP;AAMA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,SAASN,KAAK,IAAIO,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,QAAMC,oBAAoB,GAAGL,SAAS,CAAIM,MAAF,IAAc;AACrD,WAAOA,MAAM,CAAET,WAAF,CAAN,CAAsBU,iBAAtB,GAA0CC,kBAAjD;AACA,GAFqC,EAEnC,EAFmC,CAAtC;AAGA,QAAM;AAAEC,IAAAA;AAAF,MAAuBV,WAAW,CAAEI,aAAF,CAAxC;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,iCAAD,OADD,EAEGE,oBAAoB,IACrB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,0BAAMJ,EAAE,CAAE,cAAF,CAAR,CADD,EAEC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAMQ,gBAAgB,CAAE,QAAF,CAFjC;AAGC,IAAA,QAAQ,EAAGP,eAAe,CAACQ,SAAhB,CAA2B,GAA3B;AAHZ,KAKGT,EAAE,CAAE,kBAAF,CALL,CAFD,CAHF,EAcC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,SAAD,OADD,EAEC,cAAC,cAAD,OAFD,CAdD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPostTextEditor,\n\tPostTitle,\n\tTextEditorGlobalKeyboardShortcuts,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function TextEditor() {\n\tconst isRichEditingEnabled = useSelect( ( select ) => {\n\t\treturn select( editorStore ).getEditorSettings().richEditingEnabled;\n\t}, [] );\n\tconst { switchEditorMode } = useDispatch( editPostStore );\n\n\treturn (\n\t\t<div className=\"edit-post-text-editor\">\n\t\t\t<TextEditorGlobalKeyboardShortcuts />\n\t\t\t{ isRichEditingEnabled && (\n\t\t\t\t<div className=\"edit-post-text-editor__toolbar\">\n\t\t\t\t\t<h2>{ __( 'Editing code' ) }</h2>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => switchEditorMode( 'visual' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.secondary( 'm' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Exit code editor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"edit-post-text-editor__body\">\n\t\t\t\t<PostTitle />\n\t\t\t\t<PostTextEditor />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { noop } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { __ } from '@wordpress/i18n';
|
|
12
7
|
import { MenuItem } from '@wordpress/components';
|
|
13
8
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -18,6 +13,9 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
|
18
13
|
*/
|
|
19
14
|
|
|
20
15
|
import { store as editPostStore } from '../../store';
|
|
16
|
+
|
|
17
|
+
const noop = () => {};
|
|
18
|
+
|
|
21
19
|
export function BlockInspectorButton(_ref) {
|
|
22
20
|
let {
|
|
23
21
|
onClick = noop,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/visual-editor/block-inspector-button.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/visual-editor/block-inspector-button.js"],"names":["__","MenuItem","useSelect","useDispatch","speak","store","keyboardShortcutsStore","editPostStore","noop","BlockInspectorButton","onClick","small","shortcut","areAdvancedSettingsOpened","select","getShortcutRepresentation","getActiveGeneralSidebarName","openGeneralSidebar","closeGeneralSidebar","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,aAAlB,QAAuC,aAAvC;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,OAAO,SAASC,oBAAT,OAAmE;AAAA,MAApC;AAAEC,IAAAA,OAAO,GAAGF,IAAZ;AAAkBG,IAAAA,KAAK,GAAG;AAA1B,GAAoC;AACzE,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA0CX,SAAS,CACtDY,MAAF,KAAgB;AACfF,IAAAA,QAAQ,EAAEE,MAAM,CACfR,sBADe,CAAN,CAERS,yBAFQ,CAEmB,+BAFnB,CADK;AAIfF,IAAAA,yBAAyB,EACxBC,MAAM,CAAEP,aAAF,CAAN,CAAwBS,2BAAxB,OACA;AANc,GAAhB,CADwD,EASxD,EATwD,CAAzD;AAWA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MACLf,WAAW,CAAEI,aAAF,CADZ;AAGA,QAAMY,KAAK,GAAGN,yBAAyB,GACpCb,EAAE,CAAE,oBAAF,CADkC,GAEpCA,EAAE,CAAE,oBAAF,CAFL;AAIA,SACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACf,UAAKa,yBAAL,EAAiC;AAChCK,QAAAA,mBAAmB;AACnBd,QAAAA,KAAK,CAAEJ,EAAE,CAAE,uBAAF,CAAJ,CAAL;AACA,OAHD,MAGO;AACNiB,QAAAA,kBAAkB,CAAE,iBAAF,CAAlB;AACAb,QAAAA,KAAK,CACJJ,EAAE,CACD,4EADC,CADE,CAAL;AAKA;;AACDU,MAAAA,OAAO;AACP,KAdF;AAeC,IAAA,QAAQ,EAAGE;AAfZ,KAiBG,CAAED,KAAF,IAAWQ,KAjBd,CADD;AAqBA;AAED,eAAeV,oBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nconst noop = () => {};\n\nexport function BlockInspectorButton( { onClick = noop, small = false } ) {\n\tconst { shortcut, areAdvancedSettingsOpened } = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),\n\t\t\tareAdvancedSettingsOpened:\n\t\t\t\tselect( editPostStore ).getActiveGeneralSidebarName() ===\n\t\t\t\t'edit-post/block',\n\t\t} ),\n\t\t[]\n\t);\n\tconst { openGeneralSidebar, closeGeneralSidebar } =\n\t\tuseDispatch( editPostStore );\n\n\tconst label = areAdvancedSettingsOpened\n\t\t? __( 'Hide more settings' )\n\t\t: __( 'Show more settings' );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tif ( areAdvancedSettingsOpened ) {\n\t\t\t\t\tcloseGeneralSidebar();\n\t\t\t\t\tspeak( __( 'Block settings closed' ) );\n\t\t\t\t} else {\n\t\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t\t\tspeak(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Additional settings are now available in the Editor block settings sidebar'\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tshortcut={ shortcut }\n\t\t>\n\t\t\t{ ! small && label }\n\t\t</MenuItem>\n\t);\n}\n\nexport default BlockInspectorButton;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/editor.js"],"names":["forEach","size","map","without","store","blocksStore","useSelect","useDispatch","EditorProvider","ErrorBoundary","PostLockedModal","editorStore","StrictMode","useMemo","SlotFillProvider","coreStore","ShortcutProvider","preferencesStore","Layout","EditorInitialization","editPostStore","Editor","postId","postType","settings","initialEdits","onError","props","hasFixedToolbar","focusMode","hasReducedUI","hasThemeStyles","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","keepCaretInsideBlock","isTemplateMode","template","select","isFeatureActive","__experimentalGetPreviewDeviceType","isEditingTemplate","getEditedPostTemplate","getHiddenBlockTypes","getEntityRecord","getPostType","getEntityRecords","getEditorSettings","getBlockTypes","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","get","updatePreferredStyleVariations","setIsInserterOpened","editorSettings","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","styles","themeStyles","presetStyles","style","__unstableType","push","defaultEditorStyles","length","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,IAAlB,EAAwBC,GAAxB,EAA6BC,OAA7B,QAA4C,QAA5C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;A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\n */\nimport { forEach, size, map, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tEditorProvider,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { StrictMode, useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\n\nfunction Editor( {\n\tpostId,\n\tpostType,\n\tsettings,\n\tinitialEdits,\n\tonError,\n\t...props\n} ) {\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thasThemeStyles,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tkeepCaretInsideBlock,\n\t\tisTemplateMode,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t\tisEditingTemplate,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t\tgetHiddenBlockTypes,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t// to avoid the special case.\n\t\t\tlet postObject;\n\t\t\tif ( isTemplate ) {\n\t\t\t\tconst posts = getEntityRecords( 'postType', postType, {\n\t\t\t\t\twp_id: postId,\n\t\t\t\t} );\n\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t} else {\n\t\t\t\tpostObject = getEntityRecord( 'postType', postType, postId );\n\t\t\t}\n\t\t\tconst supportsTemplateMode = getEditorSettings()\n\t\t\t\t.supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\n\t\t\treturn {\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\thasReducedUI: isFeatureActive( 'reducedUI' ),\n\t\t\t\thasThemeStyles: isFeatureActive( 'themeStyles' ),\n\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tkeepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\t\tisTemplateMode: isEditingTemplate(),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst { updatePreferredStyleVariations, setIsInserterOpened } = useDispatch(\n\t\teditPostStore\n\t);\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thasReducedUI,\n\n\t\t\t// This is marked as experimental to give time for the quick inserter to mature.\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t// Keep a reference of the `allowedBlockTypes` from the server to handle use cases\n\t\t\t// where we need to differentiate if a block is disabled by the user or some plugin.\n\t\t\tdefaultAllowedBlockTypes: settings.allowedBlockTypes,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( size( hiddenBlockTypes ) > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? map( blockTypes, 'name' )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = without(\n\t\t\t\tdefaultAllowedBlockTypes,\n\t\t\t\t...hiddenBlockTypes\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tconst styles = useMemo( () => {\n\t\tconst themeStyles = [];\n\t\tconst presetStyles = [];\n\t\tforEach( settings.styles, ( style ) => {\n\t\t\tif ( ! style.__unstableType || style.__unstableType === 'theme' ) {\n\t\t\t\tthemeStyles.push( style );\n\t\t\t} else {\n\t\t\t\tpresetStyles.push( style );\n\t\t\t}\n\t\t} );\n\t\tconst defaultEditorStyles = [\n\t\t\t...settings.defaultEditorStyles,\n\t\t\t...presetStyles,\n\t\t];\n\t\treturn hasThemeStyles && themeStyles.length\n\t\t\t? settings.styles\n\t\t\t: defaultEditorStyles;\n\t}, [ settings, hasThemeStyles ] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StrictMode>\n\t\t\t<ShortcutProvider>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ post }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t__unstableTemplate={\n\t\t\t\t\t\t\tisTemplateMode ? template : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t\t\t<Layout styles={ styles } />\n\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t<PostLockedModal />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</ShortcutProvider>\n\t\t</StrictMode>\n\t);\n}\n\nexport default Editor;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/editor.js"],"names":["forEach","size","map","without","store","blocksStore","useSelect","useDispatch","EditorProvider","ErrorBoundary","PostLockedModal","editorStore","StrictMode","useMemo","SlotFillProvider","coreStore","ShortcutProvider","preferencesStore","Layout","EditorInitialization","editPostStore","Editor","postId","postType","settings","initialEdits","onError","props","hasFixedToolbar","focusMode","hasReducedUI","hasThemeStyles","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","keepCaretInsideBlock","isTemplateMode","template","select","isFeatureActive","__experimentalGetPreviewDeviceType","isEditingTemplate","getEditedPostTemplate","getHiddenBlockTypes","getEntityRecord","getPostType","getEntityRecords","getEditorSettings","getBlockTypes","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","get","updatePreferredStyleVariations","setIsInserterOpened","editorSettings","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","styles","themeStyles","presetStyles","style","__unstableType","push","defaultEditorStyles","length","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,IAAlB,EAAwBC,GAAxB,EAA6BC,OAA7B,QAA4C,QAA5C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,cADD,EAECC,aAFD,EAGCC,eAHD,EAICN,KAAK,IAAIO,WAJV,QAKO,mBALP;AAMA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,gBAAT,QAAiC,uBAAjC;AACA,SAASV,KAAK,IAAIW,SAAlB,QAAmC,sBAAnC;AACA,SAASC,gBAAT,QAAiC,+BAAjC;AACA,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,OAAOC,oBAAP,MAAiC,oCAAjC;AACA,SAASf,KAAK,IAAIgB,aAAlB,QAAuC,SAAvC;;AAEA,SAASC,MAAT,OAOI;AAAA,MAPa;AAChBC,IAAAA,MADgB;AAEhBC,IAAAA,QAFgB;AAGhBC,IAAAA,QAHgB;AAIhBC,IAAAA,YAJgB;AAKhBC,IAAAA,OALgB;AAMhB,OAAGC;AANa,GAOb;AACH,QAAM;AACLC,IAAAA,eADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,cAJK;AAKLC,IAAAA,IALK;AAMLC,IAAAA,wBANK;AAOLC,IAAAA,gBAPK;AAQLC,IAAAA,UARK;AASLC,IAAAA,oBATK;AAULC,IAAAA,cAVK;AAWLC,IAAAA;AAXK,MAYFhC,SAAS,CACViC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,eADK;AAELC,MAAAA,kCAFK;AAGLC,MAAAA,iBAHK;AAILC,MAAAA,qBAJK;AAKLC,MA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,cAAC,oBAAD;AAAsB,IAAA,MAAM,EAAGJ;AAA/B,IADD,EAEC,cAAC,MAAD;AAAQ,IAAA,MAAM,EAAG+C;AAAjB,IAFD,CAVD,EAcC,cAAC,eAAD,OAdD,CADD,CADD,CADD,CADD;AAwBA;;AAED,eAAehD,MAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { forEach, size, map, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tEditorProvider,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { StrictMode, useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\n\nfunction Editor( {\n\tpostId,\n\tpostType,\n\tsettings,\n\tinitialEdits,\n\tonError,\n\t...props\n} ) {\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thasThemeStyles,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tkeepCaretInsideBlock,\n\t\tisTemplateMode,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t\tisEditingTemplate,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t\tgetHiddenBlockTypes,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t// to avoid the special case.\n\t\t\tlet postObject;\n\t\t\tif ( isTemplate ) {\n\t\t\t\tconst posts = getEntityRecords( 'postType', postType, {\n\t\t\t\t\twp_id: postId,\n\t\t\t\t} );\n\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t} else {\n\t\t\t\tpostObject = getEntityRecord( 'postType', postType, postId );\n\t\t\t}\n\t\t\tconst supportsTemplateMode =\n\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\n\t\t\treturn {\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\thasReducedUI: isFeatureActive( 'reducedUI' ),\n\t\t\t\thasThemeStyles: isFeatureActive( 'themeStyles' ),\n\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tkeepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\t\tisTemplateMode: isEditingTemplate(),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst { updatePreferredStyleVariations, setIsInserterOpened } =\n\t\tuseDispatch( editPostStore );\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thasReducedUI,\n\n\t\t\t// This is marked as experimental to give time for the quick inserter to mature.\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t// Keep a reference of the `allowedBlockTypes` from the server to handle use cases\n\t\t\t// where we need to differentiate if a block is disabled by the user or some plugin.\n\t\t\tdefaultAllowedBlockTypes: settings.allowedBlockTypes,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( size( hiddenBlockTypes ) > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? map( blockTypes, 'name' )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = without(\n\t\t\t\tdefaultAllowedBlockTypes,\n\t\t\t\t...hiddenBlockTypes\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tconst styles = useMemo( () => {\n\t\tconst themeStyles = [];\n\t\tconst presetStyles = [];\n\t\tforEach( settings.styles, ( style ) => {\n\t\t\tif ( ! style.__unstableType || style.__unstableType === 'theme' ) {\n\t\t\t\tthemeStyles.push( style );\n\t\t\t} else {\n\t\t\t\tpresetStyles.push( style );\n\t\t\t}\n\t\t} );\n\t\tconst defaultEditorStyles = [\n\t\t\t...settings.defaultEditorStyles,\n\t\t\t...presetStyles,\n\t\t];\n\t\treturn hasThemeStyles && themeStyles.length\n\t\t\t? settings.styles\n\t\t\t: defaultEditorStyles;\n\t}, [ settings, hasThemeStyles ] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StrictMode>\n\t\t\t<ShortcutProvider>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ post }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t__unstableTemplate={\n\t\t\t\t\t\t\tisTemplateMode ? template : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t\t\t<Layout styles={ styles } />\n\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t<PostLockedModal />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</ShortcutProvider>\n\t\t</StrictMode>\n\t);\n}\n\nexport default Editor;\n"]}
|
|
@@ -80,6 +80,9 @@ class Editor extends Component {
|
|
|
80
80
|
this.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(() => {
|
|
81
81
|
if (this.postTitleRef) {
|
|
82
82
|
this.postTitleRef.focus();
|
|
83
|
+
} else {
|
|
84
|
+
// If the post title ref is not available, we postpone setting focus to when it's available.
|
|
85
|
+
this.focusTitleWhenAvailable = true;
|
|
83
86
|
}
|
|
84
87
|
});
|
|
85
88
|
this.subscriptionParentFeaturedImageIdNativeUpdated = subscribeFeaturedImageIdNativeUpdated(payload => {
|
|
@@ -102,6 +105,11 @@ class Editor extends Component {
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
setTitleRef(titleRef) {
|
|
108
|
+
if (this.focusTitleWhenAvailable && !this.postTitleRef) {
|
|
109
|
+
this.focusTitleWhenAvailable = false;
|
|
110
|
+
titleRef.focus();
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
this.postTitleRef = titleRef;
|
|
106
114
|
}
|
|
107
115
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/editor.native.js"],"names":["memize","size","map","without","I18nManager","Component","EditorProvider","parse","serialize","store","blocksStore","withDispatch","withSelect","compose","subscribeSetFocusOnTitle","subscribeFeaturedImageIdNativeUpdated","SlotFillProvider","coreStore","Layout","editPostStore","Editor","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","maxSize","setTitleRef","bind","settings","hasFixedToolbar","focusMode","hiddenBlockTypes","blockTypes","isRTL","allowedBlockTypes","undefined","defaultAllowedBlockTypes","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","postTitleRef","focus","subscriptionParentFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","type","status","meta","select","isFeatureActive","getEditorMode","__experimentalGetPreviewDeviceType","getHiddenBlockTypes","getBlockTypes","dispatch"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AACA,SAASC,IAAT,EAAeC,GAAf,EAAoBC,OAApB,QAAmC,QAAnC;AACA,SAASC,WAAT,QAA4B,cAA5B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,KAAT,EAAgBC,SAAhB,EAA2BC,KAAK,IAAIC,WAApC,QAAuD,mBAAvD;AACA,SAASC,YAAT,EA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;AAJK,MAKFJ,MAAM,CAAEtD,aAAF,CALV;AAMA,QAAM;AAAE2D,IAAAA;AAAF,MAAoBL,MAAM,CAAE/D,WAAF,CAAhC;AAEA,SAAO;AACN0B,IAAAA,eAAe,EACdsC,eAAe,CAAE,cAAF,CAAf,IACAE,kCAAkC,OAAO,SAHpC;AAINvC,IAAAA,SAAS,EAAEqC,eAAe,CAAE,WAAF,CAJpB;AAKN7C,IAAAA,IAAI,EAAE8C,aAAa,EALb;AAMNrC,IAAAA,gBAAgB,EAAEuC,mBAAmB,EAN/B;AAONtC,IAAAA,UAAU,EAAEuC,aAAa;AAPnB,GAAP;AASA,CAlBS,CADa,EAoBvBnE,YAAY,CAAIoE,QAAF,IAAgB;AAC7B,QAAM;AAAEjD,IAAAA;AAAF,MAAuBiD,QAAQ,CAAE5D,aAAF,CAArC;AACA,QAAM;AAAE0B,IAAAA;AAAF,MAAuBkC,QAAQ,CAAE9D,SAAF,CAArC;AACA,SAAO;AACNa,IAAAA,gBADM;AAENe,IAAAA;AAFM,GAAP;AAIA,CAPW,CApBW,CAAF,CAAP,CA4BVzB,MA5BU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { size, map, without } from 'lodash';\nimport { I18nManager } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize, store as blocksStore } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings(\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thiddenBlockTypes,\n\t\tblockTypes\n\t) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( size( hiddenBlockTypes ) > 0 ) {\n\t\t\tif ( settings.allowedBlockTypes === undefined ) {\n\t\t\t\t// If no specific flags for allowedBlockTypes are set, assume `true`\n\t\t\t\t// meaning allow all block types.\n\t\t\t\tsettings.allowedBlockTypes = true;\n\t\t\t}\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? map( blockTypes, 'name' )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tsettings.allowedBlockTypes = without(\n\t\t\t\tdefaultAllowedBlockTypes,\n\t\t\t\t...hiddenBlockTypes\n\t\t\t);\n\t\t}\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated = subscribeFeaturedImageIdNativeUpdated(\n\t\t\t( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\tinitialEdits,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings(\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes\n\t\t);\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<SlotFillProvider>\n\t\t\t\t<EditorProvider\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t</EditorProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tgetEditorMode,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetHiddenBlockTypes,\n\t\t} = select( editPostStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\n\t\treturn {\n\t\t\thasFixedToolbar:\n\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\tmode: getEditorMode(),\n\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\tblockTypes: getBlockTypes(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/editor.native.js"],"names":["memize","size","map","without","I18nManager","Component","EditorProvider","parse","serialize","store","blocksStore","withDispatch","withSelect","compose","subscribeSetFocusOnTitle","subscribeFeaturedImageIdNativeUpdated","SlotFillProvider","coreStore","Layout","editPostStore","Editor","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","maxSize","setTitleRef","bind","settings","hasFixedToolbar","focusMode","hiddenBlockTypes","blockTypes","isRTL","allowedBlockTypes","undefined","defaultAllowedBlockTypes","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","type","status","meta","select","isFeatureActive","getEditorMode","__experimentalGetPreviewDeviceType","getHiddenBlockTypes","getBlockTypes","dispatch"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AACA,SAASC,IAAT,EAAeC,GAAf,EAAoBC,OAApB,QAAmC,QAAnC;AACA,SAASC,WAAT,QAA4B,cAA5B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,KAAT,EAAgBC,SAAhB,EAA2BC,KAAK,IAAIC,WAApC,QAAuD,mBAAvD;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SACCC,wBADD,EAECC,qCAFD,QAGO,gCAHP;AAIA,SAASC,gBAAT,QAAiC,uBAAjC;AACA,SAASP,KAAK,IAAIQ,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,SAAST,KAAK,IAAIU,aAAlB,QAAuC,SAAvC;;AAEA,MAAMC,MAAN,SAAqBf,SAArB,CAA+B;AAC9BgB,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAO,GAAGC,SAAV,EADoB,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AAA,SAAS,EAAEsC,eAAe,CAAE,WAAF,CAJpB;AAKN9C,IAAAA,IAAI,EAAE+C,aAAa,EALb;AAMNtC,IAAAA,gBAAgB,EAAEwC,mBAAmB,EAN/B;AAONvC,IAAAA,UAAU,EAAEwC,aAAa;AAPnB,GAAP;AASA,CAlBS,CADa,EAoBvBpE,YAAY,CAAIqE,QAAF,IAAgB;AAC7B,QAAM;AAAElD,IAAAA;AAAF,MAAuBkD,QAAQ,CAAE7D,aAAF,CAArC;AACA,QAAM;AAAE0B,IAAAA;AAAF,MAAuBmC,QAAQ,CAAE/D,SAAF,CAArC;AACA,SAAO;AACNa,IAAAA,gBADM;AAENe,IAAAA;AAFM,GAAP;AAIA,CAPW,CApBW,CAAF,CAAP,CA4BVzB,MA5BU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { size, map, without } from 'lodash';\nimport { I18nManager } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize, store as blocksStore } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings(\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thiddenBlockTypes,\n\t\tblockTypes\n\t) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( size( hiddenBlockTypes ) > 0 ) {\n\t\t\tif ( settings.allowedBlockTypes === undefined ) {\n\t\t\t\t// If no specific flags for allowedBlockTypes are set, assume `true`\n\t\t\t\t// meaning allow all block types.\n\t\t\t\tsettings.allowedBlockTypes = true;\n\t\t\t}\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? map( blockTypes, 'name' )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tsettings.allowedBlockTypes = without(\n\t\t\t\tdefaultAllowedBlockTypes,\n\t\t\t\t...hiddenBlockTypes\n\t\t\t);\n\t\t}\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\tinitialEdits,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings(\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes\n\t\t);\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<SlotFillProvider>\n\t\t\t\t<EditorProvider\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t</EditorProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tgetEditorMode,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetHiddenBlockTypes,\n\t\t} = select( editPostStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\n\t\treturn {\n\t\t\thasFixedToolbar:\n\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\tmode: getEditorMode(),\n\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\tblockTypes: getBlockTypes(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -78,12 +78,18 @@ export function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
78
78
|
preferredStyleVariations: {},
|
|
79
79
|
showBlockBreadcrumbs: true,
|
|
80
80
|
showIconLabels: false,
|
|
81
|
+
showListViewByDefault: false,
|
|
81
82
|
themeStyles: true,
|
|
82
83
|
welcomeGuide: true,
|
|
83
84
|
welcomeGuideTemplate: true
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
dispatch(blocksStore).__experimentalReapplyBlockTypeFilters();
|
|
87
|
+
dispatch(blocksStore).__experimentalReapplyBlockTypeFilters(); // Check if the block list view should be open by default.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if (select(editPostStore).isFeatureActive('showListViewByDefault')) {
|
|
91
|
+
dispatch(editPostStore).setIsListViewOpened(true);
|
|
92
|
+
}
|
|
87
93
|
|
|
88
94
|
registerCoreBlocks();
|
|
89
95
|
|