@wordpress/edit-post 8.40.2-next.v.202602241322.0 → 8.40.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,19 +24,53 @@ __export(use_meta_box_initialization_exports, {
24
24
  module.exports = __toCommonJS(use_meta_box_initialization_exports);
25
25
  var import_data = require("@wordpress/data");
26
26
  var import_editor = require("@wordpress/editor");
27
+ var import_core_data = require("@wordpress/core-data");
27
28
  var import_element = require("@wordpress/element");
28
29
  var import_store = require("../../store/index.cjs");
30
+ var import_lock_unlock = require("../../lock-unlock.cjs");
29
31
  var useMetaBoxInitialization = (enabled) => {
30
- const isEnabledAndEditorReady = (0, import_data.useSelect)(
31
- (select) => enabled && select(import_editor.store).__unstableIsEditorReady(),
32
+ const {
33
+ isEnabledAndEditorReady,
34
+ isCollaborationEnabled,
35
+ hasIncompatibleMetaBoxes,
36
+ hasActiveMetaBoxes
37
+ } = (0, import_data.useSelect)(
38
+ (select) => {
39
+ const {
40
+ __unstableIsEditorReady,
41
+ isCollaborationEnabledForCurrentPost
42
+ } = (0, import_lock_unlock.unlock)(select(import_editor.store));
43
+ return {
44
+ isEnabledAndEditorReady: enabled && __unstableIsEditorReady(),
45
+ isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
46
+ hasIncompatibleMetaBoxes: enabled ? select(import_store.store).getAllMetaBoxes().some((metaBox) => !metaBox.__rtc_compatible) : false,
47
+ hasActiveMetaBoxes: enabled && select(import_store.store).hasMetaBoxes()
48
+ };
49
+ },
32
50
  [enabled]
33
51
  );
52
+ const { setCollaborationSupported } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_core_data.store));
53
+ const { updateEditorSettings } = (0, import_data.useDispatch)(import_editor.store);
34
54
  const { initializeMetaBoxes } = (0, import_data.useDispatch)(import_store.store);
35
55
  (0, import_element.useEffect)(() => {
36
56
  if (isEnabledAndEditorReady) {
37
57
  initializeMetaBoxes();
58
+ if (isCollaborationEnabled && hasIncompatibleMetaBoxes) {
59
+ setCollaborationSupported(false);
60
+ }
61
+ if (hasActiveMetaBoxes) {
62
+ updateEditorSettings({ disableVisualRevisions: true });
63
+ }
38
64
  }
39
- }, [isEnabledAndEditorReady, initializeMetaBoxes]);
65
+ }, [
66
+ isEnabledAndEditorReady,
67
+ initializeMetaBoxes,
68
+ isCollaborationEnabled,
69
+ setCollaborationSupported,
70
+ hasIncompatibleMetaBoxes,
71
+ hasActiveMetaBoxes,
72
+ updateEditorSettings
73
+ ]);
40
74
  };
41
75
  // Annotate the CommonJS export names for ESM import in node:
42
76
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/meta-boxes/use-meta-box-initialization.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst isEnabledAndEditorReady = useSelect(\n\t\t( select ) =>\n\t\t\tenabled && select( editorStore ).__unstableIsEditorReady(),\n\t\t[ enabled ]\n\t);\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\t// The effect has to rerun when the editor is ready because initializeMetaBoxes\n\t// will noop until then.\n\tuseEffect( () => {\n\t\tif ( isEnabledAndEditorReady ) {\n\t\t\tinitializeMetaBoxes();\n\t\t}\n\t}, [ isEnabledAndEditorReady, initializeMetaBoxes ] );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,oBAAqC;AACrC,qBAA0B;AAK1B,mBAAuC;AAOhC,IAAM,2BAA2B,CAAE,YAAa;AACtD,QAAM,8BAA0B;AAAA,IAC/B,CAAE,WACD,WAAW,OAAQ,cAAAA,KAAY,EAAE,wBAAwB;AAAA,IAC1D,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,oBAAoB,QAAI,yBAAa,aAAAC,KAAc;AAG3D,gCAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,yBAAyB,mBAAoB,CAAE;AACrD;",
6
- "names": ["editorStore", "editPostStore"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst {\n\t\tisEnabledAndEditorReady,\n\t\tisCollaborationEnabled,\n\t\thasIncompatibleMetaBoxes,\n\t\thasActiveMetaBoxes,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableIsEditorReady,\n\t\t\t\tisCollaborationEnabledForCurrentPost,\n\t\t\t} = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tisEnabledAndEditorReady: enabled && __unstableIsEditorReady(),\n\t\t\t\tisCollaborationEnabled: isCollaborationEnabledForCurrentPost(),\n\t\t\t\thasIncompatibleMetaBoxes: enabled\n\t\t\t\t\t? select( editPostStore )\n\t\t\t\t\t\t\t.getAllMetaBoxes()\n\t\t\t\t\t\t\t.some( ( metaBox ) => ! metaBox.__rtc_compatible )\n\t\t\t\t\t: false,\n\t\t\t\thasActiveMetaBoxes:\n\t\t\t\t\tenabled && select( editPostStore ).hasMetaBoxes(),\n\t\t\t};\n\t\t},\n\t\t[ enabled ]\n\t);\n\tconst { setCollaborationSupported } = unlock( useDispatch( coreStore ) );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\n\t// The effect has to rerun when the editor is ready because initializeMetaBoxes\n\t// will noop until then.\n\tuseEffect( () => {\n\t\tif ( isEnabledAndEditorReady ) {\n\t\t\tinitializeMetaBoxes();\n\n\t\t\t// Disable real-time collaboration when incompatible meta boxes are detected.\n\t\t\tif ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {\n\t\t\t\tsetCollaborationSupported( false );\n\t\t\t}\n\n\t\t\t// Classic meta box values are saved through a separate\n\t\t\t// admin-ajax submission that the in-editor revisions restore\n\t\t\t// does not drive, so visual revisions would silently leave\n\t\t\t// them untouched. Fall back to the classic revision.php\n\t\t\t// admin screen instead.\n\t\t\tif ( hasActiveMetaBoxes ) {\n\t\t\t\tupdateEditorSettings( { disableVisualRevisions: true } );\n\t\t\t}\n\t\t}\n\t}, [\n\t\tisEnabledAndEditorReady,\n\t\tinitializeMetaBoxes,\n\t\tisCollaborationEnabled,\n\t\tsetCollaborationSupported,\n\t\thasIncompatibleMetaBoxes,\n\t\thasActiveMetaBoxes,\n\t\tupdateEditorSettings,\n\t] );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,oBAAqC;AACrC,uBAAmC;AACnC,qBAA0B;AAK1B,mBAAuC;AACvC,yBAAuB;AAOhB,IAAM,2BAA2B,CAAE,YAAa;AACtD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,MACD,QAAI,2BAAQ,OAAQ,cAAAA,KAAY,CAAE;AAClC,aAAO;AAAA,QACN,yBAAyB,WAAW,wBAAwB;AAAA,QAC5D,wBAAwB,qCAAqC;AAAA,QAC7D,0BAA0B,UACvB,OAAQ,aAAAC,KAAc,EACrB,gBAAgB,EAChB,KAAM,CAAE,YAAa,CAAE,QAAQ,gBAAiB,IACjD;AAAA,QACH,oBACC,WAAW,OAAQ,aAAAA,KAAc,EAAE,aAAa;AAAA,MAClD;AAAA,IACD;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,0BAA0B,QAAI,+BAAQ,yBAAa,iBAAAC,KAAU,CAAE;AACvE,QAAM,EAAE,qBAAqB,QAAI,yBAAa,cAAAF,KAAY;AAC1D,QAAM,EAAE,oBAAoB,QAAI,yBAAa,aAAAC,KAAc;AAI3D,gCAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAGpB,UAAK,0BAA0B,0BAA2B;AACzD,kCAA2B,KAAM;AAAA,MAClC;AAOA,UAAK,oBAAqB;AACzB,6BAAsB,EAAE,wBAAwB,KAAK,CAAE;AAAA,MACxD;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
+ "names": ["editorStore", "editPostStore", "coreStore"]
7
7
  }
package/build/index.cjs CHANGED
@@ -77,7 +77,9 @@ function initializeEditor(id, postType, postId, settings, initialEdits) {
77
77
  showIconLabels: false,
78
78
  showListViewByDefault: false,
79
79
  enableChoosePatternModal: true,
80
- isPublishSidebarEnabled: true
80
+ isPublishSidebarEnabled: true,
81
+ showCollaborationCursor: false,
82
+ showCollaborationNotifications: true
81
83
  });
82
84
  if (window.__clientSideMediaProcessing) {
83
85
  (0, import_data.dispatch)(import_preferences.store).setDefaults("core/media", {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { unlock } from './lock-unlock';\n\nconst {\n\tBackButton: __experimentalMainDashboardButton,\n\tregisterCoreBlockBindingsSources,\n} = unlock( editorPrivateApis );\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 isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\tfullscreenMode: true,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\teditorMode: 'visual',\n\t\teditorTool: 'edit',\n\t\tfixedToolbar: false,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tenableChoosePatternModal: true,\n\t\tisPublishSidebarEnabled: true,\n\t} );\n\n\tif ( window.__clientSideMediaProcessing ) {\n\t\tdispatch( preferencesStore ).setDefaults( 'core/media', {\n\t\t\trequireApproval: true,\n\t\t\toptimizeOnUpload: true,\n\t\t} );\n\t}\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t// This behavior is disabled for small viewports.\n\tif (\n\t\tisMediumOrBigger &&\n\t\tselect( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&\n\t\t! select( preferencesStore ).get( 'core', 'distractionFree' )\n\t) {\n\t\tdispatch( editorStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterCoreBlockBindingsSources();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.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\troot.render(\n\t\t<StrictMode>\n\t\t\t<Layout\n\t\t\t\tsettings={ settings }\n\t\t\t\tpostId={ postId }\n\t\t\t\tpostType={ postType }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t/>\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as __experimentalFullscreenModeClose } from './components/back-button/fullscreen-mode-close';\nexport { __experimentalMainDashboardButton };\nexport { store } from './store';\nexport * from './deprecated';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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encies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { unlock } from './lock-unlock';\n\nconst {\n\tBackButton: __experimentalMainDashboardButton,\n\tregisterCoreBlockBindingsSources,\n} = unlock( editorPrivateApis );\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 isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\tfullscreenMode: true,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\teditorMode: 'visual',\n\t\teditorTool: 'edit',\n\t\tfixedToolbar: false,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tenableChoosePatternModal: true,\n\t\tisPublishSidebarEnabled: true,\n\t\tshowCollaborationCursor: false,\n\t\tshowCollaborationNotifications: true,\n\t} );\n\n\tif ( window.__clientSideMediaProcessing ) {\n\t\tdispatch( preferencesStore ).setDefaults( 'core/media', {\n\t\t\trequireApproval: true,\n\t\t\toptimizeOnUpload: true,\n\t\t} );\n\t}\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t// This behavior is disabled for small viewports.\n\tif (\n\t\tisMediumOrBigger &&\n\t\tselect( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&\n\t\t! select( preferencesStore ).get( 'core', 'distractionFree' )\n\t) {\n\t\tdispatch( editorStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterCoreBlockBindingsSources();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.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\troot.render(\n\t\t<StrictMode>\n\t\t\t<Layout\n\t\t\t\tsettings={ settings }\n\t\t\t\tpostId={ postId }\n\t\t\t\tpostType={ postType }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t/>\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as __experimentalFullscreenModeClose } from './components/back-button/fullscreen-mode-close';\nexport { __experimentalMainDashbo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ACD,GACD;AAAA,EACD;AAEA,SAAO;AACR;AAKO,SAAS,qBAAqB;AACpC,wBAAAC,SAAY,kCAAkC;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACH;",
6
6
  "names": ["editorPrivateApis", "preferencesStore", "blocksStore", "editorStore", "Layout", "deprecated"]
7
7
  }
@@ -43,7 +43,10 @@ function mergeMetaboxes(metaboxes = [], newMetaboxes) {
43
43
  (box) => box.id === metabox.id
44
44
  );
45
45
  if (existing !== -1) {
46
- mergedMetaboxes[existing] = metabox;
46
+ mergedMetaboxes[existing] = {
47
+ ...mergedMetaboxes[existing],
48
+ ...metabox
49
+ };
47
50
  } else {
48
51
  mergedMetaboxes.push(metabox);
49
52
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = metabox;\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,IAC/B,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,gBAAY,6BAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AACD,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = {\n\t\t\t\t...mergedMetaboxes[ existing ],\n\t\t\t\t...metabox,\n\t\t\t};\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,QAC7B,GAAG,gBAAiB,QAAS;AAAA,QAC7B,GAAG;AAAA,MACJ;AAAA,IACD,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,gBAAY,6BAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AACD,CAAE;",
6
6
  "names": []
7
7
  }
@@ -1,19 +1,53 @@
1
1
  // packages/edit-post/src/components/meta-boxes/use-meta-box-initialization.js
2
2
  import { useDispatch, useSelect } from "@wordpress/data";
3
3
  import { store as editorStore } from "@wordpress/editor";
4
+ import { store as coreStore } from "@wordpress/core-data";
4
5
  import { useEffect } from "@wordpress/element";
5
6
  import { store as editPostStore } from "../../store/index.mjs";
7
+ import { unlock } from "../../lock-unlock.mjs";
6
8
  var useMetaBoxInitialization = (enabled) => {
7
- const isEnabledAndEditorReady = useSelect(
8
- (select) => enabled && select(editorStore).__unstableIsEditorReady(),
9
+ const {
10
+ isEnabledAndEditorReady,
11
+ isCollaborationEnabled,
12
+ hasIncompatibleMetaBoxes,
13
+ hasActiveMetaBoxes
14
+ } = useSelect(
15
+ (select) => {
16
+ const {
17
+ __unstableIsEditorReady,
18
+ isCollaborationEnabledForCurrentPost
19
+ } = unlock(select(editorStore));
20
+ return {
21
+ isEnabledAndEditorReady: enabled && __unstableIsEditorReady(),
22
+ isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
23
+ hasIncompatibleMetaBoxes: enabled ? select(editPostStore).getAllMetaBoxes().some((metaBox) => !metaBox.__rtc_compatible) : false,
24
+ hasActiveMetaBoxes: enabled && select(editPostStore).hasMetaBoxes()
25
+ };
26
+ },
9
27
  [enabled]
10
28
  );
29
+ const { setCollaborationSupported } = unlock(useDispatch(coreStore));
30
+ const { updateEditorSettings } = useDispatch(editorStore);
11
31
  const { initializeMetaBoxes } = useDispatch(editPostStore);
12
32
  useEffect(() => {
13
33
  if (isEnabledAndEditorReady) {
14
34
  initializeMetaBoxes();
35
+ if (isCollaborationEnabled && hasIncompatibleMetaBoxes) {
36
+ setCollaborationSupported(false);
37
+ }
38
+ if (hasActiveMetaBoxes) {
39
+ updateEditorSettings({ disableVisualRevisions: true });
40
+ }
15
41
  }
16
- }, [isEnabledAndEditorReady, initializeMetaBoxes]);
42
+ }, [
43
+ isEnabledAndEditorReady,
44
+ initializeMetaBoxes,
45
+ isCollaborationEnabled,
46
+ setCollaborationSupported,
47
+ hasIncompatibleMetaBoxes,
48
+ hasActiveMetaBoxes,
49
+ updateEditorSettings
50
+ ]);
17
51
  };
