soinproduction-gutenberg 0.3.50 → 0.3.52
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/admin-ui/editor.css +5 -0
- package/core/editor/styles.css +4 -7
- package/core/media/universal/editor.css +3 -6
- package/dist/admin-ui/editor.css +5 -0
- package/dist/core/editor/styles.css +4 -7
- package/dist/core/media/universal/editor.css +3 -6
- package/dist/host/editor/page-canvas.js +22 -8
- package/dist/host/editor/page-canvas.js.map +2 -2
- package/host/editor/page-canvas.tsx +23 -8
- package/package.json +1 -1
package/admin-ui/editor.css
CHANGED
|
@@ -848,6 +848,7 @@
|
|
|
848
848
|
}
|
|
849
849
|
:where(.site-control-scope, .site-field-controls, .sp-media-control)
|
|
850
850
|
.components-base-control__help,
|
|
851
|
+
:where(.site-control-scope) .components-panel__body > p,
|
|
851
852
|
.sp-media-help {
|
|
852
853
|
font: 400 var(--sp-ui-font-size-small)/1.5 var(--sp-ui-font);
|
|
853
854
|
color: var(--sp-ui-muted);
|
|
@@ -872,3 +873,7 @@
|
|
|
872
873
|
text-transform: none;
|
|
873
874
|
letter-spacing: normal;
|
|
874
875
|
}
|
|
876
|
+
|
|
877
|
+
.site-control-scope > .components-panel__body > .components-base-control:not(:last-child) {
|
|
878
|
+
margin-bottom: calc(var(--sp-ui-space) * 2);
|
|
879
|
+
}
|
package/core/editor/styles.css
CHANGED
|
@@ -119,12 +119,9 @@
|
|
|
119
119
|
margin-left: 0 !important;
|
|
120
120
|
margin-right: 0 !important;
|
|
121
121
|
}
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.editor-styles-wrapper .editor-post-title {
|
|
126
|
-
max-width: none !important;
|
|
127
|
-
margin-inline: 24px !important;
|
|
122
|
+
/* Page metadata is edited in the document aside, outside the site canvas. */
|
|
123
|
+
.site-page-title-in-aside .editor-visual-editor__post-title-wrapper {
|
|
124
|
+
display: none;
|
|
128
125
|
}
|
|
129
126
|
.site-inline-number {
|
|
130
127
|
font: inherit !important;
|
|
@@ -938,7 +935,7 @@
|
|
|
938
935
|
.site-description-add.is-top{top:auto;bottom:100%;padding:0 0 8px}
|
|
939
936
|
.site-editor-button{position:relative;display:inline-flex}
|
|
940
937
|
/* Button widths: proportional presets and a direct, keyboard-accessible slider. */
|
|
941
|
-
.site-button-width-control{min-width:0;margin:16px 0;padding:0;border:0;font:400
|
|
938
|
+
.site-button-width-control{min-width:0;margin:16px 0;padding:0;border:0;font:400 var(--sp-ui-font-size)/var(--sp-ui-line-height) var(--sp-ui-font,system-ui,sans-serif);color:#1e1e1e}
|
|
942
939
|
.site-button-width-control legend{float:none;margin-bottom:8px;padding:0;font-size:var(--sp-ui-label-size);font-weight:500;text-transform:uppercase}
|
|
943
940
|
.site-button-width-presets{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}
|
|
944
941
|
.site-button-width-presets>button{display:flex;min-width:0;min-height:52px;flex-direction:column;align-items:center;justify-content:center;gap:5px;padding:6px 4px;border:1px solid #ddd;border-radius:2px;background:#fff;color:#50575e;font:inherit;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s}
|
|
@@ -99,11 +99,6 @@
|
|
|
99
99
|
.sp-media-control .components-base-control__field {
|
|
100
100
|
margin: 0 !important;
|
|
101
101
|
}
|
|
102
|
-
.sp-media-control .components-base-control__label {
|
|
103
|
-
font-size: var(--sp-ui-label-size) !important;
|
|
104
|
-
font-weight: 600 !important;
|
|
105
|
-
color: var(--sp-ui-muted, #50575e);
|
|
106
|
-
}
|
|
107
102
|
.sp-media-control .site-video-inheritance {
|
|
108
103
|
margin-top: 0;
|
|
109
104
|
}
|
|
@@ -119,7 +114,9 @@
|
|
|
119
114
|
.sp-media-advanced summary {
|
|
120
115
|
cursor: pointer;
|
|
121
116
|
font-weight: 500;
|
|
122
|
-
font-size: var(--sp-ui-
|
|
117
|
+
font-size: var(--sp-ui-label-size);
|
|
118
|
+
line-height: var(--sp-ui-line-height);
|
|
119
|
+
text-transform: uppercase;
|
|
123
120
|
}
|
|
124
121
|
.sp-media-advanced .components-base-control {
|
|
125
122
|
margin-top: 12px !important;
|
package/dist/admin-ui/editor.css
CHANGED
|
@@ -848,6 +848,7 @@
|
|
|
848
848
|
}
|
|
849
849
|
:where(.site-control-scope, .site-field-controls, .sp-media-control)
|
|
850
850
|
.components-base-control__help,
|
|
851
|
+
:where(.site-control-scope) .components-panel__body > p,
|
|
851
852
|
.sp-media-help {
|
|
852
853
|
font: 400 var(--sp-ui-font-size-small)/1.5 var(--sp-ui-font);
|
|
853
854
|
color: var(--sp-ui-muted);
|
|
@@ -872,3 +873,7 @@
|
|
|
872
873
|
text-transform: none;
|
|
873
874
|
letter-spacing: normal;
|
|
874
875
|
}
|
|
876
|
+
|
|
877
|
+
.site-control-scope > .components-panel__body > .components-base-control:not(:last-child) {
|
|
878
|
+
margin-bottom: calc(var(--sp-ui-space) * 2);
|
|
879
|
+
}
|
|
@@ -119,12 +119,9 @@
|
|
|
119
119
|
margin-left: 0 !important;
|
|
120
120
|
margin-right: 0 !important;
|
|
121
121
|
}
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.editor-styles-wrapper .editor-post-title {
|
|
126
|
-
max-width: none !important;
|
|
127
|
-
margin-inline: 24px !important;
|
|
122
|
+
/* Page metadata is edited in the document aside, outside the site canvas. */
|
|
123
|
+
.site-page-title-in-aside .editor-visual-editor__post-title-wrapper {
|
|
124
|
+
display: none;
|
|
128
125
|
}
|
|
129
126
|
.site-inline-number {
|
|
130
127
|
font: inherit !important;
|
|
@@ -938,7 +935,7 @@
|
|
|
938
935
|
.site-description-add.is-top{top:auto;bottom:100%;padding:0 0 8px}
|
|
939
936
|
.site-editor-button{position:relative;display:inline-flex}
|
|
940
937
|
/* Button widths: proportional presets and a direct, keyboard-accessible slider. */
|
|
941
|
-
.site-button-width-control{min-width:0;margin:16px 0;padding:0;border:0;font:400
|
|
938
|
+
.site-button-width-control{min-width:0;margin:16px 0;padding:0;border:0;font:400 var(--sp-ui-font-size)/var(--sp-ui-line-height) var(--sp-ui-font,system-ui,sans-serif);color:#1e1e1e}
|
|
942
939
|
.site-button-width-control legend{float:none;margin-bottom:8px;padding:0;font-size:var(--sp-ui-label-size);font-weight:500;text-transform:uppercase}
|
|
943
940
|
.site-button-width-presets{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}
|
|
944
941
|
.site-button-width-presets>button{display:flex;min-width:0;min-height:52px;flex-direction:column;align-items:center;justify-content:center;gap:5px;padding:6px 4px;border:1px solid #ddd;border-radius:2px;background:#fff;color:#50575e;font:inherit;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s}
|
|
@@ -99,11 +99,6 @@
|
|
|
99
99
|
.sp-media-control .components-base-control__field {
|
|
100
100
|
margin: 0 !important;
|
|
101
101
|
}
|
|
102
|
-
.sp-media-control .components-base-control__label {
|
|
103
|
-
font-size: var(--sp-ui-label-size) !important;
|
|
104
|
-
font-weight: 600 !important;
|
|
105
|
-
color: var(--sp-ui-muted, #50575e);
|
|
106
|
-
}
|
|
107
102
|
.sp-media-control .site-video-inheritance {
|
|
108
103
|
margin-top: 0;
|
|
109
104
|
}
|
|
@@ -119,7 +114,9 @@
|
|
|
119
114
|
.sp-media-advanced summary {
|
|
120
115
|
cursor: pointer;
|
|
121
116
|
font-weight: 500;
|
|
122
|
-
font-size: var(--sp-ui-
|
|
117
|
+
font-size: var(--sp-ui-label-size);
|
|
118
|
+
line-height: var(--sp-ui-line-height);
|
|
119
|
+
text-transform: uppercase;
|
|
123
120
|
}
|
|
124
121
|
.sp-media-advanced .components-base-control {
|
|
125
122
|
margin-top: 12px !important;
|
|
@@ -7,10 +7,15 @@ function registerPageCanvas(useSiteData) {
|
|
|
7
7
|
wp.plugins.registerPlugin("site-page-canvas", {
|
|
8
8
|
render: () => {
|
|
9
9
|
const site = useSiteData();
|
|
10
|
-
const isPage = wp.data.useSelect(
|
|
11
|
-
(select) =>
|
|
10
|
+
const { isPage, title } = wp.data.useSelect(
|
|
11
|
+
(select) => ({
|
|
12
|
+
isPage: select("core/editor").getCurrentPostType() === "page",
|
|
13
|
+
title: select("core/editor").getEditedPostAttribute("title") ?? ""
|
|
14
|
+
}),
|
|
12
15
|
[]
|
|
13
16
|
);
|
|
17
|
+
const TitlePanel = wp.editor?.PluginDocumentSettingPanel;
|
|
18
|
+
const titleInAside = isPage && Boolean(TitlePanel);
|
|
14
19
|
const [targets, setTargets] = useState(
|
|
15
20
|
null
|
|
16
21
|
);
|
|
@@ -35,6 +40,7 @@ function registerPageCanvas(useSiteData) {
|
|
|
35
40
|
const root = doc.querySelector(".block-editor-block-list__layout.is-root-container");
|
|
36
41
|
if (!root || !root.parentElement) continue;
|
|
37
42
|
doc.body.classList.add("site-page-canvas");
|
|
43
|
+
doc.body.classList.toggle("site-page-title-in-aside", titleInAside);
|
|
38
44
|
if (mounts?.header.isConnected && mounts.header.nextElementSibling === root) return;
|
|
39
45
|
mounts?.header.remove();
|
|
40
46
|
mounts?.footer.remove();
|
|
@@ -57,15 +63,15 @@ function registerPageCanvas(useSiteData) {
|
|
|
57
63
|
document.removeEventListener("load", sync, true);
|
|
58
64
|
observers.forEach((observer, doc) => {
|
|
59
65
|
observer.disconnect();
|
|
60
|
-
doc.body.classList.remove("site-page-canvas");
|
|
66
|
+
doc.body.classList.remove("site-page-canvas", "site-page-title-in-aside");
|
|
61
67
|
});
|
|
62
68
|
mounts?.header.remove();
|
|
63
69
|
mounts?.footer.remove();
|
|
64
70
|
setTargets(null);
|
|
65
71
|
};
|
|
66
|
-
}, [isPage]);
|
|
67
|
-
if (!isPage
|
|
68
|
-
const resolved = mediaValues(site, window.SITE_EDITOR_CONFIG.media);
|
|
72
|
+
}, [isPage, titleInAside]);
|
|
73
|
+
if (!isPage) return null;
|
|
74
|
+
const resolved = site && mediaValues(site, window.SITE_EDITOR_CONFIG.media);
|
|
69
75
|
const preview = (part) => /* @__PURE__ */ jsx(
|
|
70
76
|
"div",
|
|
71
77
|
{
|
|
@@ -81,8 +87,16 @@ function registerPageCanvas(useSiteData) {
|
|
|
81
87
|
}
|
|
82
88
|
);
|
|
83
89
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
titleInAside && /* @__PURE__ */ jsx(TitlePanel, { name: "site-page-title", title: "Page title", className: "site-control-scope", children: /* @__PURE__ */ jsx(
|
|
91
|
+
wp.components.TextControl,
|
|
92
|
+
{
|
|
93
|
+
label: "Title",
|
|
94
|
+
value: title,
|
|
95
|
+
onChange: (value) => wp.data.dispatch("core/editor").editPost({ title: value })
|
|
96
|
+
}
|
|
97
|
+
) }),
|
|
98
|
+
site && targets && createPortal(preview("header"), targets.header),
|
|
99
|
+
site && targets && createPortal(preview("footer"), targets.footer)
|
|
86
100
|
] });
|
|
87
101
|
}
|
|
88
102
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../host/editor/page-canvas.tsx"],
|
|
4
|
-
"sourcesContent": ["import {useEffect, useState} from 'react';\nimport {createPortal} from 'react-dom';\nimport {BlockList} from '../rendering/block-list.js';\nimport {mediaValues} from '../media/resolve.js';\n\ndeclare const wp: any;\n\n/** Preview shared site parts without storing them in the page's block content. */\nexport function registerPageCanvas(useSiteData: () => any) {\n wp.plugins.registerPlugin('site-page-canvas', {\n render: () => {\n const site = useSiteData();\n const isPage = wp.data.useSelect(\n (select: any) => select('core/editor').getCurrentPostType() === 'page',\n []\n );\n const [targets, setTargets] = useState<{ header: HTMLElement; footer: HTMLElement } | null>(\n null\n );\n useEffect(() => {\n if (!isPage) return;\n const observers = new Map<Document, MutationObserver>();\n let mounts: { header: HTMLElement; footer: HTMLElement } | null = null;\n const sync = () => {\n const docs = [document];\n for (const iframe of document.querySelectorAll('iframe')) {\n try {\n if (iframe.contentDocument) docs.push(iframe.contentDocument);\n } catch {\n /* Cross-origin frames are unrelated. */\n }\n }\n for (const doc of docs) {\n if (!observers.has(doc)) {\n const observer = new MutationObserver(sync);\n observer.observe(doc, {childList: true, subtree: true});\n observers.set(doc, observer);\n }\n const root = doc.querySelector('.block-editor-block-list__layout.is-root-container');\n if (!root || !root.parentElement) continue;\n doc.body.classList.add('site-page-canvas');\n if (mounts?.header.isConnected && mounts.header.nextElementSibling === root) return;\n mounts?.header.remove();\n mounts?.footer.remove();\n const header = doc.createElement('div'),\n footer = doc.createElement('div');\n header.className = 'site-preview site-canvas-part site-canvas-header';\n footer.className = 'site-preview site-canvas-part site-canvas-footer';\n header.contentEditable = footer.contentEditable = 'false';\n header.setAttribute('aria-label', 'Site header preview');\n footer.setAttribute('aria-label', 'Site footer preview');\n root.before(header);\n root.after(footer);\n mounts = {header, footer};\n setTargets(mounts);\n return;\n }\n };\n sync();\n document.addEventListener('load', sync, true);\n return () => {\n document.removeEventListener('load', sync, true);\n observers.forEach((observer, doc) => {\n observer.disconnect();\n doc.body.classList.remove('site-page-canvas');\n });\n mounts?.header.remove();\n mounts?.footer.remove();\n setTargets(null);\n };\n }, [isPage]);\n if (!isPage
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {useEffect, useState} from 'react';\nimport {createPortal} from 'react-dom';\nimport {BlockList} from '../rendering/block-list.js';\nimport {mediaValues} from '../media/resolve.js';\n\ndeclare const wp: any;\n\n/** Preview shared site parts without storing them in the page's block content. */\nexport function registerPageCanvas(useSiteData: () => any) {\n wp.plugins.registerPlugin('site-page-canvas', {\n render: () => {\n const site = useSiteData();\n const {isPage, title} = wp.data.useSelect(\n (select: any) => ({\n isPage: select('core/editor').getCurrentPostType() === 'page',\n title: select('core/editor').getEditedPostAttribute('title') ?? '',\n }),\n []\n );\n const TitlePanel = wp.editor?.PluginDocumentSettingPanel;\n const titleInAside = isPage && Boolean(TitlePanel);\n const [targets, setTargets] = useState<{ header: HTMLElement; footer: HTMLElement } | null>(\n null\n );\n useEffect(() => {\n if (!isPage) return;\n const observers = new Map<Document, MutationObserver>();\n let mounts: { header: HTMLElement; footer: HTMLElement } | null = null;\n const sync = () => {\n const docs = [document];\n for (const iframe of document.querySelectorAll('iframe')) {\n try {\n if (iframe.contentDocument) docs.push(iframe.contentDocument);\n } catch {\n /* Cross-origin frames are unrelated. */\n }\n }\n for (const doc of docs) {\n if (!observers.has(doc)) {\n const observer = new MutationObserver(sync);\n observer.observe(doc, {childList: true, subtree: true});\n observers.set(doc, observer);\n }\n const root = doc.querySelector('.block-editor-block-list__layout.is-root-container');\n if (!root || !root.parentElement) continue;\n doc.body.classList.add('site-page-canvas');\n doc.body.classList.toggle('site-page-title-in-aside', titleInAside);\n if (mounts?.header.isConnected && mounts.header.nextElementSibling === root) return;\n mounts?.header.remove();\n mounts?.footer.remove();\n const header = doc.createElement('div'),\n footer = doc.createElement('div');\n header.className = 'site-preview site-canvas-part site-canvas-header';\n footer.className = 'site-preview site-canvas-part site-canvas-footer';\n header.contentEditable = footer.contentEditable = 'false';\n header.setAttribute('aria-label', 'Site header preview');\n footer.setAttribute('aria-label', 'Site footer preview');\n root.before(header);\n root.after(footer);\n mounts = {header, footer};\n setTargets(mounts);\n return;\n }\n };\n sync();\n document.addEventListener('load', sync, true);\n return () => {\n document.removeEventListener('load', sync, true);\n observers.forEach((observer, doc) => {\n observer.disconnect();\n doc.body.classList.remove('site-page-canvas', 'site-page-title-in-aside');\n });\n mounts?.header.remove();\n mounts?.footer.remove();\n setTargets(null);\n };\n }, [isPage, titleInAside]);\n if (!isPage) return null;\n const resolved = site && mediaValues(site, window.SITE_EDITOR_CONFIG.media);\n const preview = (part: 'header' | 'footer') => (\n <div\n onClickCapture={(event) => {\n event.preventDefault();\n event.stopPropagation();\n }}\n onAuxClickCapture={(event) => {\n event.preventDefault();\n event.stopPropagation();\n }}\n >\n <BlockList blocks={resolved[part] ?? []} site={resolved}/>\n </div>\n );\n return (\n <>\n {titleInAside && (\n <TitlePanel name=\"site-page-title\" title=\"Page title\" className=\"site-control-scope\">\n <wp.components.TextControl\n label=\"Title\"\n value={title}\n onChange={(value: string) => wp.data.dispatch('core/editor').editPost({title: value})}\n />\n </TitlePanel>\n )}\n {site && targets && createPortal(preview('header'), targets.header)}\n {site && targets && createPortal(preview('footer'), targets.footer)}\n </>\n );\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,10 +10,15 @@ export function registerPageCanvas(useSiteData: () => any) {
|
|
|
10
10
|
wp.plugins.registerPlugin('site-page-canvas', {
|
|
11
11
|
render: () => {
|
|
12
12
|
const site = useSiteData();
|
|
13
|
-
const isPage = wp.data.useSelect(
|
|
14
|
-
(select: any) =>
|
|
13
|
+
const {isPage, title} = wp.data.useSelect(
|
|
14
|
+
(select: any) => ({
|
|
15
|
+
isPage: select('core/editor').getCurrentPostType() === 'page',
|
|
16
|
+
title: select('core/editor').getEditedPostAttribute('title') ?? '',
|
|
17
|
+
}),
|
|
15
18
|
[]
|
|
16
19
|
);
|
|
20
|
+
const TitlePanel = wp.editor?.PluginDocumentSettingPanel;
|
|
21
|
+
const titleInAside = isPage && Boolean(TitlePanel);
|
|
17
22
|
const [targets, setTargets] = useState<{ header: HTMLElement; footer: HTMLElement } | null>(
|
|
18
23
|
null
|
|
19
24
|
);
|
|
@@ -39,6 +44,7 @@ export function registerPageCanvas(useSiteData: () => any) {
|
|
|
39
44
|
const root = doc.querySelector('.block-editor-block-list__layout.is-root-container');
|
|
40
45
|
if (!root || !root.parentElement) continue;
|
|
41
46
|
doc.body.classList.add('site-page-canvas');
|
|
47
|
+
doc.body.classList.toggle('site-page-title-in-aside', titleInAside);
|
|
42
48
|
if (mounts?.header.isConnected && mounts.header.nextElementSibling === root) return;
|
|
43
49
|
mounts?.header.remove();
|
|
44
50
|
mounts?.footer.remove();
|
|
@@ -62,15 +68,15 @@ export function registerPageCanvas(useSiteData: () => any) {
|
|
|
62
68
|
document.removeEventListener('load', sync, true);
|
|
63
69
|
observers.forEach((observer, doc) => {
|
|
64
70
|
observer.disconnect();
|
|
65
|
-
doc.body.classList.remove('site-page-canvas');
|
|
71
|
+
doc.body.classList.remove('site-page-canvas', 'site-page-title-in-aside');
|
|
66
72
|
});
|
|
67
73
|
mounts?.header.remove();
|
|
68
74
|
mounts?.footer.remove();
|
|
69
75
|
setTargets(null);
|
|
70
76
|
};
|
|
71
|
-
}, [isPage]);
|
|
72
|
-
if (!isPage
|
|
73
|
-
const resolved = mediaValues(site, window.SITE_EDITOR_CONFIG.media);
|
|
77
|
+
}, [isPage, titleInAside]);
|
|
78
|
+
if (!isPage) return null;
|
|
79
|
+
const resolved = site && mediaValues(site, window.SITE_EDITOR_CONFIG.media);
|
|
74
80
|
const preview = (part: 'header' | 'footer') => (
|
|
75
81
|
<div
|
|
76
82
|
onClickCapture={(event) => {
|
|
@@ -87,8 +93,17 @@ export function registerPageCanvas(useSiteData: () => any) {
|
|
|
87
93
|
);
|
|
88
94
|
return (
|
|
89
95
|
<>
|
|
90
|
-
{
|
|
91
|
-
|
|
96
|
+
{titleInAside && (
|
|
97
|
+
<TitlePanel name="site-page-title" title="Page title" className="site-control-scope">
|
|
98
|
+
<wp.components.TextControl
|
|
99
|
+
label="Title"
|
|
100
|
+
value={title}
|
|
101
|
+
onChange={(value: string) => wp.data.dispatch('core/editor').editPost({title: value})}
|
|
102
|
+
/>
|
|
103
|
+
</TitlePanel>
|
|
104
|
+
)}
|
|
105
|
+
{site && targets && createPortal(preview('header'), targets.header)}
|
|
106
|
+
{site && targets && createPortal(preview('footer'), targets.footer)}
|
|
92
107
|
</>
|
|
93
108
|
);
|
|
94
109
|
},
|