@wordpress/edit-site 3.0.27 → 4.0.1-next.f435e9e01b.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 +12 -0
- package/LICENSE.md +1 -1
- package/README.md +7 -1
- package/build/components/add-new-template/new-template-part.js +1 -4
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +1 -0
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/code-editor/code-editor-text-area.js +95 -0
- package/build/components/code-editor/code-editor-text-area.js.map +1 -0
- package/build/components/code-editor/index.js +79 -0
- package/build/components/code-editor/index.js.map +1 -0
- package/build/components/editor/index.js +28 -8
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +27 -11
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +81 -22
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +4 -6
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +1 -0
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/header.js +2 -7
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +35 -12
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +3 -3
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +46 -15
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +1 -3
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +2 -3
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +0 -1
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +0 -2
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +5 -6
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +0 -2
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +0 -2
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +22 -3
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +138 -0
- package/build/components/global-styles/screen-style-variations.js.map +1 -0
- package/build/components/global-styles/screen-text-color.js +0 -2
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +0 -2
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +2 -3
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/ui.js +31 -14
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header/index.js +12 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +78 -0
- package/build/components/header/mode-switcher/index.js.map +1 -0
- package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
- package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
- package/build/components/header/more-menu/index.js +6 -2
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +17 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/actions/index.js +5 -4
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +3 -3
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/routes/redirect-to-homepage.js +3 -22
- package/build/components/routes/redirect-to-homepage.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +4 -2
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +1 -0
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +1 -4
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/index.js +2 -16
- package/build/index.js.map +1 -1
- package/build/store/actions.js +29 -9
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +11 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +13 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +1 -4
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +1 -0
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/code-editor/code-editor-text-area.js +83 -0
- package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
- package/build-module/components/code-editor/index.js +62 -0
- package/build-module/components/code-editor/index.js.map +1 -0
- package/build-module/components/editor/index.js +27 -9
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +26 -9
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +82 -23
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +1 -1
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +1 -1
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -5
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/navigation-button.js +35 -10
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +2 -2
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +45 -15
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +1 -3
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +1 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +0 -1
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +0 -2
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +2 -3
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +0 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +0 -2
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +21 -4
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +119 -0
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
- package/build-module/components/global-styles/screen-text-color.js +0 -2
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +0 -2
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +1 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/ui.js +29 -14
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header/index.js +13 -5
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +65 -0
- package/build-module/components/header/mode-switcher/index.js.map +1 -0
- package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
- package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
- package/build-module/components/header/more-menu/index.js +4 -2
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +17 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +5 -4
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +3 -3
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/routes/redirect-to-homepage.js +3 -22
- package/build-module/components/routes/redirect-to-homepage.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +4 -2
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +1 -4
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/index.js +2 -14
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +25 -9
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +11 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +11 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +148 -68
- package/build-style/style.css +148 -68
- package/package.json +28 -30
- package/src/components/add-new-template/new-template-part.js +1 -7
- package/src/components/block-editor/resizable-editor.js +1 -0
- package/src/components/block-editor/style.scss +10 -18
- package/src/components/code-editor/code-editor-text-area.js +79 -0
- package/src/components/code-editor/index.js +65 -0
- package/src/components/code-editor/style.scss +100 -0
- package/src/components/editor/index.js +41 -10
- package/src/components/error-boundary/index.js +28 -11
- package/src/components/global-styles/border-panel.js +106 -42
- package/src/components/global-styles/context-menu.js +1 -1
- package/src/components/global-styles/global-styles-provider.js +1 -2
- package/src/components/global-styles/header.js +3 -5
- package/src/components/global-styles/navigation-button.js +31 -10
- package/src/components/global-styles/palette.js +6 -2
- package/src/components/global-styles/preview.js +46 -18
- package/src/components/global-styles/screen-background-color.js +1 -3
- package/src/components/global-styles/screen-block-list.js +1 -2
- package/src/components/global-styles/screen-block.js +1 -1
- package/src/components/global-styles/screen-color-palette.js +0 -2
- package/src/components/global-styles/screen-colors.js +2 -3
- package/src/components/global-styles/screen-layout.js +1 -5
- package/src/components/global-styles/screen-link-color.js +0 -2
- package/src/components/global-styles/screen-root.js +32 -3
- package/src/components/global-styles/screen-style-variations.js +130 -0
- package/src/components/global-styles/screen-text-color.js +0 -2
- package/src/components/global-styles/screen-typography-element.js +0 -4
- package/src/components/global-styles/screen-typography.js +2 -3
- package/src/components/global-styles/style.scss +24 -25
- package/src/components/global-styles/ui.js +55 -25
- package/src/components/header/document-actions/style.scss +1 -9
- package/src/components/header/index.js +10 -2
- package/src/components/header/mode-switcher/index.js +67 -0
- package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
- package/src/components/header/more-menu/index.js +4 -0
- package/src/components/header/style.scss +2 -1
- package/src/components/keyboard-shortcuts/index.js +17 -1
- package/src/components/list/actions/index.js +5 -4
- package/src/components/list/actions/rename-menu-item.js +3 -3
- package/src/components/routes/redirect-to-homepage.js +4 -27
- package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
- package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
- package/src/components/secondary-sidebar/style.scss +0 -4
- package/src/components/sidebar/default-sidebar.js +2 -0
- package/src/components/sidebar/global-styles-sidebar.js +1 -0
- package/src/components/sidebar/style.scss +21 -14
- package/src/components/template-part-converter/convert-to-template-part.js +1 -6
- package/src/index.js +2 -18
- package/src/store/actions.js +25 -10
- package/src/store/defaults.js +1 -0
- package/src/store/reducer.js +6 -0
- package/src/store/selectors.js +11 -0
- package/src/store/test/actions.js +2 -2
- package/src/style.scss +1 -0
- package/build/components/error-boundary/warning.js +0 -70
- package/build/components/error-boundary/warning.js.map +0 -1
- package/build-module/components/error-boundary/warning.js +0 -60
- package/build-module/components/error-boundary/warning.js.map +0 -1
- package/src/components/error-boundary/warning.js +0 -59
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1-next.f435e9e01b.0",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,42 +27,40 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^3.
|
|
31
|
-
"@wordpress/api-fetch": "^
|
|
32
|
-
"@wordpress/block-editor": "^8.0
|
|
33
|
-
"@wordpress/block-library": "^
|
|
34
|
-
"@wordpress/blocks": "^11.1.
|
|
35
|
-
"@wordpress/components": "^19.
|
|
36
|
-
"@wordpress/compose": "^5.0
|
|
37
|
-
"@wordpress/core-data": "^4.0
|
|
38
|
-
"@wordpress/data": "^6.
|
|
39
|
-
"@wordpress/data-controls": "^2.
|
|
40
|
-
"@wordpress/editor": "^12.0
|
|
41
|
-
"@wordpress/element": "^4.0
|
|
42
|
-
"@wordpress/hooks": "^3.
|
|
43
|
-
"@wordpress/html-entities": "^3.
|
|
44
|
-
"@wordpress/i18n": "^4.
|
|
45
|
-
"@wordpress/icons": "^6.1.
|
|
46
|
-
"@wordpress/interface": "^4.
|
|
47
|
-
"@wordpress/keyboard-shortcuts": "^3.0
|
|
48
|
-
"@wordpress/keycodes": "^3.
|
|
49
|
-
"@wordpress/media-utils": "^3.0
|
|
50
|
-
"@wordpress/notices": "^3.
|
|
51
|
-
"@wordpress/plugins": "^4.0
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/viewport": "^4.0.7",
|
|
30
|
+
"@wordpress/a11y": "^3.3.1-next.f435e9e01b.0",
|
|
31
|
+
"@wordpress/api-fetch": "^6.0.1-next.f435e9e01b.0",
|
|
32
|
+
"@wordpress/block-editor": "^8.1.2-next.f435e9e01b.0",
|
|
33
|
+
"@wordpress/block-library": "^7.0.1-next.f435e9e01b.0",
|
|
34
|
+
"@wordpress/blocks": "^11.2.1-next.f435e9e01b.0",
|
|
35
|
+
"@wordpress/components": "^19.4.1-next.f435e9e01b.0",
|
|
36
|
+
"@wordpress/compose": "^5.1.1-next.f435e9e01b.0",
|
|
37
|
+
"@wordpress/core-data": "^4.1.1-next.f435e9e01b.0",
|
|
38
|
+
"@wordpress/data": "^6.2.2-next.f435e9e01b.0",
|
|
39
|
+
"@wordpress/data-controls": "^2.3.1-next.f435e9e01b.0",
|
|
40
|
+
"@wordpress/editor": "^12.2.1-next.f435e9e01b.0",
|
|
41
|
+
"@wordpress/element": "^4.1.1-next.f435e9e01b.0",
|
|
42
|
+
"@wordpress/hooks": "^3.3.1-next.f435e9e01b.0",
|
|
43
|
+
"@wordpress/html-entities": "^3.3.1-next.f435e9e01b.0",
|
|
44
|
+
"@wordpress/i18n": "^4.3.1-next.f435e9e01b.0",
|
|
45
|
+
"@wordpress/icons": "^6.3.1-next.f435e9e01b.0",
|
|
46
|
+
"@wordpress/interface": "^4.2.2-next.f435e9e01b.0",
|
|
47
|
+
"@wordpress/keyboard-shortcuts": "^3.1.2-next.f435e9e01b.0",
|
|
48
|
+
"@wordpress/keycodes": "^3.3.1-next.f435e9e01b.0",
|
|
49
|
+
"@wordpress/media-utils": "^3.1.1-next.f435e9e01b.0",
|
|
50
|
+
"@wordpress/notices": "^3.3.1-next.f435e9e01b.0",
|
|
51
|
+
"@wordpress/plugins": "^4.1.1-next.f435e9e01b.0",
|
|
52
|
+
"@wordpress/reusable-blocks": "^3.1.2-next.f435e9e01b.0",
|
|
53
|
+
"@wordpress/url": "^3.4.1-next.f435e9e01b.0",
|
|
54
|
+
"@wordpress/viewport": "^4.1.1-next.f435e9e01b.0",
|
|
56
55
|
"classnames": "^2.3.1",
|
|
57
56
|
"downloadjs": "^1.4.7",
|
|
58
|
-
"file-saver": "^2.0.2",
|
|
59
57
|
"history": "^5.1.0",
|
|
60
|
-
"jszip": "^3.2.2",
|
|
61
58
|
"lodash": "^4.17.21",
|
|
59
|
+
"react-autosize-textarea": "^7.1.0",
|
|
62
60
|
"rememo": "^3.0.0"
|
|
63
61
|
},
|
|
64
62
|
"publishConfig": {
|
|
65
63
|
"access": "public"
|
|
66
64
|
},
|
|
67
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
|
|
68
66
|
}
|
|
@@ -35,17 +35,11 @@ export default function NewTemplatePart( { postType } ) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
|
-
// Currently template parts only allow latin chars.
|
|
39
|
-
// Fallback slug will receive suffix by default.
|
|
40
|
-
const cleanSlug =
|
|
41
|
-
kebabCase( title ).replace( /[^\w-]+/g, '' ) ||
|
|
42
|
-
'wp-custom-part';
|
|
43
|
-
|
|
44
38
|
const templatePart = await saveEntityRecord(
|
|
45
39
|
'postType',
|
|
46
40
|
'wp_template_part',
|
|
47
41
|
{
|
|
48
|
-
slug:
|
|
42
|
+
slug: kebabCase( title ),
|
|
49
43
|
title,
|
|
50
44
|
content: '',
|
|
51
45
|
area,
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
align-items: center;
|
|
20
20
|
|
|
21
21
|
&.is-focus-mode {
|
|
22
|
-
padding:
|
|
22
|
+
padding: $grid-unit-60;
|
|
23
23
|
|
|
24
24
|
.edit-site-visual-editor__editor-canvas {
|
|
25
|
-
border-radius:
|
|
25
|
+
border-radius: $radius-block-ui;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// To hide the horizontal scrollbar and show the drag handle on the
|
|
@@ -39,10 +39,6 @@
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
.edit-site-visual-editor__editor-canvas {
|
|
43
|
-
border-radius: 2px 2px 0 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
42
|
.edit-site-visual-editor__back-button {
|
|
47
43
|
position: absolute;
|
|
48
44
|
top: $grid-unit-10;
|
|
@@ -63,30 +59,26 @@
|
|
|
63
59
|
bottom: 0;
|
|
64
60
|
padding: 0;
|
|
65
61
|
margin: auto 0;
|
|
66
|
-
width: $grid-unit-
|
|
62
|
+
width: $grid-unit-05;
|
|
67
63
|
height: $height;
|
|
68
64
|
appearance: none;
|
|
69
|
-
cursor:
|
|
65
|
+
cursor: ew-resize;
|
|
70
66
|
outline: none;
|
|
71
|
-
background: $gray-
|
|
72
|
-
border-radius:
|
|
67
|
+
background: $gray-600;
|
|
68
|
+
border-radius: 2px;
|
|
73
69
|
border: 0;
|
|
74
70
|
|
|
75
71
|
&.is-left {
|
|
76
|
-
left:
|
|
72
|
+
left: -$grid-unit-20;
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
&.is-right {
|
|
80
|
-
right:
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
&:hover {
|
|
84
|
-
background: $gray-600;
|
|
76
|
+
right: -$grid-unit-20;
|
|
85
77
|
}
|
|
86
78
|
|
|
79
|
+
&:hover,
|
|
87
80
|
&:active {
|
|
88
|
-
|
|
89
|
-
background: $gray-600;
|
|
81
|
+
background: $gray-400;
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
&:focus {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import Textarea from 'react-autosize-textarea';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { __ } from '@wordpress/i18n';
|
|
16
|
+
import { useState } from '@wordpress/element';
|
|
17
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
18
|
+
import { VisuallyHidden } from '@wordpress/components';
|
|
19
|
+
|
|
20
|
+
export default function CodeEditorTextArea( { value, onChange, onInput } ) {
|
|
21
|
+
const [ stateValue, setStateValue ] = useState( value );
|
|
22
|
+
const [ isDirty, setIsDirty ] = useState( false );
|
|
23
|
+
const instanceId = useInstanceId( CodeEditorTextArea );
|
|
24
|
+
|
|
25
|
+
if ( ! isDirty && stateValue !== value ) {
|
|
26
|
+
setStateValue( value );
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Handles a textarea change event to notify the onChange prop callback and
|
|
31
|
+
* reflect the new value in the component's own state. This marks the start
|
|
32
|
+
* of the user's edits, if not already changed, preventing future props
|
|
33
|
+
* changes to value from replacing the rendered value. This is expected to
|
|
34
|
+
* be followed by a reset to dirty state via `stopEditing`.
|
|
35
|
+
*
|
|
36
|
+
* @see stopEditing
|
|
37
|
+
*
|
|
38
|
+
* @param {Event} event Change event.
|
|
39
|
+
*/
|
|
40
|
+
const onChangeHandler = ( event ) => {
|
|
41
|
+
const newValue = event.target.value;
|
|
42
|
+
onInput( newValue );
|
|
43
|
+
setStateValue( newValue );
|
|
44
|
+
setIsDirty( true );
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Function called when the user has completed their edits, responsible for
|
|
49
|
+
* ensuring that changes, if made, are surfaced to the onPersist prop
|
|
50
|
+
* callback and resetting dirty state.
|
|
51
|
+
*/
|
|
52
|
+
const stopEditing = () => {
|
|
53
|
+
if ( isDirty ) {
|
|
54
|
+
onChange( stateValue );
|
|
55
|
+
setIsDirty( false );
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<VisuallyHidden
|
|
62
|
+
as="label"
|
|
63
|
+
htmlFor={ `code-editor-text-area-${ instanceId }` }
|
|
64
|
+
>
|
|
65
|
+
{ __( 'Type text or HTML' ) }
|
|
66
|
+
</VisuallyHidden>
|
|
67
|
+
<Textarea
|
|
68
|
+
autoComplete="off"
|
|
69
|
+
dir="auto"
|
|
70
|
+
value={ stateValue }
|
|
71
|
+
onChange={ onChangeHandler }
|
|
72
|
+
onBlur={ stopEditing }
|
|
73
|
+
className="edit-site-code-editor-text-area"
|
|
74
|
+
id={ `code-editor-text-area-${ instanceId }` }
|
|
75
|
+
placeholder={ __( 'Start writing with text or HTML' ) }
|
|
76
|
+
/>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { parse } from '@wordpress/blocks';
|
|
5
|
+
import { useEntityBlockEditor, useEntityProp } from '@wordpress/core-data';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { Button } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
15
|
+
import CodeEditorTextArea from './code-editor-text-area';
|
|
16
|
+
|
|
17
|
+
export default function CodeEditor() {
|
|
18
|
+
const { templateType, shortcut } = useSelect( ( select ) => {
|
|
19
|
+
const { getEditedPostType } = select( editSiteStore );
|
|
20
|
+
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
|
|
21
|
+
return {
|
|
22
|
+
templateType: getEditedPostType(),
|
|
23
|
+
shortcut: getShortcutRepresentation( 'core/edit-site/toggle-mode' ),
|
|
24
|
+
};
|
|
25
|
+
}, [] );
|
|
26
|
+
const [ contentStructure, setContent ] = useEntityProp(
|
|
27
|
+
'postType',
|
|
28
|
+
templateType,
|
|
29
|
+
'content'
|
|
30
|
+
);
|
|
31
|
+
const [ blocks, , onChange ] = useEntityBlockEditor(
|
|
32
|
+
'postType',
|
|
33
|
+
templateType
|
|
34
|
+
);
|
|
35
|
+
const content =
|
|
36
|
+
contentStructure instanceof Function
|
|
37
|
+
? contentStructure( { blocks } )
|
|
38
|
+
: contentStructure;
|
|
39
|
+
const { switchEditorMode } = useDispatch( editSiteStore );
|
|
40
|
+
return (
|
|
41
|
+
<div className="edit-site-code-editor">
|
|
42
|
+
<div className="edit-site-code-editor__toolbar">
|
|
43
|
+
<h2>{ __( 'Editing code' ) }</h2>
|
|
44
|
+
<Button
|
|
45
|
+
variant="tertiary"
|
|
46
|
+
onClick={ () => switchEditorMode( 'visual' ) }
|
|
47
|
+
shortcut={ shortcut }
|
|
48
|
+
>
|
|
49
|
+
{ __( 'Exit code editor' ) }
|
|
50
|
+
</Button>
|
|
51
|
+
</div>
|
|
52
|
+
<div className="edit-site-code-editor__body">
|
|
53
|
+
<CodeEditorTextArea
|
|
54
|
+
value={ content }
|
|
55
|
+
onChange={ ( newContent ) => {
|
|
56
|
+
onChange( parse( newContent ), {
|
|
57
|
+
selection: undefined,
|
|
58
|
+
} );
|
|
59
|
+
} }
|
|
60
|
+
onInput={ setContent }
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
.edit-site-code-editor {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
background-color: $white;
|
|
5
|
+
flex-grow: 1;
|
|
6
|
+
|
|
7
|
+
&__body {
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 0 $grid-unit-15 $grid-unit-15 $grid-unit-15;
|
|
10
|
+
max-width: $break-xlarge;
|
|
11
|
+
margin-left: auto;
|
|
12
|
+
margin-right: auto;
|
|
13
|
+
|
|
14
|
+
@include break-large() {
|
|
15
|
+
padding: $grid-unit-20 $grid-unit-30 #{ $grid-unit-60 * 2 } $grid-unit-30;
|
|
16
|
+
padding: 0 $grid-unit-30 $grid-unit-30 $grid-unit-30;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Exit code editor toolbar.
|
|
21
|
+
&__toolbar {
|
|
22
|
+
position: sticky;
|
|
23
|
+
z-index: z-index(".edit-site-code-editor__toolbar");
|
|
24
|
+
top: 0;
|
|
25
|
+
left: 0;
|
|
26
|
+
right: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
background: rgba($white, 0.8);
|
|
29
|
+
padding: $grid-unit-05 $grid-unit-15;
|
|
30
|
+
|
|
31
|
+
@include break-small() {
|
|
32
|
+
padding: $grid-unit-15;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@include break-large() {
|
|
36
|
+
padding: $grid-unit-15 $grid-unit-30;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
h2 {
|
|
40
|
+
line-height: $button-size;
|
|
41
|
+
margin: 0 auto 0 0;
|
|
42
|
+
font-size: $default-font-size;
|
|
43
|
+
color: $gray-900;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.components-button svg {
|
|
47
|
+
order: 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
textarea.edit-site-code-editor-text-area.edit-site-code-editor-text-area {
|
|
53
|
+
border: $border-width solid $gray-600;
|
|
54
|
+
border-radius: 0;
|
|
55
|
+
display: block;
|
|
56
|
+
margin: 0;
|
|
57
|
+
width: 100%;
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
resize: none;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
font-family: $editor-html-font;
|
|
62
|
+
line-height: 2.4;
|
|
63
|
+
min-height: 200px;
|
|
64
|
+
transition: border 0.1s ease-out, box-shadow 0.1s linear;
|
|
65
|
+
@include reduce-motion("transition");
|
|
66
|
+
|
|
67
|
+
// Same padding as title.
|
|
68
|
+
padding: $grid-unit-20;
|
|
69
|
+
@include break-small() {
|
|
70
|
+
padding: $grid-unit-30;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Fonts smaller than 16px causes mobile safari to zoom. */
|
|
74
|
+
font-size: $mobile-text-min-font-size !important;
|
|
75
|
+
@include break-small {
|
|
76
|
+
font-size: $text-editor-font-size !important;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&:focus {
|
|
80
|
+
border-color: var(--wp-admin-theme-color);
|
|
81
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
82
|
+
|
|
83
|
+
// Elevate the z-index on focus so the focus style is uncropped.
|
|
84
|
+
position: relative;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&::-webkit-input-placeholder {
|
|
88
|
+
color: $dark-gray-placeholder;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&::-moz-placeholder {
|
|
92
|
+
color: $dark-gray-placeholder;
|
|
93
|
+
// Override Firefox default.
|
|
94
|
+
opacity: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&:-ms-input-placeholder {
|
|
98
|
+
color: $dark-gray-placeholder;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -16,12 +16,13 @@ import {
|
|
|
16
16
|
EditorSnackbars,
|
|
17
17
|
EntitiesSavedStates,
|
|
18
18
|
} from '@wordpress/editor';
|
|
19
|
-
import { __ } from '@wordpress/i18n';
|
|
19
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
20
20
|
import { PluginArea } from '@wordpress/plugins';
|
|
21
21
|
import {
|
|
22
22
|
ShortcutProvider,
|
|
23
23
|
store as keyboardShortcutsStore,
|
|
24
24
|
} from '@wordpress/keyboard-shortcuts';
|
|
25
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Internal dependencies
|
|
@@ -30,6 +31,7 @@ import Header from '../header';
|
|
|
30
31
|
import { SidebarComplementaryAreaFills } from '../sidebar';
|
|
31
32
|
import NavigationSidebar from '../navigation-sidebar';
|
|
32
33
|
import BlockEditor from '../block-editor';
|
|
34
|
+
import CodeEditor from '../code-editor';
|
|
33
35
|
import KeyboardShortcuts from '../keyboard-shortcuts';
|
|
34
36
|
import URLQueryController from '../url-query-controller';
|
|
35
37
|
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
|
|
@@ -60,6 +62,7 @@ function Editor( { onError } ) {
|
|
|
60
62
|
isNavigationOpen,
|
|
61
63
|
previousShortcut,
|
|
62
64
|
nextShortcut,
|
|
65
|
+
editorMode,
|
|
63
66
|
} = useSelect( ( select ) => {
|
|
64
67
|
const {
|
|
65
68
|
isInserterOpened,
|
|
@@ -69,6 +72,7 @@ function Editor( { onError } ) {
|
|
|
69
72
|
getEditedPostId,
|
|
70
73
|
getPage,
|
|
71
74
|
isNavigationOpened,
|
|
75
|
+
getEditorMode,
|
|
72
76
|
} = select( editSiteStore );
|
|
73
77
|
const { hasFinishedResolution, getEntityRecord } = select( coreStore );
|
|
74
78
|
const postType = getEditedPostType();
|
|
@@ -102,10 +106,12 @@ function Editor( { onError } ) {
|
|
|
102
106
|
nextShortcut: select(
|
|
103
107
|
keyboardShortcutsStore
|
|
104
108
|
).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
|
|
109
|
+
editorMode: getEditorMode(),
|
|
105
110
|
};
|
|
106
111
|
}, [] );
|
|
107
112
|
const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
|
|
108
113
|
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
114
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
109
115
|
|
|
110
116
|
const [
|
|
111
117
|
isEntitiesSavedStatesOpen,
|
|
@@ -177,6 +183,18 @@ function Editor( { onError } ) {
|
|
|
177
183
|
return null;
|
|
178
184
|
};
|
|
179
185
|
|
|
186
|
+
function onPluginAreaError( name ) {
|
|
187
|
+
createErrorNotice(
|
|
188
|
+
sprintf(
|
|
189
|
+
/* translators: %s: plugin name */
|
|
190
|
+
__(
|
|
191
|
+
'The "%s" plugin has encountered an error and cannot be rendered.'
|
|
192
|
+
),
|
|
193
|
+
name
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
180
198
|
// Only announce the title once the editor is ready to prevent "Replace"
|
|
181
199
|
// action in <URlQueryController> from double-announcing.
|
|
182
200
|
useTitle( isReady && __( 'Editor (beta)' ) );
|
|
@@ -220,13 +238,18 @@ function Editor( { onError } ) {
|
|
|
220
238
|
content={
|
|
221
239
|
<>
|
|
222
240
|
<EditorNotices />
|
|
223
|
-
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
241
|
+
{ editorMode === 'visual' &&
|
|
242
|
+
template && (
|
|
243
|
+
<BlockEditor
|
|
244
|
+
setIsInserterOpen={
|
|
245
|
+
setIsInserterOpened
|
|
246
|
+
}
|
|
247
|
+
/>
|
|
248
|
+
) }
|
|
249
|
+
{ editorMode === 'text' &&
|
|
250
|
+
template && (
|
|
251
|
+
<CodeEditor />
|
|
252
|
+
) }
|
|
230
253
|
{ templateResolved &&
|
|
231
254
|
! template &&
|
|
232
255
|
settings?.siteUrl &&
|
|
@@ -277,7 +300,13 @@ function Editor( { onError } ) {
|
|
|
277
300
|
) }
|
|
278
301
|
</>
|
|
279
302
|
}
|
|
280
|
-
footer={
|
|
303
|
+
footer={
|
|
304
|
+
<BlockBreadcrumb
|
|
305
|
+
rootLabelText={ __(
|
|
306
|
+
'Template'
|
|
307
|
+
) }
|
|
308
|
+
/>
|
|
309
|
+
}
|
|
281
310
|
shortcuts={ {
|
|
282
311
|
previous: previousShortcut,
|
|
283
312
|
next: nextShortcut,
|
|
@@ -285,7 +314,9 @@ function Editor( { onError } ) {
|
|
|
285
314
|
/>
|
|
286
315
|
<WelcomeGuide />
|
|
287
316
|
<Popover.Slot />
|
|
288
|
-
<PluginArea
|
|
317
|
+
<PluginArea
|
|
318
|
+
onError={ onPluginAreaError }
|
|
319
|
+
/>
|
|
289
320
|
</ErrorBoundary>
|
|
290
321
|
</BlockContextProvider>
|
|
291
322
|
</GlobalStylesProvider>
|
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Component } from '@wordpress/element';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { Button } from '@wordpress/components';
|
|
7
|
+
import { Warning } from '@wordpress/block-editor';
|
|
8
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
function CopyButton( { text, children } ) {
|
|
11
|
+
const ref = useCopyToClipboard( text );
|
|
12
|
+
return (
|
|
13
|
+
<Button variant="secondary" ref={ ref }>
|
|
14
|
+
{ children }
|
|
15
|
+
</Button>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
export default class ErrorBoundary extends Component {
|
|
13
20
|
constructor() {
|
|
@@ -35,13 +42,23 @@ export default class ErrorBoundary extends Component {
|
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
<Warning
|
|
46
|
+
className="editor-error-boundary"
|
|
47
|
+
actions={ [
|
|
48
|
+
<Button
|
|
49
|
+
key="recovery"
|
|
50
|
+
onClick={ this.reboot }
|
|
51
|
+
variant="secondary"
|
|
52
|
+
>
|
|
53
|
+
{ __( 'Attempt Recovery' ) }
|
|
54
|
+
</Button>,
|
|
55
|
+
<CopyButton key="copy-error" text={ error.stack }>
|
|
56
|
+
{ __( 'Copy Error' ) }
|
|
57
|
+
</CopyButton>,
|
|
58
|
+
] }
|
|
59
|
+
>
|
|
60
|
+
{ __( 'The editor has encountered an unexpected error.' ) }
|
|
61
|
+
</Warning>
|
|
45
62
|
);
|
|
46
63
|
}
|
|
47
64
|
}
|