18
52
  export {
19
53
  useMetaBoxInitialization
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/meta-boxes/use-meta-box-initialization.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst isEnabledAndEditorReady = useSelect(\n\t\t( select ) =>\n\t\t\tenabled && select( editorStore ).__unstableIsEditorReady(),\n\t\t[ enabled ]\n\t);\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\t// The effect has to rerun when the editor is ready because initializeMetaBoxes\n\t// will noop until then.\n\tuseEffect( () => {\n\t\tif ( isEnabledAndEditorReady ) {\n\t\t\tinitializeMetaBoxes();\n\t\t}\n\t}, [ isEnabledAndEditorReady, initializeMetaBoxes ] );\n};\n"],
5
- "mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,mBAAmB;AACrC,SAAS,iBAAiB;AAK1B,SAAS,SAAS,qBAAqB;AAOhC,IAAM,2BAA2B,CAAE,YAAa;AACtD,QAAM,0BAA0B;AAAA,IAC/B,CAAE,WACD,WAAW,OAAQ,WAAY,EAAE,wBAAwB;AAAA,IAC1D,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,oBAAoB,IAAI,YAAa,aAAc;AAG3D,YAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,yBAAyB,mBAAoB,CAAE;AACrD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n *\n * @param { boolean } enabled\n */\nexport const useMetaBoxInitialization = ( enabled ) => {\n\tconst {\n\t\tisEnabledAndEditorReady,\n\t\tisCollaborationEnabled,\n\t\thasIncompatibleMetaBoxes,\n\t\thasActiveMetaBoxes,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableIsEditorReady,\n\t\t\t\tisCollaborationEnabledForCurrentPost,\n\t\t\t} = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tisEnabledAndEditorReady: enabled && __unstableIsEditorReady(),\n\t\t\t\tisCollaborationEnabled: isCollaborationEnabledForCurrentPost(),\n\t\t\t\thasIncompatibleMetaBoxes: enabled\n\t\t\t\t\t? select( editPostStore )\n\t\t\t\t\t\t\t.getAllMetaBoxes()\n\t\t\t\t\t\t\t.some( ( metaBox ) => ! metaBox.__rtc_compatible )\n\t\t\t\t\t: false,\n\t\t\t\thasActiveMetaBoxes:\n\t\t\t\t\tenabled && select( editPostStore ).hasMetaBoxes(),\n\t\t\t};\n\t\t},\n\t\t[ enabled ]\n\t);\n\tconst { setCollaborationSupported } = unlock( useDispatch( coreStore ) );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\tconst { initializeMetaBoxes } = useDispatch( editPostStore );\n\n\t// The effect has to rerun when the editor is ready because initializeMetaBoxes\n\t// will noop until then.\n\tuseEffect( () => {\n\t\tif ( isEnabledAndEditorReady ) {\n\t\t\tinitializeMetaBoxes();\n\n\t\t\t// Disable real-time collaboration when incompatible meta boxes are detected.\n\t\t\tif ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {\n\t\t\t\tsetCollaborationSupported( false );\n\t\t\t}\n\n\t\t\t// Classic meta box values are saved through a separate\n\t\t\t// admin-ajax submission that the in-editor revisions restore\n\t\t\t// does not drive, so visual revisions would silently leave\n\t\t\t// them untouched. Fall back to the classic revision.php\n\t\t\t// admin screen instead.\n\t\t\tif ( hasActiveMetaBoxes ) {\n\t\t\t\tupdateEditorSettings( { disableVisualRevisions: true } );\n\t\t\t}\n\t\t}\n\t}, [\n\t\tisEnabledAndEditorReady,\n\t\tinitializeMetaBoxes,\n\t\tisCollaborationEnabled,\n\t\tsetCollaborationSupported,\n\t\thasIncompatibleMetaBoxes,\n\t\thasActiveMetaBoxes,\n\t\tupdateEditorSettings,\n\t] );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAK1B,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAOhB,IAAM,2BAA2B,CAAE,YAAa;AACtD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,OAAQ,WAAY,CAAE;AAClC,aAAO;AAAA,QACN,yBAAyB,WAAW,wBAAwB;AAAA,QAC5D,wBAAwB,qCAAqC;AAAA,QAC7D,0BAA0B,UACvB,OAAQ,aAAc,EACrB,gBAAgB,EAChB,KAAM,CAAE,YAAa,CAAE,QAAQ,gBAAiB,IACjD;AAAA,QACH,oBACC,WAAW,OAAQ,aAAc,EAAE,aAAa;AAAA,MAClD;AAAA,IACD;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,0BAA0B,IAAI,OAAQ,YAAa,SAAU,CAAE;AACvE,QAAM,EAAE,qBAAqB,IAAI,YAAa,WAAY;AAC1D,QAAM,EAAE,oBAAoB,IAAI,YAAa,aAAc;AAI3D,YAAW,MAAM;AAChB,QAAK,yBAA0B;AAC9B,0BAAoB;AAGpB,UAAK,0BAA0B,0BAA2B;AACzD,kCAA2B,KAAM;AAAA,MAClC;AAOA,UAAK,oBAAqB;AACzB,6BAAsB,EAAE,wBAAwB,KAAK,CAAE;AAAA,MACxD;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -48,7 +48,9 @@ function initializeEditor(id, postType, postId, settings, initialEdits) {
48
48
  showIconLabels: false,
49
49
  showListViewByDefault: false,
50
50
  enableChoosePatternModal: true,
51
- isPublishSidebarEnabled: true
51
+ isPublishSidebarEnabled: true,
52
+ showCollaborationCursor: false,
53
+ showCollaborationNotifications: true
52
54
  });
