@wordpress/edit-post 6.14.3 → 6.14.4
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/build/components/visual-editor/index.js +85 -22
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/index.js +15 -10
- package/build/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +85 -23
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/index.js +15 -10
- package/build-module/index.js.map +1 -1
- package/package.json +14 -14
- package/src/components/visual-editor/index.js +126 -33
- package/src/index.js +20 -16
|
@@ -25,6 +25,8 @@ var _icons = require("@wordpress/icons");
|
|
|
25
25
|
|
|
26
26
|
var _i18n = require("@wordpress/i18n");
|
|
27
27
|
|
|
28
|
+
var _blocks = require("@wordpress/blocks");
|
|
29
|
+
|
|
28
30
|
var _blockInspectorButton = _interopRequireDefault(require("./block-inspector-button"));
|
|
29
31
|
|
|
30
32
|
var _store = require("../../store");
|
|
@@ -80,8 +82,35 @@ function MaybeIframe(_ref) {
|
|
|
80
82
|
name: "editor-canvas"
|
|
81
83
|
}, children);
|
|
82
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Given an array of nested blocks, find the first Post Content
|
|
87
|
+
* block inside it, recursing through any nesting levels.
|
|
88
|
+
*
|
|
89
|
+
* @param {Array} blocks A list of blocks.
|
|
90
|
+
*
|
|
91
|
+
* @return {Object} The Post Content block.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function findPostContent(blocks) {
|
|
96
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
97
|
+
if (blocks[i].name === 'core/post-content') {
|
|
98
|
+
return blocks[i];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (blocks[i].innerBlocks.length) {
|
|
102
|
+
const nestedPostContent = findPostContent(blocks[i].innerBlocks);
|
|
103
|
+
|
|
104
|
+
if (nestedPostContent) {
|
|
105
|
+
return nestedPostContent;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
83
110
|
|
|
84
111
|
function VisualEditor(_ref2) {
|
|
112
|
+
var _postContentBlock$att;
|
|
113
|
+
|
|
85
114
|
let {
|
|
86
115
|
styles
|
|
87
116
|
} = _ref2;
|
|
@@ -89,17 +118,20 @@ function VisualEditor(_ref2) {
|
|
|
89
118
|
deviceType,
|
|
90
119
|
isWelcomeGuideVisible,
|
|
91
120
|
isTemplateMode,
|
|
121
|
+
editedPostTemplate = {},
|
|
92
122
|
wrapperBlockName,
|
|
93
123
|
wrapperUniqueId
|
|
94
124
|
} = (0, _data.useSelect)(select => {
|
|
95
125
|
const {
|
|
96
126
|
isFeatureActive,
|
|
97
127
|
isEditingTemplate,
|
|
98
|
-
__experimentalGetPreviewDeviceType
|
|
128
|
+
__experimentalGetPreviewDeviceType,
|
|
129
|
+
getEditedPostTemplate
|
|
99
130
|
} = select(_store.store);
|
|
100
131
|
const {
|
|
101
132
|
getCurrentPostId,
|
|
102
|
-
getCurrentPostType
|
|
133
|
+
getCurrentPostType,
|
|
134
|
+
getEditorSettings
|
|
103
135
|
} = select(_editor.store);
|
|
104
136
|
|
|
105
137
|
const _isTemplateMode = isEditingTemplate();
|
|
@@ -112,10 +144,14 @@ function VisualEditor(_ref2) {
|
|
|
112
144
|
_wrapperBlockName = 'core/post-content';
|
|
113
145
|
}
|
|
114
146
|
|
|
147
|
+
const supportsTemplateMode = getEditorSettings().supportsTemplateMode;
|
|
115
148
|
return {
|
|
116
149
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
117
150
|
isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
|
|
118
151
|
isTemplateMode: _isTemplateMode,
|
|
152
|
+
// Post template fetch returns a 404 on classic themes, which
|
|
153
|
+
// messes with e2e tests, so we check it's a block theme first.
|
|
154
|
+
editedPostTemplate: supportsTemplateMode ? getEditedPostTemplate() : {},
|
|
119
155
|
wrapperBlockName: _wrapperBlockName,
|
|
120
156
|
wrapperUniqueId: getCurrentPostId()
|
|
121
157
|
};
|
|
@@ -127,18 +163,14 @@ function VisualEditor(_ref2) {
|
|
|
127
163
|
const {
|
|
128
164
|
themeHasDisabledLayoutStyles,
|
|
129
165
|
themeSupportsLayout,
|
|
130
|
-
assets
|
|
131
|
-
useRootPaddingAwareAlignments
|
|
166
|
+
assets
|
|
132
167
|
} = (0, _data.useSelect)(select => {
|
|
133
|
-
var _settings$__experimen;
|
|
134
|
-
|
|
135
168
|
const _settings = select(_blockEditor.store).getSettings();
|
|
136
169
|
|
|
137
170
|
return {
|
|
138
171
|
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
139
172
|
themeSupportsLayout: _settings.supportsLayout,
|
|
140
|
-
assets: _settings.__unstableResolvedAssets
|
|
141
|
-
useRootPaddingAwareAlignments: (_settings$__experimen = _settings.__experimentalFeatures) === null || _settings$__experimen === void 0 ? void 0 : _settings$__experimen.useRootPaddingAwareAlignments
|
|
173
|
+
assets: _settings.__unstableResolvedAssets
|
|
142
174
|
};
|
|
143
175
|
}, []);
|
|
144
176
|
const {
|
|
@@ -163,7 +195,7 @@ function VisualEditor(_ref2) {
|
|
|
163
195
|
borderBottom: 0
|
|
164
196
|
};
|
|
165
197
|
const resizedCanvasStyles = (0, _blockEditor.__experimentalUseResizeCanvas)(deviceType, isTemplateMode);
|
|
166
|
-
const
|
|
198
|
+
const globalLayoutSettings = (0, _blockEditor.useSetting)('layout');
|
|
167
199
|
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
168
200
|
let animatedStyles = isTemplateMode ? templateModeStyles : desktopCanvasStyles;
|
|
169
201
|
|
|
@@ -180,8 +212,10 @@ function VisualEditor(_ref2) {
|
|
|
180
212
|
|
|
181
213
|
const ref = (0, _element.useRef)();
|
|
182
214
|
const contentRef = (0, _compose.useMergeRefs)([ref, (0, _blockEditor.__unstableUseClipboardHandler)(), (0, _blockEditor.__unstableUseTypewriter)(), (0, _blockEditor.__unstableUseTypingObserver)(), (0, _blockEditor.__unstableUseBlockSelectionClearer)()]);
|
|
183
|
-
const blockSelectionClearerRef = (0, _blockEditor.__unstableUseBlockSelectionClearer)();
|
|
184
|
-
|
|
215
|
+
const blockSelectionClearerRef = (0, _blockEditor.__unstableUseBlockSelectionClearer)(); // fallbackLayout is used if there is no Post Content,
|
|
216
|
+
// and for Post Title.
|
|
217
|
+
|
|
218
|
+
const fallbackLayout = (0, _element.useMemo)(() => {
|
|
185
219
|
if (isTemplateMode) {
|
|
186
220
|
return {
|
|
187
221
|
type: 'default'
|
|
@@ -191,7 +225,7 @@ function VisualEditor(_ref2) {
|
|
|
191
225
|
if (themeSupportsLayout) {
|
|
192
226
|
// We need to ensure support for wide and full alignments,
|
|
193
227
|
// so we add the constrained type.
|
|
194
|
-
return { ...
|
|
228
|
+
return { ...globalLayoutSettings,
|
|
195
229
|
type: 'constrained'
|
|
196
230
|
};
|
|
197
231
|
} // Set default layout for classic themes so all alignments are supported.
|
|
@@ -200,12 +234,37 @@ function VisualEditor(_ref2) {
|
|
|
200
234
|
return {
|
|
201
235
|
type: 'default'
|
|
202
236
|
};
|
|
203
|
-
}, [isTemplateMode, themeSupportsLayout,
|
|
237
|
+
}, [isTemplateMode, themeSupportsLayout, globalLayoutSettings]);
|
|
238
|
+
const postContentBlock = (0, _element.useMemo)(() => {
|
|
239
|
+
// When in template editing mode, we can access the blocks directly.
|
|
240
|
+
if (editedPostTemplate !== null && editedPostTemplate !== void 0 && editedPostTemplate.blocks) {
|
|
241
|
+
return findPostContent(editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.blocks);
|
|
242
|
+
} // If there are no blocks, we have to parse the content string.
|
|
243
|
+
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
const parseableContent = typeof (editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.content) === 'string' ? editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.content : '';
|
|
247
|
+
return findPostContent((0, _blocks.parse)(parseableContent)) || {};
|
|
248
|
+
}, [editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.content, editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.blocks]);
|
|
249
|
+
const postContentLayoutClasses = (0, _blockEditor.__experimentaluseLayoutClasses)(postContentBlock);
|
|
204
250
|
const blockListLayoutClass = (0, _classnames.default)({
|
|
205
|
-
'is-layout-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
251
|
+
'is-layout-flow': !themeSupportsLayout
|
|
252
|
+
}, themeSupportsLayout && postContentLayoutClasses);
|
|
253
|
+
const postContentLayoutStyles = (0, _blockEditor.__experimentaluseLayoutStyles)(postContentBlock, '.block-editor-block-list__layout.is-root-container');
|
|
254
|
+
const layout = (postContentBlock === null || postContentBlock === void 0 ? void 0 : (_postContentBlock$att = postContentBlock.attributes) === null || _postContentBlock$att === void 0 ? void 0 : _postContentBlock$att.layout) || {}; // Update type for blocks using legacy layouts.
|
|
255
|
+
|
|
256
|
+
const postContentLayout = (0, _element.useMemo)(() => {
|
|
257
|
+
return layout && ((layout === null || layout === void 0 ? void 0 : layout.type) === 'constrained' || layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize) ? { ...globalLayoutSettings,
|
|
258
|
+
...layout,
|
|
259
|
+
type: 'constrained'
|
|
260
|
+
} : { ...globalLayoutSettings,
|
|
261
|
+
...layout,
|
|
262
|
+
type: 'default'
|
|
263
|
+
};
|
|
264
|
+
}, [layout === null || layout === void 0 ? void 0 : layout.type, layout === null || layout === void 0 ? void 0 : layout.inherit, layout === null || layout === void 0 ? void 0 : layout.contentSize, layout === null || layout === void 0 ? void 0 : layout.wideSize, globalLayoutSettings]); // If there is a Post Content block we use its layout for the block list;
|
|
265
|
+
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
266
|
+
|
|
267
|
+
const blockListLayout = postContentBlock ? postContentLayout : fallbackLayout;
|
|
209
268
|
const titleRef = (0, _element.useRef)();
|
|
210
269
|
(0, _element.useEffect)(() => {
|
|
211
270
|
var _titleRef$current;
|
|
@@ -246,11 +305,15 @@ function VisualEditor(_ref2) {
|
|
|
246
305
|
style: {
|
|
247
306
|
paddingBottom
|
|
248
307
|
}
|
|
249
|
-
}, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && (0, _element.createElement)(_blockEditor.__experimentalLayoutStyle, {
|
|
308
|
+
}, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.__experimentalLayoutStyle, {
|
|
250
309
|
selector: ".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container",
|
|
251
|
-
layout:
|
|
252
|
-
layoutDefinitions:
|
|
253
|
-
}),
|
|
310
|
+
layout: fallbackLayout,
|
|
311
|
+
layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions
|
|
312
|
+
}), postContentLayoutStyles && (0, _element.createElement)(_blockEditor.__experimentalLayoutStyle, {
|
|
313
|
+
layout: postContentLayout,
|
|
314
|
+
css: postContentLayoutStyles,
|
|
315
|
+
layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions
|
|
316
|
+
})), !isTemplateMode && (0, _element.createElement)("div", {
|
|
254
317
|
className: "edit-post-visual-editor__post-title-wrapper",
|
|
255
318
|
contentEditable: false
|
|
256
319
|
}, (0, _element.createElement)(_editor.PostTitle, {
|
|
@@ -261,7 +324,7 @@ function VisualEditor(_ref2) {
|
|
|
261
324
|
}, (0, _element.createElement)(_blockEditor.BlockList, {
|
|
262
325
|
className: isTemplateMode ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
263
326
|
,
|
|
264
|
-
__experimentalLayout:
|
|
327
|
+
__experimentalLayout: blockListLayout
|
|
265
328
|
}))))), (0, _element.createElement)(_blockEditor.__unstableBlockSettingsMenuFirstItem, null, _ref3 => {
|
|
266
329
|
let {
|
|
267
330
|
onClose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"names":["MaybeIframe","children","contentRef","shouldIframe","styles","assets","style","ref","flex","width","height","display","VisualEditor","deviceType","isWelcomeGuideVisible","isTemplateMode","wrapperBlockName","wrapperUniqueId","select","isFeatureActive","isEditingTemplate","__experimentalGetPreviewDeviceType","editPostStore","getCurrentPostId","getCurrentPostType","editorStore","_isTemplateMode","_wrapperBlockName","isCleanNewPost","hasMetaBoxes","themeHasDisabledLayoutStyles","themeSupportsLayout","useRootPaddingAwareAlignments","_settings","blockEditorStore","getSettings","disableLayoutStyles","supportsLayout","__unstableResolvedAssets","__experimentalFeatures","clearSelectedBlock","setIsEditingTemplate","desktopCanvasStyles","margin","flexFlow","background","templateModeStyles","borderRadius","border","borderBottom","resizedCanvasStyles","defaultLayout","previewMode","toLowerCase","animatedStyles","paddingBottom","blockSelectionClearerRef","layout","type","blockListLayoutClass","titleRef","current","focus","padding","arrowLeft","definitions","onClose"],"mappings":";;;;;;;;;AA+BA;;AA5BA;;AAKA;;AAKA;;AAmBA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AA+BA;AACA;AACA;AAIA,SAASA,WAAT,OAOI;AAAA,MAPkB;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,UAFqB;AAGrBC,IAAAA,YAHqB;AAIrBC,IAAAA,MAJqB;AAKrBC,IAAAA,MALqB;AAMrBC,IAAAA;AANqB,GAOlB;AACH,QAAMC,GAAG,GAAG,qDAAZ;;AAEA,MAAK,CAAEJ,YAAP,EAAsB;AACrB,WACC,qDACC,4BAAC,mCAAD;AAAc,MAAA,MAA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c,IACdF,UAAU,KAAK,QADf,IAEAA,UAAU,KAAK,QAJjB;AAMC,IAAA,UAAU,EAAGX,UANd;AAOC,IAAA,MAAM,EAAGE,MAPV;AAQC,IAAA,MAAM,EAAGC,MARV;AASC,IAAA,KAAK,EAAG;AAAEkD,MAAAA;AAAF;AATT,KAWGxB,mBAAmB,IACpB,CAAED,4BADD,IAED,CAAEf,cAFD,IAGA,4BAAC,sCAAD;AACC,IAAA,QAAQ,EAAC,kGADV;AAEC,IAAA,MAAM,EAAG0C,MAFV;AAGC,IAAA,iBAAiB,EAChBN,aADgB,aAChBA,aADgB,uBAChBA,aAAa,CAAEc;AAJjB,IAdH,EAsBG,CAAElD,cAAF,IACD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,eAAe,EAAG;AAFnB,KAIC,4BAAC,iBAAD;AAAW,IAAA,GAAG,EAAG6C;AAAjB,IAJD,CAvBF,EA8BC,4BAAC,4CAAD;AACC,IAAA,SAAS,EAAG5C,gBADb;AAEC,IAAA,QAAQ,EAAGC;AAFZ,KAIC,4BAAC,sBAAD;AACC,IAAA,SAAS,EACRF,cAAc,GACX,gBADW,GAEV,GAAG4C,oBAAsB,wBAHrB,CAG6C;AAJvD;AAMC,IAAA,oBAAoB,EAAGF;AANxB,IAJD,CA9BD,CALD,CAnBD,CAPD,EA6EC,4BAAC,iDAAD,QACG;AAAA,QAAE;AAAES,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,6BAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CA7ED,CADD;AAqFA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tVisualEditorGlobalKeyboardShortcuts,\n\tPostTitle,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport {\n\tWritingFlow,\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n\t__unstableUseBlockSelectionClearer as useBlockSelectionClearer,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\tuseSetting,\n\t__experimentalLayoutStyle as LayoutStyle,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\t__unstableIframe as Iframe,\n\t__experimentalRecursionProvider as RecursionProvider,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { Button, __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { arrowLeft } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from './block-inspector-button';\nimport { store as editPostStore } from '../../store';\n\nfunction MaybeIframe( {\n\tchildren,\n\tcontentRef,\n\tshouldIframe,\n\tstyles,\n\tassets,\n\tstyle,\n} ) {\n\tconst ref = useMouseMoveTypingReset();\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\tstyle={ { flex: '1', ...style } }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Iframe\n\t\t\thead={ <EditorStyles styles={ styles } /> }\n\t\t\tassets={ assets }\n\t\t\tref={ ref }\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyle={ { width: '100%', height: '100%', display: 'block' } }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tdeviceType,\n\t\tisWelcomeGuideVisible,\n\t\tisTemplateMode,\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tisEditingTemplate,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t} = select( editPostStore );\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( getCurrentPostType() === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _isTemplateMode ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\tconst {\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t\tassets,\n\t\tuseRootPaddingAwareAlignments,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\tassets: _settings.__unstableResolvedAssets,\n\t\t\tuseRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst desktopCanvasStyles = {\n\t\theight: '100%',\n\t\twidth: '100%',\n\t\tmargin: 0,\n\t\tdisplay: 'flex',\n\t\tflexFlow: 'column',\n\t\t// Default background color so that grey\n\t\t// .edit-post-editor-regions__content color doesn't show through.\n\t\tbackground: 'white',\n\t};\n\tconst templateModeStyles = {\n\t\t...desktopCanvasStyles,\n\t\tborderRadius: '2px 2px 0 0',\n\t\tborder: '1px solid #ddd',\n\t\tborderBottom: 0,\n\t};\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );\n\tconst defaultLayout = useSetting( 'layout' );\n\tconst previewMode = 'is-' + deviceType.toLowerCase() + '-preview';\n\n\tlet animatedStyles = isTemplateMode\n\t\t? templateModeStyles\n\t\t: desktopCanvasStyles;\n\tif ( resizedCanvasStyles ) {\n\t\tanimatedStyles = resizedCanvasStyles;\n\t}\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && ! resizedCanvasStyles && ! isTemplateMode ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tconst ref = useRef();\n\tconst contentRef = useMergeRefs( [\n\t\tref,\n\t\tuseClipboardHandler(),\n\t\tuseTypewriter(),\n\t\tuseTypingObserver(),\n\t\tuseBlockSelectionClearer(),\n\t] );\n\n\tconst blockSelectionClearerRef = useBlockSelectionClearer();\n\n\tconst layout = useMemo( () => {\n\t\tif ( isTemplateMode ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...defaultLayout, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ isTemplateMode, themeSupportsLayout, defaultLayout ] );\n\n\tconst blockListLayoutClass = classnames( {\n\t\t'is-layout-constrained': themeSupportsLayout,\n\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t'has-global-padding': useRootPaddingAwareAlignments,\n\t} );\n\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible, isCleanNewPost ] );\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ ref }\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': isTemplateMode,\n\t\t\t} ) }\n\t\t>\n\t\t\t<VisualEditorGlobalKeyboardShortcuts />\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-post-visual-editor__content-area\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tpadding: isTemplateMode ? '48px 48px 0' : '0',\n\t\t\t\t} }\n\t\t\t\tref={ blockSelectionClearerRef }\n\t\t\t>\n\t\t\t\t{ isTemplateMode && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-post-visual-editor__exit-template-mode\"\n\t\t\t\t\t\ticon={ arrowLeft }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<motion.div\n\t\t\t\t\tanimate={ animatedStyles }\n\t\t\t\t\tinitial={ desktopCanvasStyles }\n\t\t\t\t\tclassName={ previewMode }\n\t\t\t\t>\n\t\t\t\t\t<MaybeIframe\n\t\t\t\t\t\tshouldIframe={\n\t\t\t\t\t\t\tisTemplateMode ||\n\t\t\t\t\t\t\tdeviceType === 'Tablet' ||\n\t\t\t\t\t\t\tdeviceType === 'Mobile'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\tstyles={ styles }\n\t\t\t\t\t\tassets={ assets }\n\t\t\t\t\t\tstyle={ { paddingBottom } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\t\t! isTemplateMode && (\n\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\tselector=\".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\t\tlayoutDefinitions={\n\t\t\t\t\t\t\t\t\t\tdefaultLayout?.definitions\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"edit-post-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tisTemplateMode\n\t\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RecursionProvider>\n\t\t\t\t\t</MaybeIframe>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</BlockTools>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"names":["MaybeIframe","children","contentRef","shouldIframe","styles","assets","style","ref","flex","width","height","display","findPostContent","blocks","i","length","name","innerBlocks","nestedPostContent","VisualEditor","deviceType","isWelcomeGuideVisible","isTemplateMode","editedPostTemplate","wrapperBlockName","wrapperUniqueId","select","isFeatureActive","isEditingTemplate","__experimentalGetPreviewDeviceType","getEditedPostTemplate","editPostStore","getCurrentPostId","getCurrentPostType","getEditorSettings","editorStore","_isTemplateMode","_wrapperBlockName","supportsTemplateMode","isCleanNewPost","hasMetaBoxes","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","blockEditorStore","getSettings","disableLayoutStyles","supportsLayout","__unstableResolvedAssets","clearSelectedBlock","setIsEditingTemplate","desktopCanvasStyles","margin","flexFlow","background","templateModeStyles","borderRadius","border","borderBottom","resizedCanvasStyles","globalLayoutSettings","previewMode","toLowerCase","animatedStyles","paddingBottom","blockSelectionClearerRef","fallbackLayout","type","postContentBlock","parseableContent","content","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","layout","attributes","postContentLayout","inherit","contentSize","wideSize","blockListLayout","titleRef","current","focus","padding","arrowLeft","definitions","onClose"],"mappings":";;;;;;;;;AAiCA;;AA9BA;;AAKA;;AAKA;;AAqBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA7CA;AACA;AACA;;AAGA;AACA;AACA;;AAkCA;AACA;AACA;AAIA,SAASA,WAAT,OAOI;AAAA,MAPkB;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,UAFqB;AAGrBC,IAAAA,YAHqB;AAIrBC,IAAAA,MAJqB;AA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,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CAxFD,CADD;AAgGA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tVisualEditorGlobalKeyboardShortcuts,\n\tPostTitle,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport {\n\tWritingFlow,\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n\t__unstableUseBlockSelectionClearer as useBlockSelectionClearer,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\tuseSetting,\n\t__experimentalLayoutStyle as LayoutStyle,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\t__unstableIframe as Iframe,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentaluseLayoutClasses as useLayoutClasses,\n\t__experimentaluseLayoutStyles as useLayoutStyles,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { Button, __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { arrowLeft } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from './block-inspector-button';\nimport { store as editPostStore } from '../../store';\n\nfunction MaybeIframe( {\n\tchildren,\n\tcontentRef,\n\tshouldIframe,\n\tstyles,\n\tassets,\n\tstyle,\n} ) {\n\tconst ref = useMouseMoveTypingReset();\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\tstyle={ { flex: '1', ...style } }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Iframe\n\t\t\thead={ <EditorStyles styles={ styles } /> }\n\t\t\tassets={ assets }\n\t\t\tref={ ref }\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyle={ { width: '100%', height: '100%', display: 'block' } }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object} The Post Content block.\n */\nfunction findPostContent( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ];\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = findPostContent(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tdeviceType,\n\t\tisWelcomeGuideVisible,\n\t\tisTemplateMode,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tisEditingTemplate,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetEditedPostTemplate,\n\t\t} = select( editPostStore );\n\t\tconst { getCurrentPostId, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( getCurrentPostType() === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _isTemplateMode ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst supportsTemplateMode = getEditorSettings().supportsTemplateMode;\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so we check it's a block theme first.\n\t\t\teditedPostTemplate: supportsTemplateMode\n\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t: {},\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\tconst { themeHasDisabledLayoutStyles, themeSupportsLayout, assets } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\t\treturn {\n\t\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\t\tassets: _settings.__unstableResolvedAssets,\n\t\t\t};\n\t\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst desktopCanvasStyles = {\n\t\theight: '100%',\n\t\twidth: '100%',\n\t\tmargin: 0,\n\t\tdisplay: 'flex',\n\t\tflexFlow: 'column',\n\t\t// Default background color so that grey\n\t\t// .edit-post-editor-regions__content color doesn't show through.\n\t\tbackground: 'white',\n\t};\n\tconst templateModeStyles = {\n\t\t...desktopCanvasStyles,\n\t\tborderRadius: '2px 2px 0 0',\n\t\tborder: '1px solid #ddd',\n\t\tborderBottom: 0,\n\t};\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );\n\tconst globalLayoutSettings = useSetting( 'layout' );\n\tconst previewMode = 'is-' + deviceType.toLowerCase() + '-preview';\n\n\tlet animatedStyles = isTemplateMode\n\t\t? templateModeStyles\n\t\t: desktopCanvasStyles;\n\tif ( resizedCanvasStyles ) {\n\t\tanimatedStyles = resizedCanvasStyles;\n\t}\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && ! resizedCanvasStyles && ! isTemplateMode ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tconst ref = useRef();\n\tconst contentRef = useMergeRefs( [\n\t\tref,\n\t\tuseClipboardHandler(),\n\t\tuseTypewriter(),\n\t\tuseTypingObserver(),\n\t\tuseBlockSelectionClearer(),\n\t] );\n\n\tconst blockSelectionClearerRef = useBlockSelectionClearer();\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( isTemplateMode ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst postContentBlock = useMemo( () => {\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn findPostContent( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn findPostContent( parse( parseableContent ) ) || {};\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst postContentLayoutClasses = useLayoutClasses( postContentBlock );\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tpostContentBlock,\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\tconst layout = postContentBlock?.attributes?.layout || {};\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentBlock\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible, isCleanNewPost ] );\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ ref }\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': isTemplateMode,\n\t\t\t} ) }\n\t\t>\n\t\t\t<VisualEditorGlobalKeyboardShortcuts />\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-post-visual-editor__content-area\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tpadding: isTemplateMode ? '48px 48px 0' : '0',\n\t\t\t\t} }\n\t\t\t\tref={ blockSelectionClearerRef }\n\t\t\t>\n\t\t\t\t{ isTemplateMode && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-post-visual-editor__exit-template-mode\"\n\t\t\t\t\t\ticon={ arrowLeft }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<motion.div\n\t\t\t\t\tanimate={ animatedStyles }\n\t\t\t\t\tinitial={ desktopCanvasStyles }\n\t\t\t\t\tclassName={ previewMode }\n\t\t\t\t>\n\t\t\t\t\t<MaybeIframe\n\t\t\t\t\t\tshouldIframe={\n\t\t\t\t\t\t\tisTemplateMode ||\n\t\t\t\t\t\t\tdeviceType === 'Tablet' ||\n\t\t\t\t\t\t\tdeviceType === 'Mobile'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\tstyles={ styles }\n\t\t\t\t\t\tassets={ assets }\n\t\t\t\t\t\tstyle={ { paddingBottom } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\t\t! isTemplateMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tselector=\".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t\t\t\t\tlayoutDefinitions={\n\t\t\t\t\t\t\t\t\t\t\tglobalLayoutSettings?.definitions\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\n\t\t\t\t\t\t\t\t\t\t\tlayoutDefinitions={\n\t\t\t\t\t\t\t\t\t\t\t\tglobalLayoutSettings?.definitions\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"edit-post-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tisTemplateMode\n\t\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__experimentalLayout={ blockListLayout }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RecursionProvider>\n\t\t\t\t\t</MaybeIframe>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</BlockTools>\n\t);\n}\n"]}
|
package/build/index.js
CHANGED
|
@@ -161,15 +161,6 @@ function reinitializeEditor(postType, postId, target, settings, initialEdits) {
|
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
164
|
-
// Prevent adding template part in the post editor.
|
|
165
|
-
// Only add the filter when the post editor is initialized, not imported.
|
|
166
|
-
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (can, blockType) => {
|
|
167
|
-
if (!(0, _data.select)(_store.store).isEditingTemplate() && blockType.name === 'core/template-part') {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return can;
|
|
172
|
-
});
|
|
173
164
|
const target = document.getElementById(id);
|
|
174
165
|
const reboot = reinitializeEditor.bind(null, postType, postId, target, settings, initialEdits);
|
|
175
166
|
(0, _data.dispatch)(_preferences.store).setDefaults('core/edit-post', {
|
|
@@ -202,8 +193,22 @@ function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
202
193
|
(0, _blockLibrary.__experimentalRegisterExperimentalCoreBlocks)({
|
|
203
194
|
enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks
|
|
204
195
|
});
|
|
205
|
-
}
|
|
196
|
+
}
|
|
197
|
+
/*
|
|
198
|
+
* Prevent adding template part in the post editor.
|
|
199
|
+
* Only add the filter when the post editor is initialized, not imported.
|
|
200
|
+
* Also only add the filter(s) after registerCoreBlocks()
|
|
201
|
+
* so that common filters in the block library are not overwritten.
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
|
|
206
|
+
if (!(0, _data.select)(_store.store).isEditingTemplate() && blockType.name === 'core/template-part') {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
206
209
|
|
|
210
|
+
return canInsert;
|
|
211
|
+
}); // Show a console log warning if the browser is not in Standards rendering mode.
|
|
207
212
|
|
|
208
213
|
const documentMode = document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
|
|
209
214
|
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","can","blockType","editPostStore","isEditingTemplate","name","document","getElementById","preferencesStore","setDefaults","editorMode","fixedToolbar","fullscreenMode","hiddenBlockTypes","inactivePanels","isPublishSidebarEnabled","openPanels","preferredStyleVariations","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","themeStyles","welcomeGuide","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","isFeatureActive","setIsListViewOpened","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;AALA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAgLA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5MA;AACA;AACA;;AAWA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CACNC,QADM,EAENC,MAFM,EAGNC,MAHM,EAINC,QAJM,EAKNC,YALM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AAKgC,MAAM,CAACQ,OAAP,GAAiB,GAAtB,EAA4B;AAC3BF,UAAAA,qBAAqB,CAACG,SAAtB,GACCH,qBAAqB,CAACG,SAAtB,GAAkCT,MAAM,CAACQ,OAD1C;AAEA,SAN+B,CAOhC;;;AACA,YACCxC,QAAQ,CAACuC,sBAAT,CAAiC,gBAAjC,EAAqD,CAArD,CADD,EAEE;AACDP,UAAAA,MAAM,CAACU,QAAP,CAAiB,CAAjB,EAAoB,CAApB;AACA;AACD;AACD,KAlBD;AAmBA,GAhGA,CAkGD;;;AACAV,EAAAA,MAAM,CAACI,gBAAP,CAAyB,UAAzB,EAAuCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAZ,EAAAA,MAAM,CAACI,gBAAP,CAAyB,MAAzB,EAAmCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEA,uBACC,4BAAC,eAAD;AACC,IAAA,QAAQ,EAAGvD,QADZ;AAEC,IAAA,OAAO,EAAGE,MAFX;AAGC,IAAA,MAAM,EAAGJ,MAHV;AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,YAAY,EAAGI;AALhB,IADD,EAQCF,MARD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\t// Prevent adding template part in the post editor.\n\t// Only add the filter when the post editor is initialized, not imported.\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( can, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn can;\n\t\t}\n\t);\n\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfullscreenMode: true,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\tisPublishSidebarEnabled: true,\n\t\topenPanels: [ 'post-status' ],\n\t\tpreferredStyleVariations: {},\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\tif ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {\n\t\tdispatch( editPostStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","document","getElementById","preferencesStore","setDefaults","editorMode","fixedToolbar","fullscreenMode","hiddenBlockTypes","inactivePanels","isPublishSidebarEnabled","openPanels","preferredStyleVariations","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","themeStyles","welcomeGuide","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","editPostStore","isFeatureActive","setIsListViewOpened","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","canInsert","blockType","isEditingTemplate","name","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;AALA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAoLA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAhNA;AACA;AACA;;AAWA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CACNC,QADM,EAENC,MAFM,EAGNC,MAHM,EAINC,QAJM,EAKNC,YALM,EAML;AACD,uCAAwBF,MAAxB;AACA,QAAMG,MAAM,GAAGN,kBAAkB,CAACO,IAAnB,CACd,IADc,EAEdN,QAFc,EAGdC,MAHc,EAIdC,MAJc,EAKdC,QALc,EAMdC,YANc,CAAf;AASA,uBACC,4BAAC,eAAD;AACC,IA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ACC7C,QAAQ,CAAC4C,sBAAT,CAAiC,gBAAjC,EAAqD,CAArD,CADD,EAEE;AACDP,UAAAA,MAAM,CAACU,QAAP,CAAiB,CAAjB,EAAoB,CAApB;AACA;AACD;AACD,KAlBD;AAmBA,GApGA,CAsGD;;;AACAV,EAAAA,MAAM,CAACI,gBAAP,CAAyB,UAAzB,EAAuCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAZ,EAAAA,MAAM,CAACI,gBAAP,CAAyB,MAAzB,EAAmCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEA,uBACC,4BAAC,eAAD;AACC,IAAA,QAAQ,EAAGvD,QADZ;AAEC,IAAA,OAAO,EAAGE,MAFX;AAGC,IAAA,MAAM,EAAGJ,MAHV;AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,YAAY,EAAGI;AALhB,IADD,EAQCF,MARD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfullscreenMode: true,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\tisPublishSidebarEnabled: true,\n\t\topenPanels: [ 'post-status' ],\n\t\tpreferredStyleVariations: {},\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\tif ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {\n\t\tdispatch( editPostStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t/*\n\t * Prevent adding template part in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( canInsert, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
|
@@ -9,13 +9,14 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { VisualEditorGlobalKeyboardShortcuts, PostTitle, store as editorStore } from '@wordpress/editor';
|
|
12
|
-
import { WritingFlow, BlockList, BlockTools, store as blockEditorStore, __unstableUseBlockSelectionClearer as useBlockSelectionClearer, __unstableUseTypewriter as useTypewriter, __unstableUseClipboardHandler as useClipboardHandler, __unstableUseTypingObserver as useTypingObserver, __unstableBlockSettingsMenuFirstItem, __experimentalUseResizeCanvas as useResizeCanvas, __unstableEditorStyles as EditorStyles, useSetting, __experimentalLayoutStyle as LayoutStyle, __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, __unstableIframe as Iframe, __experimentalRecursionProvider as RecursionProvider } from '@wordpress/block-editor';
|
|
12
|
+
import { WritingFlow, BlockList, BlockTools, store as blockEditorStore, __unstableUseBlockSelectionClearer as useBlockSelectionClearer, __unstableUseTypewriter as useTypewriter, __unstableUseClipboardHandler as useClipboardHandler, __unstableUseTypingObserver as useTypingObserver, __unstableBlockSettingsMenuFirstItem, __experimentalUseResizeCanvas as useResizeCanvas, __unstableEditorStyles as EditorStyles, useSetting, __experimentalLayoutStyle as LayoutStyle, __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, __unstableIframe as Iframe, __experimentalRecursionProvider as RecursionProvider, __experimentaluseLayoutClasses as useLayoutClasses, __experimentaluseLayoutStyles as useLayoutStyles } from '@wordpress/block-editor';
|
|
13
13
|
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
14
14
|
import { Button, __unstableMotion as motion } from '@wordpress/components';
|
|
15
15
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
16
16
|
import { useMergeRefs } from '@wordpress/compose';
|
|
17
17
|
import { arrowLeft } from '@wordpress/icons';
|
|
18
18
|
import { __ } from '@wordpress/i18n';
|
|
19
|
+
import { parse } from '@wordpress/blocks';
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
21
22
|
*/
|
|
@@ -63,8 +64,35 @@ function MaybeIframe(_ref) {
|
|
|
63
64
|
name: "editor-canvas"
|
|
64
65
|
}, children);
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Given an array of nested blocks, find the first Post Content
|
|
69
|
+
* block inside it, recursing through any nesting levels.
|
|
70
|
+
*
|
|
71
|
+
* @param {Array} blocks A list of blocks.
|
|
72
|
+
*
|
|
73
|
+
* @return {Object} The Post Content block.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function findPostContent(blocks) {
|
|
78
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
79
|
+
if (blocks[i].name === 'core/post-content') {
|
|
80
|
+
return blocks[i];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (blocks[i].innerBlocks.length) {
|
|
84
|
+
const nestedPostContent = findPostContent(blocks[i].innerBlocks);
|
|
85
|
+
|
|
86
|
+
if (nestedPostContent) {
|
|
87
|
+
return nestedPostContent;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
66
92
|
|
|
67
93
|
export default function VisualEditor(_ref2) {
|
|
94
|
+
var _postContentBlock$att;
|
|
95
|
+
|
|
68
96
|
let {
|
|
69
97
|
styles
|
|
70
98
|
} = _ref2;
|
|
@@ -72,17 +100,20 @@ export default function VisualEditor(_ref2) {
|
|
|
72
100
|
deviceType,
|
|
73
101
|
isWelcomeGuideVisible,
|
|
74
102
|
isTemplateMode,
|
|
103
|
+
editedPostTemplate = {},
|
|
75
104
|
wrapperBlockName,
|
|
76
105
|
wrapperUniqueId
|
|
77
106
|
} = useSelect(select => {
|
|
78
107
|
const {
|
|
79
108
|
isFeatureActive,
|
|
80
109
|
isEditingTemplate,
|
|
81
|
-
__experimentalGetPreviewDeviceType
|
|
110
|
+
__experimentalGetPreviewDeviceType,
|
|
111
|
+
getEditedPostTemplate
|
|
82
112
|
} = select(editPostStore);
|
|
83
113
|
const {
|
|
84
114
|
getCurrentPostId,
|
|
85
|
-
getCurrentPostType
|
|
115
|
+
getCurrentPostType,
|
|
116
|
+
getEditorSettings
|
|
86
117
|
} = select(editorStore);
|
|
87
118
|
|
|
88
119
|
const _isTemplateMode = isEditingTemplate();
|
|
@@ -95,10 +126,14 @@ export default function VisualEditor(_ref2) {
|
|
|
95
126
|
_wrapperBlockName = 'core/post-content';
|
|
96
127
|
}
|
|
97
128
|
|
|
129
|
+
const supportsTemplateMode = getEditorSettings().supportsTemplateMode;
|
|
98
130
|
return {
|
|
99
131
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
100
132
|
isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
|
|
101
133
|
isTemplateMode: _isTemplateMode,
|
|
134
|
+
// Post template fetch returns a 404 on classic themes, which
|
|
135
|
+
// messes with e2e tests, so we check it's a block theme first.
|
|
136
|
+
editedPostTemplate: supportsTemplateMode ? getEditedPostTemplate() : {},
|
|
102
137
|
wrapperBlockName: _wrapperBlockName,
|
|
103
138
|
wrapperUniqueId: getCurrentPostId()
|
|
104
139
|
};
|
|
@@ -110,18 +145,14 @@ export default function VisualEditor(_ref2) {
|
|
|
110
145
|
const {
|
|
111
146
|
themeHasDisabledLayoutStyles,
|
|
112
147
|
themeSupportsLayout,
|
|
113
|
-
assets
|
|
114
|
-
useRootPaddingAwareAlignments
|
|
148
|
+
assets
|
|
115
149
|
} = useSelect(select => {
|
|
116
|
-
var _settings$__experimen;
|
|
117
|
-
|
|
118
150
|
const _settings = select(blockEditorStore).getSettings();
|
|
119
151
|
|
|
120
152
|
return {
|
|
121
153
|
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
122
154
|
themeSupportsLayout: _settings.supportsLayout,
|
|
123
|
-
assets: _settings.__unstableResolvedAssets
|
|
124
|
-
useRootPaddingAwareAlignments: (_settings$__experimen = _settings.__experimentalFeatures) === null || _settings$__experimen === void 0 ? void 0 : _settings$__experimen.useRootPaddingAwareAlignments
|
|
155
|
+
assets: _settings.__unstableResolvedAssets
|
|
125
156
|
};
|
|
126
157
|
}, []);
|
|
127
158
|
const {
|
|
@@ -146,7 +177,7 @@ export default function VisualEditor(_ref2) {
|
|
|
146
177
|
borderBottom: 0
|
|
147
178
|
};
|
|
148
179
|
const resizedCanvasStyles = useResizeCanvas(deviceType, isTemplateMode);
|
|
149
|
-
const
|
|
180
|
+
const globalLayoutSettings = useSetting('layout');
|
|
150
181
|
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
151
182
|
let animatedStyles = isTemplateMode ? templateModeStyles : desktopCanvasStyles;
|
|
152
183
|
|
|
@@ -163,8 +194,10 @@ export default function VisualEditor(_ref2) {
|
|
|
163
194
|
|
|
164
195
|
const ref = useRef();
|
|
165
196
|
const contentRef = useMergeRefs([ref, useClipboardHandler(), useTypewriter(), useTypingObserver(), useBlockSelectionClearer()]);
|
|
166
|
-
const blockSelectionClearerRef = useBlockSelectionClearer();
|
|
167
|
-
|
|
197
|
+
const blockSelectionClearerRef = useBlockSelectionClearer(); // fallbackLayout is used if there is no Post Content,
|
|
198
|
+
// and for Post Title.
|
|
199
|
+
|
|
200
|
+
const fallbackLayout = useMemo(() => {
|
|
168
201
|
if (isTemplateMode) {
|
|
169
202
|
return {
|
|
170
203
|
type: 'default'
|
|
@@ -174,7 +207,7 @@ export default function VisualEditor(_ref2) {
|
|
|
174
207
|
if (themeSupportsLayout) {
|
|
175
208
|
// We need to ensure support for wide and full alignments,
|
|
176
209
|
// so we add the constrained type.
|
|
177
|
-
return { ...
|
|
210
|
+
return { ...globalLayoutSettings,
|
|
178
211
|
type: 'constrained'
|
|
179
212
|
};
|
|
180
213
|
} // Set default layout for classic themes so all alignments are supported.
|
|
@@ -183,12 +216,37 @@ export default function VisualEditor(_ref2) {
|
|
|
183
216
|
return {
|
|
184
217
|
type: 'default'
|
|
185
218
|
};
|
|
186
|
-
}, [isTemplateMode, themeSupportsLayout,
|
|
219
|
+
}, [isTemplateMode, themeSupportsLayout, globalLayoutSettings]);
|
|
220
|
+
const postContentBlock = useMemo(() => {
|
|
221
|
+
// When in template editing mode, we can access the blocks directly.
|
|
222
|
+
if (editedPostTemplate !== null && editedPostTemplate !== void 0 && editedPostTemplate.blocks) {
|
|
223
|
+
return findPostContent(editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.blocks);
|
|
224
|
+
} // If there are no blocks, we have to parse the content string.
|
|
225
|
+
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
const parseableContent = typeof (editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.content) === 'string' ? editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.content : '';
|
|
229
|
+
return findPostContent(parse(parseableContent)) || {};
|
|
230
|
+
}, [editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.content, editedPostTemplate === null || editedPostTemplate === void 0 ? void 0 : editedPostTemplate.blocks]);
|
|
231
|
+
const postContentLayoutClasses = useLayoutClasses(postContentBlock);
|
|
187
232
|
const blockListLayoutClass = classnames({
|
|
188
|
-
'is-layout-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
233
|
+
'is-layout-flow': !themeSupportsLayout
|
|
234
|
+
}, themeSupportsLayout && postContentLayoutClasses);
|
|
235
|
+
const postContentLayoutStyles = useLayoutStyles(postContentBlock, '.block-editor-block-list__layout.is-root-container');
|
|
236
|
+
const layout = (postContentBlock === null || postContentBlock === void 0 ? void 0 : (_postContentBlock$att = postContentBlock.attributes) === null || _postContentBlock$att === void 0 ? void 0 : _postContentBlock$att.layout) || {}; // Update type for blocks using legacy layouts.
|
|
237
|
+
|
|
238
|
+
const postContentLayout = useMemo(() => {
|
|
239
|
+
return layout && ((layout === null || layout === void 0 ? void 0 : layout.type) === 'constrained' || layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize) ? { ...globalLayoutSettings,
|
|
240
|
+
...layout,
|
|
241
|
+
type: 'constrained'
|
|
242
|
+
} : { ...globalLayoutSettings,
|
|
243
|
+
...layout,
|
|
244
|
+
type: 'default'
|
|
245
|
+
};
|
|
246
|
+
}, [layout === null || layout === void 0 ? void 0 : layout.type, layout === null || layout === void 0 ? void 0 : layout.inherit, layout === null || layout === void 0 ? void 0 : layout.contentSize, layout === null || layout === void 0 ? void 0 : layout.wideSize, globalLayoutSettings]); // If there is a Post Content block we use its layout for the block list;
|
|
247
|
+
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
248
|
+
|
|
249
|
+
const blockListLayout = postContentBlock ? postContentLayout : fallbackLayout;
|
|
192
250
|
const titleRef = useRef();
|
|
193
251
|
useEffect(() => {
|
|
194
252
|
var _titleRef$current;
|
|
@@ -229,11 +287,15 @@ export default function VisualEditor(_ref2) {
|
|
|
229
287
|
style: {
|
|
230
288
|
paddingBottom
|
|
231
289
|
}
|
|
232
|
-
}, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && createElement(LayoutStyle, {
|
|
290
|
+
}, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && createElement(Fragment, null, createElement(LayoutStyle, {
|
|
233
291
|
selector: ".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container",
|
|
234
|
-
layout:
|
|
235
|
-
layoutDefinitions:
|
|
236
|
-
}),
|
|
292
|
+
layout: fallbackLayout,
|
|
293
|
+
layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions
|
|
294
|
+
}), postContentLayoutStyles && createElement(LayoutStyle, {
|
|
295
|
+
layout: postContentLayout,
|
|
296
|
+
css: postContentLayoutStyles,
|
|
297
|
+
layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions
|
|
298
|
+
})), !isTemplateMode && createElement("div", {
|
|
237
299
|
className: "edit-post-visual-editor__post-title-wrapper",
|
|
238
300
|
contentEditable: false
|
|
239
301
|
}, createElement(PostTitle, {
|
|
@@ -244,7 +306,7 @@ export default function VisualEditor(_ref2) {
|
|
|
244
306
|
}, createElement(BlockList, {
|
|
245
307
|
className: isTemplateMode ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
246
308
|
,
|
|
247
|
-
__experimentalLayout:
|
|
309
|
+
__experimentalLayout: blockListLayout
|
|
248
310
|
}))))), createElement(__unstableBlockSettingsMenuFirstItem, null, _ref3 => {
|
|
249
311
|
let {
|
|
250
312
|
onClose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"names":["classnames","VisualEditorGlobalKeyboardShortcuts","PostTitle","store","editorStore","WritingFlow","BlockList","BlockTools","blockEditorStore","__unstableUseBlockSelectionClearer","useBlockSelectionClearer","__unstableUseTypewriter","useTypewriter","__unstableUseClipboardHandler","useClipboardHandler","__unstableUseTypingObserver","useTypingObserver","__unstableBlockSettingsMenuFirstItem","__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","useSetting","__experimentalLayoutStyle","LayoutStyle","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","__unstableIframe","Iframe","__experimentalRecursionProvider","RecursionProvider","useEffect","useRef","useMemo","Button","__unstableMotion","motion","useSelect","useDispatch","useMergeRefs","arrowLeft","__","BlockInspectorButton","editPostStore","MaybeIframe","children","contentRef","shouldIframe","styles","assets","style","ref","flex","width","height","display","VisualEditor","deviceType","isWelcomeGuideVisible","isTemplateMode","wrapperBlockName","wrapperUniqueId","select","isFeatureActive","isEditingTemplate","__experimentalGetPreviewDeviceType","getCurrentPostId","getCurrentPostType","_isTemplateMode","_wrapperBlockName","isCleanNewPost","hasMetaBoxes","themeHasDisabledLayoutStyles","themeSupportsLayout","useRootPaddingAwareAlignments","_settings","getSettings","disableLayoutStyles","supportsLayout","__unstableResolvedAssets","__experimentalFeatures","clearSelectedBlock","setIsEditingTemplate","desktopCanvasStyles","margin","flexFlow","background","templateModeStyles","borderRadius","border","borderBottom","resizedCanvasStyles","defaultLayout","previewMode","toLowerCase","animatedStyles","paddingBottom","blockSelectionClearerRef","layout","type","blockListLayoutClass","titleRef","current","focus","padding","definitions","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,mCADD,EAECC,SAFD,EAGCC,KAAK,IAAIC,WAHV,QAIO,mBAJP;AAKA,SACCC,WADD,EAECC,SAFD,EAGCC,UAHD,EAICJ,KAAK,IAAIK,gBAJV,EAKCC,kCAAkC,IAAIC,wBALvC,EAMCC,uBAAuB,IAAIC,aAN5B,EAOCC,6BAA6B,IAAIC,mBAPlC,EAQCC,2BAA2B,IAAIC,iBARhC,EASCC,oCATD,EAUCC,6BAA6B,IAAIC,eAVlC,EAWCC,sBAAsB,IAAIC,YAX3B,EAYCC,UAZD,EAaCC,yBAAyB,IAAIC,WAb9B,EAcCC,iCAAiC,IAAIC,uBAdtC,EAeCC,gBAAgB,IAAIC,MAfrB,EAgBCC,+BAA+B,IAAIC,iBAhBpC,QAiBO,yBAjBP;AAkBA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,OAA5B,QAA2C,oBAA3C;AACA,SAASC,MAAT,EAAiBC,gBAAgB,IAAIC,MAArC,QAAmD,uBAAnD;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,SAASvC,KAAK,IAAIwC,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,WAAT,OAOI;AAAA,MAPkB;A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CAPD,EA6EC,cAAC,oCAAD,QACG;AAAA,QAAE;AAAEQ,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,oBAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CA7ED,CADD;AAqFA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tVisualEditorGlobalKeyboardShortcuts,\n\tPostTitle,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport {\n\tWritingFlow,\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n\t__unstableUseBlockSelectionClearer as useBlockSelectionClearer,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\tuseSetting,\n\t__experimentalLayoutStyle as LayoutStyle,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\t__unstableIframe as Iframe,\n\t__experimentalRecursionProvider as RecursionProvider,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { Button, __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { arrowLeft } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from './block-inspector-button';\nimport { store as editPostStore } from '../../store';\n\nfunction MaybeIframe( {\n\tchildren,\n\tcontentRef,\n\tshouldIframe,\n\tstyles,\n\tassets,\n\tstyle,\n} ) {\n\tconst ref = useMouseMoveTypingReset();\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\tstyle={ { flex: '1', ...style } }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Iframe\n\t\t\thead={ <EditorStyles styles={ styles } /> }\n\t\t\tassets={ assets }\n\t\t\tref={ ref }\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyle={ { width: '100%', height: '100%', display: 'block' } }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tdeviceType,\n\t\tisWelcomeGuideVisible,\n\t\tisTemplateMode,\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tisEditingTemplate,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t} = select( editPostStore );\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( getCurrentPostType() === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _isTemplateMode ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\tconst {\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t\tassets,\n\t\tuseRootPaddingAwareAlignments,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\tassets: _settings.__unstableResolvedAssets,\n\t\t\tuseRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst desktopCanvasStyles = {\n\t\theight: '100%',\n\t\twidth: '100%',\n\t\tmargin: 0,\n\t\tdisplay: 'flex',\n\t\tflexFlow: 'column',\n\t\t// Default background color so that grey\n\t\t// .edit-post-editor-regions__content color doesn't show through.\n\t\tbackground: 'white',\n\t};\n\tconst templateModeStyles = {\n\t\t...desktopCanvasStyles,\n\t\tborderRadius: '2px 2px 0 0',\n\t\tborder: '1px solid #ddd',\n\t\tborderBottom: 0,\n\t};\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );\n\tconst defaultLayout = useSetting( 'layout' );\n\tconst previewMode = 'is-' + deviceType.toLowerCase() + '-preview';\n\n\tlet animatedStyles = isTemplateMode\n\t\t? templateModeStyles\n\t\t: desktopCanvasStyles;\n\tif ( resizedCanvasStyles ) {\n\t\tanimatedStyles = resizedCanvasStyles;\n\t}\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && ! resizedCanvasStyles && ! isTemplateMode ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tconst ref = useRef();\n\tconst contentRef = useMergeRefs( [\n\t\tref,\n\t\tuseClipboardHandler(),\n\t\tuseTypewriter(),\n\t\tuseTypingObserver(),\n\t\tuseBlockSelectionClearer(),\n\t] );\n\n\tconst blockSelectionClearerRef = useBlockSelectionClearer();\n\n\tconst layout = useMemo( () => {\n\t\tif ( isTemplateMode ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...defaultLayout, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ isTemplateMode, themeSupportsLayout, defaultLayout ] );\n\n\tconst blockListLayoutClass = classnames( {\n\t\t'is-layout-constrained': themeSupportsLayout,\n\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t'has-global-padding': useRootPaddingAwareAlignments,\n\t} );\n\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible, isCleanNewPost ] );\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ ref }\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': isTemplateMode,\n\t\t\t} ) }\n\t\t>\n\t\t\t<VisualEditorGlobalKeyboardShortcuts />\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-post-visual-editor__content-area\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tpadding: isTemplateMode ? '48px 48px 0' : '0',\n\t\t\t\t} }\n\t\t\t\tref={ blockSelectionClearerRef }\n\t\t\t>\n\t\t\t\t{ isTemplateMode && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-post-visual-editor__exit-template-mode\"\n\t\t\t\t\t\ticon={ arrowLeft }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<motion.div\n\t\t\t\t\tanimate={ animatedStyles }\n\t\t\t\t\tinitial={ desktopCanvasStyles }\n\t\t\t\t\tclassName={ previewMode }\n\t\t\t\t>\n\t\t\t\t\t<MaybeIframe\n\t\t\t\t\t\tshouldIframe={\n\t\t\t\t\t\t\tisTemplateMode ||\n\t\t\t\t\t\t\tdeviceType === 'Tablet' ||\n\t\t\t\t\t\t\tdeviceType === 'Mobile'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\tstyles={ styles }\n\t\t\t\t\t\tassets={ assets }\n\t\t\t\t\t\tstyle={ { paddingBottom } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\t\t! isTemplateMode && (\n\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\tselector=\".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\t\tlayoutDefinitions={\n\t\t\t\t\t\t\t\t\t\tdefaultLayout?.definitions\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"edit-post-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tisTemplateMode\n\t\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RecursionProvider>\n\t\t\t\t\t</MaybeIframe>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</BlockTools>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"names":["classnames","VisualEditorGlobalKeyboardShortcuts","PostTitle","store","editorStore","WritingFlow","BlockList","BlockTools","blockEditorStore","__unstableUseBlockSelectionClearer","useBlockSelectionClearer","__unstableUseTypewriter","useTypewriter","__unstableUseClipboardHandler","useClipboardHandler","__unstableUseTypingObserver","useTypingObserver","__unstableBlockSettingsMenuFirstItem","__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","useSetting","__experimentalLayoutStyle","LayoutStyle","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","__unstableIframe","Iframe","__experimentalRecursionProvider","RecursionProvider","__experimentaluseLayoutClasses","useLayoutClasses","__experimentaluseLayoutStyles","useLayoutStyles","useEffect","useRef","useMemo","Button","__unstableMotion","motion","useSelect","useDispatch","useMergeRefs","arrowLeft","__","parse","BlockInspectorButton","editPostStore","MaybeIframe","children","contentRef","shouldIframe","styles","assets","style","ref","flex","width","height","display","findPostContent","blocks","i","length","name","innerBlocks","nestedPostContent","VisualEditor","deviceType","isWelcomeGuideVisible","isTemplateMode","editedPostTemplate","wrapperBlockName","wrapperUniqueId","select","isFeatureActive","isEditingTemplate","__experimentalGetPreviewDeviceType","getEditedPostTemplate","getCurrentPostId","getCurrentPostType","getEditorSettings","_isTemplateMode","_wrapperBlockName","supportsTemplateMode","isCleanNewPost","hasMetaBoxes","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","getSettings","disableLayoutStyles","supportsLayout","__unstableResolvedAssets","clearSelectedBlock","setIsEditingTemplate","desktopCanvasStyles","margin","flexFlow","background","templateModeStyles","borderRadius","border","borderBottom","resizedCanvasStyles","globalLayoutSettings","previewMode","toLowerCase","animatedStyles","paddingBottom","blockSelectionClearerRef","fallbackLayout","type","postContentBlock","parseableContent","content","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","layout","attributes","postContentLayout","inherit","contentSize","wideSize","blockListLayout","titleRef","current","focus","padding","definitions","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,mCADD,EAECC,SAFD,EAGCC,KAAK,IAAIC,WAHV,QAIO,mBAJP;AAKA,SACCC,WADD,EAECC,SAFD,EAGCC,UAHD,EAICJ,KAAK,IAAIK,gBAJV,EAKCC,kCAAkC,IAAIC,wBALvC,EAMCC,uBAAuB,IAAIC,aAN5B,EAOCC,6BAA6B,IAAIC,mBAPlC,EAQCC,2BAA2B,IAAIC,iBARhC,EASCC,oCATD,EAUCC,6BAA6B,IAAIC,eAVlC,EAWCC,sBAAsB,IAAIC,YAX3B,EAYCC,UAZD,EAaCC,yBAAyB,IAAIC,WAb9B,EAcCC,iCAAiC,IAAIC,uBAdtC,EAeCC,gBAAgB,IAAIC,MAfrB,EAgBCC,+BAA+B,IAAIC,iBAhBpC,EAiBCC,8BAA8B,IAAIC,gBAjBnC,EAkBCC,6BAA6B,IAAIC,eAl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gB,aAChBA,oBADgB,uBAChBA,oBAAoB,CAAEyB;AAJxB,IADD,EAQGZ,uBAAuB,IACxB,cAAC,WAAD;AACC,IAAA,MAAM,EAAGG,iBADV;AAEC,IAAA,GAAG,EAAGH,uBAFP;AAGC,IAAA,iBAAiB,EAChBb,oBADgB,aAChBA,oBADgB,uBAChBA,oBAAoB,CAAEyB;AAJxB,IATF,CAdH,EAiCG,CAAE5D,cAAF,IACD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,eAAe,EAAG;AAFnB,KAIC,cAAC,SAAD;AAAW,IAAA,GAAG,EAAGwD;AAAjB,IAJD,CAlCF,EAyCC,cAAC,iBAAD;AACC,IAAA,SAAS,EAAGtD,gBADb;AAEC,IAAA,QAAQ,EAAGC;AAFZ,KAIC,cAAC,SAAD;AACC,IAAA,SAAS,EACRH,cAAc,GACX,gBADW,GAEV,GAAG+C,oBAAsB,wBAHrB,CAG6C;AAJvD;AAMC,IAAA,oBAAoB,EAAGQ;AANxB,IAJD,CAzCD,CALD,CAnBD,CAPD,EAwFC,cAAC,oCAAD,QACG;AAAA,QAAE;AAAEM,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,oBAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CAxFD,CADD;AAgGA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tVisualEditorGlobalKeyboardShortcuts,\n\tPostTitle,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport {\n\tWritingFlow,\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n\t__unstableUseBlockSelectionClearer as useBlockSelectionClearer,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\tuseSetting,\n\t__experimentalLayoutStyle as LayoutStyle,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\t__unstableIframe as Iframe,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentaluseLayoutClasses as useLayoutClasses,\n\t__experimentaluseLayoutStyles as useLayoutStyles,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { Button, __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { arrowLeft } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from './block-inspector-button';\nimport { store as editPostStore } from '../../store';\n\nfunction MaybeIframe( {\n\tchildren,\n\tcontentRef,\n\tshouldIframe,\n\tstyles,\n\tassets,\n\tstyle,\n} ) {\n\tconst ref = useMouseMoveTypingReset();\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\tstyle={ { flex: '1', ...style } }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Iframe\n\t\t\thead={ <EditorStyles styles={ styles } /> }\n\t\t\tassets={ assets }\n\t\t\tref={ ref }\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyle={ { width: '100%', height: '100%', display: 'block' } }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object} The Post Content block.\n */\nfunction findPostContent( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ];\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = findPostContent(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tdeviceType,\n\t\tisWelcomeGuideVisible,\n\t\tisTemplateMode,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tisEditingTemplate,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetEditedPostTemplate,\n\t\t} = select( editPostStore );\n\t\tconst { getCurrentPostId, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( getCurrentPostType() === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _isTemplateMode ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst supportsTemplateMode = getEditorSettings().supportsTemplateMode;\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so we check it's a block theme first.\n\t\t\teditedPostTemplate: supportsTemplateMode\n\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t: {},\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\tconst { themeHasDisabledLayoutStyles, themeSupportsLayout, assets } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\t\treturn {\n\t\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\t\tassets: _settings.__unstableResolvedAssets,\n\t\t\t};\n\t\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst desktopCanvasStyles = {\n\t\theight: '100%',\n\t\twidth: '100%',\n\t\tmargin: 0,\n\t\tdisplay: 'flex',\n\t\tflexFlow: 'column',\n\t\t// Default background color so that grey\n\t\t// .edit-post-editor-regions__content color doesn't show through.\n\t\tbackground: 'white',\n\t};\n\tconst templateModeStyles = {\n\t\t...desktopCanvasStyles,\n\t\tborderRadius: '2px 2px 0 0',\n\t\tborder: '1px solid #ddd',\n\t\tborderBottom: 0,\n\t};\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );\n\tconst globalLayoutSettings = useSetting( 'layout' );\n\tconst previewMode = 'is-' + deviceType.toLowerCase() + '-preview';\n\n\tlet animatedStyles = isTemplateMode\n\t\t? templateModeStyles\n\t\t: desktopCanvasStyles;\n\tif ( resizedCanvasStyles ) {\n\t\tanimatedStyles = resizedCanvasStyles;\n\t}\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && ! resizedCanvasStyles && ! isTemplateMode ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tconst ref = useRef();\n\tconst contentRef = useMergeRefs( [\n\t\tref,\n\t\tuseClipboardHandler(),\n\t\tuseTypewriter(),\n\t\tuseTypingObserver(),\n\t\tuseBlockSelectionClearer(),\n\t] );\n\n\tconst blockSelectionClearerRef = useBlockSelectionClearer();\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( isTemplateMode ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst postContentBlock = useMemo( () => {\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn findPostContent( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn findPostContent( parse( parseableContent ) ) || {};\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst postContentLayoutClasses = useLayoutClasses( postContentBlock );\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tpostContentBlock,\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\tconst layout = postContentBlock?.attributes?.layout || {};\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentBlock\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible, isCleanNewPost ] );\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ ref }\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': isTemplateMode,\n\t\t\t} ) }\n\t\t>\n\t\t\t<VisualEditorGlobalKeyboardShortcuts />\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-post-visual-editor__content-area\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tpadding: isTemplateMode ? '48px 48px 0' : '0',\n\t\t\t\t} }\n\t\t\t\tref={ blockSelectionClearerRef }\n\t\t\t>\n\t\t\t\t{ isTemplateMode && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-post-visual-editor__exit-template-mode\"\n\t\t\t\t\t\ticon={ arrowLeft }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<motion.div\n\t\t\t\t\tanimate={ animatedStyles }\n\t\t\t\t\tinitial={ desktopCanvasStyles }\n\t\t\t\t\tclassName={ previewMode }\n\t\t\t\t>\n\t\t\t\t\t<MaybeIframe\n\t\t\t\t\t\tshouldIframe={\n\t\t\t\t\t\t\tisTemplateMode ||\n\t\t\t\t\t\t\tdeviceType === 'Tablet' ||\n\t\t\t\t\t\t\tdeviceType === 'Mobile'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\tstyles={ styles }\n\t\t\t\t\t\tassets={ assets }\n\t\t\t\t\t\tstyle={ { paddingBottom } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\t\t! isTemplateMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tselector=\".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t\t\t\t\tlayoutDefinitions={\n\t\t\t\t\t\t\t\t\t\t\tglobalLayoutSettings?.definitions\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\n\t\t\t\t\t\t\t\t\t\t\tlayoutDefinitions={\n\t\t\t\t\t\t\t\t\t\t\t\tglobalLayoutSettings?.definitions\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"edit-post-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tisTemplateMode\n\t\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__experimentalLayout={ blockListLayout }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RecursionProvider>\n\t\t\t\t\t</MaybeIframe>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</BlockTools>\n\t);\n}\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -56,15 +56,6 @@ export function reinitializeEditor(postType, postId, target, settings, initialEd
|
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
58
|
export function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
59
|
-
// Prevent adding template part in the post editor.
|
|
60
|
-
// Only add the filter when the post editor is initialized, not imported.
|
|
61
|
-
addFilter('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (can, blockType) => {
|
|
62
|
-
if (!select(editPostStore).isEditingTemplate() && blockType.name === 'core/template-part') {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return can;
|
|
67
|
-
});
|
|
68
59
|
const target = document.getElementById(id);
|
|
69
60
|
const reboot = reinitializeEditor.bind(null, postType, postId, target, settings, initialEdits);
|
|
70
61
|
dispatch(preferencesStore).setDefaults('core/edit-post', {
|
|
@@ -97,8 +88,22 @@ export function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
97
88
|
__experimentalRegisterExperimentalCoreBlocks({
|
|
98
89
|
enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks
|
|
99
90
|
});
|
|
100
|
-
}
|
|
91
|
+
}
|
|
92
|
+
/*
|
|
93
|
+
* Prevent adding template part in the post editor.
|
|
94
|
+
* Only add the filter when the post editor is initialized, not imported.
|
|
95
|
+
* Also only add the filter(s) after registerCoreBlocks()
|
|
96
|
+
* so that common filters in the block library are not overwritten.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
addFilter('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
|
|
101
|
+
if (!select(editPostStore).isEditingTemplate() && blockType.name === 'core/template-part') {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
101
104
|
|
|
105
|
+
return canInsert;
|
|
106
|
+
}); // Show a console log warning if the browser is not in Standards rendering mode.
|
|
102
107
|
|
|
103
108
|
const documentMode = document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
|
|
104
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","render","unmountComponentAtNode","dispatch","select","addFilter","preferencesStore","Editor","editPostStore","reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","can","blockType","isEditingTemplate","name","document","getElementById","setDefaults","editorMode","fixedToolbar","fullscreenMode","hiddenBlockTypes","inactivePanels","isPublishSidebarEnabled","openPanels","preferredStyleVariations","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","themeStyles","welcomeGuide","welcomeGuideTemplate","__experimentalReapplyBlockTypeFilters","isFeatureActive","setIsListViewOpened","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault","default","PluginBlockSettingsMenuItem","PluginDocumentSettingPanel","PluginMoreMenuItem","PluginPostPublishPanel","PluginPostStatusInfo","PluginPrePublishPanel","PluginSidebar","PluginSidebarMoreMenuItem","__experimentalFullscreenModeClose","__experimentalMainDashboardButton"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,iBAAjC;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASR,KAAK,IAAIS,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,SAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CACNC,QADM,EAENC,MAFM,EAGNC,MAHM,EAINC,QAJM,EAKNC,YALM,EAML;AACDZ,EAAAA,sBAAsB,CAAEU,MAAF,CAAtB;AACA,QAAMG,MAAM,GAAGN,kBAAkB,CAACO,IAAnB,CACd,IADc,EAEdN,QAFc,EAGdC,MAHc,EAIdC,MAJc,EAKdC,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AApB,QAA6D,2CAA7D;AACA,SAAST,OAAO,IAAIU,iCAApB,QAA6D,2CAA7D;AACA,SAAS/E,KAAT,QAAsB,SAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\t// Prevent adding template part in the post editor.\n\t// Only add the filter when the post editor is initialized, not imported.\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( can, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn can;\n\t\t}\n\t);\n\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfullscreenMode: true,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\tisPublishSidebarEnabled: true,\n\t\topenPanels: [ 'post-status' ],\n\t\tpreferredStyleVariations: {},\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\tif ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {\n\t\tdispatch( editPostStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","render","unmountComponentAtNode","dispatch","select","addFilter","preferencesStore","Editor","editPostStore","reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","document","getElementById","setDefaults","editorMode","fixedToolbar","fullscreenMode","hiddenBlockTypes","inactivePanels","isPublishSidebarEnabled","openPanels","preferredStyleVariations","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","themeStyles","welcomeGuide","welcomeGuideTemplate","__experimentalReapplyBlockTypeFilters","isFeatureActive","setIsListViewOpened","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","canInsert","blockType","isEditingTemplate","name","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault","default","PluginBlockSettingsMenuItem","PluginDocumentSettingPanel","PluginMoreMenuItem","PluginPostPublishPanel","PluginPostStatusInfo","PluginPrePublishPanel","PluginSidebar","PluginSidebarMoreMenuItem","__experimentalFullscreenModeClose","__experimentalMainDashboardButton"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,iBAAjC;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASR,KAAK,IAAIS,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,SAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CACNC,QADM,EAENC,MAFM,EAGNC,MAHM,EAINC,QAJM,EAKNC,YALM,EAML;AACDZ,EAAAA,sBAAsB,CAAEU,MAAF,CAAtB;AACA,QAAMG,MAAM,GAAGN,kBAAkB,CAACO,IAAnB,CACd,IADc,EAEdN,QAFc,EAGdC,MAHc,EAIdC,MAJc,EAKdC,QALc,EAMdC,YANc,CAAf;AASAb,EAAAA,MAAM,CACL,cAAC,MAAD;AACC,IAAA,QAAQ,EAAGY,QADZ;AAEC,IAAA,OAAO,EAAGE,MAFX;AAGC,IAAA,MAAM,EAAGJ,MAHV;AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,YAAY,EAAGI,YALhB;AAMC,IAAA,QAAQ;AANT,IADK,EASLF,MATK,CAAN;AAWA;AAED;AACA;AACA;AACA;AACA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ArD,CADD,EAEE;AACDP,UAAAA,MAAM,CAACU,QAAP,CAAiB,CAAjB,EAAoB,CAApB;AACA;AACD;AACD,KAlBD;AAmBA,GApGA,CAsGD;;;AACAV,EAAAA,MAAM,CAACI,gBAAP,CAAyB,UAAzB,EAAuCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAZ,EAAAA,MAAM,CAACI,gBAAP,CAAyB,MAAzB,EAAmCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEAhE,EAAAA,MAAM,CACL,cAAC,MAAD;AACC,IAAA,QAAQ,EAAGY,QADZ;AAEC,IAAA,OAAO,EAAGE,MAFX;AAGC,IAAA,MAAM,EAAGJ,MAHV;AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,YAAY,EAAGI;AALhB,IADK,EAQLF,MARK,CAAN;AAUA;AAED,SAASsD,OAAO,IAAIC,2BAApB,QAAuD,kEAAvD;AACA,SAASD,OAAO,IAAIE,0BAApB,QAAsD,oDAAtD;AACA,SAASF,OAAO,IAAIG,kBAApB,QAA8C,2CAA9C;AACA,SAASH,OAAO,IAAII,sBAApB,QAAkD,gDAAlD;AACA,SAASJ,OAAO,IAAIK,oBAApB,QAAgD,8CAAhD;AACA,SAASL,OAAO,IAAIM,qBAApB,QAAiD,+CAAjD;AACA,SAASN,OAAO,IAAIO,aAApB,QAAyC,qCAAzC;AACA,SAASP,OAAO,IAAIQ,yBAApB,QAAqD,mDAArD;AACA,SAASR,OAAO,IAAIS,iCAApB,QAA6D,2CAA7D;AACA,SAAST,OAAO,IAAIU,iCAApB,QAA6D,2CAA7D;AACA,SAAS/E,KAAT,QAAsB,SAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfullscreenMode: true,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\tisPublishSidebarEnabled: true,\n\t\topenPanels: [ 'post-status' ],\n\t\tpreferredStyleVariations: {},\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\tif ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {\n\t\tdispatch( editPostStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t/*\n\t * Prevent adding template part in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( canInsert, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "6.14.
|
|
3
|
+
"version": "6.14.4",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,28 +29,28 @@
|
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@wordpress/a11y": "^3.17.1",
|
|
31
31
|
"@wordpress/api-fetch": "^6.14.1",
|
|
32
|
-
"@wordpress/block-editor": "^10.0.
|
|
33
|
-
"@wordpress/block-library": "^7.14.
|
|
34
|
-
"@wordpress/blocks": "^11.16.
|
|
35
|
-
"@wordpress/components": "^21.0.
|
|
32
|
+
"@wordpress/block-editor": "^10.0.4",
|
|
33
|
+
"@wordpress/block-library": "^7.14.4",
|
|
34
|
+
"@wordpress/blocks": "^11.16.4",
|
|
35
|
+
"@wordpress/components": "^21.0.4",
|
|
36
36
|
"@wordpress/compose": "^5.15.2",
|
|
37
|
-
"@wordpress/core-data": "^5.0.
|
|
38
|
-
"@wordpress/data": "^7.1.
|
|
37
|
+
"@wordpress/core-data": "^5.0.4",
|
|
38
|
+
"@wordpress/data": "^7.1.3",
|
|
39
39
|
"@wordpress/deprecated": "^3.17.1",
|
|
40
|
-
"@wordpress/editor": "^12.16.
|
|
40
|
+
"@wordpress/editor": "^12.16.4",
|
|
41
41
|
"@wordpress/element": "^4.15.1",
|
|
42
42
|
"@wordpress/hooks": "^3.17.1",
|
|
43
43
|
"@wordpress/i18n": "^4.17.1",
|
|
44
44
|
"@wordpress/icons": "^9.8.1",
|
|
45
|
-
"@wordpress/interface": "^4.16.
|
|
46
|
-
"@wordpress/keyboard-shortcuts": "^3.15.
|
|
45
|
+
"@wordpress/interface": "^4.16.4",
|
|
46
|
+
"@wordpress/keyboard-shortcuts": "^3.15.3",
|
|
47
47
|
"@wordpress/keycodes": "^3.17.1",
|
|
48
48
|
"@wordpress/media-utils": "^4.8.1",
|
|
49
|
-
"@wordpress/notices": "^3.17.
|
|
49
|
+
"@wordpress/notices": "^3.17.3",
|
|
50
50
|
"@wordpress/plugins": "^4.15.2",
|
|
51
|
-
"@wordpress/preferences": "^2.9.
|
|
51
|
+
"@wordpress/preferences": "^2.9.4",
|
|
52
52
|
"@wordpress/url": "^3.18.1",
|
|
53
|
-
"@wordpress/viewport": "^4.15.
|
|
53
|
+
"@wordpress/viewport": "^4.15.3",
|
|
54
54
|
"@wordpress/warning": "^2.17.1",
|
|
55
55
|
"classnames": "^2.3.1",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "491b4b522dffb4d25aca066ec55500f456ac4aa3"
|
|
68
68
|
}
|
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,
|
|
29
29
|
__unstableIframe as Iframe,
|
|
30
30
|
__experimentalRecursionProvider as RecursionProvider,
|
|
31
|
+
__experimentaluseLayoutClasses as useLayoutClasses,
|
|
32
|
+
__experimentaluseLayoutStyles as useLayoutStyles,
|
|
31
33
|
} from '@wordpress/block-editor';
|
|
32
34
|
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
33
35
|
import { Button, __unstableMotion as motion } from '@wordpress/components';
|
|
@@ -35,6 +37,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
35
37
|
import { useMergeRefs } from '@wordpress/compose';
|
|
36
38
|
import { arrowLeft } from '@wordpress/icons';
|
|
37
39
|
import { __ } from '@wordpress/i18n';
|
|
40
|
+
import { parse } from '@wordpress/blocks';
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
* Internal dependencies
|
|
@@ -82,11 +85,37 @@ function MaybeIframe( {
|
|
|
82
85
|
);
|
|
83
86
|
}
|
|
84
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Given an array of nested blocks, find the first Post Content
|
|
90
|
+
* block inside it, recursing through any nesting levels.
|
|
91
|
+
*
|
|
92
|
+
* @param {Array} blocks A list of blocks.
|
|
93
|
+
*
|
|
94
|
+
* @return {Object} The Post Content block.
|
|
95
|
+
*/
|
|
96
|
+
function findPostContent( blocks ) {
|
|
97
|
+
for ( let i = 0; i < blocks.length; i++ ) {
|
|
98
|
+
if ( blocks[ i ].name === 'core/post-content' ) {
|
|
99
|
+
return blocks[ i ];
|
|
100
|
+
}
|
|
101
|
+
if ( blocks[ i ].innerBlocks.length ) {
|
|
102
|
+
const nestedPostContent = findPostContent(
|
|
103
|
+
blocks[ i ].innerBlocks
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if ( nestedPostContent ) {
|
|
107
|
+
return nestedPostContent;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
85
113
|
export default function VisualEditor( { styles } ) {
|
|
86
114
|
const {
|
|
87
115
|
deviceType,
|
|
88
116
|
isWelcomeGuideVisible,
|
|
89
117
|
isTemplateMode,
|
|
118
|
+
editedPostTemplate = {},
|
|
90
119
|
wrapperBlockName,
|
|
91
120
|
wrapperUniqueId,
|
|
92
121
|
} = useSelect( ( select ) => {
|
|
@@ -94,8 +123,10 @@ export default function VisualEditor( { styles } ) {
|
|
|
94
123
|
isFeatureActive,
|
|
95
124
|
isEditingTemplate,
|
|
96
125
|
__experimentalGetPreviewDeviceType,
|
|
126
|
+
getEditedPostTemplate,
|
|
97
127
|
} = select( editPostStore );
|
|
98
|
-
const { getCurrentPostId, getCurrentPostType } =
|
|
128
|
+
const { getCurrentPostId, getCurrentPostType, getEditorSettings } =
|
|
129
|
+
select( editorStore );
|
|
99
130
|
const _isTemplateMode = isEditingTemplate();
|
|
100
131
|
let _wrapperBlockName;
|
|
101
132
|
|
|
@@ -105,10 +136,17 @@ export default function VisualEditor( { styles } ) {
|
|
|
105
136
|
_wrapperBlockName = 'core/post-content';
|
|
106
137
|
}
|
|
107
138
|
|
|
139
|
+
const supportsTemplateMode = getEditorSettings().supportsTemplateMode;
|
|
140
|
+
|
|
108
141
|
return {
|
|
109
142
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
110
143
|
isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
|
|
111
144
|
isTemplateMode: _isTemplateMode,
|
|
145
|
+
// Post template fetch returns a 404 on classic themes, which
|
|
146
|
+
// messes with e2e tests, so we check it's a block theme first.
|
|
147
|
+
editedPostTemplate: supportsTemplateMode
|
|
148
|
+
? getEditedPostTemplate()
|
|
149
|
+
: {},
|
|
112
150
|
wrapperBlockName: _wrapperBlockName,
|
|
113
151
|
wrapperUniqueId: getCurrentPostId(),
|
|
114
152
|
};
|
|
@@ -118,21 +156,15 @@ export default function VisualEditor( { styles } ) {
|
|
|
118
156
|
( select ) => select( editPostStore ).hasMetaBoxes(),
|
|
119
157
|
[]
|
|
120
158
|
);
|
|
121
|
-
const {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
themeSupportsLayout: _settings.supportsLayout,
|
|
131
|
-
assets: _settings.__unstableResolvedAssets,
|
|
132
|
-
useRootPaddingAwareAlignments:
|
|
133
|
-
_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
|
|
134
|
-
};
|
|
135
|
-
}, [] );
|
|
159
|
+
const { themeHasDisabledLayoutStyles, themeSupportsLayout, assets } =
|
|
160
|
+
useSelect( ( select ) => {
|
|
161
|
+
const _settings = select( blockEditorStore ).getSettings();
|
|
162
|
+
return {
|
|
163
|
+
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
164
|
+
themeSupportsLayout: _settings.supportsLayout,
|
|
165
|
+
assets: _settings.__unstableResolvedAssets,
|
|
166
|
+
};
|
|
167
|
+
}, [] );
|
|
136
168
|
const { clearSelectedBlock } = useDispatch( blockEditorStore );
|
|
137
169
|
const { setIsEditingTemplate } = useDispatch( editPostStore );
|
|
138
170
|
const desktopCanvasStyles = {
|
|
@@ -152,7 +184,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
152
184
|
borderBottom: 0,
|
|
153
185
|
};
|
|
154
186
|
const resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );
|
|
155
|
-
const
|
|
187
|
+
const globalLayoutSettings = useSetting( 'layout' );
|
|
156
188
|
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
157
189
|
|
|
158
190
|
let animatedStyles = isTemplateMode
|
|
@@ -181,7 +213,9 @@ export default function VisualEditor( { styles } ) {
|
|
|
181
213
|
|
|
182
214
|
const blockSelectionClearerRef = useBlockSelectionClearer();
|
|
183
215
|
|
|
184
|
-
|
|
216
|
+
// fallbackLayout is used if there is no Post Content,
|
|
217
|
+
// and for Post Title.
|
|
218
|
+
const fallbackLayout = useMemo( () => {
|
|
185
219
|
if ( isTemplateMode ) {
|
|
186
220
|
return { type: 'default' };
|
|
187
221
|
}
|
|
@@ -189,17 +223,65 @@ export default function VisualEditor( { styles } ) {
|
|
|
189
223
|
if ( themeSupportsLayout ) {
|
|
190
224
|
// We need to ensure support for wide and full alignments,
|
|
191
225
|
// so we add the constrained type.
|
|
192
|
-
return { ...
|
|
226
|
+
return { ...globalLayoutSettings, type: 'constrained' };
|
|
193
227
|
}
|
|
194
228
|
// Set default layout for classic themes so all alignments are supported.
|
|
195
229
|
return { type: 'default' };
|
|
196
|
-
}, [ isTemplateMode, themeSupportsLayout,
|
|
230
|
+
}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );
|
|
231
|
+
|
|
232
|
+
const postContentBlock = useMemo( () => {
|
|
233
|
+
// When in template editing mode, we can access the blocks directly.
|
|
234
|
+
if ( editedPostTemplate?.blocks ) {
|
|
235
|
+
return findPostContent( editedPostTemplate?.blocks );
|
|
236
|
+
}
|
|
237
|
+
// If there are no blocks, we have to parse the content string.
|
|
238
|
+
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
239
|
+
const parseableContent =
|
|
240
|
+
typeof editedPostTemplate?.content === 'string'
|
|
241
|
+
? editedPostTemplate?.content
|
|
242
|
+
: '';
|
|
243
|
+
|
|
244
|
+
return findPostContent( parse( parseableContent ) ) || {};
|
|
245
|
+
}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );
|
|
246
|
+
|
|
247
|
+
const postContentLayoutClasses = useLayoutClasses( postContentBlock );
|
|
248
|
+
|
|
249
|
+
const blockListLayoutClass = classnames(
|
|
250
|
+
{
|
|
251
|
+
'is-layout-flow': ! themeSupportsLayout,
|
|
252
|
+
},
|
|
253
|
+
themeSupportsLayout && postContentLayoutClasses
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const postContentLayoutStyles = useLayoutStyles(
|
|
257
|
+
postContentBlock,
|
|
258
|
+
'.block-editor-block-list__layout.is-root-container'
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const layout = postContentBlock?.attributes?.layout || {};
|
|
262
|
+
|
|
263
|
+
// Update type for blocks using legacy layouts.
|
|
264
|
+
const postContentLayout = useMemo( () => {
|
|
265
|
+
return layout &&
|
|
266
|
+
( layout?.type === 'constrained' ||
|
|
267
|
+
layout?.inherit ||
|
|
268
|
+
layout?.contentSize ||
|
|
269
|
+
layout?.wideSize )
|
|
270
|
+
? { ...globalLayoutSettings, ...layout, type: 'constrained' }
|
|
271
|
+
: { ...globalLayoutSettings, ...layout, type: 'default' };
|
|
272
|
+
}, [
|
|
273
|
+
layout?.type,
|
|
274
|
+
layout?.inherit,
|
|
275
|
+
layout?.contentSize,
|
|
276
|
+
layout?.wideSize,
|
|
277
|
+
globalLayoutSettings,
|
|
278
|
+
] );
|
|
197
279
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
280
|
+
// If there is a Post Content block we use its layout for the block list;
|
|
281
|
+
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
282
|
+
const blockListLayout = postContentBlock
|
|
283
|
+
? postContentLayout
|
|
284
|
+
: fallbackLayout;
|
|
203
285
|
|
|
204
286
|
const titleRef = useRef();
|
|
205
287
|
useEffect( () => {
|
|
@@ -255,13 +337,24 @@ export default function VisualEditor( { styles } ) {
|
|
|
255
337
|
{ themeSupportsLayout &&
|
|
256
338
|
! themeHasDisabledLayoutStyles &&
|
|
257
339
|
! isTemplateMode && (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
340
|
+
<>
|
|
341
|
+
<LayoutStyle
|
|
342
|
+
selector=".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container"
|
|
343
|
+
layout={ fallbackLayout }
|
|
344
|
+
layoutDefinitions={
|
|
345
|
+
globalLayoutSettings?.definitions
|
|
346
|
+
}
|
|
347
|
+
/>
|
|
348
|
+
{ postContentLayoutStyles && (
|
|
349
|
+
<LayoutStyle
|
|
350
|
+
layout={ postContentLayout }
|
|
351
|
+
css={ postContentLayoutStyles }
|
|
352
|
+
layoutDefinitions={
|
|
353
|
+
globalLayoutSettings?.definitions
|
|
354
|
+
}
|
|
355
|
+
/>
|
|
356
|
+
) }
|
|
357
|
+
</>
|
|
265
358
|
) }
|
|
266
359
|
{ ! isTemplateMode && (
|
|
267
360
|
<div
|
|
@@ -281,7 +374,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
281
374
|
? 'wp-site-blocks'
|
|
282
375
|
: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
283
376
|
}
|
|
284
|
-
__experimentalLayout={
|
|
377
|
+
__experimentalLayout={ blockListLayout }
|
|
285
378
|
/>
|
|
286
379
|
</RecursionProvider>
|
|
287
380
|
</MaybeIframe>
|
package/src/index.js
CHANGED
|
@@ -80,22 +80,6 @@ export function initializeEditor(
|
|
|
80
80
|
settings,
|
|
81
81
|
initialEdits
|
|
82
82
|
) {
|
|
83
|
-
// Prevent adding template part in the post editor.
|
|
84
|
-
// Only add the filter when the post editor is initialized, not imported.
|
|
85
|
-
addFilter(
|
|
86
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
87
|
-
'removeTemplatePartsFromInserter',
|
|
88
|
-
( can, blockType ) => {
|
|
89
|
-
if (
|
|
90
|
-
! select( editPostStore ).isEditingTemplate() &&
|
|
91
|
-
blockType.name === 'core/template-part'
|
|
92
|
-
) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
return can;
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
|
|
99
83
|
const target = document.getElementById( id );
|
|
100
84
|
const reboot = reinitializeEditor.bind(
|
|
101
85
|
null,
|
|
@@ -137,6 +121,26 @@ export function initializeEditor(
|
|
|
137
121
|
} );
|
|
138
122
|
}
|
|
139
123
|
|
|
124
|
+
/*
|
|
125
|
+
* Prevent adding template part in the post editor.
|
|
126
|
+
* Only add the filter when the post editor is initialized, not imported.
|
|
127
|
+
* Also only add the filter(s) after registerCoreBlocks()
|
|
128
|
+
* so that common filters in the block library are not overwritten.
|
|
129
|
+
*/
|
|
130
|
+
addFilter(
|
|
131
|
+
'blockEditor.__unstableCanInsertBlockType',
|
|
132
|
+
'removeTemplatePartsFromInserter',
|
|
133
|
+
( canInsert, blockType ) => {
|
|
134
|
+
if (
|
|
135
|
+
! select( editPostStore ).isEditingTemplate() &&
|
|
136
|
+
blockType.name === 'core/template-part'
|
|
137
|
+
) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return canInsert;
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
|
|
140
144
|
// Show a console log warning if the browser is not in Standards rendering mode.
|
|
141
145
|
const documentMode =
|
|
142
146
|
document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
|