@wordpress/editor 11.0.1 → 12.0.2
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 +7 -0
- package/README.md +1 -1
- package/build/components/autosave-monitor/index.js +5 -0
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/character-count/index.js +1 -1
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js +6 -5
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/customize-blocks.native.js +7 -6
- package/build/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js +29 -15
- package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build/components/editor-help/help-get-support-button.native.js +46 -0
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -0
- package/build/components/editor-help/help-topic-row.native.js +3 -2
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +87 -26
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js +19 -9
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/editor-help/move-blocks.native.js +6 -5
- package/build/components/editor-help/move-blocks.native.js.map +1 -1
- package/build/components/editor-help/remove-blocks.native.js +6 -5
- package/build/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build/components/editor-help/view-sections.native.js +23 -5
- package/build/components/editor-help/view-sections.native.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +22 -13
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +23 -4
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +1 -2
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/post-format/index.js +3 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +37 -46
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +154 -211
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-title/index.js +53 -25
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/provider/index.native.js +18 -7
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +32 -5
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/word-count/index.js +1 -1
- package/build/components/word-count/index.js.map +1 -1
- package/build/store/actions.js +13 -38
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +7 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/selectors.js +4 -93
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +15 -18
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build/{store/utils → utils}/get-template-part-icon.js +1 -1
- package/build/utils/get-template-part-icon.js.map +1 -0
- package/build/utils/index.js +8 -0
- package/build/utils/index.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +5 -0
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/character-count/index.js +1 -1
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/editor-help/add-blocks.native.js +7 -6
- package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/customize-blocks.native.js +8 -7
- package/build-module/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js +31 -18
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build-module/components/editor-help/help-get-support-button.native.js +34 -0
- package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -0
- package/build-module/components/editor-help/help-topic-row.native.js +3 -2
- package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +81 -28
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-help/intro-to-blocks.native.js +19 -10
- package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/move-blocks.native.js +7 -6
- package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/remove-blocks.native.js +7 -6
- package/build-module/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/view-sections.native.js +22 -5
- package/build-module/components/editor-help/view-sections.native.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +24 -13
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +23 -4
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +1 -2
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/post-format/index.js +4 -2
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +38 -46
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +156 -214
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.js +53 -22
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +18 -7
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +31 -5
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/word-count/index.js +1 -1
- package/build-module/components/word-count/index.js.map +1 -1
- package/build-module/store/actions.js +13 -36
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +7 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/selectors.js +3 -85
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +15 -18
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-module/{store/utils → utils}/get-template-part-icon.js +2 -2
- package/build-module/utils/get-template-part-icon.js.map +1 -0
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-style/style-rtl.css +9 -60
- package/build-style/style.css +9 -60
- package/package.json +28 -28
- package/src/components/autosave-monitor/index.js +5 -0
- package/src/components/autosave-monitor/test/index.js +10 -4
- package/src/components/character-count/index.js +3 -2
- package/src/components/editor-help/add-blocks.native.js +17 -12
- package/src/components/editor-help/customize-blocks.native.js +16 -13
- package/src/components/editor-help/help-detail-navigation-screen.native.js +45 -15
- package/src/components/editor-help/help-get-support-button.native.js +38 -0
- package/src/components/editor-help/help-topic-row.native.js +2 -2
- package/src/components/editor-help/images/add-dark.png +0 -0
- package/src/components/editor-help/images/add-dark@2x.png +0 -0
- package/src/components/editor-help/images/add-dark@3x.png +0 -0
- package/src/components/editor-help/images/add-light.png +0 -0
- package/src/components/editor-help/images/add-light@2x.png +0 -0
- package/src/components/editor-help/images/add-light@3x.png +0 -0
- package/src/components/editor-help/images/block-layout-collage.png +0 -0
- package/src/components/editor-help/images/block-layout-collage@2x.png +0 -0
- package/src/components/editor-help/images/block-layout-collage@3x.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark@2x.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark@3x.png +0 -0
- package/src/components/editor-help/images/build-layouts-light.png +0 -0
- package/src/components/editor-help/images/build-layouts-light@2x.png +0 -0
- package/src/components/editor-help/images/build-layouts-light@3x.png +0 -0
- package/src/components/editor-help/images/edit-media-dark.png +0 -0
- package/src/components/editor-help/images/edit-media-dark@2x.png +0 -0
- package/src/components/editor-help/images/edit-media-dark@3x.png +0 -0
- package/src/components/editor-help/images/edit-media-light.png +0 -0
- package/src/components/editor-help/images/edit-media-light@2x.png +0 -0
- package/src/components/editor-help/images/edit-media-light@3x.png +0 -0
- package/src/components/editor-help/images/embed-media-dark.png +0 -0
- package/src/components/editor-help/images/embed-media-dark@2x.png +0 -0
- package/src/components/editor-help/images/embed-media-dark@3x.png +0 -0
- package/src/components/editor-help/images/embed-media-light.png +0 -0
- package/src/components/editor-help/images/embed-media-light@2x.png +0 -0
- package/src/components/editor-help/images/embed-media-light@3x.png +0 -0
- package/src/components/editor-help/images/move-dark.png +0 -0
- package/src/components/editor-help/images/move-dark@2x.png +0 -0
- package/src/components/editor-help/images/move-dark@3x.png +0 -0
- package/src/components/editor-help/images/move-light.png +0 -0
- package/src/components/editor-help/images/move-light@2x.png +0 -0
- package/src/components/editor-help/images/move-light@3x.png +0 -0
- package/src/components/editor-help/images/options-dark.png +0 -0
- package/src/components/editor-help/images/options-dark@2x.png +0 -0
- package/src/components/editor-help/images/options-dark@3x.png +0 -0
- package/src/components/editor-help/images/options-light.png +0 -0
- package/src/components/editor-help/images/options-light@2x.png +0 -0
- package/src/components/editor-help/images/options-light@3x.png +0 -0
- package/src/components/editor-help/images/rich-text-dark.png +0 -0
- package/src/components/editor-help/images/rich-text-dark@2x.png +0 -0
- package/src/components/editor-help/images/rich-text-dark@3x.png +0 -0
- package/src/components/editor-help/images/rich-text-light.png +0 -0
- package/src/components/editor-help/images/rich-text-light@2x.png +0 -0
- package/src/components/editor-help/images/rich-text-light@3x.png +0 -0
- package/src/components/editor-help/images/settings-dark.png +0 -0
- package/src/components/editor-help/images/settings-dark@2x.png +0 -0
- package/src/components/editor-help/images/settings-dark@3x.png +0 -0
- package/src/components/editor-help/images/settings-light.png +0 -0
- package/src/components/editor-help/images/settings-light@2x.png +0 -0
- package/src/components/editor-help/images/settings-light@3x.png +0 -0
- package/src/components/editor-help/index.native.js +147 -43
- package/src/components/editor-help/intro-to-blocks.native.js +63 -43
- package/src/components/editor-help/move-blocks.native.js +12 -7
- package/src/components/editor-help/remove-blocks.native.js +11 -8
- package/src/components/editor-help/style.android.scss +6 -0
- package/src/components/editor-help/style.ios.scss +6 -0
- package/src/components/editor-help/style.scss +49 -32
- package/src/components/editor-help/test/index.native.js +80 -0
- package/src/components/editor-help/view-sections.native.js +47 -4
- package/src/components/entities-saved-states/entity-type-list.js +29 -10
- package/src/components/entities-saved-states/index.js +38 -8
- package/src/components/global-keyboard-shortcuts/save-shortcut.js +34 -42
- package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +8 -16
- package/src/components/index.js +1 -0
- package/src/components/local-autosave-monitor/index.js +1 -3
- package/src/components/post-format/index.js +6 -2
- package/src/components/post-format/style.scss +1 -0
- package/src/components/post-locked-modal/index.js +1 -1
- package/src/components/post-saved-state/index.js +41 -55
- package/src/components/post-saved-state/style.scss +10 -1
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +20 -0
- package/src/components/post-saved-state/test/index.js +2 -2
- package/src/components/post-taxonomies/flat-term-selector.js +220 -254
- package/src/components/post-title/index.js +47 -30
- package/src/components/post-title/style.scss +1 -70
- package/src/components/provider/index.native.js +17 -5
- package/src/components/provider/use-block-editor-settings.js +25 -2
- package/src/components/word-count/index.js +3 -2
- package/src/store/actions.js +13 -41
- package/src/store/defaults.js +7 -2
- package/src/store/selectors.js +2 -112
- package/src/store/test/actions.js +4 -2
- package/src/store/utils/notice-builder.js +17 -19
- package/src/store/utils/test/notice-builder.js +1 -1
- package/src/{store/utils → utils}/get-template-part-icon.js +2 -2
- package/src/utils/index.js +1 -0
- package/build/store/utils/get-template-part-icon.js.map +0 -1
- package/build-module/store/utils/get-template-part-icon.js.map +0 -1
- package/src/components/editor-help/images/add-blocks.png +0 -0
- package/src/components/editor-help/images/customize-blocks.png +0 -0
- package/src/components/editor-help/images/cut-copy-duplicate-blocks.png +0 -0
- package/src/components/editor-help/images/edit-or-replace-media.png +0 -0
- package/src/components/editor-help/images/intro-blocks-1.png +0 -0
- package/src/components/editor-help/images/intro-blocks-2.png +0 -0
- package/src/components/editor-help/images/intro-blocks-3.png +0 -0
- package/src/components/editor-help/images/intro-blocks-4.png +0 -0
- package/src/components/editor-help/images/move-blocks.png +0 -0
- package/src/components/editor-help/images/remove-blocks.png +0 -0
- package/src/components/editor-help/images/what-is-a-block.png +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/remove-blocks.native.js"],"names":["View","__","styles","HelpDetailBodyText","HelpDetailImage","RemoveBlocks","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/remove-blocks.native.js"],"names":["View","__","styles","HelpDetailBodyText","HelpDetailImage","RemoveBlocks","require","helpDetailContainer"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,SAASC,kBAAT,EAA6BC,eAA7B,QAAoD,iBAApD;;AAEA,MAAMC,YAAY,GAAG,MAAM;AAC1B,SACC,8BACC,cAAC,eAAD;AACC,IAAA,MAAM,EAAGC,OAAO,CAAE,4BAAF,CADjB;AAEC,IAAA,cAAc,EAAGA,OAAO,CAAE,2BAAF;AAFzB,IADD,EAKC,cAAC,IAAD;AAAM,IAAA,KAAK,EAAGJ,MAAM,CAACK;AAArB,KACC,cAAC,kBAAD;AACC,IAAA,IAAI,EAAGN,EAAE,CACR,wKADQ;AADV,IADD,CALD,CADD;AAeA,CAhBD;;AAkBA,eAAeI,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { HelpDetailBodyText, HelpDetailImage } from './view-sections';\n\nconst RemoveBlocks = () => {\n\treturn (\n\t\t<>\n\t\t\t<HelpDetailImage\n\t\t\t\tsource={ require( './images/options-light.png' ) }\n\t\t\t\tsourceDarkMode={ require( './images/options-dark.png' ) }\n\t\t\t/>\n\t\t\t<View style={ styles.helpDetailContainer }>\n\t\t\t\t<HelpDetailBodyText\n\t\t\t\t\ttext={ __(\n\t\t\t\t\t\t'To remove a block, select the block and click the three dots in the bottom right of the block to view the settings. From there, choose the option to remove the block.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default RemoveBlocks;\n"]}
|
|
@@ -4,6 +4,11 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { Text, Image } from 'react-native';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { usePreferredColorScheme, usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
7
12
|
/**
|
|
8
13
|
* Internal dependencies
|
|
9
14
|
*/
|
|
@@ -12,23 +17,35 @@ import styles from './style.scss';
|
|
|
12
17
|
export const HelpDetailBodyText = ({
|
|
13
18
|
text
|
|
14
19
|
}) => {
|
|
20
|
+
const bodyStyle = usePreferredColorSchemeStyle(styles.helpDetailBody, styles.helpDetailBodyDark);
|
|
15
21
|
return createElement(Text, {
|
|
16
|
-
|
|
22
|
+
selectable: true,
|
|
23
|
+
style: bodyStyle
|
|
17
24
|
}, text);
|
|
18
25
|
};
|
|
19
26
|
export const HelpDetailSectionHeadingText = ({
|
|
20
27
|
text
|
|
21
28
|
}) => {
|
|
29
|
+
const headingStyle = usePreferredColorSchemeStyle(styles.helpDetailSectionHeading, styles.helpDetailSectionHeadingDark);
|
|
22
30
|
return createElement(Text, {
|
|
23
|
-
|
|
31
|
+
accessibilityRole: "header",
|
|
32
|
+
selectable: true,
|
|
33
|
+
style: headingStyle
|
|
24
34
|
}, text);
|
|
25
35
|
};
|
|
26
36
|
export const HelpDetailImage = ({
|
|
27
|
-
|
|
37
|
+
accessible,
|
|
38
|
+
accessibilityLabel,
|
|
39
|
+
source,
|
|
40
|
+
sourceDarkMode
|
|
28
41
|
}) => {
|
|
42
|
+
const imageStyle = usePreferredColorSchemeStyle(styles.helpDetailImage, styles.helpDetailImageDark);
|
|
43
|
+
const darkModeEnabled = usePreferredColorScheme() === 'dark';
|
|
29
44
|
return createElement(Image, {
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
accessible: accessible,
|
|
46
|
+
accessibilityLabel: accessibilityLabel,
|
|
47
|
+
source: darkModeEnabled && sourceDarkMode ? sourceDarkMode : source,
|
|
48
|
+
style: imageStyle
|
|
32
49
|
});
|
|
33
50
|
};
|
|
34
51
|
//# sourceMappingURL=view-sections.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/view-sections.native.js"],"names":["Text","Image","styles","HelpDetailBodyText","text","helpDetailBody","HelpDetailSectionHeadingText","helpDetailSectionHeading","HelpDetailImage","source","helpDetailImage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,KAAf,QAA4B,cAA5B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,OAAO,MAAMC,kBAAkB,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAAgB;AACjD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/editor-help/view-sections.native.js"],"names":["Text","Image","usePreferredColorScheme","usePreferredColorSchemeStyle","styles","HelpDetailBodyText","text","bodyStyle","helpDetailBody","helpDetailBodyDark","HelpDetailSectionHeadingText","headingStyle","helpDetailSectionHeading","helpDetailSectionHeadingDark","HelpDetailImage","accessible","accessibilityLabel","source","sourceDarkMode","imageStyle","helpDetailImage","helpDetailImageDark","darkModeEnabled"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,KAAf,QAA4B,cAA5B;AAEA;AACA;AACA;;AACA,SACCC,uBADD,EAECC,4BAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,OAAO,MAAMC,kBAAkB,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAAgB;AACjD,QAAMC,SAAS,GAAGJ,4BAA4B,CAC7CC,MAAM,CAACI,cADsC,EAE7CJ,MAAM,CAACK,kBAFsC,CAA9C;AAIA,SACC,cAAC,IAAD;AAAM,IAAA,UAAU,MAAhB;AAAiB,IAAA,KAAK,EAAGF;AAAzB,KACGD,IADH,CADD;AAKA,CAVM;AAYP,OAAO,MAAMI,4BAA4B,GAAG,CAAE;AAAEJ,EAAAA;AAAF,CAAF,KAAgB;AAC3D,QAAMK,YAAY,GAAGR,4BAA4B,CAChDC,MAAM,CAACQ,wBADyC,EAEhDR,MAAM,CAACS,4BAFyC,CAAjD;AAIA,SACC,cAAC,IAAD;AAAM,IAAA,iBAAiB,EAAC,QAAxB;AAAiC,IAAA,UAAU,MAA3C;AAA4C,IAAA,KAAK,EAAGF;AAApD,KACGL,IADH,CADD;AAKA,CAVM;AAYP,OAAO,MAAMQ,eAAe,GAAG,CAAE;AAChCC,EAAAA,UADgC;AAEhCC,EAAAA,kBAFgC;AAGhCC,EAAAA,MAHgC;AAIhCC,EAAAA;AAJgC,CAAF,KAKxB;AACN,QAAMC,UAAU,GAAGhB,4BAA4B,CAC9CC,MAAM,CAACgB,eADuC,EAE9ChB,MAAM,CAACiB,mBAFuC,CAA/C;AAIA,QAAMC,eAAe,GAAGpB,uBAAuB,OAAO,MAAtD;AACA,SACC,cAAC,KAAD;AACC,IAAA,UAAU,EAAGa,UADd;AAEC,IAAA,kBAAkB,EAAGC,kBAFtB;AAGC,IAAA,MAAM,EACLM,eAAe,IAAIJ,cAAnB,GAAoCA,cAApC,GAAqDD,MAJvD;AAMC,IAAA,KAAK,EAAGE;AANT,IADD;AAUA,CArBM","sourcesContent":["/**\n * External dependencies\n */\nimport { Text, Image } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport const HelpDetailBodyText = ( { text } ) => {\n\tconst bodyStyle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailBody,\n\t\tstyles.helpDetailBodyDark\n\t);\n\treturn (\n\t\t<Text selectable style={ bodyStyle }>\n\t\t\t{ text }\n\t\t</Text>\n\t);\n};\n\nexport const HelpDetailSectionHeadingText = ( { text } ) => {\n\tconst headingStyle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailSectionHeading,\n\t\tstyles.helpDetailSectionHeadingDark\n\t);\n\treturn (\n\t\t<Text accessibilityRole=\"header\" selectable style={ headingStyle }>\n\t\t\t{ text }\n\t\t</Text>\n\t);\n};\n\nexport const HelpDetailImage = ( {\n\taccessible,\n\taccessibilityLabel,\n\tsource,\n\tsourceDarkMode,\n} ) => {\n\tconst imageStyle = usePreferredColorSchemeStyle(\n\t\tstyles.helpDetailImage,\n\t\tstyles.helpDetailImageDark\n\t);\n\tconst darkModeEnabled = usePreferredColorScheme() === 'dark';\n\treturn (\n\t\t<Image\n\t\t\taccessible={ accessible }\n\t\t\taccessibilityLabel={ accessibilityLabel }\n\t\t\tsource={\n\t\t\t\tdarkModeEnabled && sourceDarkMode ? sourceDarkMode : source\n\t\t\t}\n\t\t\tstyle={ imageStyle }\n\t\t/>\n\t);\n};\n"]}
|
|
@@ -8,19 +8,30 @@ import { some } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { __, _n } from '@wordpress/i18n';
|
|
11
12
|
import { useSelect } from '@wordpress/data';
|
|
12
|
-
import { PanelBody } from '@wordpress/components';
|
|
13
|
-
import { page, layout } from '@wordpress/icons';
|
|
13
|
+
import { PanelBody, PanelRow } from '@wordpress/components';
|
|
14
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import EntityRecordItem from './entity-record-item';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
|
|
21
|
+
function getEntityDescription(entity, length) {
|
|
22
|
+
switch (entity) {
|
|
23
|
+
case 'site':
|
|
24
|
+
return _n('This change will affect your whole site.', 'These changes will affect your whole site.', length);
|
|
25
|
+
|
|
26
|
+
case 'wp_template':
|
|
27
|
+
return _n('This change will affect pages and posts that use this template.', 'These changes will affect pages and posts that use these templates.', length);
|
|
28
|
+
|
|
29
|
+
case 'page':
|
|
30
|
+
case 'post':
|
|
31
|
+
return __('The following content has been modified.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
24
35
|
export default function EntityTypeList({
|
|
25
36
|
list,
|
|
26
37
|
unselectedEntities,
|
|
@@ -28,17 +39,17 @@ export default function EntityTypeList({
|
|
|
28
39
|
closePanel
|
|
29
40
|
}) {
|
|
30
41
|
const firstRecord = list[0];
|
|
31
|
-
const entity = useSelect(select => select(coreStore).getEntity(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
|
|
32
|
-
|
|
42
|
+
const entity = useSelect(select => select(coreStore).getEntity(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
|
|
33
43
|
const {
|
|
34
44
|
name
|
|
35
45
|
} = firstRecord;
|
|
36
|
-
const
|
|
46
|
+
const entityLabel = name === 'wp_template_part' ? _n('Template Part', 'Template Parts', list.length) : entity.label; // Set description based on type of entity.
|
|
47
|
+
|
|
48
|
+
const description = getEntityDescription(name, list.length);
|
|
37
49
|
return createElement(PanelBody, {
|
|
38
|
-
title:
|
|
39
|
-
initialOpen: true
|
|
40
|
-
|
|
41
|
-
}, list.map(record => {
|
|
50
|
+
title: entityLabel,
|
|
51
|
+
initialOpen: true
|
|
52
|
+
}, description && createElement(PanelRow, null, description), list.map(record => {
|
|
42
53
|
return createElement(EntityRecordItem, {
|
|
43
54
|
key: record.key || record.property,
|
|
44
55
|
record: record,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/entity-type-list.js"],"names":["some","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/entity-type-list.js"],"names":["some","__","_n","useSelect","PanelBody","PanelRow","store","coreStore","EntityRecordItem","getEntityDescription","entity","length","EntityTypeList","list","unselectedEntities","setUnselectedEntities","closePanel","firstRecord","select","getEntity","kind","name","entityLabel","label","description","map","record","key","property","elt","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,uBAApC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;;AAEA,SAASC,oBAAT,CAA+BC,MAA/B,EAAuCC,MAAvC,EAAgD;AAC/C,UAASD,MAAT;AACC,SAAK,MAAL;AACC,aAAOR,EAAE,CACR,0CADQ,EAER,4CAFQ,EAGRS,MAHQ,CAAT;;AAKD,SAAK,aAAL;AACC,aAAOT,EAAE,CACR,iEADQ,EAER,qEAF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AS,GAAG,CAACR,IAAJ,KAAaK,MAAM,CAACL,IADpB,IAEAQ,GAAG,CAACF,GAAJ,KAAYD,MAAM,CAACC,GAFnB,IAGAE,GAAG,CAACD,QAAJ,KAAiBF,MAAM,CAACE,QANpB,CAJR;AAaC,MAAA,QAAQ,EAAKE,KAAF,IACVf,qBAAqB,CAAEW,MAAF,EAAUI,KAAV,CAdvB;AAgBC,MAAA,UAAU,EAAGd;AAhBd,MADD;AAoBA,GArBC,CAFH,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport { some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EntityRecordItem from './entity-record-item';\n\nfunction getEntityDescription( entity, length ) {\n\tswitch ( entity ) {\n\t\tcase 'site':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect your whole site.',\n\t\t\t\t'These changes will affect your whole site.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'wp_template':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect pages and posts that use this template.',\n\t\t\t\t'These changes will affect pages and posts that use these templates.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'page':\n\t\tcase 'post':\n\t\t\treturn __( 'The following content has been modified.' );\n\t}\n}\n\nexport default function EntityTypeList( {\n\tlist,\n\tunselectedEntities,\n\tsetUnselectedEntities,\n\tclosePanel,\n} ) {\n\tconst firstRecord = list[ 0 ];\n\tconst entity = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntity( firstRecord.kind, firstRecord.name ),\n\t\t[ firstRecord.kind, firstRecord.name ]\n\t);\n\tconst { name } = firstRecord;\n\tconst entityLabel =\n\t\tname === 'wp_template_part'\n\t\t\t? _n( 'Template Part', 'Template Parts', list.length )\n\t\t\t: entity.label;\n\t// Set description based on type of entity.\n\tconst description = getEntityDescription( name, list.length );\n\n\treturn (\n\t\t<PanelBody title={ entityLabel } initialOpen={ true }>\n\t\t\t{ description && <PanelRow>{ description }</PanelRow> }\n\t\t\t{ list.map( ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityRecordItem\n\t\t\t\t\t\tkey={ record.key || record.property }\n\t\t\t\t\t\trecord={ record }\n\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t! some(\n\t\t\t\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\t\t\t\telt.kind === record.kind &&\n\t\t\t\t\t\t\t\t\telt.name === record.name &&\n\t\t\t\t\t\t\t\t\telt.key === record.key &&\n\t\t\t\t\t\t\t\t\telt.property === record.property\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetUnselectedEntities( record, value )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclosePanel={ closePanel }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
@@ -21,13 +21,17 @@ import { close as closeIcon } from '@wordpress/icons';
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import EntityTypeList from './entity-type-list';
|
|
24
|
-
const
|
|
24
|
+
const TRANSLATED_SITE_PROPERTIES = {
|
|
25
25
|
title: __('Title'),
|
|
26
26
|
description: __('Tagline'),
|
|
27
27
|
site_logo: __('Logo'),
|
|
28
28
|
show_on_front: __('Show on front'),
|
|
29
29
|
page_on_front: __('Page on front')
|
|
30
30
|
};
|
|
31
|
+
const PUBLISH_ON_SAVE_ENTITIES = [{
|
|
32
|
+
kind: 'postType',
|
|
33
|
+
name: 'wp_navigation'
|
|
34
|
+
}];
|
|
31
35
|
export default function EntitiesSavedStates({
|
|
32
36
|
close
|
|
33
37
|
}) {
|
|
@@ -46,7 +50,7 @@ export default function EntitiesSavedStates({
|
|
|
46
50
|
siteEditsAsEntities.push({
|
|
47
51
|
kind: 'root',
|
|
48
52
|
name: 'site',
|
|
49
|
-
title:
|
|
53
|
+
title: TRANSLATED_SITE_PROPERTIES[property] || property,
|
|
50
54
|
property
|
|
51
55
|
});
|
|
52
56
|
}
|
|
@@ -57,11 +61,20 @@ export default function EntitiesSavedStates({
|
|
|
57
61
|
};
|
|
58
62
|
}, []);
|
|
59
63
|
const {
|
|
64
|
+
editEntityRecord,
|
|
60
65
|
saveEditedEntityRecord,
|
|
61
66
|
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
|
|
62
67
|
} = useDispatch(coreStore); // To group entities by type.
|
|
63
68
|
|
|
64
|
-
const partitionedSavables =
|
|
69
|
+
const partitionedSavables = groupBy(dirtyEntityRecords, 'name'); // Sort entity groups.
|
|
70
|
+
|
|
71
|
+
const {
|
|
72
|
+
site: siteSavables,
|
|
73
|
+
wp_template: templateSavables,
|
|
74
|
+
wp_template_part: templatePartSavables,
|
|
75
|
+
...contentSavables
|
|
76
|
+
} = partitionedSavables;
|
|
77
|
+
const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray); // Unchecked entities to be ignored by save function.
|
|
65
78
|
|
|
66
79
|
const [unselectedEntities, _setUnselectedEntities] = useState([]);
|
|
67
80
|
|
|
@@ -103,6 +116,12 @@ export default function EntitiesSavedStates({
|
|
|
103
116
|
if ('root' === kind && 'site' === name) {
|
|
104
117
|
siteItemsToSave.push(property);
|
|
105
118
|
} else {
|
|
119
|
+
if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
|
|
120
|
+
editEntityRecord(kind, name, key, {
|
|
121
|
+
status: 'publish'
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
106
125
|
saveEditedEntityRecord(kind, name, key);
|
|
107
126
|
}
|
|
108
127
|
});
|
|
@@ -133,7 +152,7 @@ export default function EntitiesSavedStates({
|
|
|
133
152
|
label: __('Close panel')
|
|
134
153
|
})), createElement("div", {
|
|
135
154
|
className: "entities-saved-states__text-prompt"
|
|
136
|
-
}, createElement("strong", null, __('
|
|
155
|
+
}, createElement("strong", null, __('Are you ready to save?')), createElement("p", null, __('The following changes have been made to your site, templates, and content.'))), sortedPartitionedSavables.map(list => {
|
|
137
156
|
return createElement(EntityTypeList, {
|
|
138
157
|
key: list[0].name,
|
|
139
158
|
list: list,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"names":["some","groupBy","Button","__","useSelect","useDispatch","useState","useCallback","useRef","store","coreStore","__experimentalUseDialog","useDialog","close","closeIcon","EntityTypeList","TRANSLATED_SITE_PROTPERTIES","title","description","site_logo","show_on_front","page_on_front","EntitiesSavedStates","saveButtonRef","dirtyEntityRecords","select","dirtyRecords","__experimentalGetDirtyEntityRecords","dirtyRecordsWithoutSite","filter","record","kind","name","siteEdits","getEntityRecordEdits","siteEditsAsEntities","property","push","dirtyRecordsWithSiteItems","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","partitionedSavables","Object","values","unselectedEntities","_setUnselectedEntities","setUnselectedEntities","key","checked","elt","saveCheckedEntities","entitiesToSave","siteItemsToSave","forEach","undefined","dismissPanel","saveDialogRef","saveDialogProps","onClose","length","map","list"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,OAAf,QAA8B,QAA9B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,MAAhC,QAA8C,oBAA9C;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,uBAAuB,IAAIC,SAApC,Q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C,MAAD;AACC,IAAA,GAAG,EAAGnC,aADP;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,QAAQ,EACPC,kBAAkB,CAACoC,MAAnB,GACCf,kBAAkB,CAACe,MADpB,KAEA,CANF;AAQC,IAAA,OAAO,EAAGT,mBARX;AASC,IAAA,SAAS,EAAC;AATX,KAWGhD,EAAE,CAAE,MAAF,CAXL,CADD,EAcC,cAAC,MAAD;AACC,IAAA,IAAI,EAAGW,SADR;AAEC,IAAA,OAAO,EAAG0C,YAFX;AAGC,IAAA,KAAK,EAAGrD,EAAE,CAAE,aAAF;AAHX,IAdD,CALD,EA0BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,8BAAUA,EAAE,CAAE,qCAAF,CAAZ,CADD,EAEC,yBACGA,EAAE,CACH,mDADG,CADL,CAFD,CA1BD,EAmCGuC,mBAAmB,CAACmB,GAApB,CAA2BC,IAAF,IAAY;AACtC,WACC,cAAC,cAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAAE,CAAF,CAAJ,CAAU9B,IADjB;AAEC,MAAA,IAAI,EAAG8B,IAFR;AAGC,MAAA,UAAU,EAAGN,YAHd;AAIC,MAAA,kBAAkB,EAAGX,kBAJtB;AAKC,MAAA,qBAAqB,EAAGE;AALzB,MADD;AASA,GAVC,CAnCH,CADD;AAiDA","sourcesContent":["/**\n * External dependencies\n */\nimport { some, groupBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close as closeIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\n\nconst TRANSLATED_SITE_PROTPERTIES = {\n\ttitle: __( 'Title' ),\n\tdescription: __( 'Tagline' ),\n\tsite_logo: __( 'Logo' ),\n\tshow_on_front: __( 'Show on front' ),\n\tpage_on_front: __( 'Page on front' ),\n};\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst saveButtonRef = useRef();\n\tconst { dirtyEntityRecords } = useSelect( ( select ) => {\n\t\tconst dirtyRecords = select(\n\t\t\tcoreStore\n\t\t).__experimentalGetDirtyEntityRecords();\n\n\t\t// Remove site object and decouple into its edited pieces.\n\t\tconst dirtyRecordsWithoutSite = dirtyRecords.filter(\n\t\t\t( record ) => ! ( record.kind === 'root' && record.name === 'site' )\n\t\t);\n\n\t\tconst siteEdits = select( coreStore ).getEntityRecordEdits(\n\t\t\t'root',\n\t\t\t'site'\n\t\t);\n\n\t\tconst siteEditsAsEntities = [];\n\t\tfor ( const property in siteEdits ) {\n\t\t\tsiteEditsAsEntities.push( {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t\ttitle: TRANSLATED_SITE_PROTPERTIES[ property ] || property,\n\t\t\t\tproperty,\n\t\t\t} );\n\t\t}\n\t\tconst dirtyRecordsWithSiteItems = [\n\t\t\t...dirtyRecordsWithoutSite,\n\t\t\t...siteEditsAsEntities,\n\t\t];\n\n\t\treturn {\n\t\t\tdirtyEntityRecords: dirtyRecordsWithSiteItems,\n\t\t};\n\t}, [] );\n\tconst {\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = Object.values(\n\t\tgroupBy( dirtyEntityRecords, 'name' )\n\t);\n\n\t// Unchecked entities to be ignored by save function.\n\tconst [ unselectedEntities, _setUnselectedEntities ] = useState( [] );\n\n\tconst setUnselectedEntities = (\n\t\t{ kind, name, key, property },\n\t\tchecked\n\t) => {\n\t\tif ( checked ) {\n\t\t\t_setUnselectedEntities(\n\t\t\t\tunselectedEntities.filter(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind !== kind ||\n\t\t\t\t\t\telt.name !== name ||\n\t\t\t\t\t\telt.key !== key ||\n\t\t\t\t\t\telt.property !== property\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\t_setUnselectedEntities( [\n\t\t\t\t...unselectedEntities,\n\t\t\t\t{ kind, name, key, property },\n\t\t\t] );\n\t\t}\n\t};\n\n\tconst saveCheckedEntities = () => {\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! some(\n\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tsaveEditedEntityRecord( kind, name, key );\n\t\t\t}\n\t\t} );\n\t\tsaveSpecifiedEntityEdits( 'root', 'site', undefined, siteItemsToSave );\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<div className=\"entities-saved-states__panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={\n\t\t\t\t\t\tdirtyEntityRecords.length -\n\t\t\t\t\t\t\tunselectedEntities.length ===\n\t\t\t\t\t\t0\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeIcon }\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t\tlabel={ __( 'Close panel' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong>{ __( 'Select the changes you want to save' ) }</strong>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Some changes may affect other areas of your site.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ partitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tclosePanel={ dismissPanel }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"names":["some","groupBy","Button","__","useSelect","useDispatch","useState","useCallback","useRef","store","coreStore","__experimentalUseDialog","useDialog","close","closeIcon","EntityTypeList","TRANSLATED_SITE_PROPERTIES","title","description","site_logo","show_on_front","page_on_front","PUBLISH_ON_SAVE_ENTITIES","kind","name","EntitiesSavedStates","saveButtonRef","dirtyEntityRecords","select","dirtyRecords","__experimentalGetDirtyEntityRecords","dirtyRecordsWithoutSite","filter","record","siteEdits","getEntityRecordEdits","siteEditsAsEntities","property","push","dirtyRecordsWithSiteItems","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","partitionedSavables","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","values","Array","isArray","unselectedEntities","_setUnselectedEntities","setUnselectedEntities","key","checked","elt","saveCheckedEntities","entitiesToSave","siteItemsToSave","forEach","typeToPublish","status","undefined","dismissPanel","saveDialogRef","saveDialogProps","onClose","length","map","list"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,OAAf,QAA8B,QAA9B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,MAAhC,QAA8C,oBAA9C;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,uBAAuB,IAAIC,SAApC,QAAqD,oBAArD;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,kBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,MAAMC,0BAA0B,GAAG;AAClCC,EAAAA,KAAK,EAAEd,EAAE,CAAE,OAAF,CADyB;AAElCe,EAAAA,WAAW,EAAEf,EAAE,CAAE,SAAF,CAFmB;AAGlCgB,EAAAA,SAAS,EAAEhB,EAAE,CAAE,MAAF,CAHqB;AAIlCiB,EAAAA,aAAa,EAAEjB,EAAE,CAAE,eAAF,CAJiB;AAKlCkB,EAAAA,aAAa,EAAElB,EAAE,CAAE,eAAF;AALiB,CAAnC;AAQA,MAAMmB,wBAAwB,GAAG,CAChC;AACCC,EAAAA,IAAI,EAAE,UADP;AAECC,EAAAA,IAAI,EAAE;AAFP,CADgC,CAAjC;AAOA,eAAe,SAASC,mBAAT,CAA8B;AAAEZ,EAAAA;AAAF,CAA9B,EAA0C;AACxD,QAAMa,a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ACC,IAAA,GAAG,EAAGC;AADP,KAEMC,eAFN;AAGC,IAAA,SAAS,EAAC;AAHX,MAKC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,GAAG,EAAG9C,aADP;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,QAAQ,EACPC,kBAAkB,CAAC+C,MAAnB,GACCjB,kBAAkB,CAACiB,MADpB,KAEA,CANF;AAQC,IAAA,OAAO,EAAGX,mBARX;AASC,IAAA,SAAS,EAAC;AATX,KAWG5D,EAAE,CAAE,MAAF,CAXL,CADD,EAcC,cAAC,MAAD;AACC,IAAA,IAAI,EAAGW,SADR;AAEC,IAAA,OAAO,EAAGwD,YAFX;AAGC,IAAA,KAAK,EAAGnE,EAAE,CAAE,aAAF;AAHX,IAdD,CALD,EA0BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,8BAAUA,EAAE,CAAE,wBAAF,CAAZ,CADD,EAEC,yBACGA,EAAE,CACH,4EADG,CADL,CAFD,CA1BD,EAmCGiD,yBAAyB,CAACuB,GAA1B,CAAiCC,IAAF,IAAY;AAC5C,WACC,cAAC,cAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAAE,CAAF,CAAJ,CAAUpD,IADjB;AAEC,MAAA,IAAI,EAAGoD,IAFR;AAGC,MAAA,UAAU,EAAGN,YAHd;AAIC,MAAA,kBAAkB,EAAGb,kBAJtB;AAKC,MAAA,qBAAqB,EAAGE;AALzB,MADD;AASA,GAVC,CAnCH,CADD;AAiDA","sourcesContent":["/**\n * External dependencies\n */\nimport { some, groupBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close as closeIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\n\nconst TRANSLATED_SITE_PROPERTIES = {\n\ttitle: __( 'Title' ),\n\tdescription: __( 'Tagline' ),\n\tsite_logo: __( 'Logo' ),\n\tshow_on_front: __( 'Show on front' ),\n\tpage_on_front: __( 'Page on front' ),\n};\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst saveButtonRef = useRef();\n\tconst { dirtyEntityRecords } = useSelect( ( select ) => {\n\t\tconst dirtyRecords = select(\n\t\t\tcoreStore\n\t\t).__experimentalGetDirtyEntityRecords();\n\n\t\t// Remove site object and decouple into its edited pieces.\n\t\tconst dirtyRecordsWithoutSite = dirtyRecords.filter(\n\t\t\t( record ) => ! ( record.kind === 'root' && record.name === 'site' )\n\t\t);\n\n\t\tconst siteEdits = select( coreStore ).getEntityRecordEdits(\n\t\t\t'root',\n\t\t\t'site'\n\t\t);\n\n\t\tconst siteEditsAsEntities = [];\n\t\tfor ( const property in siteEdits ) {\n\t\t\tsiteEditsAsEntities.push( {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t\ttitle: TRANSLATED_SITE_PROPERTIES[ property ] || property,\n\t\t\t\tproperty,\n\t\t\t} );\n\t\t}\n\t\tconst dirtyRecordsWithSiteItems = [\n\t\t\t...dirtyRecordsWithoutSite,\n\t\t\t...siteEditsAsEntities,\n\t\t];\n\n\t\treturn {\n\t\t\tdirtyEntityRecords: dirtyRecordsWithSiteItems,\n\t\t};\n\t}, [] );\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = groupBy( dirtyEntityRecords, 'name' );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\t// Unchecked entities to be ignored by save function.\n\tconst [ unselectedEntities, _setUnselectedEntities ] = useState( [] );\n\n\tconst setUnselectedEntities = (\n\t\t{ kind, name, key, property },\n\t\tchecked\n\t) => {\n\t\tif ( checked ) {\n\t\t\t_setUnselectedEntities(\n\t\t\t\tunselectedEntities.filter(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind !== kind ||\n\t\t\t\t\t\telt.name !== name ||\n\t\t\t\t\t\telt.key !== key ||\n\t\t\t\t\t\telt.property !== property\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\t_setUnselectedEntities( [\n\t\t\t\t...unselectedEntities,\n\t\t\t\t{ kind, name, key, property },\n\t\t\t] );\n\t\t}\n\t};\n\n\tconst saveCheckedEntities = () => {\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! some(\n\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tsaveEditedEntityRecord( kind, name, key );\n\t\t\t}\n\t\t} );\n\t\tsaveSpecifiedEntityEdits( 'root', 'site', undefined, siteItemsToSave );\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<div className=\"entities-saved-states__panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={\n\t\t\t\t\t\tdirtyEntityRecords.length -\n\t\t\t\t\t\t\tunselectedEntities.length ===\n\t\t\t\t\t\t0\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeIcon }\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t\tlabel={ __( 'Close panel' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong>{ __( 'Are you ready to save?' ) }</strong>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tclosePanel={ dismissPanel }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -19,24 +19,24 @@ function SaveShortcut({
|
|
|
19
19
|
} = useDispatch(editorStore);
|
|
20
20
|
const {
|
|
21
21
|
isEditedPostDirty,
|
|
22
|
-
getPostEdits
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
isEditedPostDirty: _isEditedPostDirty,
|
|
26
|
-
getPostEdits: _getPostEdits
|
|
27
|
-
} = select(editorStore);
|
|
28
|
-
return {
|
|
29
|
-
isEditedPostDirty: _isEditedPostDirty,
|
|
30
|
-
getPostEdits: _getPostEdits
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
22
|
+
getPostEdits,
|
|
23
|
+
isPostSavingLocked
|
|
24
|
+
} = useSelect(editorStore);
|
|
33
25
|
useShortcut('core/editor/save', event => {
|
|
34
|
-
event.preventDefault();
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
/**
|
|
28
|
+
* Do not save the post if post saving is locked.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
if (isPostSavingLocked()) {
|
|
32
|
+
return;
|
|
33
|
+
} // TODO: This should be handled in the `savePost` effect in
|
|
35
34
|
// considering `isSaveable`. See note on `isEditedPostSaveable`
|
|
36
35
|
// selector about dirtiness and meta-boxes.
|
|
37
36
|
//
|
|
38
37
|
// See: `isEditedPostSaveable`
|
|
39
38
|
|
|
39
|
+
|
|
40
40
|
if (!isEditedPostDirty()) {
|
|
41
41
|
return;
|
|
42
42
|
} // The text editor requires that editor blocks are updated for a
|
|
@@ -55,8 +55,6 @@ function SaveShortcut({
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
savePost();
|
|
58
|
-
}, {
|
|
59
|
-
bindGlobal: true
|
|
60
58
|
});
|
|
61
59
|
return null;
|
|
62
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/save-shortcut.js"],"names":["useShortcut","useDispatch","useSelect","parse","store","editorStore","SaveShortcut","resetBlocksOnSave","resetEditorBlocks","savePost","isEditedPostDirty","getPostEdits","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/save-shortcut.js"],"names":["useShortcut","useDispatch","useSelect","parse","store","editorStore","SaveShortcut","resetBlocksOnSave","resetEditorBlocks","savePost","isEditedPostDirty","getPostEdits","isPostSavingLocked","event","preventDefault","postEdits","content","blocks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,+BAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,YAAT,CAAuB;AAAEC,EAAAA;AAAF,CAAvB,EAA+C;AAC9C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAkCR,WAAW,CAAEI,WAAF,CAAnD;AACA,QAAM;AAAEK,IAAAA,iBAAF;AAAqBC,IAAAA,YAArB;AAAmCC,IAAAA;AAAnC,MAA0DV,SAAS,CACxEG,WADwE,CAAzE;AAIAL,EAAAA,WAAW,CAAE,kBAAF,EAAwBa,KAAF,IAAa;AAC7CA,IAAAA,KAAK,CAACC,cAAN;AAEA;AACF;AACA;;AACE,QAAKF,kBAAkB,EAAvB,EAA4B;AAC3B;AACA,KAR4C,CAU7C;AACA;AACA;AACA;AACA;;;AACA,QAAK,CAAEF,iBAAiB,EAAxB,EAA6B;AAC5B;AACA,KAjB4C,CAmB7C;AACA;AACA;AACA;;;AACA,QAAKH,iBAAL,EAAyB;AACxB,YAAMQ,SAAS,GAAGJ,YAAY,EAA9B;;AACA,UAAKI,SAAS,CAACC,OAAV,IAAqB,OAAOD,SAAS,CAACC,OAAjB,KAA6B,QAAvD,EAAkE;AACjE,cAAMC,MAAM,GAAGd,KAAK,CAAEY,SAAS,CAACC,OAAZ,CAApB;AACAR,QAAAA,iBAAiB,CAAES,MAAF,CAAjB;AACA;AACD;;AAEDR,IAAAA,QAAQ;AACR,GAhCU,CAAX;AAkCA,SAAO,IAAP;AACA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction SaveShortcut( { resetBlocksOnSave } ) {\n\tconst { resetEditorBlocks, savePost } = useDispatch( editorStore );\n\tconst { isEditedPostDirty, getPostEdits, isPostSavingLocked } = useSelect(\n\t\teditorStore\n\t);\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The text editor requires that editor blocks are updated for a\n\t\t// save to work correctly. Usually this happens when the textarea\n\t\t// for the code editors blurs, but the shortcut can be used without\n\t\t// blurring the textarea.\n\t\tif ( resetBlocksOnSave ) {\n\t\t\tconst postEdits = getPostEdits();\n\t\t\tif ( postEdits.content && typeof postEdits.content === 'string' ) {\n\t\t\t\tconst blocks = parse( postEdits.content );\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t}\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\treturn null;\n}\n\nexport default SaveShortcut;\n"]}
|
|
@@ -20,14 +20,10 @@ function VisualEditorGlobalKeyboardShortcuts() {
|
|
|
20
20
|
useShortcut('core/editor/undo', event => {
|
|
21
21
|
undo();
|
|
22
22
|
event.preventDefault();
|
|
23
|
-
}, {
|
|
24
|
-
bindGlobal: true
|
|
25
23
|
});
|
|
26
24
|
useShortcut('core/editor/redo', event => {
|
|
27
25
|
redo();
|
|
28
26
|
event.preventDefault();
|
|
29
|
-
}, {
|
|
30
|
-
bindGlobal: true
|
|
31
27
|
});
|
|
32
28
|
return createElement(SaveShortcut, null);
|
|
33
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js"],"names":["useShortcut","useDispatch","SaveShortcut","store","editorStore","VisualEditorGlobalKeyboardShortcuts","redo","undo","event","preventDefault"
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js"],"names":["useShortcut","useDispatch","SaveShortcut","store","editorStore","VisualEditorGlobalKeyboardShortcuts","redo","undo","event","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,+BAA5B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,mCAAT,GAA+C;AAC9C,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAiBN,WAAW,CAAEG,WAAF,CAAlC;AAEAJ,EAAAA,WAAW,CAAE,kBAAF,EAAwBQ,KAAF,IAAa;AAC7CD,IAAAA,IAAI;AACJC,IAAAA,KAAK,CAACC,cAAN;AACA,GAHU,CAAX;AAKAT,EAAAA,WAAW,CAAE,kBAAF,EAAwBQ,KAAF,IAAa;AAC7CF,IAAAA,IAAI;AACJE,IAAAA,KAAK,CAACC,cAAN;AACA,GAHU,CAAX;AAKA,SAAO,cAAC,YAAD,OAAP;AACA;;AAED,eAAeJ,mCAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SaveShortcut from './save-shortcut';\nimport { store as editorStore } from '../../store';\n\nfunction VisualEditorGlobalKeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( editorStore );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\treturn <SaveShortcut />;\n}\n\nexport default VisualEditorGlobalKeyboardShortcuts;\n"]}
|
|
@@ -57,6 +57,7 @@ export { default as PostVisibility } from './post-visibility';
|
|
|
57
57
|
export { default as PostVisibilityLabel } from './post-visibility/label';
|
|
58
58
|
export { default as PostVisibilityCheck } from './post-visibility/check';
|
|
59
59
|
export { default as TableOfContents } from './table-of-contents';
|
|
60
|
+
export { default as ThemeSupportCheck } from './theme-support-check';
|
|
60
61
|
export { default as UnsavedChangesWarning } from './unsaved-changes-warning';
|
|
61
62
|
export { default as WordCount } from './word-count'; // State Related Components
|
|
62
63
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":["default","AutosaveMonitor","DocumentOutline","DocumentOutlineCheck","VisualEditorGlobalKeyboardShortcuts","TextEditorGlobalKeyboardShortcuts","EditorKeyboardShortcutsRegister","EditorHistoryRedo","EditorHistoryUndo","EditorNotices","EditorSnackbars","EntitiesSavedStates","ErrorBoundary","LocalAutosaveMonitor","PageAttributesCheck","PageAttributesOrder","PageAttributesParent","PageTemplate","PostAuthor","PostAuthorCheck","PostComments","PostExcerpt","PostExcerptCheck","PostFeaturedImage","PostFeaturedImageCheck","PostFormat","PostFormatCheck","PostLastRevision","PostLastRevisionCheck","PostLockedModal","PostPendingStatus","PostPendingStatusCheck","PostPingbacks","PostPreviewButton","PostPublishButton","PostPublishButtonLabel","PostPublishPanel","PostSavedState","PostSchedule","PostScheduleCheck","PostScheduleLabel","PostSlug","PostSlugCheck","PostSticky","PostStickyCheck","PostSwitchToDraftButton","PostTaxonomies","PostTaxonomiesCheck","PostTextEditor","PostTitle","PostTrash","PostTrashCheck","PostTypeSupportCheck","PostVisibility","PostVisibilityLabel","PostVisibilityCheck","TableOfContents","UnsavedChangesWarning","WordCount","EditorProvider"],"mappings":"AAAA;AACA,cAAc,kBAAd,C,CAEA;;AACA,SAASA,OAAO,IAAIC,eAApB,QAA2C,oBAA3C;AACA,SAASD,OAAO,IAAIE,eAApB,QAA2C,oBAA3C;AACA,SAASF,OAAO,IAAIG,oBAApB,QAAgD,0BAAhD;AACA,SAASH,OAAO,IAAII,mCAApB,QAA+D,qDAA/D;AACA,SAASJ,OAAO,IAAIK,iCAApB,QAA6D,mDAA7D;AACA,SAASL,OAAO,IAAIM,+BAApB,QAA2D,gDAA3D;AACA,SAASN,OAAO,IAAIO,iBAApB,QAA6C,uBAA7C;AACA,SAASP,OAAO,IAAIQ,iBAApB,QAA6C,uBAA7C;AACA,SAASR,OAAO,IAAIS,aAApB,QAAyC,kBAAzC;AACA,SAAST,OAAO,IAAIU,eAApB,QAA2C,oBAA3C;AACA,SAASV,OAAO,IAAIW,mBAApB,QAA+C,yBAA/C;AACA,SAASX,OAAO,IAAIY,aAApB,QAAyC,kBAAzC;AACA,SAASZ,OAAO,IAAIa,oBAApB,QAAgD,0BAAhD;AACA,SAASb,OAAO,IAAIc,mBAApB,QAA+C,yBAA/C;AACA,SAASd,OAAO,IAAIe,mBAApB,QAA+C,yBAA/C;AACA,S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,IAAIyC,QAApB,QAAoC,aAApC;AACA,SAASzC,OAAO,IAAI0C,aAApB,QAAyC,mBAAzC;AACA,SAAS1C,OAAO,IAAI2C,UAApB,QAAsC,eAAtC;AACA,SAAS3C,OAAO,IAAI4C,eAApB,QAA2C,qBAA3C;AACA,SAAS5C,OAAO,IAAI6C,uBAApB,QAAmD,+BAAnD;AACA,SAAS7C,OAAO,IAAI8C,cAApB,QAA0C,mBAA1C;AACA,SAAS9C,OAAO,IAAI+C,mBAApB,QAA+C,yBAA/C;AACA,SAAS/C,OAAO,IAAIgD,cAApB,QAA0C,oBAA1C;AACA,SAAShD,OAAO,IAAIiD,SAApB,QAAqC,cAArC;AACA,SAASjD,OAAO,IAAIkD,SAApB,QAAqC,cAArC;AACA,SAASlD,OAAO,IAAImD,cAApB,QAA0C,oBAA1C;AACA,SAASnD,OAAO,IAAIoD,oBAApB,QAAgD,2BAAhD;AACA,SAASpD,OAAO,IAAIqD,cAApB,QAA0C,mBAA1C;AACA,SAASrD,OAAO,IAAIsD,mBAApB,QAA+C,yBAA/C;AACA,SAAStD,OAAO,IAAIuD,mBAApB,QAA+C,yBAA/C;AACA,SAASvD,OAAO,IAAIwD,eAApB,QAA2C,qBAA3C;AACA,SAASxD,OAAO,IAAIyD,qBAApB,QAAiD,2BAAjD;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":["default","AutosaveMonitor","DocumentOutline","DocumentOutlineCheck","VisualEditorGlobalKeyboardShortcuts","TextEditorGlobalKeyboardShortcuts","EditorKeyboardShortcutsRegister","EditorHistoryRedo","EditorHistoryUndo","EditorNotices","EditorSnackbars","EntitiesSavedStates","ErrorBoundary","LocalAutosaveMonitor","PageAttributesCheck","PageAttributesOrder","PageAttributesParent","PageTemplate","PostAuthor","PostAuthorCheck","PostComments","PostExcerpt","PostExcerptCheck","PostFeaturedImage","PostFeaturedImageCheck","PostFormat","PostFormatCheck","PostLastRevision","PostLastRevisionCheck","PostLockedModal","PostPendingStatus","PostPendingStatusCheck","PostPingbacks","PostPreviewButton","PostPublishButton","PostPublishButtonLabel","PostPublishPanel","PostSavedState","PostSchedule","PostScheduleCheck","PostScheduleLabel","PostSlug","PostSlugCheck","PostSticky","PostStickyCheck","PostSwitchToDraftButton","PostTaxonomies","PostTaxonomiesCheck","PostTextEditor","PostTitle","PostTrash","PostTrashCheck","PostTypeSupportCheck","PostVisibility","PostVisibilityLabel","PostVisibilityCheck","TableOfContents","ThemeSupportCheck","UnsavedChangesWarning","WordCount","EditorProvider"],"mappings":"AAAA;AACA,cAAc,kBAAd,C,CAEA;;AACA,SAASA,OAAO,IAAIC,eAApB,QAA2C,oBAA3C;AACA,SAASD,OAAO,IAAIE,eAApB,QAA2C,oBAA3C;AACA,SAASF,OAAO,IAAIG,oBAApB,QAAgD,0BAAhD;AACA,SAASH,OAAO,IAAII,mCAApB,QAA+D,qDAA/D;AACA,SAASJ,OAAO,IAAIK,iCAApB,QAA6D,mDAA7D;AACA,SAASL,OAAO,IAAIM,+BAApB,QAA2D,gDAA3D;AACA,SAASN,OAAO,IAAIO,iBAApB,QAA6C,uBAA7C;AACA,SAASP,OAAO,IAAIQ,iBAApB,QAA6C,uBAA7C;AACA,SAASR,OAAO,IAAIS,aAApB,QAAyC,kBAAzC;AACA,SAAST,OAAO,IAAIU,eAApB,QAA2C,oBAA3C;AACA,SAASV,OAAO,IAAIW,mBAApB,QAA+C,yBAA/C;AACA,SAASX,OAAO,IAAIY,aAApB,QAAyC,kBAAzC;AACA,SAASZ,OAAO,IAAIa,oBAApB,QAAgD,0BAAhD;AACA,SAASb,OAAO,IAAIc,mBAApB,QAA+C,yBAA/C;AACA,SAASd,OAAO,IAAIe,mBAApB,QAA+C,yBAA/C;AACA,SAASf,OAAO,IAAIgB,oBAApB,QAAgD,0BAAhD;AACA,SAAShB,OAAO,IAAIiB,YAApB,QAAwC,iBAAxC;AACA,SAASjB,OAAO,IAAIkB,UAApB,QAAsC,eAAtC;AACA,SAASlB,OAA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eAApB,QAA2C,qBAA3C;AACA,SAAS5C,OAAO,IAAI6C,uBAApB,QAAmD,+BAAnD;AACA,SAAS7C,OAAO,IAAI8C,cAApB,QAA0C,mBAA1C;AACA,SAAS9C,OAAO,IAAI+C,mBAApB,QAA+C,yBAA/C;AACA,SAAS/C,OAAO,IAAIgD,cAApB,QAA0C,oBAA1C;AACA,SAAShD,OAAO,IAAIiD,SAApB,QAAqC,cAArC;AACA,SAASjD,OAAO,IAAIkD,SAApB,QAAqC,cAArC;AACA,SAASlD,OAAO,IAAImD,cAApB,QAA0C,oBAA1C;AACA,SAASnD,OAAO,IAAIoD,oBAApB,QAAgD,2BAAhD;AACA,SAASpD,OAAO,IAAIqD,cAApB,QAA0C,mBAA1C;AACA,SAASrD,OAAO,IAAIsD,mBAApB,QAA+C,yBAA/C;AACA,SAAStD,OAAO,IAAIuD,mBAApB,QAA+C,yBAA/C;AACA,SAASvD,OAAO,IAAIwD,eAApB,QAA2C,qBAA3C;AACA,SAASxD,OAAO,IAAIyD,iBAApB,QAA6C,uBAA7C;AACA,SAASzD,OAAO,IAAI0D,qBAApB,QAAiD,2BAAjD;AACA,SAAS1D,OAAO,IAAI2D,SAApB,QAAqC,cAArC,C,CAEA;;AACA,SAAS3D,OAAO,IAAI4D,cAApB,QAA0C,YAA1C;AAEA,cAAc,cAAd","sourcesContent":["// Block Creation Components\nexport * from './autocompleters';\n\n// Post Related Components\nexport { default as AutosaveMonitor } from './autosave-monitor';\nexport { default as DocumentOutline } from './document-outline';\nexport { default as DocumentOutlineCheck } from './document-outline/check';\nexport { default as VisualEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/visual-editor-shortcuts';\nexport { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts';\nexport { default as EditorKeyboardShortcutsRegister } from './global-keyboard-shortcuts/register-shortcuts';\nexport { default as EditorHistoryRedo } from './editor-history/redo';\nexport { default as EditorHistoryUndo } from './editor-history/undo';\nexport { default as EditorNotices } from './editor-notices';\nexport { default as EditorSnackbars } from './editor-snackbars';\nexport { default as EntitiesSavedStates } from './entities-saved-states';\nexport { default as ErrorBoundary } from './error-boundary';\nexport { default as LocalAutosaveMonitor } from './local-autosave-monitor';\nexport { default as PageAttributesCheck } from './page-attributes/check';\nexport { default as PageAttributesOrder } from './page-attributes/order';\nexport { default as PageAttributesParent } from './page-attributes/parent';\nexport { default as PageTemplate } from './post-template';\nexport { default as PostAuthor } from './post-author';\nexport { default as PostAuthorCheck } from './post-author/check';\nexport { default as PostComments } from './post-comments';\nexport { default as PostExcerpt } from './post-excerpt';\nexport { default as PostExcerptCheck } from './post-excerpt/check';\nexport { default as PostFeaturedImage } from './post-featured-image';\nexport { default as PostFeaturedImageCheck } from './post-featured-image/check';\nexport { default as PostFormat } from './post-format';\nexport { default as PostFormatCheck } from './post-format/check';\nexport { default as PostLastRevision } from './post-last-revision';\nexport { default as PostLastRevisionCheck } from './post-last-revision/check';\nexport { default as PostLockedModal } from './post-locked-modal';\nexport { default as PostPendingStatus } from './post-pending-status';\nexport { default as PostPendingStatusCheck } from './post-pending-status/check';\nexport { default as PostPingbacks } from './post-pingbacks';\nexport { default as PostPreviewButton } from './post-preview-button';\nexport { default as PostPublishButton } from './post-publish-button';\nexport { default as PostPublishButtonLabel } from './post-publish-button/label';\nexport { default as PostPublishPanel } from './post-publish-panel';\nexport { default as PostSavedState } from './post-saved-state';\nexport { default as PostSchedule } from './post-schedule';\nexport { default as PostScheduleCheck } from './post-schedule/check';\nexport { default as PostScheduleLabel } from './post-schedule/label';\nexport { default as PostSlug } from './post-slug';\nexport { default as PostSlugCheck } from './post-slug/check';\nexport { default as PostSticky } from './post-sticky';\nexport { default as PostStickyCheck } from './post-sticky/check';\nexport { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';\nexport { default as PostTaxonomies } from './post-taxonomies';\nexport { default as PostTaxonomiesCheck } from './post-taxonomies/check';\nexport { default as PostTextEditor } from './post-text-editor';\nexport { default as PostTitle } from './post-title';\nexport { default as PostTrash } from './post-trash';\nexport { default as PostTrashCheck } from './post-trash/check';\nexport { default as PostTypeSupportCheck } from './post-type-support-check';\nexport { default as PostVisibility } from './post-visibility';\nexport { default as PostVisibilityLabel } from './post-visibility/label';\nexport { default as PostVisibilityCheck } from './post-visibility/check';\nexport { default as TableOfContents } from './table-of-contents';\nexport { default as ThemeSupportCheck } from './theme-support-check';\nexport { default as UnsavedChangesWarning } from './unsaved-changes-warning';\nexport { default as WordCount } from './word-count';\n\n// State Related Components\nexport { default as EditorProvider } from './provider';\n\nexport * from './deprecated';\n"]}
|
|
@@ -53,12 +53,11 @@ function useAutosaveNotice() {
|
|
|
53
53
|
} = useSelect(select => ({
|
|
54
54
|
postId: select(editorStore).getCurrentPostId(),
|
|
55
55
|
isEditedPostNew: select(editorStore).isEditedPostNew(),
|
|
56
|
-
getEditedPostAttribute: select(editorStore).getEditedPostAttribute,
|
|
57
56
|
hasRemoteAutosave: !!select(editorStore).getEditorSettings().autosave
|
|
58
57
|
}), []);
|
|
59
58
|
const {
|
|
60
59
|
getEditedPostAttribute
|
|
61
|
-
} = useSelect(
|
|
60
|
+
} = useSelect(editorStore);
|
|
62
61
|
const {
|
|
63
62
|
createWarningNotice,
|
|
64
63
|
removeNotice
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["once","uniqueId","omit","useCallback","useEffect","useRef","ifCondition","usePrevious","useSelect","useDispatch","__","parse","store","noticesStore","AutosaveMonitor","localAutosaveGet","localAutosaveClear","editorStore","requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","getCurrentPostId","getEditedPostAttribute","getEditorSettings","autosave","createWarningNotice","removeNotice","editPost","resetEditorBlocks","localAutosave","JSON","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval","__experimentalLocalAutosaveInterval"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,QAAf,EAAyBC,IAAzB,QAAqC,QAArC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,oBAA/C;AACA,SAASC,WAAT,EAAsBC,WAAtB,QAAyC,oBAAzC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,gBAAT,EAA2BC,kBAA3B,QAAqD,sBAArD;AACA,SAASJ,KAAK,IAAIK,WAAlB,QAAqC,aAArC;AAEA,MAAMC,mBAAmB,GAAGC,MAAM,CAACD,mBAAP,GACzBC,MAAM,CAACD,mBADkB,GAEzBC,MAAM,CAACC,qBAFV;AAIA;AACA;AACA;AACA;AACA;;AACA,MAAMC,wBAAwB,GAAGrB,IAAI,CAAE,MAAM;AAC5C,MAAI;AACH;AACA;AACA;AACAmB,IAAAA,MAAM,CAACG,cAAP,CAAsBC,OAAtB,CAA+B,8BAA/B,EAA+D,EAA/D;AACAJ,IAAAA,MAAM,CAACG,cAAP,CAAsBE,UAAtB,CAAkC,8BAAlC;AACA,WAAO,IAAP;AACA,GAPD,CAOE,OAAQC,KAAR,EAAgB;AACjB,WAAO,KAAP;AACA;AACD,CAXoC,CAArC;AAaA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,GAA6B;AAC5B,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,eAAV;AAA2BC,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Ce,IAAAA,mBAAmB,CAAE,MAAMgB,QAAQ,CAAE;AAAEoC,MAAAA,KAAK,EAAE;AAAT,KAAF,CAAhB,CAAnB;AACA,GAFmC,EAEjC,EAFiC,CAApC;AAGA5C,EAAAA,iBAAiB;AACjB8B,EAAAA,gBAAgB;AAEhB,QAAM;AAAEe,IAAAA;AAAF,MAA4B/D,SAAS,CACxCsB,MAAF,KAAgB;AACfyC,IAAAA,qBAAqB,EAAEzC,MAAM,CAAEb,WAAF,CAAN,CAAsBgB,iBAAtB,GACrBuC;AAFa,GAAhB,CAD0C,EAK1C,EAL0C,CAA3C;AAQA,SACC,cAAC,eAAD;AACC,IAAA,QAAQ,EAAGD,qBADZ;AAEC,IAAA,QAAQ,EAAGF;AAFZ,IADD;AAMA;;AAED,eAAe/D,WAAW,CAAEe,wBAAF,CAAX,CAAyC+C,oBAAzC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { once, uniqueId, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport { localAutosaveGet, localAutosaveClear } from '../../store/controls';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tgetEditedPostAttribute: select( editorStore )\n\t\t\t\t.getEditedPostAttribute,\n\t\t\thasRemoteAutosave: !! select( editorStore ).getEditorSettings()\n\t\t\t\t.autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( 'core/editor' );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\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);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst {\n\t\tpostId,\n\t\tisEditedPostNew,\n\t\tisDirty,\n\t\tisAutosaving,\n\t\tdidError,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval: select( editorStore ).getEditorSettings()\n\t\t\t\t.__experimentalLocalAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["once","uniqueId","omit","useCallback","useEffect","useRef","ifCondition","usePrevious","useSelect","useDispatch","__","parse","store","noticesStore","AutosaveMonitor","localAutosaveGet","localAutosaveClear","editorStore","requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","editPost","resetEditorBlocks","localAutosave","JSON","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval","__experimental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B/D,SAAS,CACxCsB,MAAF,KAAgB;AACfyC,IAAAA,qBAAqB,EAAEzC,MAAM,CAAEb,WAAF,CAAN,CAAsBe,iBAAtB,GACrBwC;AAFa,GAAhB,CAD0C,EAK1C,EAL0C,CAA3C;AAQA,SACC,cAAC,eAAD;AACC,IAAA,QAAQ,EAAGD,qBADZ;AAEC,IAAA,QAAQ,EAAGF;AAFZ,IADD;AAMA;;AAED,eAAe/D,WAAW,CAAEe,wBAAF,CAAX,CAAyC+C,oBAAzC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { once, uniqueId, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport { localAutosaveGet, localAutosaveClear } from '../../store/controls';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave: !! select( editorStore ).getEditorSettings()\n\t\t\t\t.autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\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);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst {\n\t\tpostId,\n\t\tisEditedPostNew,\n\t\tisDirty,\n\t\tisAutosaving,\n\t\tdidError,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval: select( editorStore ).getEditorSettings()\n\t\t\t\t.__experimentalLocalAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
|
|
@@ -8,7 +8,7 @@ import { find, get, includes, union } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
12
12
|
import { Button, SelectControl } from '@wordpress/components';
|
|
13
13
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
14
|
import { useInstanceId } from '@wordpress/compose';
|
|
@@ -117,6 +117,8 @@ export default function PostFormat() {
|
|
|
117
117
|
}, __('Suggestion:'), ' ', createElement(Button, {
|
|
118
118
|
variant: "link",
|
|
119
119
|
onClick: () => onUpdatePostFormat(suggestion.id)
|
|
120
|
-
},
|
|
120
|
+
}, sprintf(
|
|
121
|
+
/* translators: %s: post format */
|
|
122
|
+
__('Apply format: %s'), suggestion.caption)))));
|
|
121
123
|
}
|
|
122
124
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-format/index.js"],"names":["find","get","includes","union","__","Button","SelectControl","useDispatch","useSelect","useInstanceId","store","coreStore","PostFormatCheck","editorStore","POST_FORMATS","id","caption","sort","a","b","normalizedA","toUpperCase","normalizedB","PostFormat","instanceId","postFormatSelectorId","postFormat","suggestedFormat","supportedFormats","select","getEditedPostAttribute","getSuggestedPostFormat","_postFormat","themeSupports","getThemeSupports","formats","filter","format","suggestion","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,GAAf,EAAoBC,QAApB,EAA8BC,KAA9B,QAA2C,QAA3C;AAEA;AACA;AACA;;AACA,SAASC,EAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-format/index.js"],"names":["find","get","includes","union","__","sprintf","Button","SelectControl","useDispatch","useSelect","useInstanceId","store","coreStore","PostFormatCheck","editorStore","POST_FORMATS","id","caption","sort","a","b","normalizedA","toUpperCase","normalizedB","PostFormat","instanceId","postFormatSelectorId","postFormat","suggestedFormat","supportedFormats","select","getEditedPostAttribute","getSuggestedPostFormat","_postFormat","themeSupports","getThemeSupports","formats","filter","format","suggestion","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,GAAf,EAAoBC,QAApB,EAA8BC,KAA9B,QAA2C,QAA3C;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,EAAiBC,aAAjB,QAAsC,uBAAtC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,SAA5B;AACA,SAASF,KAAK,IAAIG,WAAlB,QAAqC,aAArC,C,CAEA;;AACA,OAAO,MAAMC,YAAY,GAAG,CAC3B;AAAEC,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAEb,EAAE,CAAE,OAAF;AAA1B,CAD2B,EAE3B;AAAEY,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAEb,EAAE,CAAE,OAAF;AAA1B,CAF2B,EAG3B;AAAEY,EAAAA,EAAE,EAAE,MAAN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E,CAAE,aAAF,CADL,CADD,EAIC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGuB,UADT;AAEC,IAAA,QAAQ,EAAKW,MAAF,IAAcG,kBAAkB,CAAEH,MAAF,CAF5C;AAGC,IAAA,EAAE,EAAGZ,oBAHN;AAIC,IAAA,OAAO,EAAGU,OAAO,CAACM,GAAR,CAAeJ,MAAF,KAAgB;AACtCK,MAAAA,KAAK,EAAEL,MAAM,CAACrB,OADwB;AAEtC2B,MAAAA,KAAK,EAAEN,MAAM,CAACtB;AAFwB,KAAhB,CAAb;AAJX,IAJD,CADD,EAgBGuB,UAAU,IAAIA,UAAU,CAACvB,EAAX,KAAkBW,UAAhC,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGvB,EAAE,CAAE,aAAF,CADL,EAC0B,GAD1B,EAEC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MACTqC,kBAAkB,CAAEF,UAAU,CAACvB,EAAb;AAHpB,KAMGX,OAAO;AACR;AACAD,EAAAA,EAAE,CAAE,kBAAF,CAFM,EAGRmC,UAAU,CAACtB,OAHH,CANV,CAFD,CAjBF,CADD,CADD;AAsCA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get, includes, union } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, SelectControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFormatCheck from './check';\nimport { store as editorStore } from '../../store';\n\n// All WP post formats, sorted alphabetically by translated name.\nexport const POST_FORMATS = [\n\t{ id: 'aside', caption: __( 'Aside' ) },\n\t{ id: 'audio', caption: __( 'Audio' ) },\n\t{ id: 'chat', caption: __( 'Chat' ) },\n\t{ id: 'gallery', caption: __( 'Gallery' ) },\n\t{ id: 'image', caption: __( 'Image' ) },\n\t{ id: 'link', caption: __( 'Link' ) },\n\t{ id: 'quote', caption: __( 'Quote' ) },\n\t{ id: 'standard', caption: __( 'Standard' ) },\n\t{ id: 'status', caption: __( 'Status' ) },\n\t{ id: 'video', caption: __( 'Video' ) },\n].sort( ( a, b ) => {\n\tconst normalizedA = a.caption.toUpperCase();\n\tconst normalizedB = b.caption.toUpperCase();\n\n\tif ( normalizedA < normalizedB ) {\n\t\treturn -1;\n\t}\n\tif ( normalizedA > normalizedB ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n} );\n\nexport default function PostFormat() {\n\tconst instanceId = useInstanceId( PostFormat );\n\tconst postFormatSelectorId = `post-format-selector-${ instanceId }`;\n\n\tconst { postFormat, suggestedFormat, supportedFormats } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } = select(\n\t\t\t\teditorStore\n\t\t\t);\n\t\t\tconst _postFormat = getEditedPostAttribute( 'format' );\n\t\t\tconst themeSupports = select( coreStore ).getThemeSupports();\n\t\t\treturn {\n\t\t\t\tpostFormat: _postFormat ?? 'standard',\n\t\t\t\tsuggestedFormat: getSuggestedPostFormat(),\n\t\t\t\t// Ensure current format is always in the set.\n\t\t\t\t// The current format may not be a format supported by the theme.\n\t\t\t\tsupportedFormats: union(\n\t\t\t\t\t[ _postFormat ],\n\t\t\t\t\tget( themeSupports, [ 'formats' ], [] )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst formats = POST_FORMATS.filter( ( format ) =>\n\t\tincludes( supportedFormats, format.id )\n\t);\n\tconst suggestion = find(\n\t\tformats,\n\t\t( format ) => format.id === suggestedFormat\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\treturn (\n\t\t<PostFormatCheck>\n\t\t\t<div className=\"editor-post-format\">\n\t\t\t\t<div className=\"editor-post-format__content\">\n\t\t\t\t\t<label htmlFor={ postFormatSelectorId }>\n\t\t\t\t\t\t{ __( 'Post Format' ) }\n\t\t\t\t\t</label>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tvalue={ postFormat }\n\t\t\t\t\t\tonChange={ ( format ) => onUpdatePostFormat( format ) }\n\t\t\t\t\t\tid={ postFormatSelectorId }\n\t\t\t\t\t\toptions={ formats.map( ( format ) => ( {\n\t\t\t\t\t\t\tlabel: format.caption,\n\t\t\t\t\t\t\tvalue: format.id,\n\t\t\t\t\t\t} ) ) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t{ suggestion && suggestion.id !== postFormat && (\n\t\t\t\t\t<div className=\"editor-post-format__suggestion\">\n\t\t\t\t\t\t{ __( 'Suggestion:' ) }{ ' ' }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tonUpdatePostFormat( suggestion.id )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t\t\t__( 'Apply format: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFormatCheck>\n\t);\n}\n"]}
|