53
55
  if (window.__clientSideMediaProcessing) {
54
56
  dispatch(preferencesStore).setDefaults("core/media", {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { unlock } from './lock-unlock';\n\nconst {\n\tBackButton: __experimentalMainDashboardButton,\n\tregisterCoreBlockBindingsSources,\n} = unlock( editorPrivateApis );\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 isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\tfullscreenMode: true,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\teditorMode: 'visual',\n\t\teditorTool: 'edit',\n\t\tfixedToolbar: false,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tenableChoosePatternModal: true,\n\t\tisPublishSidebarEnabled: true,\n\t} );\n\n\tif ( window.__clientSideMediaProcessing ) {\n\t\tdispatch( preferencesStore ).setDefaults( 'core/media', {\n\t\t\trequireApproval: true,\n\t\t\toptimizeOnUpload: true,\n\t\t} );\n\t}\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t// This behavior is disabled for small viewports.\n\tif (\n\t\tisMediumOrBigger &&\n\t\tselect( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&\n\t\t! select( preferencesStore ).get( 'core', 'distractionFree' )\n\t) {\n\t\tdispatch( editorStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterCoreBlockBindingsSources();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.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\troot.render(\n\t\t<StrictMode>\n\t\t\t<Layout\n\t\t\t\tsettings={ settings }\n\t\t\t\tpostId={ postId }\n\t\t\t\tpostType={ postType }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t/>\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as __experimentalFullscreenModeClose } from './components/back-button/fullscreen-mode-close';\nexport { __experimentalMainDashboardButton };\nexport { store } from './store';\nexport * from './deprecated';\n"],
5
- "mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,OAAO,gBAAgB;AACvB,SAAS,YAAY,kBAAkB;AACvC,SAAS,UAAU,cAAc;AACjC,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,OAAO,YAAY;AACnB,SAAS,cAAc;AAqJvB,SAAoB,WAAXA,gBAAoD;AAE7D,SAAS,aAAa;AACtB,cAAc;AAzBX;AA7HH,IAAM;AAAA,EACL,YAAY;AAAA,EACZ;AACD,IAAI,OAAQ,iBAAkB;AAavB,SAAS,iBACf,IACA,UACA,QACA,UACA,cACC;AACD,QAAM,mBAAmB,OAAO,WAAY,oBAAqB,EAAE;AACnE,QAAM,SAAS,SAAS,eAAgB,EAAG;AAC3C,QAAM,OAAO,WAAY,MAAO;AAE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AAM,wBAAwB,SAAS;AAAA,QACtC;AAAA,MACD,EAAG,CAAE;AACL,UAAK,MAAM,WAAW,UAAW;AAGhC,YAAK,OAAO,UAAU,KAAM;AAC3B,gCAAsB,YACrB,sBAAsB,YAAY,OAAO;AAAA,QAC3C;AAEA,YACC,SAAS,uBAAwB,gBAAiB,EAAG,CAAE,GACtD;AACD,iBAAO,SAAU,GAAG,CAAE;AAAA,QACvB;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH;AAGA,SAAO,iBAAkB,YAAY,CAAE,MAAO,EAAE,eAAe,GAAG,KAAM;AACxE,SAAO,iBAAkB,QAAQ,CAAE,MAAO,EAAE,eAAe,GAAG,KAAM;AAEpE,OAAK;AAAA,IACJ,oBAAC,cACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD,GACD;AAAA,EACD;AAEA,SAAO;AACR;AAKO,SAAS,qBAAqB;AACpC,aAAY,kCAAkC;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACH;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { unlock } from './lock-unlock';\n\nconst {\n\tBackButton: __experimentalMainDashboardButton,\n\tregisterCoreBlockBindingsSources,\n} = unlock( editorPrivateApis );\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 isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\tfullscreenMode: true,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\teditorMode: 'visual',\n\t\teditorTool: 'edit',\n\t\tfixedToolbar: false,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tenableChoosePatternModal: true,\n\t\tisPublishSidebarEnabled: true,\n\t\tshowCollaborationCursor: false,\n\t\tshowCollaborationNotifications: true,\n\t} );\n\n\tif ( window.__clientSideMediaProcessing ) {\n\t\tdispatch( preferencesStore ).setDefaults( 'core/media', {\n\t\t\trequireApproval: true,\n\t\t\toptimizeOnUpload: true,\n\t\t} );\n\t}\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t// This behavior is disabled for small viewports.\n\tif (\n\t\tisMediumOrBigger &&\n\t\tselect( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&\n\t\t! select( preferencesStore ).get( 'core', 'distractionFree' )\n\t) {\n\t\tdispatch( editorStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterCoreBlockBindingsSources();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.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\troot.render(\n\t\t<StrictMode>\n\t\t\t<Layout\n\t\t\t\tsettings={ settings }\n\t\t\t\tpostId={ postId }\n\t\t\t\tpostType={ postType }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t/>\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as __experimentalFullscreenModeClose } from './components/back-button/fullscreen-mode-close';\nexport { __experimentalMainDashboardButton };\nexport { store } from './store';\nexport * from './deprecated';\n"],
5
+ "mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,OAAO,gBAAgB;AACvB,SAAS,YAAY,kBAAkB;AACvC,SAAS,UAAU,cAAc;AACjC,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,OAAO,YAAY;AACnB,SAAS,cAAc;AAuJvB,SAAoB,WAAXA,gBAAoD;AAE7D,SAAS,aAAa;AACtB,cAAc;AAzBX;AA/HH,IAAM;AAAA,EACL,YAAY;AAAA,EACZ;AACD,IAAI,OAAQ,iBAAkB;AAavB,SAAS,iBACf,IACA,UACA,QACA,UACA,cACC;AACD,Q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;AAAA,MACP;AAAA,IACD;AAAA,EACD;AASA,QAAM,WAAW,OAAO,UAAU,UAAU,QAAS,QAAS,MAAM;AACpE,MAAK,UAAW;AACf,WAAO,iBAAkB,UAAU,CAAE,UAAW;AAC/C,YAAM,wBAAwB,SAAS;AAAA,QACtC;AAAA,MACD,EAAG,CAAE;AACL,UAAK,MAAM,WAAW,UAAW;AAGhC,YAAK,OAAO,UAAU,KAAM;AAC3B,gCAAsB,YACrB,sBAAsB,YAAY,OAAO;AAAA,QAC3C;AAEA,YACC,SAAS,uBAAwB,gBAAiB,EAAG,CAAE,GACtD;AACD,iBAAO,SAAU,GAAG,CAAE;AAAA,QACvB;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH;AAGA,SAAO,iBAAkB,YAAY,CAAE,MAAO,EAAE,eAAe,GAAG,KAAM;AACxE,SAAO,iBAAkB,QAAQ,CAAE,MAAO,EAAE,eAAe,GAAG,KAAM;AAEpE,OAAK;AAAA,IACJ,oBAAC,cACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD,GACD;AAAA,EACD;AAEA,SAAO;AACR;AAKO,SAAS,qBAAqB;AACpC,aAAY,kCAAkC;AAAA,IAC7C,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACH;",
6
6
  "names": ["default"]
7
7
  }
@@ -18,7 +18,10 @@ function mergeMetaboxes(metaboxes = [], newMetaboxes) {
18
18
  (box) => box.id === metabox.id
19
19
  );
20
20
  if (existing !== -1) {
21
- mergedMetaboxes[existing] = metabox;
21
+ mergedMetaboxes[existing] = {
22
+ ...mergedMetaboxes[existing],
23
+ ...metabox
24
+ };
22
25
  } else {
23
26
  mergedMetaboxes.push(metabox);
24
27
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = metabox;\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
- "mappings": ";AAGA,SAAS,uBAAuB;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,IAC/B,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,YAAY,gBAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AACD,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\nfunction mergeMetaboxes( metaboxes = [], newMetaboxes ) {\n\tconst mergedMetaboxes = [ ...metaboxes ];\n\tfor ( const metabox of newMetaboxes ) {\n\t\tconst existing = mergedMetaboxes.findIndex(\n\t\t\t( box ) => box.id === metabox.id\n\t\t);\n\t\tif ( existing !== -1 ) {\n\t\t\tmergedMetaboxes[ existing ] = {\n\t\t\t\t...mergedMetaboxes[ existing ],\n\t\t\t\t...metabox,\n\t\t\t};\n\t\t} else {\n\t\t\tmergedMetaboxes.push( metabox );\n\t\t}\n\t}\n\treturn mergedMetaboxes;\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS': {\n\t\t\tconst newState = { ...state };\n\t\t\tfor ( const [ location, metaboxes ] of Object.entries(\n\t\t\t\taction.metaBoxesPerLocation\n\t\t\t) ) {\n\t\t\t\tnewState[ location ] = mergeMetaboxes(\n\t\t\t\t\tnewState[ location ],\n\t\t\t\t\tmetaboxes\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn newState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tmetaBoxes,\n} );\n"],
5
+ "mappings": ";AAGA,SAAS,uBAAuB;AAYzB,SAAS,kBAAmB,QAAQ,OAAO,QAAS;AAC1D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,eAAgB,YAAY,CAAC,GAAG,cAAe;AACvD,QAAM,kBAAkB,CAAE,GAAG,SAAU;AACvC,aAAY,WAAW,cAAe;AACrC,UAAM,WAAW,gBAAgB;AAAA,MAChC,CAAE,QAAS,IAAI,OAAO,QAAQ;AAAA,IAC/B;AACA,QAAK,aAAa,IAAK;AACtB,sBAAiB,QAAS,IAAI;AAAA,QAC7B,GAAG,gBAAiB,QAAS;AAAA,QAC7B,GAAG;AAAA,MACJ;AAAA,IACD,OAAO;AACN,sBAAgB,KAAM,OAAQ;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAUO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,gCAAgC;AACpC,YAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,iBAAY,CAAE,UAAU,SAAU,KAAK,OAAO;AAAA,QAC7C,OAAO;AAAA,MACR,GAAI;AACH,iBAAU,QAAS,IAAI;AAAA,UACtB,SAAU,QAAS;AAAA,UACnB;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,qBAAsB,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAM,YAAY,gBAAiB;AAAA,EAClC,UAAU;AAAA,EACV,WAAW;AAAA,EACX,aAAa;AACd,CAAE;AAEF,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AACD,CAAE;",
6
6
  "names": []
7
7
  }
@@ -92,9 +92,10 @@
92
92
  margin-left: auto;
93
93
  }
94
94
 
