mirror of
https://github.com/WenPai-org/wpmind.git
synced 2025-08-06 21:53:53 +08:00
changed replaceBlocks
store to insertionPlace
This commit is contained in:
parent
b08b333ab4
commit
896d629ae3
6 changed files with 35 additions and 38 deletions
|
@ -92,7 +92,7 @@ export default function Popup(props) {
|
|||
isOpen,
|
||||
input,
|
||||
context,
|
||||
replaceBlocks,
|
||||
insertionPlace,
|
||||
screen,
|
||||
loading,
|
||||
response,
|
||||
|
@ -102,7 +102,7 @@ export default function Popup(props) {
|
|||
isOpen: checkIsOpen,
|
||||
getInput,
|
||||
getContext,
|
||||
getReplaceBlocks,
|
||||
getInsertionPlace,
|
||||
getScreen,
|
||||
getLoading,
|
||||
getResponse,
|
||||
|
@ -113,7 +113,7 @@ export default function Popup(props) {
|
|||
isOpen: checkIsOpen(),
|
||||
input: getInput(),
|
||||
context: getContext(),
|
||||
replaceBlocks: getReplaceBlocks(),
|
||||
insertionPlace: getInsertionPlace(),
|
||||
screen: getScreen(),
|
||||
loading: getLoading(),
|
||||
response: getResponse(),
|
||||
|
@ -121,6 +121,16 @@ export default function Popup(props) {
|
|||
};
|
||||
});
|
||||
|
||||
const { selectedClientIds } = useSelect((select) => {
|
||||
const { getSelectedBlockClientIds } = select('core/block-editor');
|
||||
|
||||
const ids = getSelectedBlockClientIds();
|
||||
|
||||
return {
|
||||
selectedClientIds: ids,
|
||||
};
|
||||
}, []);
|
||||
|
||||
let contextLabel = context;
|
||||
|
||||
switch (context) {
|
||||
|
@ -133,8 +143,7 @@ export default function Popup(props) {
|
|||
// no default
|
||||
}
|
||||
|
||||
const { insertBlocks: wpInsertBlocks, replaceBlocks: wpReplaceBlocks } =
|
||||
useDispatch('core/block-editor');
|
||||
const { insertBlocks, replaceBlocks } = useDispatch('core/block-editor');
|
||||
|
||||
function focusInput() {
|
||||
if (ref?.current) {
|
||||
|
@ -156,10 +165,10 @@ export default function Popup(props) {
|
|||
const parsedBlocks = rawHandler({ HTML: response });
|
||||
|
||||
if (parsedBlocks.length) {
|
||||
if (replaceBlocks && replaceBlocks.length) {
|
||||
wpReplaceBlocks(replaceBlocks, parsedBlocks);
|
||||
if (insertionPlace === 'selected-blocks') {
|
||||
replaceBlocks(selectedClientIds, parsedBlocks);
|
||||
} else {
|
||||
wpInsertBlocks(parsedBlocks);
|
||||
insertBlocks(parsedBlocks);
|
||||
}
|
||||
|
||||
setHighlightBlocks(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue