@wordpress/edit-widgets 5.33.0 → 5.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/header/document-tools/index.js +0 -9
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -59
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +1 -4
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +5 -1
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +1 -10
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -60
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -5
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +5 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-style/style-rtl.css +11 -1
- package/build-style/style.css +11 -1
- package/package.json +28 -28
- package/src/components/header/document-tools/index.js +0 -7
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -1
- package/src/components/keyboard-shortcuts/index.js +1 -72
- package/src/components/layout/style.scss +4 -0
- package/src/components/secondary-sidebar/inserter-sidebar.js +2 -5
- package/src/components/widget-areas-block-editor-provider/index.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -26,9 +26,6 @@ var _lockUnlock = require("../../../lock-unlock");
|
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
const {
|
|
30
|
-
useShowBlockTools
|
|
31
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
32
29
|
function DocumentTools() {
|
|
33
30
|
const isMediumViewport = (0, _compose.useViewportMatch)('medium');
|
|
34
31
|
const inserterButton = (0, _element.useRef)();
|
|
@@ -78,15 +75,9 @@ function DocumentTools() {
|
|
|
78
75
|
}
|
|
79
76
|
};
|
|
80
77
|
const toggleListView = (0, _element.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
|
|
81
|
-
|
|
82
|
-
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
83
|
-
const {
|
|
84
|
-
showFixedToolbar
|
|
85
|
-
} = useShowBlockTools();
|
|
86
78
|
return (0, _react.createElement)(_blockEditor.NavigableToolbar, {
|
|
87
79
|
className: "edit-widgets-header-toolbar",
|
|
88
80
|
"aria-label": (0, _i18n.__)('Document tools'),
|
|
89
|
-
shouldUseKeyboardFocusShortcut: !showFixedToolbar,
|
|
90
81
|
variant: "unstyled"
|
|
91
82
|
}, (0, _react.createElement)(_components.ToolbarItem, {
|
|
92
83
|
ref: inserterButton,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_i18n","_components","_blockEditor","_icons","_element","_compose","_undo","_interopRequireDefault","_redo","_useLastSelectedWidgetArea","_store","_lockUnlock","
|
|
1
|
+
{"version":3,"names":["_data","require","_i18n","_components","_blockEditor","_icons","_element","_compose","_undo","_interopRequireDefault","_redo","_useLastSelectedWidgetArea","_store","_lockUnlock","DocumentTools","isMediumViewport","useViewportMatch","inserterButton","useRef","widgetAreaClientId","useLastSelectedWidgetArea","isLastSelectedWidgetAreaOpen","useSelect","select","editWidgetsStore","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","listViewToggleRef","isInserterOpened","isListViewOpened","getListViewToggleRef","unlock","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","useDispatch","selectBlock","blockEditorStore","handleClick","window","requestAnimationFrame","toggleListView","useCallback","_react","createElement","NavigableToolbar","className","__","variant","ToolbarItem","ref","as","Button","isPressed","onMouseDown","event","preventDefault","onClick","icon","plus","label","_x","size","Fragment","UndoButton","RedoButton","listView","_default","exports","default"],"sources":["@wordpress/edit-widgets/src/components/header/document-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction DocumentTools() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\n\tconst { isInserterOpen, isListViewOpen, listViewToggleRef } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isInserterOpened, isListViewOpened, getListViewToggleRef } =\n\t\t\t\tunlock( select( editWidgetsStore ) );\n\t\t\treturn {\n\t\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterButton }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ handleClick }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<ToolbarItem as={ UndoButton } />\n\t\t\t\t\t<ToolbarItem as={ RedoButton } />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,KAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,KAAA,GAAAD,sBAAA,CAAAR,OAAA;AACA,IAAAU,0BAAA,GAAAF,sBAAA,CAAAR,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AArBA;AACA;AACA;;AAYA;AACA;AACA;;AAOA,SAASa,aAAaA,CAAA,EAAG;EACxB,MAAMC,gBAAgB,GAAG,IAAAC,yBAAgB,EAAE,QAAS,CAAC;EACrD,MAAMC,cAAc,GAAG,IAAA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iBAAmB;IACzBmC,IAAI,EAAC;EAAS,CACd,CACA,CAEc,CAAC;AAErB;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcxD,aAAa","ignoreList":[]}
|
|
@@ -61,6 +61,10 @@ const textFormattingShortcuts = exports.textFormattingShortcuts = [{
|
|
|
61
61
|
modifier: 'access',
|
|
62
62
|
character: '0'
|
|
63
63
|
},
|
|
64
|
+
aliases: [{
|
|
65
|
+
modifier: 'access',
|
|
66
|
+
character: '7'
|
|
67
|
+
}],
|
|
64
68
|
description: (0, _i18n.__)('Convert the current heading to a paragraph.')
|
|
65
69
|
}, {
|
|
66
70
|
keyCombination: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","textFormattingShortcuts","exports","keyCombination","modifier","character","description","__"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {
|
|
1
|
+
{"version":3,"names":["_i18n","require","textFormattingShortcuts","exports","keyCombination","modifier","character","description","__","aliases"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {\n\t\t\tmodifier: 'access',\n\t\t\tcharacter: '0',\n\t\t},\n\t\taliases: [\n\t\t\t{\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '7',\n\t\t\t},\n\t\t],\n\t\tdescription: __( 'Convert the current heading to a paragraph.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: '1-6' },\n\t\tdescription: __(\n\t\t\t'Convert the current paragraph or heading to a heading of level 1 to 6.'\n\t\t),\n\t},\n\t{\n\t\tkeyCombination: { modifier: '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C,WAAW,EAAE,IAAAC,QAAE,EAAE,qCAAsC;AACxD,CAAC,EACD;EACCJ,cAAc,EAAE;IACfC,QAAQ,EAAE,QAAQ;IAClBC,SAAS,EAAE;EACZ,CAAC;EACDG,OAAO,EAAE,CACR;IACCJ,QAAQ,EAAE,QAAQ;IAClBC,SAAS,EAAE;EACZ,CAAC,CACD;EACDC,WAAW,EAAE,IAAAC,QAAE,EAAE,6CAA8C;AAChE,CAAC,EACD;EACCJ,cAAc,EAAE;IAAEC,QAAQ,EAAE,QAAQ;IAAEC,SAAS,EAAE;EAAM,CAAC;EACxDC,WAAW,EAAE,IAAAC,QAAE,EACd,wEACD;AACD,CAAC,EACD;EACCJ,cAAc,EAAE;IAAEC,QAAQ,EAAE,cAAc;IAAEC,SAAS,EAAE;EAAQ,CAAC;EAChEC,WAAW,EAAE,IAAAC,QAAE,EAAE,yBAA0B;AAC5C,CAAC,CACD","ignoreList":[]}
|
|
@@ -10,8 +10,6 @@ var _keycodes = require("@wordpress/keycodes");
|
|
|
10
10
|
var _data = require("@wordpress/data");
|
|
11
11
|
var _i18n = require("@wordpress/i18n");
|
|
12
12
|
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
14
|
-
var _blocks = require("@wordpress/blocks");
|
|
15
13
|
var _store = require("../../store");
|
|
16
14
|
/**
|
|
17
15
|
* WordPress dependencies
|
|
@@ -29,36 +27,6 @@ function KeyboardShortcuts() {
|
|
|
29
27
|
const {
|
|
30
28
|
saveEditedWidgetAreas
|
|
31
29
|
} = (0, _data.useDispatch)(_store.store);
|
|
32
|
-
const {
|
|
33
|
-
replaceBlocks
|
|
34
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
35
|
-
const {
|
|
36
|
-
getBlockName,
|
|
37
|
-
getSelectedBlockClientId,
|
|
38
|
-
getBlockAttributes
|
|
39
|
-
} = (0, _data.useSelect)(_blockEditor.store);
|
|
40
|
-
const handleTextLevelShortcut = (event, level) => {
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
const destinationBlockName = level === 0 ? 'core/paragraph' : 'core/heading';
|
|
43
|
-
const currentClientId = getSelectedBlockClientId();
|
|
44
|
-
if (currentClientId === null) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const blockName = getBlockName(currentClientId);
|
|
48
|
-
if (blockName !== 'core/paragraph' && blockName !== 'core/heading') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const attributes = getBlockAttributes(currentClientId);
|
|
52
|
-
const textAlign = blockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
53
|
-
const destinationTextAlign = destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
54
|
-
replaceBlocks(currentClientId, (0, _blocks.createBlock)(destinationBlockName, {
|
|
55
|
-
level,
|
|
56
|
-
content: attributes.content,
|
|
57
|
-
...{
|
|
58
|
-
[destinationTextAlign]: attributes[textAlign]
|
|
59
|
-
}
|
|
60
|
-
}));
|
|
61
|
-
};
|
|
62
30
|
(0, _keyboardShortcuts.useShortcut)('core/edit-widgets/undo', event => {
|
|
63
31
|
undo();
|
|
64
32
|
event.preventDefault();
|
|
@@ -71,13 +39,6 @@ function KeyboardShortcuts() {
|
|
|
71
39
|
event.preventDefault();
|
|
72
40
|
saveEditedWidgetAreas();
|
|
73
41
|
});
|
|
74
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-widgets/transform-heading-to-paragraph', event => handleTextLevelShortcut(event, 0));
|
|
75
|
-
[1, 2, 3, 4, 5, 6].forEach(level => {
|
|
76
|
-
//the loop is based off on a constant therefore
|
|
77
|
-
//the hook will execute the same way every time
|
|
78
|
-
//eslint-disable-next-line react-hooks/rules-of-hooks
|
|
79
|
-
(0, _keyboardShortcuts.useShortcut)(`core/edit-widgets/transform-paragraph-to-heading-${level}`, event => handleTextLevelShortcut(event, level));
|
|
80
|
-
});
|
|
81
42
|
return null;
|
|
82
43
|
}
|
|
83
44
|
function KeyboardShortcutsRegister() {
|
|
@@ -159,26 +120,6 @@ function KeyboardShortcutsRegister() {
|
|
|
159
120
|
character: '~'
|
|
160
121
|
}]
|
|
161
122
|
});
|
|
162
|
-
registerShortcut({
|
|
163
|
-
name: 'core/edit-widgets/transform-heading-to-paragraph',
|
|
164
|
-
category: 'block-library',
|
|
165
|
-
description: (0, _i18n.__)('Transform heading to paragraph.'),
|
|
166
|
-
keyCombination: {
|
|
167
|
-
modifier: 'access',
|
|
168
|
-
character: `0`
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
[1, 2, 3, 4, 5, 6].forEach(level => {
|
|
172
|
-
registerShortcut({
|
|
173
|
-
name: `core/edit-widgets/transform-paragraph-to-heading-${level}`,
|
|
174
|
-
category: 'block-library',
|
|
175
|
-
description: (0, _i18n.__)('Transform paragraph to heading.'),
|
|
176
|
-
keyCombination: {
|
|
177
|
-
modifier: 'access',
|
|
178
|
-
character: `${level}`
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
123
|
}, [registerShortcut]);
|
|
183
124
|
return null;
|
|
184
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_keyboardShortcuts","_keycodes","_data","_i18n","_coreData","_blockEditor","_blocks","_store","KeyboardShortcuts","redo","undo","useDispatch","coreStore","saveEditedWidgetAreas","editWidgetsStore","replaceBlocks","blockEditorStore","getBlockName","getSelectedBlockClientId","getBlockAttributes","useSelect","handleTextLevelShortcut","event","level","preventDefault","destinationBlockName","currentClientId","blockName","attributes","textAlign","destinationTextAlign","createBlock","content","useShortcut","forEach","KeyboardShortcutsRegister","registerShortcut","keyboardShortcutsStore","useEffect","name","category","description","__","keyCombination","modifier","character","aliases","isAppleOS","Register","_default","exports","default"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nfunction KeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { getBlockName, getSelectedBlockClientId, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst handleTextLevelShortcut = ( event, level ) => {\n\t\tevent.preventDefault();\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tif ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\t\tconst textAlign =\n\t\t\tblockName === 'core/paragraph' ? 'align' : 'textAlign';\n\t\tconst destinationTextAlign =\n\t\t\tdestinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, {\n\t\t\t\tlevel,\n\t\t\t\tcontent: attributes.content,\n\t\t\t\t...{ [ destinationTextAlign ]: attributes[ textAlign ] },\n\t\t\t} )\n\t\t);\n\t};\n\n\tuseShortcut( 'core/edit-widgets/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/save', ( event ) => {\n\t\tevent.preventDefault();\n\t\tsaveEditedWidgetAreas();\n\t} );\n\n\tuseShortcut(\n\t\t'core/edit-widgets/transform-heading-to-paragraph',\n\t\t( event ) => handleTextLevelShortcut( event, 0 )\n\t);\n\n\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t//the loop is based off on a constant therefore\n\t\t//the hook will execute the same way every time\n\t\t//eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tuseShortcut(\n\t\t\t`core/edit-widgets/transform-paragraph-to-heading-${ level }`,\n\t\t\t( event ) => handleTextLevelShortcut( event, level )\n\t\t);\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t ],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/transform-heading-to-paragraph',\n\t\t\tcategory: 'block-library',\n\t\t\tdescription: __( 'Transform heading to paragraph.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: `0`,\n\t\t\t},\n\t\t} );\n\n\t\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t\tregisterShortcut( {\n\t\t\t\tname: `core/edit-widgets/transform-paragraph-to-heading-${ level }`,\n\t\t\t\tcategory: 'block-library',\n\t\t\t\tdescription: __( 'Transform paragraph to heading.' ),\n\t\t\t\tkeyCombination: {\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: `${ level }`,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAIA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AAlBA;AACA;AACA;;AAaA;AACA;AACA;;AAGA,SAASS,iBAAiBA,CAAA,EAAG;EAC5B,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAC,GAAG,IAAAC,iBAAW,EAAEC,eAAU,CAAC;EAC/C,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAF,iBAAW,EAAEG,YAAiB,CAAC;EAEjE,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAJ,iBAAW,EAAEK,kBAAiB,CAAC;EACzD,MAAM;IAAEC,YAAY;IAAEC,wBAAwB;IAAEC;EAAmB,CAAC,GACnE,IAAAC,eAAS,EAAEJ,kBAAiB,CAAC;EAE9B,MAAMK,uBAAuB,GAAGA,CAAEC,KAAK,EAAEC,KAAK,KAAM;IACnDD,KAAK,CAACE,cAAc,CAAC,CAAC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B,CAAE;QACjBG,IAAI,EAAG,oDAAoDhB,KAAO,EAAC;QACnEiB,QAAQ,EAAE,eAAe;QACzBC,WAAW,EAAE,IAAAC,QAAE,EAAE,iCAAkC,CAAC;QACpDC,cAAc,EAAE;UACfC,QAAQ,EAAE,QAAQ;UAClBC,SAAS,EAAG,GAAGtB,KAAO;QACvB;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEa,gBAAgB,CAAG,CAAC;EAEzB,OAAO,IAAI;AACZ;AAEA5B,iBAAiB,CAACwC,QAAQ,GAAGb,yBAAyB;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACxC3C,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_keyboardShortcuts","_keycodes","_data","_i18n","_coreData","_store","KeyboardShortcuts","redo","undo","useDispatch","coreStore","saveEditedWidgetAreas","editWidgetsStore","useShortcut","event","preventDefault","KeyboardShortcutsRegister","registerShortcut","keyboardShortcutsStore","useEffect","name","category","description","__","keyCombination","modifier","character","aliases","isAppleOS","Register","_default","exports","default"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nfunction KeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );\n\n\tuseShortcut( 'core/edit-widgets/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/save', ( event ) => {\n\t\tevent.preventDefault();\n\t\tsaveEditedWidgetAreas();\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t ],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAIA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAhBA;AACA;AACA;;AAWA;AACA;AACA;;AAGA,SAASO,iBAAiBA,CAAA,EAAG;EAC5B,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAC,GAAG,IAAAC,iBAAW,E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Gb,yBAAyB;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACxC1B,iBAAiB","ignoreList":[]}
|
|
@@ -38,12 +38,9 @@ function InserterSidebar() {
|
|
|
38
38
|
const TagName = !isMobileViewport ? _components.VisuallyHidden : 'div';
|
|
39
39
|
const [inserterDialogRef, inserterDialogProps] = (0, _compose.__experimentalUseDialog)({
|
|
40
40
|
onClose: closeInserter,
|
|
41
|
-
focusOnMount:
|
|
41
|
+
focusOnMount: true
|
|
42
42
|
});
|
|
43
43
|
const libraryRef = (0, _element.useRef)();
|
|
44
|
-
(0, _element.useEffect)(() => {
|
|
45
|
-
libraryRef.current.focusSearch();
|
|
46
|
-
}, []);
|
|
47
44
|
return (0, _react.createElement)("div", {
|
|
48
45
|
ref: inserterDialogRef,
|
|
49
46
|
...inserterDialogProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_icons","_blockEditor","_compose","_element","_data","_i18n","_useWidgetLibraryInsertionPoint","_interopRequireDefault","_store","InserterSidebar","isMobileViewport","useViewportMatch","rootClientId","insertionIndex","useWidgetLibraryInsertionPoint","setIsInserterOpened","useDispatch","editWidgetsStore","closeInserter","useCallback","TagName","VisuallyHidden","inserterDialogRef","inserterDialogProps","useDialog","onClose","focusOnMount","libraryRef","useRef","
|
|
1
|
+
{"version":3,"names":["_components","require","_icons","_blockEditor","_compose","_element","_data","_i18n","_useWidgetLibraryInsertionPoint","_interopRequireDefault","_store","InserterSidebar","isMobileViewport","useViewportMatch","rootClientId","insertionIndex","useWidgetLibraryInsertionPoint","setIsInserterOpened","useDispatch","editWidgetsStore","closeInserter","useCallback","TagName","VisuallyHidden","inserterDialogRef","inserterDialogProps","useDialog","onClose","focusOnMount","libraryRef","useRef","_react","createElement","ref","className","Button","icon","close","onClick","label","__","__experimentalLibrary","showInserterHelpPanel","shouldFocusBlock","__experimentalInsertionIndex"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { close } from '@wordpress/icons';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useWidgetLibraryInsertionPoint from '../../hooks/use-widget-library-insertion-point';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { rootClientId, insertionIndex } = useWidgetLibraryInsertionPoint();\n\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst closeInserter = useCallback( () => {\n\t\treturn setIsInserterOpened( false );\n\t}, [ setIsInserterOpened ] );\n\n\tconst TagName = ! isMobileViewport ? VisuallyHidden : 'div';\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: closeInserter,\n\t\tfocusOnMount: true,\n\t} );\n\n\tconst libraryRef = useRef();\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-widgets-layout__inserter-panel\"\n\t\t>\n\t\t\t<TagName className=\"edit-widgets-layout__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tonClick={ closeInserter }\n\t\t\t\t\tlabel={ __( 'Close block inserter' ) }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t\t<div className=\"edit-widgets-layout__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobileViewport }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={ insertionIndex }\n\t\t\t\t\t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AAO;IAACY,SAAS,EAAC;EAA4C,GAC9D,IAAAH,MAAA,CAAAC,aAAA,EAAChC,WAAA,CAAAmC,MAAM;IACNC,IAAI,EAAGC,YAAO;IACdC,OAAO,EAAGlB,aAAe;IACzBmB,KAAK,EAAG,IAAAC,QAAE,EAAE,sBAAuB;EAAG,CACtC,CACO,CAAC,EACV,IAAAT,MAAA,CAAAC,aAAA;IAAKE,SAAS,EAAC;EAA6C,GAC3D,IAAAH,MAAA,CAAAC,aAAA,EAAC7B,YAAA,CAAAsC,qBAAO;IACPC,qBAAqB;IACrBC,gBAAgB,EAAG/B,gBAAkB;IACrCE,YAAY,EAAGA,YAAc;IAC7B8B,4BAA4B,EAAG7B,cAAgB;IAC/CkB,GAAG,EAAGJ;EAAY,CAClB,CACG,CACD,CAAC;AAER","ignoreList":[]}
|
|
@@ -15,6 +15,7 @@ var _element = require("@wordpress/element");
|
|
|
15
15
|
var _blockEditor = require("@wordpress/block-editor");
|
|
16
16
|
var _patterns = require("@wordpress/patterns");
|
|
17
17
|
var _preferences = require("@wordpress/preferences");
|
|
18
|
+
var _blockLibrary = require("@wordpress/block-library");
|
|
18
19
|
var _keyboardShortcuts = _interopRequireDefault(require("../keyboard-shortcuts"));
|
|
19
20
|
var _utils = require("../../store/utils");
|
|
20
21
|
var _useLastSelectedWidgetArea = _interopRequireDefault(require("../../hooks/use-last-selected-widget-area"));
|
|
@@ -35,6 +36,9 @@ const {
|
|
|
35
36
|
const {
|
|
36
37
|
PatternsMenuItems
|
|
37
38
|
} = (0, _lockUnlock.unlock)(_patterns.privateApis);
|
|
39
|
+
const {
|
|
40
|
+
BlockKeyboardShortcuts
|
|
41
|
+
} = (0, _lockUnlock.unlock)(_blockLibrary.privateApis);
|
|
38
42
|
function WidgetAreasBlockEditorProvider({
|
|
39
43
|
blockEditorSettings,
|
|
40
44
|
children,
|
|
@@ -100,7 +104,7 @@ function WidgetAreasBlockEditorProvider({
|
|
|
100
104
|
const [blocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)(_utils.KIND, _utils.POST_TYPE, {
|
|
101
105
|
id: (0, _utils.buildWidgetAreasPostId)()
|
|
102
106
|
});
|
|
103
|
-
return (0, _react.createElement)(_components.SlotFillProvider, null, (0, _react.createElement)(_keyboardShortcuts.default.Register, null), (0, _react.createElement)(ExperimentalBlockEditorProvider, {
|
|
107
|
+
return (0, _react.createElement)(_components.SlotFillProvider, null, (0, _react.createElement)(_keyboardShortcuts.default.Register, null), (0, _react.createElement)(BlockKeyboardShortcuts, null), (0, _react.createElement)(ExperimentalBlockEditorProvider, {
|
|
104
108
|
value: blocks,
|
|
105
109
|
onInput: onInput,
|
|
106
110
|
onChange: onChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_compose","_mediaUtils","_data","_coreData","_element","_blockEditor","_patterns","_preferences","_keyboardShortcuts","_interopRequireDefault","_utils","_useLastSelectedWidgetArea","_store","_constants","_lockUnlock","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","mediaPermissions","useResourcePermissions","isLargeViewport","useViewportMatch","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","useSelect","select","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","undefined","widgetAreas","editWidgetsStore","getWidgetAreas","widgets","getWidgets","ALLOW_REUSABLE_BLOCKS","preferencesStore","get","page_on_front","page_for_posts","setIsInserterOpened","useDispatch","settings","useMemo","mediaUploadBlockEditor","canCreate","onError","argumentsObject","uploadMedia","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","useLastSelectedWidgetArea","blocks","onInput","onChange","useEntityBlockEditor","KIND","POST_TYPE","id","buildWidgetAreasPostId","_react","createElement","SlotFillProvider","default","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\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 { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\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 '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst mediaPermissions = useResourcePermissions( 'media' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: [],\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\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 || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\tmediaPermissions.canCreate,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\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<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;
|
|
1
|
+
{"version":3,"names":["_components","require","_compose","_mediaUtils","_data","_coreData","_element","_blockEditor","_patterns","_preferences","_blockLibrary","_keyboardShortcuts","_interopRequireDefault","_utils","_useLastSelectedWidgetArea","_store","_constants","_lockUnlock","ExperimentalBlockEditorProvider","unlock","blockEditorPrivateApis","PatternsMenuItems","editPatternsPrivateApis","BlockKeyboardShortcuts","blockLibraryPrivateApis","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","mediaPermissions","useResourcePermissions","isLargeViewport","useViewportMatch","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","useSelect","select","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","undefined","widgetAreas","editWidgetsStore","getWidgetAreas","widgets","getWidgets","ALLOW_REUSABLE_BLOCKS","preferencesStore","get","page_on_front","page_for_posts","setIsInserterOpened","useDispatch","settings","useMemo","mediaUploadBlockEditor","canCreate","onError","argumentsObject","uploadMedia","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","useLastSelectedWidgetArea","blocks","onInput","onChange","useEntityBlockEditor","KIND","POST_TYPE","id","buildWidgetAreasPostId","_react","createElement","SlotFillProvider","default","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\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 { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\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 '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst mediaPermissions = useResourcePermissions( 'media' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: [],\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\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 || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\tmediaPermissions.canCreate,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\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<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<BlockKeyboardShortcuts />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAKA,IAAAU,kBAAA,GAAAC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AAY,CACX,CAAC;EAEH,MAAMoC,YAAY,GAAG,IAAAC,kCAAyB,EAAC,CAAC;EAEhD,MAAM,CAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAE,GAAG,IAAAC,8BAAoB,EACzDC,WAAI,EACJC,gBAAS,EACT;IAAEC,EAAE,EAAE,IAAAC,6BAAsB,EAAC;EAAE,CAChC,CAAC;EAED,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACpF,WAAA,CAAAqF,gBAAgB,QAChB,IAAAF,MAAA,CAAAC,aAAA,EAACzE,kBAAA,CAAA2E,OAAiB,CAACC,QAAQ,MAAE,CAAC,EAC9B,IAAAJ,MAAA,CAAAC,aAAA,EAAC7D,sBAAsB,MAAE,CAAC,EAC1B,IAAA4D,MAAA,CAAAC,aAAA,EAAClE,+BAA+B;IAC/BsE,KAAK,EAAGb,MAAQ;IAChBC,OAAO,EAAGA,OAAS;IACnBC,QAAQ,EAAGA,QAAU;IACrBnB,QAAQ,EAAGA,QAAU;IACrB+B,cAAc,EAAG,KAAO;IAAA,GACnB7D;EAAK,GAERD,QAAQ,EACV,IAAAwD,MAAA,CAAAC,aAAA,EAAC/D,iBAAiB;IAACqE,YAAY,EAAGjB;EAAc,CAAE,CAClB,CAChB,CAAC;AAErB","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ import { createElement, Fragment } from "react";
|
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { __, _x } from '@wordpress/i18n';
|
|
7
7
|
import { Button, ToolbarItem } from '@wordpress/components';
|
|
8
|
-
import { NavigableToolbar, store as blockEditorStore
|
|
8
|
+
import { NavigableToolbar, store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
9
|
import { listView, plus } from '@wordpress/icons';
|
|
10
10
|
import { useCallback, useRef } from '@wordpress/element';
|
|
11
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
@@ -18,9 +18,6 @@ import RedoButton from '../undo-redo/redo';
|
|
|
18
18
|
import useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area';
|
|
19
19
|
import { store as editWidgetsStore } from '../../../store';
|
|
20
20
|
import { unlock } from '../../../lock-unlock';
|
|
21
|
-
const {
|
|
22
|
-
useShowBlockTools
|
|
23
|
-
} = unlock(blockEditorPrivateApis);
|
|
24
21
|
function DocumentTools() {
|
|
25
22
|
const isMediumViewport = useViewportMatch('medium');
|
|
26
23
|
const inserterButton = useRef();
|
|
@@ -70,15 +67,9 @@ function DocumentTools() {
|
|
|
70
67
|
}
|
|
71
68
|
};
|
|
72
69
|
const toggleListView = useCallback(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
|
|
73
|
-
|
|
74
|
-
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
75
|
-
const {
|
|
76
|
-
showFixedToolbar
|
|
77
|
-
} = useShowBlockTools();
|
|
78
70
|
return createElement(NavigableToolbar, {
|
|
79
71
|
className: "edit-widgets-header-toolbar",
|
|
80
72
|
"aria-label": __('Document tools'),
|
|
81
|
-
shouldUseKeyboardFocusShortcut: !showFixedToolbar,
|
|
82
73
|
variant: "unstyled"
|
|
83
74
|
}, createElement(ToolbarItem, {
|
|
84
75
|
ref: inserterButton,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","NavigableToolbar","store","blockEditorStore","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","NavigableToolbar","store","blockEditorStore","listView","plus","useCallback","useRef","useViewportMatch","UndoButton","RedoButton","useLastSelectedWidgetArea","editWidgetsStore","unlock","DocumentTools","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","listViewToggleRef","isInserterOpened","isListViewOpened","getListViewToggleRef","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","createElement","className","variant","ref","as","isPressed","onMouseDown","event","preventDefault","onClick","icon","label","size","Fragment"],"sources":["@wordpress/edit-widgets/src/components/header/document-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction DocumentTools() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\n\tconst { isInserterOpen, isListViewOpen, listViewToggleRef } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isInserterOpened, isListViewOpened, getListViewToggleRef } =\n\t\t\t\tunlock( select( editWidgetsStore ) );\n\t\t\treturn {\n\t\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterButton }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ handleClick }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<ToolbarItem as={ UndoButton } />\n\t\t\t\t\t<ToolbarItem as={ RedoButton } />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AAC3D,SACCC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,yBAAyB,MAAM,8CAA8C;AACpF,SAAST,KAAK,IAAIU,gBAAgB,QAAQ,gBAAgB;AAC1D,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,SAASC,aAAaA,CAAA,EAAG;EACxB,MAAMC,gBAAgB,GAAGP,gBAAgB,CAAE,QAAS,CAAC;EACrD,MAAMQ,cAAc,GAAGT,MAAM,CAAC,CAAC;EAC/B,MAAMU,kBAA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OACCa,aAAA,CAAClC,gBAAgB;IAChBmC,SAAS,EAAC,6BAA6B;IACvC,cAAavC,EAAE,CAAE,gBAAiB,CAAG;IACrCwC,OAAO,EAAC;EAAU,GAElBF,aAAA,CAACnC,WAAW;IACXsC,GAAG,EAAGtB,cAAgB;IACtBuB,EAAE,EAAGxC,MAAQ;IACbqC,SAAS,EAAC,8CAA8C;IACxDC,OAAO,EAAC,SAAS;IACjBG,SAAS,EAAGnB,cAAgB;IAC5BoB,WAAW,EAAKC,KAAK,IAAM;MAC1BA,KAAK,CAACC,cAAc,CAAC,CAAC;IACvB,CAAG;IACHC,OAAO,EAAGb,WAAa;IACvBc,IAAI,EAAGxC;IACP;AACJ,mBADI;IAEAyC,KAAK,EAAGhD,EAAE,CACT,uBAAuB,EACvB,yCACD,CAAG;IACHiD,IAAI,EAAC;EAAS,CACd,CAAC,EACAhC,gBAAgB,IACjBoB,aAAA,CAAAa,QAAA,QACCb,aAAA,CAACnC,WAAW;IAACuC,EAAE,EAAG9B;EAAY,CAAE,CAAC,EACjC0B,aAAA,CAACnC,WAAW;IAACuC,EAAE,EAAG7B;EAAY,CAAE,CAAC,EACjCyB,aAAA,CAACnC,WAAW;IACXuC,EAAE,EAAGxC,MAAQ;IACbqC,SAAS,EAAC,+CAA+C;IACzDS,IAAI,EAAGzC,QAAU;IACjBoC,SAAS,EAAGlB;IACZ;IACAwB,KAAK,EAAGjD,EAAE,CAAE,WAAY,CAAG;IAC3B+C,OAAO,EAAGV,cAAgB;IAC1BI,GAAG,EAAGf,iBAAmB;IACzBwB,IAAI,EAAC;EAAS,CACd,CACA,CAEc,CAAC;AAErB;AAEA,eAAejC,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","textFormattingShortcuts","keyCombination","modifier","character","description"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {
|
|
1
|
+
{"version":3,"names":["__","textFormattingShortcuts","keyCombination","modifier","character","description","aliases"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {\n\t\t\tmodifier: 'access',\n\t\t\tcharacter: '0',\n\t\t},\n\t\taliases: [\n\t\t\t{\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '7',\n\t\t\t},\n\t\t],\n\t\tdescription: __( 'Convert the current heading to a paragraph.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: '1-6' },\n\t\tdescription: __(\n\t\t\t'Convert the current paragraph or heading to a heading of level 1 to 6.'\n\t\t),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'SPACE' },\n\t\tdescription: __( 'Add non breaking space.' ),\n\t},\n];\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AAEpC,OAAO,MAAMC,uBAAuB,GAAG,CACtC;EACCC,cAAc,EAAE;IAAEC,QAAQ,EAAE,SAAS;IAAEC,SAAS,EAAE;EAAI,CAAC;EACvDC,WAAW,EAAEL,EAAE,CAAE,8BAA+B;AACjD,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,SAAS;IAAEC,SAAS,EAAE;EAAI,CAAC;EACvDC,WAAW,EAAEL,EAAE,CAAE,gCAAiC;AACnD,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,SAAS;IAAEC,SAAS,EAAE;EAAI,CAAC;EACvDC,WAAW,EAAEL,EAAE,CAAE,wCAAyC;AAC3D,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,cAAc;IAAEC,SAAS,EAAE;EAAI,CAAC;EAC5DC,WAAW,EAAEL,EAAE,CAAE,gBAAiB;AACnC,CAAC,EACD;EACCE,cAAc,EAAE;IAAEE,SAAS,EAAE;EAAK,CAAC;EACnCC,WAAW,EAAEL,EAAE,CAAE,kCAAmC;AACrD,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,SAAS;IAAEC,SAAS,EAAE;EAAI,CAAC;EACvDC,WAAW,EAAEL,EAAE,CAAE,8BAA+B;AACjD,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,QAAQ;IAAEC,SAAS,EAAE;EAAI,CAAC;EACtDC,WAAW,EAAEL,EAAE,CAAE,kCAAmC;AACrD,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,QAAQ;IAAEC,SAAS,EAAE;EAAI,CAAC;EACtDC,WAAW,EAAEL,EAAE,CAAE,qCAAsC;AACxD,CAAC,EACD;EACCE,cAAc,EAAE;IACfC,QAAQ,EAAE,QAAQ;IAClBC,SAAS,EAAE;EACZ,CAAC;EACDE,OAAO,EAAE,CACR;IACCH,QAAQ,EAAE,QAAQ;IAClBC,SAAS,EAAE;EACZ,CAAC,CACD;EACDC,WAAW,EAAEL,EAAE,CAAE,6CAA8C;AAChE,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,QAAQ;IAAEC,SAAS,EAAE;EAAM,CAAC;EACxDC,WAAW,EAAEL,EAAE,CACd,wEACD;AACD,CAAC,EACD;EACCE,cAAc,EAAE;IAAEC,QAAQ,EAAE,cAAc;IAAEC,SAAS,EAAE;EAAQ,CAAC;EAChEC,WAAW,EAAEL,EAAE,CAAE,yBAA0B;AAC5C,CAAC,CACD","ignoreList":[]}
|
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
import { useEffect } from '@wordpress/element';
|
|
5
5
|
import { useShortcut, store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
6
6
|
import { isAppleOS } from '@wordpress/keycodes';
|
|
7
|
-
import { useDispatch
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
|
-
import { createBlock } from '@wordpress/blocks';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Internal dependencies
|
|
@@ -22,36 +20,6 @@ function KeyboardShortcuts() {
|
|
|
22
20
|
const {
|
|
23
21
|
saveEditedWidgetAreas
|
|
24
22
|
} = useDispatch(editWidgetsStore);
|
|
25
|
-
const {
|
|
26
|
-
replaceBlocks
|
|
27
|
-
} = useDispatch(blockEditorStore);
|
|
28
|
-
const {
|
|
29
|
-
getBlockName,
|
|
30
|
-
getSelectedBlockClientId,
|
|
31
|
-
getBlockAttributes
|
|
32
|
-
} = useSelect(blockEditorStore);
|
|
33
|
-
const handleTextLevelShortcut = (event, level) => {
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
const destinationBlockName = level === 0 ? 'core/paragraph' : 'core/heading';
|
|
36
|
-
const currentClientId = getSelectedBlockClientId();
|
|
37
|
-
if (currentClientId === null) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const blockName = getBlockName(currentClientId);
|
|
41
|
-
if (blockName !== 'core/paragraph' && blockName !== 'core/heading') {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const attributes = getBlockAttributes(currentClientId);
|
|
45
|
-
const textAlign = blockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
46
|
-
const destinationTextAlign = destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
47
|
-
replaceBlocks(currentClientId, createBlock(destinationBlockName, {
|
|
48
|
-
level,
|
|
49
|
-
content: attributes.content,
|
|
50
|
-
...{
|
|
51
|
-
[destinationTextAlign]: attributes[textAlign]
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
};
|
|
55
23
|
useShortcut('core/edit-widgets/undo', event => {
|
|
56
24
|
undo();
|
|
57
25
|
event.preventDefault();
|
|
@@ -64,13 +32,6 @@ function KeyboardShortcuts() {
|
|
|
64
32
|
event.preventDefault();
|
|
65
33
|
saveEditedWidgetAreas();
|
|
66
34
|
});
|
|
67
|
-
useShortcut('core/edit-widgets/transform-heading-to-paragraph', event => handleTextLevelShortcut(event, 0));
|
|
68
|
-
[1, 2, 3, 4, 5, 6].forEach(level => {
|
|
69
|
-
//the loop is based off on a constant therefore
|
|
70
|
-
//the hook will execute the same way every time
|
|
71
|
-
//eslint-disable-next-line react-hooks/rules-of-hooks
|
|
72
|
-
useShortcut(`core/edit-widgets/transform-paragraph-to-heading-${level}`, event => handleTextLevelShortcut(event, level));
|
|
73
|
-
});
|
|
74
35
|
return null;
|
|
75
36
|
}
|
|
76
37
|
function KeyboardShortcutsRegister() {
|
|
@@ -152,26 +113,6 @@ function KeyboardShortcutsRegister() {
|
|
|
152
113
|
character: '~'
|
|
153
114
|
}]
|
|
154
115
|
});
|
|
155
|
-
registerShortcut({
|
|
156
|
-
name: 'core/edit-widgets/transform-heading-to-paragraph',
|
|
157
|
-
category: 'block-library',
|
|
158
|
-
description: __('Transform heading to paragraph.'),
|
|
159
|
-
keyCombination: {
|
|
160
|
-
modifier: 'access',
|
|
161
|
-
character: `0`
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
[1, 2, 3, 4, 5, 6].forEach(level => {
|
|
165
|
-
registerShortcut({
|
|
166
|
-
name: `core/edit-widgets/transform-paragraph-to-heading-${level}`,
|
|
167
|
-
category: 'block-library',
|
|
168
|
-
description: __('Transform paragraph to heading.'),
|
|
169
|
-
keyCombination: {
|
|
170
|
-
modifier: 'access',
|
|
171
|
-
character: `${level}`
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
116
|
}, [registerShortcut]);
|
|
176
117
|
return null;
|
|
177
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useShortcut","store","keyboardShortcutsStore","isAppleOS","useDispatch","useSelect","__","coreStore","blockEditorStore","createBlock","editWidgetsStore","KeyboardShortcuts","redo","undo","saveEditedWidgetAreas","replaceBlocks","getBlockName","getSelectedBlockClientId","getBlockAttributes","handleTextLevelShortcut","event","level","preventDefault","destinationBlockName","currentClientId","blockName","attributes","textAlign","destinationTextAlign","content","forEach","KeyboardShortcutsRegister","registerShortcut","name","category","description","keyCombination","modifier","character","aliases","Register"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nfunction KeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { getBlockName, getSelectedBlockClientId, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst handleTextLevelShortcut = ( event, level ) => {\n\t\tevent.preventDefault();\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tif ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\t\tconst textAlign =\n\t\t\tblockName === 'core/paragraph' ? 'align' : 'textAlign';\n\t\tconst destinationTextAlign =\n\t\t\tdestinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, {\n\t\t\t\tlevel,\n\t\t\t\tcontent: attributes.content,\n\t\t\t\t...{ [ destinationTextAlign ]: attributes[ textAlign ] },\n\t\t\t} )\n\t\t);\n\t};\n\n\tuseShortcut( 'core/edit-widgets/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/save', ( event ) => {\n\t\tevent.preventDefault();\n\t\tsaveEditedWidgetAreas();\n\t} );\n\n\tuseShortcut(\n\t\t'core/edit-widgets/transform-heading-to-paragraph',\n\t\t( event ) => handleTextLevelShortcut( event, 0 )\n\t);\n\n\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t//the loop is based off on a constant therefore\n\t\t//the hook will execute the same way every time\n\t\t//eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tuseShortcut(\n\t\t\t`core/edit-widgets/transform-paragraph-to-heading-${ level }`,\n\t\t\t( event ) => handleTextLevelShortcut( event, level )\n\t\t);\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t ],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/transform-heading-to-paragraph',\n\t\t\tcategory: 'block-library',\n\t\t\tdescription: __( 'Transform heading to paragraph.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: `0`,\n\t\t\t},\n\t\t} );\n\n\t\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t\tregisterShortcut( {\n\t\t\t\tname: `core/edit-widgets/transform-paragraph-to-heading-${ level }`,\n\t\t\t\tcategory: 'block-library',\n\t\t\t\tdescription: __( 'Transform paragraph to heading.' ),\n\t\t\t\tkeyCombination: {\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: `${ level }`,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,WAAW,EACXC,KAAK,IAAIC,sBAAsB,QACzB,+BAA+B;AACtC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASL,KAAK,IAAIM,SAAS,QAAQ,sBAAsB;AACzD,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,WAAW,QAAQ,mBAA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,CAAC,EACD;QACCD,QAAQ,EAAE,WAAW;QACrBC,SAAS,EAAE;MACZ,CAAC;IAEH,CAAE,CAAC;IAEHN,gBAAgB,CAAE;MACjBC,IAAI,EAAE,kDAAkD;MACxDC,QAAQ,EAAE,eAAe;MACzBC,WAAW,EAAE7B,EAAE,CAAE,iCAAkC,CAAC;MACpD8B,cAAc,EAAE;QACfC,QAAQ,EAAE,QAAQ;QAClBC,SAAS,EAAG;MACb;IACD,CAAE,CAAC;IAEH,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAACR,OAAO,CAAIT,KAAK,IAAM;MAC1CW,gBAAgB,CAAE;QACjBC,IAAI,EAAG,oDAAoDZ,KAAO,EAAC;QACnEa,QAAQ,EAAE,eAAe;QACzBC,WAAW,EAAE7B,EAAE,CAAE,iCAAkC,CAAC;QACpD8B,cAAc,EAAE;UACfC,QAAQ,EAAE,QAAQ;UAClBC,SAAS,EAAG,GAAGjB,KAAO;QACvB;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEW,gBAAgB,CAAG,CAAC;EAEzB,OAAO,IAAI;AACZ;AAEArB,iBAAiB,CAAC6B,QAAQ,GAAGT,yBAAyB;AACtD,eAAepB,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useEffect","useShortcut","store","keyboardShortcutsStore","isAppleOS","useDispatch","__","coreStore","editWidgetsStore","KeyboardShortcuts","redo","undo","saveEditedWidgetAreas","event","preventDefault","KeyboardShortcutsRegister","registerShortcut","name","category","description","keyCombination","modifier","character","aliases","Register"],"sources":["@wordpress/edit-widgets/src/components/keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nfunction KeyboardShortcuts() {\n\tconst { redo, undo } = useDispatch( coreStore );\n\tconst { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );\n\n\tuseShortcut( 'core/edit-widgets/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/edit-widgets/save', ( event ) => {\n\t\tevent.preventDefault();\n\t\tsaveEditedWidgetAreas();\n\t} );\n\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t ],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-widgets/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\nexport default KeyboardShortcuts;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAA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AE,WAAW;QACrBC,SAAS,EAAE;MACZ,CAAC;MACDC,OAAO,EAAE,CACR;QACCF,QAAQ,EAAE,QAAQ;QAClBC,SAAS,EAAE;MACZ,CAAC,EACD;QACCD,QAAQ,EAAE,WAAW;QACrBC,SAAS,EAAE;MACZ,CAAC;IAEH,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEN,gBAAgB,CAAG,CAAC;EAEzB,OAAO,IAAI;AACZ;AAEAP,iBAAiB,CAACe,QAAQ,GAAGT,yBAAyB;AACtD,eAAeN,iBAAiB","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ import { Button, VisuallyHidden } from '@wordpress/components';
|
|
|
6
6
|
import { close } from '@wordpress/icons';
|
|
7
7
|
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
8
8
|
import { useViewportMatch, __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
9
|
-
import { useCallback,
|
|
9
|
+
import { useCallback, useRef } from '@wordpress/element';
|
|
10
10
|
import { useDispatch } from '@wordpress/data';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
|
|
@@ -30,12 +30,9 @@ export default function InserterSidebar() {
|
|
|
30
30
|
const TagName = !isMobileViewport ? VisuallyHidden : 'div';
|
|
31
31
|
const [inserterDialogRef, inserterDialogProps] = useDialog({
|
|
32
32
|
onClose: closeInserter,
|
|
33
|
-
focusOnMount:
|
|
33
|
+
focusOnMount: true
|
|
34
34
|
});
|
|
35
35
|
const libraryRef = useRef();
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
libraryRef.current.focusSearch();
|
|
38
|
-
}, []);
|
|
39
36
|
return createElement("div", {
|
|
40
37
|
ref: inserterDialogRef,
|
|
41
38
|
...inserterDialogProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","VisuallyHidden","close","__experimentalLibrary","Library","useViewportMatch","__experimentalUseDialog","useDialog","useCallback","
|
|
1
|
+
{"version":3,"names":["Button","VisuallyHidden","close","__experimentalLibrary","Library","useViewportMatch","__experimentalUseDialog","useDialog","useCallback","useRef","useDispatch","__","useWidgetLibraryInsertionPoint","store","editWidgetsStore","InserterSidebar","isMobileViewport","rootClientId","insertionIndex","setIsInserterOpened","closeInserter","TagName","inserterDialogRef","inserterDialogProps","onClose","focusOnMount","libraryRef","createElement","ref","className","icon","onClick","label","showInserterHelpPanel","shouldFocusBlock","__experimentalInsertionIndex"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { close } from '@wordpress/icons';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useWidgetLibraryInsertionPoint from '../../hooks/use-widget-library-insertion-point';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { rootClientId, insertionIndex } = useWidgetLibraryInsertionPoint();\n\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst closeInserter = useCallback( () => {\n\t\treturn setIsInserterOpened( false );\n\t}, [ setIsInserterOpened ] );\n\n\tconst TagName = ! isMobileViewport ? VisuallyHidden : 'div';\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: closeInserter,\n\t\tfocusOnMount: true,\n\t} );\n\n\tconst libraryRef = useRef();\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-widgets-layout__inserter-panel\"\n\t\t>\n\t\t\t<TagName className=\"edit-widgets-layout__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tonClick={ closeInserter }\n\t\t\t\t\tlabel={ __( 'Close block inserter' ) }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t\t<div className=\"edit-widgets-layout__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobileViewport }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={ insertionIndex }\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,cAAc,QAAQ,uBAAuB;AAC9D,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,qBAAqB,IAAIC,OAAO,QAAQ,yBAAyB;AAC1E,SACCC,gBAAgB,EAChBC,uBAAuB,IAAIC,SAAS,QAC9B,oBAAoB;AAC3B,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,8BAA8B,MAAM,gDAAgD;AAC3F,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,eAAe,SAASC,eAAeA,CAAA,EAAG;EACzC,MAAMC,gBAAgB,GAAGX,gBAAgB,CAAE,QAAQ,EAAE,GAAI,CAAC;EAC1D,MAAM;IAAEY,YAAY;IAAEC;EAAe,CAAC,GAAGN,8BAA8B,CAAC,CAAC;EAEzE,MAAM;IAAEO;EAAoB,CAAC,GAAGT,WAAW,CAAEI,gBAAiB,CAAC;EAE/D,MAAMM,aAAa,GAAGZ,WAAW,CAAE,MAAM;IACxC,OAAOW,mBAAmB,CAAE,KAAM,CAAC;EACpC,CAAC,EAAE,CAAEA,mBAAmB,CAAG,CAAC;EAE5B,MAAME,OAAO,GAAG,CAAEL,gBAAgB,GAAGf,cAAc,GAAG,KAAK;EAC3D,MAAM,CAAEqB,iBAAiB,EAAEC,mBAAmB,CAAE,GAAGhB,SAAS,CAAE;IAC7DiB,OAAO,EAAEJ,aAAa;IACtBK,YAAY,EAAE;EACf,CAAE,CAAC;EAEH,MAAMC,UAAU,GAAGjB,MAAM,CAAC,CAAC;EAE3B,OACCkB,aAAA;IACCC,GAAG,EAAGN,iBAAmB;IAAA,GACpBC,mBAAmB;IACxBM,SAAS,EAAC;EAAqC,GAE/CF,aAAA,CAACN,OAAO;IAACQ,SAAS,EAAC;EAA4C,GAC9DF,aAAA,CAAC3B,MAAM;IACN8B,IAAI,EAAG5B,KAAO;IACd6B,OAAO,EAAGX,aAAe;IACzBY,KAAK,EAAGrB,EAAE,CAAE,sBAAuB;EAAG,CACtC,CACO,CAAC,EACVgB,aAAA;IAAKE,SAAS,EAAC;EAA6C,GAC3DF,aAAA,CAACvB,OAAO;IACP6B,qBAAqB;IACrBC,gBAAgB,EAAGlB,gBAAkB;IACrCC,YAAY,EAAGA,YAAc;IAC7BkB,4BAA4B,EAAGjB,cAAgB;IAC/CU,GAAG,EAAGF;EAAY,CAClB,CACG,CACD,CAAC;AAER","ignoreList":[]}
|
|
@@ -11,6 +11,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
11
11
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
12
12
|
import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
|
|
13
13
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
14
|
+
import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -27,6 +28,9 @@ const {
|
|
|
27
28
|
const {
|
|
28
29
|
PatternsMenuItems
|
|
29
30
|
} = unlock(editPatternsPrivateApis);
|
|
31
|
+
const {
|
|
32
|
+
BlockKeyboardShortcuts
|
|
33
|
+
} = unlock(blockLibraryPrivateApis);
|
|
30
34
|
export default function WidgetAreasBlockEditorProvider({
|
|
31
35
|
blockEditorSettings,
|
|
32
36
|
children,
|
|
@@ -92,7 +96,7 @@ export default function WidgetAreasBlockEditorProvider({
|
|
|
92
96
|
const [blocks, onInput, onChange] = useEntityBlockEditor(KIND, POST_TYPE, {
|
|
93
97
|
id: buildWidgetAreasPostId()
|
|
94
98
|
});
|
|
95
|
-
return createElement(SlotFillProvider, null, createElement(KeyboardShortcuts.Register, null), createElement(ExperimentalBlockEditorProvider, {
|
|
99
|
+
return createElement(SlotFillProvider, null, createElement(KeyboardShortcuts.Register, null), createElement(BlockKeyboardShortcuts, null), createElement(ExperimentalBlockEditorProvider, {
|
|
96
100
|
value: blocks,
|
|
97
101
|
onInput: onInput,
|
|
98
102
|
onChange: onChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SlotFillProvider","useViewportMatch","uploadMedia","useDispatch","useSelect","useEntityBlockEditor","store","coreStore","useResourcePermissions","useMemo","privateApis","blockEditorPrivateApis","editPatternsPrivateApis","preferencesStore","KeyboardShortcuts","buildWidgetAreasPostId","KIND","POST_TYPE","useLastSelectedWidgetArea","editWidgetsStore","ALLOW_REUSABLE_BLOCKS","unlock","ExperimentalBlockEditorProvider","PatternsMenuItems","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","mediaPermissions","isLargeViewport","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","select","canUser","getEntityRecord","getEntityRecords","siteSettings","undefined","widgetAreas","getWidgetAreas","widgets","getWidgets","get","page_on_front","page_for_posts","setIsInserterOpened","settings","mediaUploadBlockEditor","canCreate","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","blocks","onInput","onChange","id","createElement","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\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 { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\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 '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst mediaPermissions = useResourcePermissions( 'media' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: [],\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\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 || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\tmediaPermissions.canCreate,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\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<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,oBAAoB,EACpBC,KAAK,IAAIC,SAAS,EAClBC,sBAAsB,QAChB,sBAAsB;AAC7B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASD,WAAW,IAAIE,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,wBAAwB;;
|
|
1
|
+
{"version":3,"names":["SlotFillProvider","useViewportMatch","uploadMedia","useDispatch","useSelect","useEntityBlockEditor","store","coreStore","useResourcePermissions","useMemo","privateApis","blockEditorPrivateApis","editPatternsPrivateApis","preferencesStore","blockLibraryPrivateApis","KeyboardShortcuts","buildWidgetAreasPostId","KIND","POST_TYPE","useLastSelectedWidgetArea","editWidgetsStore","ALLOW_REUSABLE_BLOCKS","unlock","ExperimentalBlockEditorProvider","PatternsMenuItems","BlockKeyboardShortcuts","WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","mediaPermissions","isLargeViewport","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","pageOnFront","pageForPosts","select","canUser","getEntityRecord","getEntityRecords","siteSettings","undefined","widgetAreas","getWidgetAreas","widgets","getWidgets","get","page_on_front","page_for_posts","setIsInserterOpened","settings","mediaUploadBlockEditor","canCreate","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","blocks","onInput","onChange","id","createElement","Register","value","useSubRegistry","rootClientId"],"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\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 { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\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 '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst mediaPermissions = useResourcePermissions( 'media' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: [],\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\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 || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\tmediaPermissions.canCreate,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\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<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<BlockKeyboardShortcuts />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,oBAAoB,EACpBC,KAAK,IAAIC,SAAS,EAClBC,sBAAsB,QAChB,sBAAsB;AAC7B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASD,WAAW,IAAIE,uBAAuB,QAAQ,qB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F,eAAe,EACfG,oBAAoB,EACpBJ,gBAAgB,CAACuB,SAAS,EAC1BrB,cAAc,EACdkB,mBAAmB,EACnBf,WAAW,EACXC,YAAY,CACX,CAAC;EAEH,MAAM4B,YAAY,GAAG7C,yBAAyB,CAAC,CAAC;EAEhD,MAAM,CAAE8C,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAE,GAAG9D,oBAAoB,CACzDY,IAAI,EACJC,SAAS,EACT;IAAEkD,EAAE,EAAEpD,sBAAsB,CAAC;EAAE,CAChC,CAAC;EAED,OACCqD,aAAA,CAACrE,gBAAgB,QAChBqE,aAAA,CAACtD,iBAAiB,CAACuD,QAAQ,MAAE,CAAC,EAC9BD,aAAA,CAAC5C,sBAAsB,MAAE,CAAC,EAC1B4C,aAAA,CAAC9C,+BAA+B;IAC/BgD,KAAK,EAAGN,MAAQ;IAChBC,OAAO,EAAGA,OAAS;IACnBC,QAAQ,EAAGA,QAAU;IACrBhB,QAAQ,EAAGA,QAAU;IACrBqB,cAAc,EAAG,KAAO;IAAA,GACnB3C;EAAK,GAERD,QAAQ,EACVyC,aAAA,CAAC7C,iBAAiB;IAACiD,YAAY,EAAGT;EAAc,CAAE,CAClB,CAChB,CAAC;AAErB","ignoreList":[]}
|
|
@@ -150,6 +150,8 @@
|
|
|
150
150
|
.interface-complementary-area {
|
|
151
151
|
background: #fff;
|
|
152
152
|
color: #1e1e1e;
|
|
153
|
+
height: 100%;
|
|
154
|
+
overflow: auto;
|
|
153
155
|
}
|
|
154
156
|
@media (min-width: 600px) {
|
|
155
157
|
.interface-complementary-area {
|
|
@@ -215,6 +217,10 @@
|
|
|
215
217
|
right: auto;
|
|
216
218
|
}
|
|
217
219
|
|
|
220
|
+
.interface-complementary-area__fill {
|
|
221
|
+
height: 100%;
|
|
222
|
+
}
|
|
223
|
+
|
|
218
224
|
@media (min-width: 782px) {
|
|
219
225
|
body.js.is-fullscreen-mode {
|
|
220
226
|
margin-top: -32px;
|
|
@@ -307,6 +313,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
307
313
|
}
|
|
308
314
|
|
|
309
315
|
.interface-interface-skeleton__body {
|
|
316
|
+
position: relative;
|
|
310
317
|
flex-grow: 1;
|
|
311
318
|
display: flex;
|
|
312
319
|
overflow: auto;
|
|
@@ -355,7 +362,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
355
362
|
}
|
|
356
363
|
|
|
357
364
|
.interface-interface-skeleton__sidebar {
|
|
358
|
-
overflow:
|
|
365
|
+
overflow: hidden;
|
|
359
366
|
}
|
|
360
367
|
@media (min-width: 782px) {
|
|
361
368
|
.interface-interface-skeleton__sidebar {
|
|
@@ -790,6 +797,9 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
|
|
|
790
797
|
.edit-widgets-layout__inserter-panel-content {
|
|
791
798
|
height: calc(100% - 36px - 8px);
|
|
792
799
|
}
|
|
800
|
+
.edit-widgets-layout__inserter-panel-content .block-editor-inserter__tab {
|
|
801
|
+
display: none;
|
|
802
|
+
}
|
|
793
803
|
@media (min-width: 782px) {
|
|
794
804
|
.edit-widgets-layout__inserter-panel-content {
|
|
795
805
|
height: 100%;
|
package/build-style/style.css
CHANGED
|
@@ -150,6 +150,8 @@
|
|
|
150
150
|
.interface-complementary-area {
|
|
151
151
|
background: #fff;
|
|
152
152
|
color: #1e1e1e;
|
|
153
|
+
height: 100%;
|
|
154
|
+
overflow: auto;
|
|
153
155
|
}
|
|
154
156
|
@media (min-width: 600px) {
|
|
155
157
|
.interface-complementary-area {
|
|
@@ -215,6 +217,10 @@
|
|
|
215
217
|
left: auto;
|
|
216
218
|
}
|
|
217
219
|
|
|
220
|
+
.interface-complementary-area__fill {
|
|
221
|
+
height: 100%;
|
|
222
|
+
}
|
|
223
|
+
|
|
218
224
|
@media (min-width: 782px) {
|
|
219
225
|
body.js.is-fullscreen-mode {
|
|
220
226
|
margin-top: -32px;
|
|
@@ -307,6 +313,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
307
313
|
}
|
|
308
314
|
|
|
309
315
|
.interface-interface-skeleton__body {
|
|
316
|
+
position: relative;
|
|
310
317
|
flex-grow: 1;
|
|
311
318
|
display: flex;
|
|
312
319
|
overflow: auto;
|
|
@@ -355,7 +362,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
355
362
|
}
|
|
356
363
|
|
|
357
364
|
.interface-interface-skeleton__sidebar {
|
|
358
|
-
overflow:
|
|
365
|
+
overflow: hidden;
|
|
359
366
|
}
|
|
360
367
|
@media (min-width: 782px) {
|
|
361
368
|
.interface-interface-skeleton__sidebar {
|
|
@@ -790,6 +797,9 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
|
|
|
790
797
|
.edit-widgets-layout__inserter-panel-content {
|
|
791
798
|
height: calc(100% - 36px - 8px);
|
|
792
799
|
}
|
|
800
|
+
.edit-widgets-layout__inserter-panel-content .block-editor-inserter__tab {
|
|
801
|
+
display: none;
|
|
802
|
+
}
|
|
793
803
|
@media (min-width: 782px) {
|
|
794
804
|
.edit-widgets-layout__inserter-panel-content {
|
|
795
805
|
height: 100%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.34.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,32 +27,32 @@
|
|
|
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": "^12.
|
|
32
|
-
"@wordpress/block-library": "^8.
|
|
33
|
-
"@wordpress/blocks": "^12.
|
|
34
|
-
"@wordpress/components": "^27.
|
|
35
|
-
"@wordpress/compose": "^6.
|
|
36
|
-
"@wordpress/core-data": "^6.
|
|
37
|
-
"@wordpress/data": "^9.
|
|
38
|
-
"@wordpress/deprecated": "^3.
|
|
39
|
-
"@wordpress/dom": "^3.
|
|
40
|
-
"@wordpress/element": "^5.
|
|
41
|
-
"@wordpress/hooks": "^3.
|
|
42
|
-
"@wordpress/i18n": "^4.
|
|
43
|
-
"@wordpress/icons": "^9.
|
|
44
|
-
"@wordpress/interface": "^5.
|
|
45
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
46
|
-
"@wordpress/keycodes": "^3.
|
|
47
|
-
"@wordpress/media-utils": "^4.
|
|
48
|
-
"@wordpress/notices": "^4.
|
|
49
|
-
"@wordpress/patterns": "^1.
|
|
50
|
-
"@wordpress/plugins": "^6.
|
|
51
|
-
"@wordpress/preferences": "^3.
|
|
52
|
-
"@wordpress/private-apis": "^0.
|
|
53
|
-
"@wordpress/reusable-blocks": "^4.
|
|
54
|
-
"@wordpress/url": "^3.
|
|
55
|
-
"@wordpress/widgets": "^3.
|
|
30
|
+
"@wordpress/api-fetch": "^6.54.0",
|
|
31
|
+
"@wordpress/block-editor": "^12.25.0",
|
|
32
|
+
"@wordpress/block-library": "^8.34.0",
|
|
33
|
+
"@wordpress/blocks": "^12.34.0",
|
|
34
|
+
"@wordpress/components": "^27.5.0",
|
|
35
|
+
"@wordpress/compose": "^6.34.0",
|
|
36
|
+
"@wordpress/core-data": "^6.34.0",
|
|
37
|
+
"@wordpress/data": "^9.27.0",
|
|
38
|
+
"@wordpress/deprecated": "^3.57.0",
|
|
39
|
+
"@wordpress/dom": "^3.57.0",
|
|
40
|
+
"@wordpress/element": "^5.34.0",
|
|
41
|
+
"@wordpress/hooks": "^3.57.0",
|
|
42
|
+
"@wordpress/i18n": "^4.57.0",
|
|
43
|
+
"@wordpress/icons": "^9.48.0",
|
|
44
|
+
"@wordpress/interface": "^5.34.0",
|
|
45
|
+
"@wordpress/keyboard-shortcuts": "^4.34.0",
|
|
46
|
+
"@wordpress/keycodes": "^3.57.0",
|
|
47
|
+
"@wordpress/media-utils": "^4.48.0",
|
|
48
|
+
"@wordpress/notices": "^4.25.0",
|
|
49
|
+
"@wordpress/patterns": "^1.18.0",
|
|
50
|
+
"@wordpress/plugins": "^6.25.0",
|
|
51
|
+
"@wordpress/preferences": "^3.34.0",
|
|
52
|
+
"@wordpress/private-apis": "^0.39.0",
|
|
53
|
+
"@wordpress/reusable-blocks": "^4.34.0",
|
|
54
|
+
"@wordpress/url": "^3.58.0",
|
|
55
|
+
"@wordpress/widgets": "^3.34.0",
|
|
56
56
|
"classnames": "^2.3.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "581d8a5580dba8f600b7268d51eb554771ae482c"
|
|
66
66
|
}
|
|
@@ -7,7 +7,6 @@ import { Button, ToolbarItem } from '@wordpress/components';
|
|
|
7
7
|
import {
|
|
8
8
|
NavigableToolbar,
|
|
9
9
|
store as blockEditorStore,
|
|
10
|
-
privateApis as blockEditorPrivateApis,
|
|
11
10
|
} from '@wordpress/block-editor';
|
|
12
11
|
import { listView, plus } from '@wordpress/icons';
|
|
13
12
|
import { useCallback, useRef } from '@wordpress/element';
|
|
@@ -22,8 +21,6 @@ import useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-a
|
|
|
22
21
|
import { store as editWidgetsStore } from '../../../store';
|
|
23
22
|
import { unlock } from '../../../lock-unlock';
|
|
24
23
|
|
|
25
|
-
const { useShowBlockTools } = unlock( blockEditorPrivateApis );
|
|
26
|
-
|
|
27
24
|
function DocumentTools() {
|
|
28
25
|
const isMediumViewport = useViewportMatch( 'medium' );
|
|
29
26
|
const inserterButton = useRef();
|
|
@@ -75,14 +72,10 @@ function DocumentTools() {
|
|
|
75
72
|
[ setIsListViewOpened, isListViewOpen ]
|
|
76
73
|
);
|
|
77
74
|
|
|
78
|
-
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
79
|
-
const { showFixedToolbar } = useShowBlockTools();
|
|
80
|
-
|
|
81
75
|
return (
|
|
82
76
|
<NavigableToolbar
|
|
83
77
|
className="edit-widgets-header-toolbar"
|
|
84
78
|
aria-label={ __( 'Document tools' ) }
|
|
85
|
-
shouldUseKeyboardFocusShortcut={ ! showFixedToolbar }
|
|
86
79
|
variant="unstyled"
|
|
87
80
|
>
|
|
88
81
|
<ToolbarItem
|
|
@@ -37,7 +37,16 @@ export const textFormattingShortcuts = [
|
|
|
37
37
|
description: __( 'Make the selected text inline code.' ),
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
keyCombination: {
|
|
40
|
+
keyCombination: {
|
|
41
|
+
modifier: 'access',
|
|
42
|
+
character: '0',
|
|
43
|
+
},
|
|
44
|
+
aliases: [
|
|
45
|
+
{
|
|
46
|
+
modifier: 'access',
|
|
47
|
+
character: '7',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
41
50
|
description: __( 'Convert the current heading to a paragraph.' ),
|
|
42
51
|
},
|
|
43
52
|
{
|
|
@@ -7,11 +7,9 @@ import {
|
|
|
7
7
|
store as keyboardShortcutsStore,
|
|
8
8
|
} from '@wordpress/keyboard-shortcuts';
|
|
9
9
|
import { isAppleOS } from '@wordpress/keycodes';
|
|
10
|
-
import { useDispatch
|
|
10
|
+
import { useDispatch } from '@wordpress/data';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
|
-
import { createBlock } from '@wordpress/blocks';
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Internal dependencies
|
|
@@ -22,38 +20,6 @@ function KeyboardShortcuts() {
|
|
|
22
20
|
const { redo, undo } = useDispatch( coreStore );
|
|
23
21
|
const { saveEditedWidgetAreas } = useDispatch( editWidgetsStore );
|
|
24
22
|
|
|
25
|
-
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
26
|
-
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
|
|
27
|
-
useSelect( blockEditorStore );
|
|
28
|
-
|
|
29
|
-
const handleTextLevelShortcut = ( event, level ) => {
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
const destinationBlockName =
|
|
32
|
-
level === 0 ? 'core/paragraph' : 'core/heading';
|
|
33
|
-
const currentClientId = getSelectedBlockClientId();
|
|
34
|
-
if ( currentClientId === null ) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const blockName = getBlockName( currentClientId );
|
|
38
|
-
if ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const attributes = getBlockAttributes( currentClientId );
|
|
42
|
-
const textAlign =
|
|
43
|
-
blockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
44
|
-
const destinationTextAlign =
|
|
45
|
-
destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
46
|
-
|
|
47
|
-
replaceBlocks(
|
|
48
|
-
currentClientId,
|
|
49
|
-
createBlock( destinationBlockName, {
|
|
50
|
-
level,
|
|
51
|
-
content: attributes.content,
|
|
52
|
-
...{ [ destinationTextAlign ]: attributes[ textAlign ] },
|
|
53
|
-
} )
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
23
|
useShortcut( 'core/edit-widgets/undo', ( event ) => {
|
|
58
24
|
undo();
|
|
59
25
|
event.preventDefault();
|
|
@@ -69,21 +35,6 @@ function KeyboardShortcuts() {
|
|
|
69
35
|
saveEditedWidgetAreas();
|
|
70
36
|
} );
|
|
71
37
|
|
|
72
|
-
useShortcut(
|
|
73
|
-
'core/edit-widgets/transform-heading-to-paragraph',
|
|
74
|
-
( event ) => handleTextLevelShortcut( event, 0 )
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
|
|
78
|
-
//the loop is based off on a constant therefore
|
|
79
|
-
//the hook will execute the same way every time
|
|
80
|
-
//eslint-disable-next-line react-hooks/rules-of-hooks
|
|
81
|
-
useShortcut(
|
|
82
|
-
`core/edit-widgets/transform-paragraph-to-heading-${ level }`,
|
|
83
|
-
( event ) => handleTextLevelShortcut( event, level )
|
|
84
|
-
);
|
|
85
|
-
} );
|
|
86
|
-
|
|
87
38
|
return null;
|
|
88
39
|
}
|
|
89
40
|
|
|
@@ -178,28 +129,6 @@ function KeyboardShortcutsRegister() {
|
|
|
178
129
|
},
|
|
179
130
|
],
|
|
180
131
|
} );
|
|
181
|
-
|
|
182
|
-
registerShortcut( {
|
|
183
|
-
name: 'core/edit-widgets/transform-heading-to-paragraph',
|
|
184
|
-
category: 'block-library',
|
|
185
|
-
description: __( 'Transform heading to paragraph.' ),
|
|
186
|
-
keyCombination: {
|
|
187
|
-
modifier: 'access',
|
|
188
|
-
character: `0`,
|
|
189
|
-
},
|
|
190
|
-
} );
|
|
191
|
-
|
|
192
|
-
[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
|
|
193
|
-
registerShortcut( {
|
|
194
|
-
name: `core/edit-widgets/transform-paragraph-to-heading-${ level }`,
|
|
195
|
-
category: 'block-library',
|
|
196
|
-
description: __( 'Transform paragraph to heading.' ),
|
|
197
|
-
keyCombination: {
|
|
198
|
-
modifier: 'access',
|
|
199
|
-
character: `${ level }`,
|
|
200
|
-
},
|
|
201
|
-
} );
|
|
202
|
-
} );
|
|
203
132
|
}, [ registerShortcut ] );
|
|
204
133
|
|
|
205
134
|
return null;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useViewportMatch,
|
|
9
9
|
__experimentalUseDialog as useDialog,
|
|
10
10
|
} from '@wordpress/compose';
|
|
11
|
-
import { useCallback,
|
|
11
|
+
import { useCallback, useRef } from '@wordpress/element';
|
|
12
12
|
import { useDispatch } from '@wordpress/data';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
14
|
|
|
@@ -31,13 +31,10 @@ export default function InserterSidebar() {
|
|
|
31
31
|
const TagName = ! isMobileViewport ? VisuallyHidden : 'div';
|
|
32
32
|
const [ inserterDialogRef, inserterDialogProps ] = useDialog( {
|
|
33
33
|
onClose: closeInserter,
|
|
34
|
-
focusOnMount:
|
|
34
|
+
focusOnMount: true,
|
|
35
35
|
} );
|
|
36
36
|
|
|
37
37
|
const libraryRef = useRef();
|
|
38
|
-
useEffect( () => {
|
|
39
|
-
libraryRef.current.focusSearch();
|
|
40
|
-
}, [] );
|
|
41
38
|
|
|
42
39
|
return (
|
|
43
40
|
<div
|
|
@@ -14,6 +14,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
14
14
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
15
15
|
import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
|
|
16
16
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
17
|
+
import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -27,6 +28,8 @@ import { unlock } from '../../lock-unlock';
|
|
|
27
28
|
|
|
28
29
|
const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
|
|
29
30
|
const { PatternsMenuItems } = unlock( editPatternsPrivateApis );
|
|
31
|
+
const { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );
|
|
32
|
+
|
|
30
33
|
export default function WidgetAreasBlockEditorProvider( {
|
|
31
34
|
blockEditorSettings,
|
|
32
35
|
children,
|
|
@@ -111,6 +114,7 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
111
114
|
return (
|
|
112
115
|
<SlotFillProvider>
|
|
113
116
|
<KeyboardShortcuts.Register />
|
|
117
|
+
<BlockKeyboardShortcuts />
|
|
114
118
|
<ExperimentalBlockEditorProvider
|
|
115
119
|
value={ blocks }
|
|
116
120
|
onInput={ onInput }
|