95
- html :where(.editor-styles-wrapper) {
95
+ .editor-styles-wrapper {
96
96
  padding: 8px;
97
97
  }
98
+
98
99
  html :where(.editor-styles-wrapper) .block-editor-block-list__layout.is-root-container > .wp-block[data-align=full] {
99
100
  margin-right: -8px;
100
101
  margin-left: -8px;
@@ -92,9 +92,10 @@
92
92
  margin-right: auto;
93
93
  }
94
94
 
95
- html :where(.editor-styles-wrapper) {
95
+ .editor-styles-wrapper {
96
96
  padding: 8px;
97
97
  }
98
+
98
99
  html :where(.editor-styles-wrapper) .block-editor-block-list__layout.is-root-container > .wp-block[data-align=full] {
99
100
  margin-left: -8px;
100
101
  margin-right: -8px;
@@ -106,100 +106,11 @@
106
106
  }
107
107
  }
108
108
 
109
- /**
110
- * Colors
111
- */
112
- /**
113
- * SCSS Variables.
114
- *
115
- * Please use variables from this sheet to ensure consistency across the UI.
116
- * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
117
- * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
118
- */
119
- /**
120
- * Fonts & basic variables.
121
- */
122
- /**
123
- * Typography
124
- */
125
- /**
126
- * Grid System.
127
- * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
128
- */
129
- /**
130
- * Radius scale.
131
- */
132
- /**
133
- * Elevation scale.
134
- */
135
- /**
136
- * Dimensions.
137
- */
138
- /**
139
- * Mobile specific styles
140
- */
141
- /**
142
- * Editor styles.
143
- */
144
- /**
145
- * Block & Editor UI.
146
- */
147
- /**
148
- * Block paddings.
149
- */
150
- /**
151
- * React Native specific.
152
- * These variables do not appear to be used anywhere else.
153
- */
154
- /**
155
- * Typography
156
- */
157
- /**
158
- * Breakpoints & Media Queries
159
- */
160
- /**
161
- * Converts a hex value into the rgb equivalent.
162
- *
163
- * @param {string} hex - the hexadecimal value to convert
164
- * @return {string} comma separated rgb values
165
- */
166
- /**
167
- * Long content fade mixin
168
- *
169
- * Creates a fading overlay to signify that the content is longer
170
- * than the space allows.
171
- */
172
- /**
173
- * Breakpoint mixins
174
- */
175
- /**
176
- * Focus styles.
177
- */
178
- /**
179
- * Applies editor left position to the selector passed as argument
180
- */
181
- /**
182
- * Styles that are reused verbatim in a few places
183
- */
184
- /**
185
- * Allows users to opt-out of animations via OS-level preferences.
186
- */
187
- /**
188
- * Reset default styles for JavaScript UI based pages.
189
- * This is a WP-admin agnostic reset
190
- */
191
- /**
192
- * Reset the WP Admin page styles for Gutenberg-like pages.
193
- */
194
- /**
195
- * Creates a checkerboard pattern background to indicate transparency.
196
- * @param {String} $size - The size of the squares in the checkerboard pattern. Default is 12px.
197
- */
198
109
  .admin-ui-page {
199
110
  display: flex;
200
111
  height: 100%;
201
- background-color: #fff;
202
- color: #2f2f2f;
112
+ background-color: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
113
+ color: var(--wpds-color-fg-content-neutral, #1e1e1e);
203
114
  position: relative;
204
115
  z-index: 1;
205
116
  flex-flow: column;
@@ -207,25 +118,34 @@
207
118
  }
208
119
 
209
120
  .admin-ui-page__header {
210
- padding: 16px 24px;
211
- border-bottom: 1px solid #f0f0f0;
212
- background: #fff;
121
+ padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
122
+ border-bottom: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #e0e0e0);
123
+ background: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
213
124
  position: sticky;
214
125
  top: 0;
215
126
  z-index: 1;
216
127
  }
217
128
 
129
+ .admin-ui-page__header-title {
130
+ font-family: var(--wpds-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
131
+ font-size: var(--wpds-font-size-xl, 20px);
132
+ font-weight: var(--wpds-font-weight-medium, 499);
133
+ line-height: var(--wpds-font-line-height-xl, 32px);
134
+ margin: 0;
135
+ overflow: hidden;
136
+ text-overflow: ellipsis;
137
+ white-space: nowrap;
138
+ }
139
+
218
140
  .admin-ui-page__sidebar-toggle-slot:empty {
219
141
  display: none;
220
142
  }
221
143
 
222
144
  .admin-ui-page__header-subtitle {
223
- padding-block-end: 8px;
224
- color: #757575;
225
- font-family: -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
226
- font-weight: 400;
227
- font-size: 13px;
228
- line-height: 20px;
145
+ padding-block-end: var(--wpds-dimension-padding-xs, 4px);
146
+ color: var(--wpds-color-fg-content-neutral-weak, #6d6d6d);
147
+ font-size: var(--wpds-font-size-md, 13px);
148
+ line-height: var(--wpds-font-line-height-md, 24px);
229
149
  margin: 0;
230
150
  }
231
151
 
@@ -237,12 +157,12 @@
237
157
  }
238
158
 
239
159
  .admin-ui-page__content.has-padding {
240
- padding: 16px 24px;
160
+ padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
241
161
  }
242
162
 
243
163
  .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon {
244
164
  width: auto;
245
- padding: 0 8px;
165
+ padding: 0 var(--wpds-dimension-padding-xs, 4px);
246
166
  }
247
167
 
248
168
  .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon svg {
@@ -251,9 +171,54 @@
251
171
 
252
172
  .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon::after {
253
173
  content: attr(aria-label);
254
- font-size: 12px;
174
+ font-size: var(--wpds-font-size-sm, 12px);
255
175
  }
256
176
 
177
+ /**
178
+ * SCSS Variables.
179
+ *
180
+ * Please use variables from this sheet to ensure consistency across the UI.
181
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
182
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
183
+ */
184
+ /**
185
+ * Colors
186
+ */
187
+ /**
188
+ * Fonts & basic variables.
189
+ */
190
+ /**
191
+ * Typography
192
+ */
193
+ /**
194
+ * Grid System.
195
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
196
+ */
197
+ /**
198
+ * Radius scale.
199
+ */
200
+ /**
201
+ * Elevation scale.
202
+ */
203
+ /**
204
+ * Dimensions.
205
+ */
206
+ /**
207
+ * Mobile specific styles
208
+ */
209
+ /**
210
+ * Editor styles.
211
+ */
212
+ /**
213
+ * Block & Editor UI.
214
+ */
215
+ /**
216
+ * Block paddings.
217
+ */
218
+ /**
219
+ * React Native specific.
220
+ * These variables do not appear to be used anywhere else.
221
+ */
257
222
  .admin-ui-breadcrumbs__list {
258
223
  list-style: none;
259
224
  padding: 0;
@@ -561,16 +526,6 @@
561
526
  .edit-post-meta-boxes-area .is-hidden {
562
527
  display: none;
563
528
  }
564
- .edit-post-meta-boxes-area .metabox-location-side .postbox input[type=checkbox] {
565
- border: 1px solid #757575;
566
- }
567
- .edit-post-meta-boxes-area .metabox-location-side .postbox input[type=checkbox]:checked {
568
- background: #fff;
569
- border-color: #757575;
570
- }
571
- .edit-post-meta-boxes-area .metabox-location-side .postbox input[type=checkbox]::before {
572
- margin: -3px -4px;
573
- }
574
529
 
575
530
  .edit-post-meta-boxes-area__clear {
576
531
  clear: both;
@@ -106,100 +106,11 @@
106
106
  }
107
107
  }
108
108
 
109
- /**
110
- * Colors
111
- */
112
- /**
113
- * SCSS Variables.
114
- *
115
- * Please use variables from this sheet to ensure consistency across the UI.
116
- * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
117
- * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
118
- */
119
- /**
120
- * Fonts & basic variables.
121
- */
122
- /**
123
- * Typography
124
- */
125
- /**
126
- * Grid System.
127
- * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
128
- */
129
- /**
130
- * Radius scale.
131
- */
132
- /**
133
- * Elevation scale.
134
- */
135
- /**
136
- * Dimensions.
137
- */
138
- /**
139
- * Mobile specific styles
140
- */
141
- /**
142
- * Editor styles.
143
- */
144
- /**
145
- * Block & Editor UI.
146
- */
147
- /**
148
- * Block paddings.
149
- */
150
- /**
151
- * React Native specific.
152
- * These variables do not appear to be used anywhere else.
153
- */
154
- /**
155
- * Typography
156
- */
157
- /**
158
- * Breakpoints & Media Queries
159
- */
160
- /**
161
- * Converts a hex value into the rgb equivalent.
162
- *
163
- * @param {string} hex - the hexadecimal value to convert
164
- * @return {string} comma separated rgb values
165
- */
166
- /**
167
- * Long content fade mixin
168
- *
169
- * Creates a fading overlay to signify that the content is longer
170
- * than the space allows.
171
- */
172
- /**
173
- * Breakpoint mixins
174
- */
175
- /**
176
- * Focus styles.
177
- */
178
- /**
179
- * Applies editor left position to the selector passed as argument
180
- */
181
- /**
182
- * Styles that are reused verbatim in a few places
183
- */
184
- /**
185
- * Allows users to opt-out of animations via OS-level preferences.
186
- */
187
- /**
188
- * Reset default styles for JavaScript UI based pages.
189
- * This is a WP-admin agnostic reset
190
- */
191
- /**
192
- * Reset the WP Admin page styles for Gutenberg-like pages.
193
- */
194
- /**
195
- * Creates a checkerboard pattern background to indicate transparency.
196
- * @param {String} $size - The size of the squares in the checkerboard pattern. Default is 12px.
197
- */
198
109
  .admin-ui-page {
199
110
  display: flex;
200
111
  height: 100%;
201
- background-color: #fff;
202
- color: #2f2f2f;
112
+ background-color: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
113
+ color: var(--wpds-color-fg-content-neutral, #1e1e1e);
203
114
  position: relative;
204
115
  z-index: 1;
205
116
  flex-flow: column;
@@ -207,25 +118,34 @@
207
118
  }
208
119
 
209
120
  .admin-ui-page__header {
210
- padding: 16px 24px;
211
- border-bottom: 1px solid #f0f0f0;
212
- background: #fff;
121
+ padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
122
+ border-bottom: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #e0e0e0);
123
+ background: var(--wpds-color-bg-surface-neutral-strong, #ffffff);
213
124
  position: sticky;
214
125
  top: 0;
215
126
  z-index: 1;
216
127
  }
217
128
 
129
+ .admin-ui-page__header-title {
130
+ font-family: var(--wpds-font-family-heading, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
131
+ font-size: var(--wpds-font-size-xl, 20px);
132
+ font-weight: var(--wpds-font-weight-medium, 499);
133
+ line-height: var(--wpds-font-line-height-xl, 32px);
134
+ margin: 0;
135
+ overflow: hidden;
136
+ text-overflow: ellipsis;
137
+ white-space: nowrap;
138
+ }
139
+
218
140
  .admin-ui-page__sidebar-toggle-slot:empty {
219
141
  display: none;
220
142
  }
221
143
 
222
144
  .admin-ui-page__header-subtitle {
223
- padding-block-end: 8px;
224
- color: #757575;
225
- font-family: -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
226
- font-weight: 400;
227
- font-size: 13px;
228
- line-height: 20px;
145
+ padding-block-end: var(--wpds-dimension-padding-xs, 4px);
146
+ color: var(--wpds-color-fg-content-neutral-weak, #6d6d6d);
147
+ font-size: var(--wpds-font-size-md, 13px);
148
+ line-height: var(--wpds-font-line-height-md, 24px);
229
149
  margin: 0;
230
150
  }
231
151
 
@@ -237,12 +157,12 @@
237
157
  }
238
158
 
239
159
  .admin-ui-page__content.has-padding {
240
- padding: 16px 24px;
160
+ padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
241
161
  }
242
162
 
243
163
  .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon {
244
164
  width: auto;
245
- padding: 0 8px;
165
+ padding: 0 var(--wpds-dimension-padding-xs, 4px);
246
166
  }
247
167
 
248
168
  .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon svg {
@@ -251,9 +171,54 @@
251
171
 
252
172
  .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon::after {
253
173
  content: attr(aria-label);
254
- font-size: 12px;
174
+ font-size: var(--wpds-font-size-sm, 12px);
255
175
  }
256
176
 
177
+ /**
178
+ * SCSS Variables.
179
+ *
180
+ * Please use variables from this sheet to ensure consistency across the UI.
181
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
182
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
183
+ */
184
+ /**
185
+ * Colors
186
+ */
187
+ /**
188
+ * Fonts & basic variables.
189
+ */
190
+ /**
191
+ * Typography
192
+ */
193
+ /**
194
+ * Grid System.
195
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
196
+ */
197
+ /**
198
+ * Radius scale.
199
+ */
200
+ /**
201
+ * Elevation scale.
202
+ */
203
+ /**
204
+ * Dimensions.
205
+ */
206
+ /**
207
+ * Mobile specific styles
208
+ */
209
+ /**
210
+ * Editor styles.
211
+ */
212
+ /**
213
+ * Block & Editor UI.
214
+ */
215
+ /**
216
+ * Block paddings.
217
+ */
218
+ /**
219
+ * React Native specific.
220
+ * These variables do not appear to be used anywhere else.
221
+ */
257
222
  .admin-ui-breadcrumbs__list {
258
223
  list-style: none;
259
224
  padding: 0;
@@ -561,16 +526,6 @@
561
526
  .edit-post-meta-boxes-area .is-hidden {
562
527
  display: none;
563
528
  }
564
- .edit-post-meta-boxes-area .metabox-location-side .postbox input[type=checkbox] {
565
- border: 1px solid #757575;
566
- }
567
- .edit-post-meta-boxes-area .metabox-location-side .postbox input[type=checkbox]:checked {
568
- background: #fff;
569
- border-color: #757575;
570
- }
571
- .edit-post-meta-boxes-area .metabox-location-side .postbox input[type=checkbox]::before {
572
- margin: -3px -4px;
573
- }
574
529
 
575
530
  .edit-post-meta-boxes-area__clear {
576
531
  clear: both;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-post",
3
- "version": "8.40.2-next.v.202602241322.0+bce7cff88",
3
+ "version": "8.40.2",
4
4
  "description": "Edit Post module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -48,37 +48,37 @@
48
48
  "postbox"
49
49
  ],
50
50
  "dependencies": {
51
- "@wordpress/a11y": "^4.40.1-next.v.202602241322.0+bce7cff88",
52
- "@wordpress/admin-ui": "^1.8.1-next.v.202602241322.0+bce7cff88",
53
- "@wordpress/api-fetch": "^7.40.1-next.v.202602241322.0+bce7cff88",
54
- "@wordpress/base-styles": "^6.16.1-next.v.202602241322.0+bce7cff88",
55
- "@wordpress/block-editor": "^15.13.2-next.v.202602241322.0+bce7cff88",
56
- "@wordpress/block-library": "^9.40.2-next.v.202602241322.0+bce7cff88",
57
- "@wordpress/blocks": "^15.13.1-next.v.202602241322.0+bce7cff88",
58
- "@wordpress/commands": "^1.40.1-next.v.202602241322.0+bce7cff88",
59
- "@wordpress/components": "^32.3.1-next.v.202602241322.0+bce7cff88",
60
- "@wordpress/compose": "^7.40.1-next.v.202602241322.0+bce7cff88",
61
- "@wordpress/core-data": "^7.40.2-next.v.202602241322.0+bce7cff88",
62
- "@wordpress/data": "^10.40.1-next.v.202602241322.0+bce7cff88",
63
- "@wordpress/deprecated": "^4.40.1-next.v.202602241322.0+bce7cff88",
64
- "@wordpress/dom": "^4.40.1-next.v.202602241322.0+bce7cff88",
65
- "@wordpress/editor": "^14.40.2-next.v.202602241322.0+bce7cff88",
66
- "@wordpress/element": "^6.40.1-next.v.202602241322.0+bce7cff88",
67
- "@wordpress/global-styles-engine": "^1.7.1-next.v.202602241322.0+bce7cff88",
68
- "@wordpress/hooks": "^4.40.1-next.v.202602241322.0+bce7cff88",
69
- "@wordpress/html-entities": "^4.40.1-next.v.202602241322.0+bce7cff88",
70
- "@wordpress/i18n": "^6.13.1-next.v.202602241322.0+bce7cff88",
71
- "@wordpress/icons": "^11.7.1-next.v.202602241322.0+bce7cff88",
72
- "@wordpress/keyboard-shortcuts": "^5.40.1-next.v.202602241322.0+bce7cff88",
73
- "@wordpress/keycodes": "^4.40.1-next.v.202602241322.0+bce7cff88",
74
- "@wordpress/notices": "^5.40.1-next.v.202602241322.0+bce7cff88",
75
- "@wordpress/plugins": "^7.40.1-next.v.202602241322.0+bce7cff88",
76
- "@wordpress/preferences": "^4.40.1-next.v.202602241322.0+bce7cff88",
77
- "@wordpress/private-apis": "^1.40.1-next.v.202602241322.0+bce7cff88",
78
- "@wordpress/url": "^4.40.1-next.v.202602241322.0+bce7cff88",
79
- "@wordpress/viewport": "^6.40.1-next.v.202602241322.0+bce7cff88",
80
- "@wordpress/warning": "^3.40.1-next.v.202602241322.0+bce7cff88",
81
- "@wordpress/widgets": "^4.40.2-next.v.202602241322.0+bce7cff88",
51
+ "@wordpress/a11y": "^4.40.1",
52
+ "@wordpress/admin-ui": "^1.8.1",
53
+ "@wordpress/api-fetch": "^7.40.1",
54
+ "@wordpress/base-styles": "^6.16.1",
55
+ "@wordpress/block-editor": "^15.13.2",
56
+ "@wordpress/block-library": "^9.40.2",
57
+ "@wordpress/blocks": "^15.13.1",
58
+ "@wordpress/commands": "^1.40.1",
59
+ "@wordpress/components": "^32.2.1",
60
+ "@wordpress/compose": "^7.40.1",
61
+ "@wordpress/core-data": "^7.40.2",
62
+ "@wordpress/data": "^10.40.1",
63
+ "@wordpress/deprecated": "^4.40.1",
64
+ "@wordpress/dom": "^4.40.1",
65
+ "@wordpress/editor": "^14.40.2",
66
+ "@wordpress/element": "^6.40.1",
67
+ "@wordpress/global-styles-engine": "^1.7.1",
68
+ "@wordpress/hooks": "^4.40.1",
69
+ "@wordpress/html-entities": "^4.40.1",
70
+ "@wordpress/i18n": "^6.13.1",
71
+ "@wordpress/icons": "^11.7.1",
72
+ "@wordpress/keyboard-shortcuts": "^5.40.1",
73
+ "@wordpress/keycodes": "^4.40.1",
74
+ "@wordpress/notices": "^5.40.1",
75
+ "@wordpress/plugins": "^7.40.1",
76
+ "@wordpress/preferences": "^4.40.1",
77
+ "@wordpress/private-apis": "^1.40.1",
78
+ "@wordpress/url": "^4.40.1",
79
+ "@wordpress/viewport": "^6.40.1",
80
+ "@wordpress/warning": "^3.40.1",
81
+ "@wordpress/widgets": "^4.40.2",
82
82
  "clsx": "^2.1.1",
83
83
  "memize": "^2.1.0"
84
84
  },
@@ -89,5 +89,5 @@
89
89
  "publishConfig": {
90
90
  "access": "public"
91
91
  },
92
- "gitHead": "943dde7f0b600ce238726c36284bc9f70ce0ffa4"
92
+ "gitHead": "adb6623c9f32490cfc73c7ac7f122578c1f10c65"
93
93
  }
package/src/classic.scss CHANGED
@@ -14,8 +14,11 @@
14
14
  // Themes with theme.json can control this themselves.
15
15
  // For full-wide blocks, we compensate for the base padding.
16
16
  // These margins should match the padding value above.
17
- html :where(.editor-styles-wrapper) {
17
+ .editor-styles-wrapper {
18
18
  padding: 8px;
19
+ }
20
+
21
+ html :where(.editor-styles-wrapper) {
19
22
  .block-editor-block-list__layout.is-root-container > .wp-block[data-align="full"] {
20
23
  margin-left: -8px;
21
24
  margin-right: -8px;
@@ -87,24 +87,6 @@
87
87
  .is-hidden {
88
88
  display: none;
89
89
  }
90
-
91
-
92
- // Until checkboxes WordPress-wide are updated to match the new style,
93
- // checkboxes used in metaboxes have to be slightly unstyled here.
94
- // @todo remove this entire rule once checkboxes are the same everywhere.
95
- // See: https://github.com/WordPress/gutenberg/issues/18053
96
- .metabox-location-side .postbox input[type="checkbox"] {
97
- border: $border-width solid $gray-700;
98
-
99
- &:checked {
100
- background: $white;
101
- border-color: $gray-700;
102
- }
103
-
104
- &::before {
105
- margin: -3px -4px;
106
- }
107
- }
108
90
  }
109
91
 
110
92
  .edit-post-meta-boxes-area__clear {
@@ -0,0 +1,222 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render } from '@testing-library/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { RegistryProvider, createRegistry } from '@wordpress/data';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { useMetaBoxInitialization } from '../use-meta-box-initialization';
15
+ import { STORE_NAME } from '../../../store/constants';
16
+
17
+ // Mock unlock to be an identity function so private actions are directly accessible.
18
+ jest.mock( '../../../lock-unlock', () => ( {
19
+ unlock: ( value ) => value,
20
+ } ) );
21
+
22
+ const storeConfig = {
23
+ actions: {
24
+ forceUpdate: jest.fn( () => ( { type: 'FORCE_UPDATE' } ) ),
25
+ },
26
+ reducer: ( state = {}, action ) =>
27
+ action.type === 'FORCE_UPDATE' ? { ...state } : state,
28
+ };
29
+
30
+ const setCollaborationSupported = jest.fn( () => ( {
31
+ type: 'SET_COLLABORATION_SUPPORTED',
32
+ } ) );
33
+
34
+ const initializeMetaBoxes = jest.fn( () => ( {
35
+ type: 'META_BOXES_INITIALIZED',
36
+ } ) );
37
+
38
+ const updateEditorSettings = jest.fn( () => ( {
39
+ type: 'UPDATE_EDITOR_SETTINGS',
40
+ } ) );
41
+
42
+ function createMockStores( {
43
+ isEditorReady = true,
44
+ isCollaborationEnabled = true,
45
+ metaBoxes = [],
46
+ } = {} ) {
47
+ return {
48
+ 'core/editor': {
49
+ ...storeConfig,
50
+ actions: {
51
+ ...storeConfig.actions,
52
+ updateEditorSettings,
53
+ },
54
+ selectors: {
55
+ __unstableIsEditorReady: jest.fn( () => isEditorReady ),
56
+ isCollaborationEnabledForCurrentPost: jest.fn(
57
+ () => isCollaborationEnabled
58
+ ),
59
+ },
60
+ },
61
+ core: {
62
+ ...storeConfig,
63
+ actions: {
64
+ ...storeConfig.actions,
65
+ setCollaborationSupported,
66
+ },
67
+ },
68
+ [ STORE_NAME ]: {
69
+ ...storeConfig,
70
+ actions: {
71
+ ...storeConfig.actions,
72
+ initializeMetaBoxes,
73
+ },
74
+ selectors: {
75
+ getAllMetaBoxes: jest.fn( () => metaBoxes ),
76
+ hasMetaBoxes: jest.fn( () => metaBoxes.length > 0 ),
77
+ getActiveMetaBoxLocations: jest.fn( () =>
78
+ metaBoxes.length > 0 ? [ 'normal' ] : []
79
+ ),
80
+ },
81
+ },
82
+ };
83
+ }
84
+
85
+ function TestComponent( { enabled } ) {
86
+ useMetaBoxInitialization( enabled );
87
+ return null;
88
+ }
89
+
90
+ function renderHook( registry, enabled = true ) {
91
+ return render(
92
+ <RegistryProvider value={ registry }>
93
+ <TestComponent enabled={ enabled } />
94
+ </RegistryProvider>
95
+ );
96
+ }
97
+
98
+ describe( 'useMetaBoxInitialization', () => {
99
+ afterEach( () => {
100
+ setCollaborationSupported.mockClear();
101
+ initializeMetaBoxes.mockClear();
102
+ updateEditorSettings.mockClear();
103
+ } );
104
+
105
+ it( 'disables collaboration when metaboxes are present', () => {
106
+ const mockStores = createMockStores( {
107
+ metaBoxes: [
108
+ { id: 'my-metabox', title: 'My Meta Box' },
109
+ { id: 'another-metabox', title: 'Another' },
110
+ ],
111
+ } );
112
+ const registry = createRegistry( mockStores );
113
+
114
+ renderHook( registry );
115
+
116
+ expect( initializeMetaBoxes ).toHaveBeenCalled();
117
+ expect( setCollaborationSupported ).toHaveBeenCalledWith( false );
118
+ } );
119
+
120
+ it( 'does not disable collaboration when all metaboxes are rtcCompatible', () => {
121
+ const mockStores = createMockStores( {
122
+ metaBoxes: [
123
+ {
124
+ id: 'my-metabox',
125
+ title: 'My Meta Box',
126
+ __rtc_compatible: true,
127
+ },
128
+ {
129
+ id: 'another-metabox',
130
+ title: 'Another',
131
+ __rtc_compatible: true,
132
+ },
133
+ ],
134
+ } );
135
+ const registry = createRegistry( mockStores );
136
+
137
+ renderHook( registry );
138
+
139
+ expect( initializeMetaBoxes ).toHaveBeenCalled();
140
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
141
+ } );
142
+
143
+ it( 'disables collaboration when some metaboxes lack rtcCompatible', () => {
144
+ const mockStores = createMockStores( {
145
+ metaBoxes: [
146
+ {
147
+ id: 'compatible-metabox',
148
+ title: 'Compatible',
149
+ __rtc_compatible: true,
150
+ },
151
+ { id: 'incompatible-metabox', title: 'Incompatible' },
152
+ ],
153
+ } );
154
+ const registry = createRegistry( mockStores );
155
+
156
+ renderHook( registry );
157
+
158
+ expect( setCollaborationSupported ).toHaveBeenCalledWith( false );
159
+ } );
160
+
161
+ it( 'does not disable collaboration when the only metabox is rtcCompatible', () => {
162
+ const mockStores = createMockStores( {
163
+ metaBoxes: [
164
+ {
165
+ id: 'compatible-metabox',
166
+ title: 'Compatible',
167
+ __rtc_compatible: true,
168
+ },
169
+ ],
170
+ } );
171
+ const registry = createRegistry( mockStores );
172
+
173
+ renderHook( registry );
174
+
175
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
176
+ } );
177
+
178
+ it( 'does not disable collaboration when there are no metaboxes', () => {
179
+ const mockStores = createMockStores( {
180
+ metaBoxes: [],
181
+ } );
182
+ const registry = createRegistry( mockStores );
183
+
184
+ renderHook( registry );
185
+
186
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
187
+ } );
188
+
189
+ it( 'does not disable collaboration when collaboration is not enabled', () => {
190
+ const mockStores = createMockStores( {
191
+ isCollaborationEnabled: false,
192
+ metaBoxes: [ { id: 'my-metabox', title: 'My Meta Box' } ],
193
+ } );
194
+ const registry = createRegistry( mockStores );
195
+
196
+ renderHook( registry );
197
+
198
+ expect( setCollaborationSupported ).not.toHaveBeenCalled();
199
+ } );
200
+
201
+ it( 'disables visual revisions when metaboxes are present', () => {
202
+ const mockStores = createMockStores( {
203
+ metaBoxes: [ { id: 'my-metabox', title: 'My Meta Box' } ],
204
+ } );
205
+ const registry = createRegistry( mockStores );
206
+
207
+ renderHook( registry );
208
+
209
+ expect( updateEditorSettings ).toHaveBeenCalledWith( {
210
+ disableVisualRevisions: true,
211
+ } );
212
+ } );
213
+
214
+ it( 'does not disable visual revisions when there are no metaboxes', () => {
215
+ const mockStores = createMockStores( { metaBoxes: [] } );
216
+ const registry = createRegistry( mockStores );
217
+
218
+ renderHook( registry );
219
+
220
+ expect( updateEditorSettings ).not.toHaveBeenCalled();
221
+ } );
222
+ } );
@@ -3,12 +3,14 @@
3
3
  */
4
4
  import { useDispatch, useSelect } from '@wordpress/data';
5
5
  import { store as editorStore } from '@wordpress/editor';
6
+ import { store as coreStore } from '@wordpress/core-data';
6
7
  import { useEffect } from '@wordpress/element';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
12
  import { store as editPostStore } from '../../store';
13
+ import { unlock } from '../../lock-unlock';
12
14
 
13
15
  /**
14
16
  * Initializes WordPress `postboxes` script and the logic for saving meta boxes.
@@ -16,17 +18,62 @@ import { store as editPostStore } from '../../store';
16
18
  * @param { boolean } enabled
17
19
  */
18
20
  export const useMetaBoxInitialization = ( enabled ) => {
19
- const isEnabledAndEditorReady = useSelect(
20
- ( select ) =>
21
- enabled && select( editorStore ).__unstableIsEditorReady(),
21
+ const {
22
+ isEnabledAndEditorReady,
23
+ isCollaborationEnabled,
24
+ hasIncompatibleMetaBoxes,
25
+ hasActiveMetaBoxes,
26
+ } = useSelect(
27
+ ( select ) => {
28
+ const {
29
+ __unstableIsEditorReady,
30
+ isCollaborationEnabledForCurrentPost,
31
+ } = unlock( select( editorStore ) );
32
+ return {
33
+ isEnabledAndEditorReady: enabled && __unstableIsEditorReady(),
34
+ isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
35
+ hasIncompatibleMetaBoxes: enabled
36
+ ? select( editPostStore )
37
+ .getAllMetaBoxes()
38
+ .some( ( metaBox ) => ! metaBox.__rtc_compatible )
39
+ : false,
40
+ hasActiveMetaBoxes:
41
+ enabled && select( editPostStore ).hasMetaBoxes(),
42
+ };
43
+ },
22
44
  [ enabled ]
23
45
  );
46
+ const { setCollaborationSupported } = unlock( useDispatch( coreStore ) );
47
+ const { updateEditorSettings } = useDispatch( editorStore );
24
48
  const { initializeMetaBoxes } = useDispatch( editPostStore );
49
+
25
50
  // The effect has to rerun when the editor is ready because initializeMetaBoxes
26
51
  // will noop until then.
27
52
  useEffect( () => {
28
53
  if ( isEnabledAndEditorReady ) {
29
54
  initializeMetaBoxes();
55
+
56
+ // Disable real-time collaboration when incompatible meta boxes are detected.
57
+ if ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {
58
+ setCollaborationSupported( false );
59
+ }
60
+
61
+ // Classic meta box values are saved through a separate
62
+ // admin-ajax submission that the in-editor revisions restore
63
+ // does not drive, so visual revisions would silently leave
64
+ // them untouched. Fall back to the classic revision.php
65
+ // admin screen instead.
66
+ if ( hasActiveMetaBoxes ) {
67
+ updateEditorSettings( { disableVisualRevisions: true } );
68
+ }
30
69
  }
31
- }, [ isEnabledAndEditorReady, initializeMetaBoxes ] );
70
+ }, [
71
+ isEnabledAndEditorReady,
72
+ initializeMetaBoxes,
73
+ isCollaborationEnabled,
74
+ setCollaborationSupported,
75
+ hasIncompatibleMetaBoxes,
76
+ hasActiveMetaBoxes,
77
+ updateEditorSettings,
78
+ ] );
32
79
  };
package/src/index.js CHANGED
@@ -72,6 +72,8 @@ export function initializeEditor(
72
72
  showListViewByDefault: false,
73
73
  enableChoosePatternModal: true,
74
74
  isPublishSidebarEnabled: true,
75
+ showCollaborationCursor: false,
76
+ showCollaborationNotifications: true,
75
77
  } );
76
78
 
77
79
  if ( window.__clientSideMediaProcessing ) {
@@ -32,7 +32,10 @@ function mergeMetaboxes( metaboxes = [], newMetaboxes ) {
32
32
  ( box ) => box.id === metabox.id
33
33
  );
34
34
  if ( existing !== -1 ) {
35
- mergedMetaboxes[ existing ] = metabox;
35
+ mergedMetaboxes[ existing ] = {
36
+ ...mergedMetaboxes[ existing ],
37
+ ...metabox,
38
+ };
36
39
  } else {
37
40
  mergedMetaboxes.push( metabox );
38
41
  }