@wordpress/edit-widgets 5.2.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/error-boundary/index.js +24 -22
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/index.js +2 -5
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/unsaved-changes-warning.js +1 -1
- package/build/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +7 -1
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/experiments.js +19 -0
- package/build/experiments.js.map +1 -0
- package/build/index.js +24 -25
- package/build/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +24 -22
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/index.js +2 -5
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +6 -2
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/experiments.js +9 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/index.js +19 -24
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +27 -26
- package/src/components/error-boundary/index.js +23 -25
- package/src/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/src/components/layout/index.js +2 -2
- package/src/components/layout/unsaved-changes-warning.js +1 -1
- package/src/components/sidebar/style.scss +8 -0
- package/src/components/widget-areas-block-editor-provider/index.js +6 -3
- package/src/experiments.js +10 -0
- package/src/index.js +21 -24
|
@@ -32,7 +32,7 @@ export default function UnsavedChangesWarning() {
|
|
|
32
32
|
*
|
|
33
33
|
* @param {Event} event `beforeunload` event.
|
|
34
34
|
*
|
|
35
|
-
* @return {
|
|
35
|
+
* @return {string | undefined} Warning prompt message, if unsaved changes exist.
|
|
36
36
|
*/
|
|
37
37
|
const warnIfUnsavedChanges = event => {
|
|
38
38
|
if (isDirty) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/components/layout/unsaved-changes-warning.js"],"names":["__","useEffect","useSelect","store","editWidgetsStore","UnsavedChangesWarning","isDirty","select","getEditedWidgetAreas","editedWidgetAreas","length","warnIfUnsavedChanges","event","returnValue","window","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,GAAiC;AAC/C,QAAMC,OAAO,GAAGJ,SAAS,CAAIK,MAAF,IAAc;AACxC,UAAM;AAAEC,MAAAA;AAAF,QAA2BD,MAAM,CAAEH,gBAAF,CAAvC;AACA,UAAMK,iBAAiB,GAAGD,oBAAoB,EAA9C;AAEA,WAAO,CAAAC,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,YAAAA,iBAAiB,CAAEC,MAAnB,IAA4B,CAAnC;AACA,GALwB,EAKtB,EALsB,CAAzB;AAOAT,EAAAA,SAAS,CAAE,MAAM;AAChB;AACF;AACA;AACA;AACA;AACA;AACA;AACE,UAAMU,oBAAoB,GAAKC,KAAF,IAAa;AACzC,UAAKN,OAAL,EAAe;AACdM,QAAAA,KAAK,CAACC,WAAN,GAAoBb,EAAE,CACrB,8DADqB,CAAtB;AAGA,eAAOY,KAAK,CAACC,WAAb;AACA;AACD,KAPD;;AASAC,IAAAA,MAAM,CAACC,gBAAP,CAAyB,cAAzB,EAAyCJ,oBAAzC;AAEA,WAAO,MAAM;AACZG,MAAAA,MAAM,CAACE,mBAAP,CAA4B,cAA5B,EAA4CL,oBAA5C;AACA,KAFD;AAGA,GAtBQ,EAsBN,CAAEL,OAAF,CAtBM,CAAT;AAwBA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n *\n * This is a duplicate of the component implemented in the editor package.\n * Duplicated here as edit-widgets doesn't depend on editor.\n *\n * @return {WPComponent} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst isDirty = useSelect( ( select ) => {\n\t\tconst { getEditedWidgetAreas } = select( editWidgetsStore );\n\t\tconst editedWidgetAreas = getEditedWidgetAreas();\n\n\t\treturn editedWidgetAreas?.length > 0;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {Event} event `beforeunload` event.\n\t\t *\n\t\t * @return {
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/components/layout/unsaved-changes-warning.js"],"names":["__","useEffect","useSelect","store","editWidgetsStore","UnsavedChangesWarning","isDirty","select","getEditedWidgetAreas","editedWidgetAreas","length","warnIfUnsavedChanges","event","returnValue","window","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,GAAiC;AAC/C,QAAMC,OAAO,GAAGJ,SAAS,CAAIK,MAAF,IAAc;AACxC,UAAM;AAAEC,MAAAA;AAAF,QAA2BD,MAAM,CAAEH,gBAAF,CAAvC;AACA,UAAMK,iBAAiB,GAAGD,oBAAoB,EAA9C;AAEA,WAAO,CAAAC,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,YAAAA,iBAAiB,CAAEC,MAAnB,IAA4B,CAAnC;AACA,GALwB,EAKtB,EALsB,CAAzB;AAOAT,EAAAA,SAAS,CAAE,MAAM;AAChB;AACF;AACA;AACA;AACA;AACA;AACA;AACE,UAAMU,oBAAoB,GAAKC,KAAF,IAAa;AACzC,UAAKN,OAAL,EAAe;AACdM,QAAAA,KAAK,CAACC,WAAN,GAAoBb,EAAE,CACrB,8DADqB,CAAtB;AAGA,eAAOY,KAAK,CAACC,WAAb;AACA;AACD,KAPD;;AASAC,IAAAA,MAAM,CAACC,gBAAP,CAAyB,cAAzB,EAAyCJ,oBAAzC;AAEA,WAAO,MAAM;AACZG,MAAAA,MAAM,CAACE,mBAAP,CAA4B,cAA5B,EAA4CL,oBAA5C;AACA,KAFD;AAGA,GAtBQ,EAsBN,CAAEL,OAAF,CAtBM,CAAT;AAwBA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\n/**\n * Warns the user if there are unsaved changes before leaving the editor.\n *\n * This is a duplicate of the component implemented in the editor package.\n * Duplicated here as edit-widgets doesn't depend on editor.\n *\n * @return {WPComponent} The component.\n */\nexport default function UnsavedChangesWarning() {\n\tconst isDirty = useSelect( ( select ) => {\n\t\tconst { getEditedWidgetAreas } = select( editWidgetsStore );\n\t\tconst editedWidgetAreas = getEditedWidgetAreas();\n\n\t\treturn editedWidgetAreas?.length > 0;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Warns the user if there are unsaved changes before leaving the editor.\n\t\t *\n\t\t * @param {Event} event `beforeunload` event.\n\t\t *\n\t\t * @return {string | undefined} Warning prompt message, if unsaved changes exist.\n\t\t */\n\t\tconst warnIfUnsavedChanges = ( event ) => {\n\t\t\tif ( isDirty ) {\n\t\t\t\tevent.returnValue = __(\n\t\t\t\t\t'You have unsaved changes. If you proceed, they will be lost.'\n\t\t\t\t);\n\t\t\t\treturn event.returnValue;\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener( 'beforeunload', warnIfUnsavedChanges );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'beforeunload', warnIfUnsavedChanges );\n\t\t};\n\t}, [ isDirty ] );\n\n\treturn null;\n}\n"]}
|
|
@@ -9,7 +9,7 @@ import { uploadMedia } from '@wordpress/media-utils';
|
|
|
9
9
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
10
|
import { useEntityBlockEditor, store as coreStore, useResourcePermissions } from '@wordpress/core-data';
|
|
11
11
|
import { useMemo } from '@wordpress/element';
|
|
12
|
-
import {
|
|
12
|
+
import { BlockEditorKeyboardShortcuts, CopyHandler, experiments as blockEditorExperiments } from '@wordpress/block-editor';
|
|
13
13
|
import { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';
|
|
14
14
|
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
15
15
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -22,6 +22,10 @@ import { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';
|
|
|
22
22
|
import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';
|
|
23
23
|
import { store as editWidgetsStore } from '../../store';
|
|
24
24
|
import { ALLOW_REUSABLE_BLOCKS } from '../../constants';
|
|
25
|
+
import { unlock } from '../../experiments';
|
|
26
|
+
const {
|
|
27
|
+
ExperimentalBlockEditorProvider
|
|
28
|
+
} = unlock(blockEditorExperiments);
|
|
25
29
|
export default function WidgetAreasBlockEditorProvider(_ref) {
|
|
26
30
|
let {
|
|
27
31
|
blockEditorSettings,
|
|
@@ -78,7 +82,7 @@ export default function WidgetAreasBlockEditorProvider(_ref) {
|
|
|
78
82
|
const [blocks, onInput, onChange] = useEntityBlockEditor(KIND, POST_TYPE, {
|
|
79
83
|
id: buildWidgetAreasPostId()
|
|
80
84
|
});
|
|
81
|
-
return createElement(ShortcutProvider, null, createElement(BlockEditorKeyboardShortcuts.Register, null), createElement(KeyboardShortcuts.Register, null), createElement(SlotFillProvider, null, createElement(
|
|
85
|
+
return createElement(ShortcutProvider, null, createElement(BlockEditorKeyboardShortcuts.Register, null), createElement(KeyboardShortcuts.Register, null), createElement(SlotFillProvider, null, createElement(ExperimentalBlockEditorProvider, _extends({
|
|
82
86
|
value: blocks,
|
|
83
87
|
onInput: onInput,
|
|
84
88
|
onChange: onChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"names":["SlotFillProvider","uploadMedia","useDispatch","useSelect","useEntityBlockEditor","store","coreStore","useResourcePermissions","useMemo","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"names":["SlotFillProvider","uploadMedia","useDispatch","useSelect","useEntityBlockEditor","store","coreStore","useResourcePermissions","useMemo","BlockEditorKeyboardShortcuts","CopyHandler","experiments","blockEditorExperiments","ReusableBlocksMenuItems","ShortcutProvider","preferencesStore","KeyboardShortcuts","buildWidgetAreasPostId","KIND","POST_TYPE","useLastSelectedWidgetArea","editWidgetsStore","ALLOW_REUSABLE_BLOCKS","unlock","ExperimentalBlockEditorProvider","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","mediaPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","select","widgetAreas","getWidgetAreas","widgets","getWidgets","getEntityRecords","get","setIsInserterOpened","settings","mediaUploadBlockEditor","canCreate","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","blocks","onInput","onChange","id"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,uBAAjC;AACA,SAASC,WAAT,QAA4B,wBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,oBADD,EAECC,KAAK,IAAIC,SAFV,EAGCC,sBAHD,QAIO,sBAJP;AAKA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SACCC,4BADD,EAECC,WAFD,EAGCC,WAAW,IAAIC,sBAHhB,QAIO,yBAJP;AAKA,SAASC,uBAAT,QAAwC,4BAAxC;AACA,SAASC,gBAAT,QAAiC,+BAAjC;AACA,SAAST,KAAK,IAAIU,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SAASC,sBAAT,EAAiCC,IAAjC,EAAuCC,SAAvC,QAAwD,mBAAxD;AACA,OAAOC,yBAAP,MAAsC,2CAAtC;AACA,SAASf,KAAK,IAAIgB,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,QAAsC,iBAAtC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAsCD,MAAM,CAAEX,sBAAF,CAAlD;AAEA,eAAe,SAASa,8BAAT,OAIX;AAAA,MAJoD;AACvDC,IAAAA,mBADuD;AAEvDC,IAAAA,QAFuD;AAGvD,OAAGC;AAHoD,GAIpD;AACH,QAAMC,gBAAgB,GAAGtB,sBAAsB,CAAE,OAAF,CAA/C;AACA,QAAM;AAAEuB,IAAAA,cAAF;AAAkBC,IAAAA,oBAAlB;AAAwCC,IAAAA;AAAxC,MACL7B,SAAS,CACN8B,MAAF,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,WAAW,EAAET,sBALP;AAMNU,MAAAA,YAAY,EAAE,KANR;AAONC,MAAAA,iCAAiC,EAAEb;AAP7B,KAAP;AASA,GApBuB,EAoBrB,CACFd,mBADE,EAEFK,oBAFE,EAGFC,oBAHE,EAIFH,gBAAgB,CAACc,SAJf,EAKFb,cALE,EAMFU,mBANE,CApBqB,CAAxB;AA6BA,QAAMc,YAAY,GAAGlC,yBAAyB,EAA9C;AAEA,QAAM,CAAEmC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgCrD,oBAAoB,CACzDc,IADyD,EAEzDC,SAFyD,EAGzD;AAAEuC,IAAAA,EAAE,EAAEzC,sBAAsB;AAA5B,GAHyD,CAA1D;AAMA,SACC,cAAC,gBAAD,QACC,cAAC,4BAAD,CAA8B,QAA9B,OADD,EAEC,cAAC,iBAAD,CAAmB,QAAnB,OAFD,EAGC,cAAC,gBAAD,QACC,cAAC,+BAAD;AACC,IAAA,KAAK,EAAGsC,MADT;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ,EAAGhB,QAJZ;AAKC,IAAA,cAAc,EAAG;AALlB,KAMMb,KANN,GAQC,cAAC,WAAD,QAAeD,QAAf,CARD,EASC,cAAC,uBAAD;AAAyB,IAAA,YAAY,EAAG2B;AAAxC,IATD,CADD,CAHD,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n\tuseResourcePermissions,\n} from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBlockEditorKeyboardShortcuts,\n\tCopyHandler,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../experiments';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst mediaPermissions = useResourcePermissions( 'media' );\n\tconst { reusableBlocks, isFixedToolbarActive, keepCaretInsideBlock } =\n\t\tuseSelect(\n\t\t\t( select ) => ( {\n\t\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t'wp_block'\n\t\t\t\t\t )\n\t\t\t\t\t: [],\n\t\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-widgets',\n\t\t\t\t\t'fixedToolbar'\n\t\t\t\t),\n\t\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-widgets',\n\t\t\t\t\t'keepCaretInsideBlock'\n\t\t\t\t),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( mediaPermissions.canCreate ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tmediaPermissions.canCreate,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<ShortcutProvider>\n\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<SlotFillProvider>\n\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<CopyHandler>{ children }</CopyHandler>\n\t\t\t\t\t<ReusableBlocksMenuItems rootClientId={ widgetAreaId } />\n\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';
|
|
5
|
+
export const {
|
|
6
|
+
lock,
|
|
7
|
+
unlock
|
|
8
|
+
} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-widgets');
|
|
9
|
+
//# sourceMappingURL=experiments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/experiments.js"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,wBAAjE;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZF,gDAAgD,CAC/C,8GAD+C,EAE/C,yBAF+C,CAD1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-widgets'\n\t);\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -6,7 +6,8 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
import { registerBlockType, unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase
|
|
7
7
|
setFreeformContentHandlerName, store as blocksStore } from '@wordpress/blocks';
|
|
8
8
|
import { dispatch } from '@wordpress/data';
|
|
9
|
-
import
|
|
9
|
+
import deprecated from '@wordpress/deprecated';
|
|
10
|
+
import { createRoot } from '@wordpress/element';
|
|
10
11
|
import { registerCoreBlocks, __experimentalGetCoreBlocks, __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
|
|
11
12
|
import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
|
|
12
13
|
import { registerLegacyWidgetBlock, registerLegacyWidgetVariations, registerWidgetGroupBlock } from '@wordpress/widgets';
|
|
@@ -21,23 +22,6 @@ import * as widgetArea from './blocks/widget-area';
|
|
|
21
22
|
import Layout from './components/layout';
|
|
22
23
|
import { ALLOW_REUSABLE_BLOCKS, ENABLE_EXPERIMENTAL_FSE_BLOCKS } from './constants';
|
|
23
24
|
const disabledBlocks = ['core/more', 'core/freeform', 'core/template-part', ...(ALLOW_REUSABLE_BLOCKS ? [] : ['core/block'])];
|
|
24
|
-
/**
|
|
25
|
-
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
26
|
-
* an unhandled error occurs, replacing previously mounted editor element using
|
|
27
|
-
* an initial state from prior to the crash.
|
|
28
|
-
*
|
|
29
|
-
* @param {Element} target DOM node in which editor is rendered.
|
|
30
|
-
* @param {?Object} settings Editor settings object.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
export function reinitializeEditor(target, settings) {
|
|
34
|
-
unmountComponentAtNode(target);
|
|
35
|
-
const reboot = reinitializeEditor.bind(null, target, settings);
|
|
36
|
-
render(createElement(Layout, {
|
|
37
|
-
blockEditorSettings: settings,
|
|
38
|
-
onError: reboot
|
|
39
|
-
}), target);
|
|
40
|
-
}
|
|
41
25
|
/**
|
|
42
26
|
* Initializes the block editor in the widgets screen.
|
|
43
27
|
*
|
|
@@ -45,9 +29,9 @@ export function reinitializeEditor(target, settings) {
|
|
|
45
29
|
* @param {Object} settings Block editor settings.
|
|
46
30
|
*/
|
|
47
31
|
|
|
48
|
-
export function
|
|
32
|
+
export function initializeEditor(id, settings) {
|
|
49
33
|
const target = document.getElementById(id);
|
|
50
|
-
const
|
|
34
|
+
const root = createRoot(target);
|
|
51
35
|
|
|
52
36
|
const coreBlocks = __experimentalGetCoreBlocks().filter(block => {
|
|
53
37
|
return !(disabledBlocks.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site') || block.name.startsWith('core/navigation'));
|
|
@@ -82,10 +66,21 @@ export function initialize(id, settings) {
|
|
|
82
66
|
|
|
83
67
|
|
|
84
68
|
setFreeformContentHandlerName('core/html');
|
|
85
|
-
render(createElement(Layout, {
|
|
86
|
-
blockEditorSettings: settings
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
root.render(createElement(Layout, {
|
|
70
|
+
blockEditorSettings: settings
|
|
71
|
+
}));
|
|
72
|
+
return root;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compatibility export under the old `initialize` name.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
export const initialize = initializeEditor;
|
|
79
|
+
export function reinitializeEditor() {
|
|
80
|
+
deprecated('wp.editWidgets.reinitializeEditor', {
|
|
81
|
+
since: '6.2',
|
|
82
|
+
version: '6.3'
|
|
83
|
+
});
|
|
89
84
|
}
|
|
90
85
|
/**
|
|
91
86
|
* Function to register an individual block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/index.js"],"names":["registerBlockType","unstable__bootstrapServerSideBlockDefinitions","setFreeformContentHandlerName","store","blocksStore","dispatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/index.js"],"names":["registerBlockType","unstable__bootstrapServerSideBlockDefinitions","setFreeformContentHandlerName","store","blocksStore","dispatch","deprecated","createRoot","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","registerLegacyWidgetBlock","registerLegacyWidgetVariations","registerWidgetGroupBlock","preferencesStore","widgetArea","Layout","ALLOW_REUSABLE_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","disabledBlocks","initializeEditor","id","settings","target","document","getElementById","root","coreBlocks","filter","block","includes","name","startsWith","setDefaults","fixedToolbar","welcomeGuide","showBlockBreadcrumbs","themeStyles","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","registerBlock","search","searchOptions","render","initialize","reinitializeEditor","since","version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AAE,KADyC;AAEhDC,IAAAA,OAAO,EAAE;AAFuC,GAAvC,CAAV;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMP,aAAa,GAAKd,KAAF,IAAa;AAClC,MAAK,CAAEA,KAAP,EAAe;AACd;AACA;;AACD,QAAM;AAAEsB,IAAAA,QAAF;AAAY7B,IAAAA,QAAZ;AAAsBS,IAAAA;AAAtB,MAA+BF,KAArC;;AACA,MAAKsB,QAAL,EAAgB;AACfpD,IAAAA,6CAA6C,CAAE;AAAE,OAAEgC,IAAF,GAAUoB;AAAZ,KAAF,CAA7C;AACA;;AACDrD,EAAAA,iBAAiB,CAAEiC,IAAF,EAAQT,QAAR,CAAjB;AACA,CATD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\n\nimport Layout from './components/layout';\nimport {\n\tALLOW_REUSABLE_BLOCKS,\n\tENABLE_EXPERIMENTAL_FSE_BLOCKS,\n} from './constants';\n\nconst disabledBlocks = [\n\t'core/more',\n\t'core/freeform',\n\t'core/template-part',\n\t...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),\n];\n\n/**\n * Initializes the block editor in the widgets screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Block editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tdisabledBlocks.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\tthemeStyles: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( settings );\n\tregisterBlock( widgetArea );\n\tregisterWidgetGroupBlock();\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\troot.render( <Layout blockEditorSettings={ settings } /> );\n\n\treturn root;\n}\n\n/**\n * Compatibility export under the old `initialize` name.\n */\nexport const initialize = initializeEditor;\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editWidgets.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\n/**\n * Function to register an individual block.\n *\n * @param {Object} block The block to be registered.\n *\n */\nconst registerBlock = ( block ) => {\n\tif ( ! block ) {\n\t\treturn;\n\t}\n\tconst { metadata, settings, name } = block;\n\tif ( metadata ) {\n\t\tunstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );\n\t}\n\tregisterBlockType( name, settings );\n};\n"]}
|
|
@@ -779,6 +779,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
779
779
|
.components-button.edit-widgets-sidebar__panel-tab:focus:not(:disabled) {
|
|
780
780
|
position: relative;
|
|
781
781
|
box-shadow: none;
|
|
782
|
+
outline: none;
|
|
782
783
|
}
|
|
783
784
|
.components-button.edit-widgets-sidebar__panel-tab::after {
|
|
784
785
|
content: "";
|
|
@@ -800,6 +801,8 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
800
801
|
}
|
|
801
802
|
.components-button.edit-widgets-sidebar__panel-tab.is-active::after {
|
|
802
803
|
height: calc(1 * var(--wp-admin-border-width-focus));
|
|
804
|
+
outline: 2px solid transparent;
|
|
805
|
+
outline-offset: -1px;
|
|
803
806
|
}
|
|
804
807
|
.components-button.edit-widgets-sidebar__panel-tab::before {
|
|
805
808
|
content: "";
|
|
@@ -821,6 +824,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
821
824
|
}
|
|
822
825
|
.components-button.edit-widgets-sidebar__panel-tab:focus-visible::before {
|
|
823
826
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
827
|
+
outline: 2px solid transparent;
|
|
824
828
|
}
|
|
825
829
|
|
|
826
830
|
.edit-widgets-widget-areas__top-container {
|
package/build-style/style.css
CHANGED
|
@@ -779,6 +779,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
779
779
|
.components-button.edit-widgets-sidebar__panel-tab:focus:not(:disabled) {
|
|
780
780
|
position: relative;
|
|
781
781
|
box-shadow: none;
|
|
782
|
+
outline: none;
|
|
782
783
|
}
|
|
783
784
|
.components-button.edit-widgets-sidebar__panel-tab::after {
|
|
784
785
|
content: "";
|
|
@@ -800,6 +801,8 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
800
801
|
}
|
|
801
802
|
.components-button.edit-widgets-sidebar__panel-tab.is-active::after {
|
|
802
803
|
height: calc(1 * var(--wp-admin-border-width-focus));
|
|
804
|
+
outline: 2px solid transparent;
|
|
805
|
+
outline-offset: -1px;
|
|
803
806
|
}
|
|
804
807
|
.components-button.edit-widgets-sidebar__panel-tab::before {
|
|
805
808
|
content: "";
|
|
@@ -821,6 +824,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
821
824
|
}
|
|
822
825
|
.components-button.edit-widgets-sidebar__panel-tab:focus-visible::before {
|
|
823
826
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
827
|
+
outline: 2px solid transparent;
|
|
824
828
|
}
|
|
825
829
|
|
|
826
830
|
.edit-widgets-widget-areas__top-container {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,30 +27,31 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/api-fetch": "^6.
|
|
31
|
-
"@wordpress/block-editor": "^11.
|
|
32
|
-
"@wordpress/block-library": "^8.
|
|
33
|
-
"@wordpress/blocks": "^12.
|
|
34
|
-
"@wordpress/components": "^23.
|
|
35
|
-
"@wordpress/compose": "^6.
|
|
36
|
-
"@wordpress/core-data": "^6.
|
|
37
|
-
"@wordpress/data": "^8.
|
|
38
|
-
"@wordpress/deprecated": "^3.
|
|
39
|
-
"@wordpress/dom": "^3.
|
|
40
|
-
"@wordpress/element": "^5.
|
|
41
|
-
"@wordpress/
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"@wordpress/
|
|
44
|
-
"@wordpress/
|
|
45
|
-
"@wordpress/
|
|
46
|
-
"@wordpress/
|
|
47
|
-
"@wordpress/
|
|
48
|
-
"@wordpress/
|
|
49
|
-
"@wordpress/
|
|
50
|
-
"@wordpress/
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
30
|
+
"@wordpress/api-fetch": "^6.23.1",
|
|
31
|
+
"@wordpress/block-editor": "^11.3.1",
|
|
32
|
+
"@wordpress/block-library": "^8.3.1",
|
|
33
|
+
"@wordpress/blocks": "^12.3.1",
|
|
34
|
+
"@wordpress/components": "^23.3.1",
|
|
35
|
+
"@wordpress/compose": "^6.3.1",
|
|
36
|
+
"@wordpress/core-data": "^6.3.1",
|
|
37
|
+
"@wordpress/data": "^8.3.1",
|
|
38
|
+
"@wordpress/deprecated": "^3.26.1",
|
|
39
|
+
"@wordpress/dom": "^3.26.1",
|
|
40
|
+
"@wordpress/element": "^5.3.1",
|
|
41
|
+
"@wordpress/experiments": "^0.8.1",
|
|
42
|
+
"@wordpress/hooks": "^3.26.1",
|
|
43
|
+
"@wordpress/i18n": "^4.26.1",
|
|
44
|
+
"@wordpress/icons": "^9.17.1",
|
|
45
|
+
"@wordpress/interface": "^5.3.1",
|
|
46
|
+
"@wordpress/keyboard-shortcuts": "^4.3.1",
|
|
47
|
+
"@wordpress/keycodes": "^3.26.1",
|
|
48
|
+
"@wordpress/media-utils": "^4.17.1",
|
|
49
|
+
"@wordpress/notices": "^3.26.1",
|
|
50
|
+
"@wordpress/plugins": "^5.3.1",
|
|
51
|
+
"@wordpress/preferences": "^3.3.1",
|
|
52
|
+
"@wordpress/reusable-blocks": "^4.3.1",
|
|
53
|
+
"@wordpress/url": "^3.27.1",
|
|
54
|
+
"@wordpress/widgets": "^3.3.1",
|
|
54
55
|
"classnames": "^2.3.1"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"access": "public"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "e9ff92d836928aba65dde94d9d193bc401a934d7"
|
|
64
65
|
}
|
|
@@ -17,51 +17,49 @@ function CopyButton( { text, children } ) {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function ErrorBoundaryWarning( { message, error } ) {
|
|
21
|
+
const actions = [
|
|
22
|
+
<CopyButton key="copy-error" text={ error.stack }>
|
|
23
|
+
{ __( 'Copy Error' ) }
|
|
24
|
+
</CopyButton>,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Warning className="edit-widgets-error-boundary" actions={ actions }>
|
|
29
|
+
{ message }
|
|
30
|
+
</Warning>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
export default class ErrorBoundary extends Component {
|
|
21
35
|
constructor() {
|
|
22
36
|
super( ...arguments );
|
|
23
37
|
|
|
24
|
-
this.reboot = this.reboot.bind( this );
|
|
25
|
-
|
|
26
38
|
this.state = {
|
|
27
39
|
error: null,
|
|
28
40
|
};
|
|
29
41
|
}
|
|
30
42
|
|
|
31
43
|
componentDidCatch( error ) {
|
|
32
|
-
this.setState( { error } );
|
|
33
|
-
|
|
34
44
|
doAction( 'editor.ErrorBoundary.errorLogged', error );
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
static getDerivedStateFromError( error ) {
|
|
48
|
+
return { error };
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
render() {
|
|
42
|
-
|
|
43
|
-
if ( ! error ) {
|
|
52
|
+
if ( ! this.state.error ) {
|
|
44
53
|
return this.props.children;
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
return (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
variant="secondary"
|
|
55
|
-
>
|
|
56
|
-
{ __( 'Attempt Recovery' ) }
|
|
57
|
-
</Button>,
|
|
58
|
-
<CopyButton key="copy-error" text={ error.stack }>
|
|
59
|
-
{ __( 'Copy Error' ) }
|
|
60
|
-
</CopyButton>,
|
|
61
|
-
] }
|
|
62
|
-
>
|
|
63
|
-
{ __( 'The editor has encountered an unexpected error.' ) }
|
|
64
|
-
</Warning>
|
|
57
|
+
<ErrorBoundaryWarning
|
|
58
|
+
message={ __(
|
|
59
|
+
'The editor has encountered an unexpected error.'
|
|
60
|
+
) }
|
|
61
|
+
error={ this.state.error }
|
|
62
|
+
/>
|
|
65
63
|
);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
@@ -101,7 +101,6 @@ export default function KeyboardShortcutHelpModal( {
|
|
|
101
101
|
<Modal
|
|
102
102
|
className="edit-widgets-keyboard-shortcut-help-modal"
|
|
103
103
|
title={ __( 'Keyboard shortcuts' ) }
|
|
104
|
-
closeLabel={ __( 'Close' ) }
|
|
105
104
|
onRequestClose={ toggleModal }
|
|
106
105
|
>
|
|
107
106
|
<ShortcutSection
|
|
@@ -17,7 +17,7 @@ import Interface from './interface';
|
|
|
17
17
|
import UnsavedChangesWarning from './unsaved-changes-warning';
|
|
18
18
|
import WelcomeGuide from '../welcome-guide';
|
|
19
19
|
|
|
20
|
-
function Layout( { blockEditorSettings
|
|
20
|
+
function Layout( { blockEditorSettings } ) {
|
|
21
21
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
22
22
|
|
|
23
23
|
function onPluginAreaError( name ) {
|
|
@@ -33,7 +33,7 @@ function Layout( { blockEditorSettings, onError } ) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<ErrorBoundary
|
|
36
|
+
<ErrorBoundary>
|
|
37
37
|
<WidgetAreasBlockEditorProvider
|
|
38
38
|
blockEditorSettings={ blockEditorSettings }
|
|
39
39
|
>
|
|
@@ -32,7 +32,7 @@ export default function UnsavedChangesWarning() {
|
|
|
32
32
|
*
|
|
33
33
|
* @param {Event} event `beforeunload` event.
|
|
34
34
|
*
|
|
35
|
-
* @return {
|
|
35
|
+
* @return {string | undefined} Warning prompt message, if unsaved changes exist.
|
|
36
36
|
*/
|
|
37
37
|
const warnIfUnsavedChanges = ( event ) => {
|
|
38
38
|
if ( isDirty ) {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
&:focus:not(:disabled) {
|
|
39
39
|
position: relative;
|
|
40
40
|
box-shadow: none;
|
|
41
|
+
outline: none;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
// Tab indicator
|
|
@@ -62,6 +63,10 @@
|
|
|
62
63
|
// Active.
|
|
63
64
|
&.is-active::after {
|
|
64
65
|
height: calc(1 * var(--wp-admin-border-width-focus));
|
|
66
|
+
|
|
67
|
+
// Windows high contrast mode.
|
|
68
|
+
outline: 2px solid transparent;
|
|
69
|
+
outline-offset: -1px;
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
// Focus.
|
|
@@ -85,6 +90,9 @@
|
|
|
85
90
|
|
|
86
91
|
&:focus-visible::before {
|
|
87
92
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
93
|
+
|
|
94
|
+
// Windows high contrast mode.
|
|
95
|
+
outline: 2px solid transparent;
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
} from '@wordpress/core-data';
|
|
12
12
|
import { useMemo } from '@wordpress/element';
|
|
13
13
|
import {
|
|
14
|
-
BlockEditorProvider,
|
|
15
14
|
BlockEditorKeyboardShortcuts,
|
|
16
15
|
CopyHandler,
|
|
16
|
+
experiments as blockEditorExperiments,
|
|
17
17
|
} from '@wordpress/block-editor';
|
|
18
18
|
import { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';
|
|
19
19
|
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
@@ -27,6 +27,9 @@ import { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';
|
|
|
27
27
|
import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';
|
|
28
28
|
import { store as editWidgetsStore } from '../../store';
|
|
29
29
|
import { ALLOW_REUSABLE_BLOCKS } from '../../constants';
|
|
30
|
+
import { unlock } from '../../experiments';
|
|
31
|
+
|
|
32
|
+
const { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );
|
|
30
33
|
|
|
31
34
|
export default function WidgetAreasBlockEditorProvider( {
|
|
32
35
|
blockEditorSettings,
|
|
@@ -100,7 +103,7 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
100
103
|
<BlockEditorKeyboardShortcuts.Register />
|
|
101
104
|
<KeyboardShortcuts.Register />
|
|
102
105
|
<SlotFillProvider>
|
|
103
|
-
<
|
|
106
|
+
<ExperimentalBlockEditorProvider
|
|
104
107
|
value={ blocks }
|
|
105
108
|
onInput={ onInput }
|
|
106
109
|
onChange={ onChange }
|
|
@@ -110,7 +113,7 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
110
113
|
>
|
|
111
114
|
<CopyHandler>{ children }</CopyHandler>
|
|
112
115
|
<ReusableBlocksMenuItems rootClientId={ widgetAreaId } />
|
|
113
|
-
</
|
|
116
|
+
</ExperimentalBlockEditorProvider>
|
|
114
117
|
</SlotFillProvider>
|
|
115
118
|
</ShortcutProvider>
|
|
116
119
|
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';
|
|
5
|
+
|
|
6
|
+
export const { lock, unlock } =
|
|
7
|
+
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
8
|
+
'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
|
|
9
|
+
'@wordpress/edit-widgets'
|
|
10
|
+
);
|
package/src/index.js
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
store as blocksStore,
|
|
9
9
|
} from '@wordpress/blocks';
|
|
10
10
|
import { dispatch } from '@wordpress/data';
|
|
11
|
-
import
|
|
11
|
+
import deprecated from '@wordpress/deprecated';
|
|
12
|
+
import { createRoot } from '@wordpress/element';
|
|
12
13
|
import {
|
|
13
14
|
registerCoreBlocks,
|
|
14
15
|
__experimentalGetCoreBlocks,
|
|
@@ -42,32 +43,16 @@ const disabledBlocks = [
|
|
|
42
43
|
...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),
|
|
43
44
|
];
|
|
44
45
|
|
|
45
|
-
/**
|
|
46
|
-
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
47
|
-
* an unhandled error occurs, replacing previously mounted editor element using
|
|
48
|
-
* an initial state from prior to the crash.
|
|
49
|
-
*
|
|
50
|
-
* @param {Element} target DOM node in which editor is rendered.
|
|
51
|
-
* @param {?Object} settings Editor settings object.
|
|
52
|
-
*/
|
|
53
|
-
export function reinitializeEditor( target, settings ) {
|
|
54
|
-
unmountComponentAtNode( target );
|
|
55
|
-
const reboot = reinitializeEditor.bind( null, target, settings );
|
|
56
|
-
render(
|
|
57
|
-
<Layout blockEditorSettings={ settings } onError={ reboot } />,
|
|
58
|
-
target
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
46
|
/**
|
|
63
47
|
* Initializes the block editor in the widgets screen.
|
|
64
48
|
*
|
|
65
49
|
* @param {string} id ID of the root element to render the screen in.
|
|
66
50
|
* @param {Object} settings Block editor settings.
|
|
67
51
|
*/
|
|
68
|
-
export function
|
|
52
|
+
export function initializeEditor( id, settings ) {
|
|
69
53
|
const target = document.getElementById( id );
|
|
70
|
-
const
|
|
54
|
+
const root = createRoot( target );
|
|
55
|
+
|
|
71
56
|
const coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {
|
|
72
57
|
return ! (
|
|
73
58
|
disabledBlocks.includes( block.name ) ||
|
|
@@ -105,10 +90,22 @@ export function initialize( id, settings ) {
|
|
|
105
90
|
// do this will result in errors in the default block parser.
|
|
106
91
|
// see: https://github.com/WordPress/gutenberg/issues/33097
|
|
107
92
|
setFreeformContentHandlerName( 'core/html' );
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
93
|
+
|
|
94
|
+
root.render( <Layout blockEditorSettings={ settings } /> );
|
|
95
|
+
|
|
96
|
+
return root;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Compatibility export under the old `initialize` name.
|
|
101
|
+
*/
|
|
102
|
+
export const initialize = initializeEditor;
|
|
103
|
+
|
|
104
|
+
export function reinitializeEditor() {
|
|
105
|
+
deprecated( 'wp.editWidgets.reinitializeEditor', {
|
|
106
|
+
since: '6.2',
|
|
107
|
+
version: '6.3',
|
|
108
|
+
} );
|
|
112
109
|
}
|
|
113
110
|
|
|
114
111
|
/**
|