Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: block-editor.js
* blocks that exist in the post, leaving blocks that exist only in state (e.g.
[9000] Fix | Delete
* reusable blocks and blocks controlled by inner blocks controllers) alone.
[9001] Fix | Delete
*
[9002] Fix | Delete
* @param {Function} reducer Original reducer function.
[9003] Fix | Delete
*
[9004] Fix | Delete
* @return {Function} Enhanced reducer function.
[9005] Fix | Delete
*/
[9006] Fix | Delete
const withBlockReset = reducer => (state, action) => {
[9007] Fix | Delete
if (action.type === 'RESET_BLOCKS') {
[9008] Fix | Delete
const newState = {
[9009] Fix | Delete
...state,
[9010] Fix | Delete
byClientId: new Map(getFlattenedBlocksWithoutAttributes(action.blocks)),
[9011] Fix | Delete
attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
[9012] Fix | Delete
order: mapBlockOrder(action.blocks),
[9013] Fix | Delete
parents: new Map(mapBlockParents(action.blocks)),
[9014] Fix | Delete
controlledInnerBlocks: {}
[9015] Fix | Delete
};
[9016] Fix | Delete
newState.tree = new Map(state?.tree);
[9017] Fix | Delete
updateBlockTreeForBlocks(newState, action.blocks);
[9018] Fix | Delete
newState.tree.set('', {
[9019] Fix | Delete
innerBlocks: action.blocks.map(subBlock => newState.tree.get(subBlock.clientId))
[9020] Fix | Delete
});
[9021] Fix | Delete
return newState;
[9022] Fix | Delete
}
[9023] Fix | Delete
return reducer(state, action);
[9024] Fix | Delete
};
[9025] Fix | Delete
[9026] Fix | Delete
/**
[9027] Fix | Delete
* Higher-order reducer which targets the combined blocks reducer and handles
[9028] Fix | Delete
* the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state
[9029] Fix | Delete
* should become equivalent to the execution of a `REMOVE_BLOCKS` action
[9030] Fix | Delete
* containing all the child's of the root block followed by the execution of
[9031] Fix | Delete
* `INSERT_BLOCKS` with the new blocks.
[9032] Fix | Delete
*
[9033] Fix | Delete
* @param {Function} reducer Original reducer function.
[9034] Fix | Delete
*
[9035] Fix | Delete
* @return {Function} Enhanced reducer function.
[9036] Fix | Delete
*/
[9037] Fix | Delete
const withReplaceInnerBlocks = reducer => (state, action) => {
[9038] Fix | Delete
if (action.type !== 'REPLACE_INNER_BLOCKS') {
[9039] Fix | Delete
return reducer(state, action);
[9040] Fix | Delete
}
[9041] Fix | Delete
[9042] Fix | Delete
// Finds every nested inner block controller. We must check the action blocks
[9043] Fix | Delete
// and not just the block parent state because some inner block controllers
[9044] Fix | Delete
// should be deleted if specified, whereas others should not be deleted. If
[9045] Fix | Delete
// a controlled should not be deleted, then we need to avoid deleting its
[9046] Fix | Delete
// inner blocks from the block state because its inner blocks will not be
[9047] Fix | Delete
// attached to the block in the action.
[9048] Fix | Delete
const nestedControllers = {};
[9049] Fix | Delete
if (Object.keys(state.controlledInnerBlocks).length) {
[9050] Fix | Delete
const stack = [...action.blocks];
[9051] Fix | Delete
while (stack.length) {
[9052] Fix | Delete
const {
[9053] Fix | Delete
innerBlocks,
[9054] Fix | Delete
...block
[9055] Fix | Delete
} = stack.shift();
[9056] Fix | Delete
stack.push(...innerBlocks);
[9057] Fix | Delete
if (!!state.controlledInnerBlocks[block.clientId]) {
[9058] Fix | Delete
nestedControllers[block.clientId] = true;
[9059] Fix | Delete
}
[9060] Fix | Delete
}
[9061] Fix | Delete
}
[9062] Fix | Delete
[9063] Fix | Delete
// The `keepControlledInnerBlocks` prop will keep the inner blocks of the
[9064] Fix | Delete
// marked block in the block state so that they can be reattached to the
[9065] Fix | Delete
// marked block when we re-insert everything a few lines below.
[9066] Fix | Delete
let stateAfterBlocksRemoval = state;
[9067] Fix | Delete
if (state.order.get(action.rootClientId)) {
[9068] Fix | Delete
stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
[9069] Fix | Delete
type: 'REMOVE_BLOCKS',
[9070] Fix | Delete
keepControlledInnerBlocks: nestedControllers,
[9071] Fix | Delete
clientIds: state.order.get(action.rootClientId)
[9072] Fix | Delete
});
[9073] Fix | Delete
}
[9074] Fix | Delete
let stateAfterInsert = stateAfterBlocksRemoval;
[9075] Fix | Delete
if (action.blocks.length) {
[9076] Fix | Delete
stateAfterInsert = reducer(stateAfterInsert, {
[9077] Fix | Delete
...action,
[9078] Fix | Delete
type: 'INSERT_BLOCKS',
[9079] Fix | Delete
index: 0
[9080] Fix | Delete
});
[9081] Fix | Delete
[9082] Fix | Delete
// We need to re-attach the controlled inner blocks to the blocks tree and
[9083] Fix | Delete
// preserve their block order. Otherwise, an inner block controller's blocks
[9084] Fix | Delete
// will be deleted entirely from its entity.
[9085] Fix | Delete
const stateAfterInsertOrder = new Map(stateAfterInsert.order);
[9086] Fix | Delete
Object.keys(nestedControllers).forEach(key => {
[9087] Fix | Delete
if (state.order.get(key)) {
[9088] Fix | Delete
stateAfterInsertOrder.set(key, state.order.get(key));
[9089] Fix | Delete
}
[9090] Fix | Delete
});
[9091] Fix | Delete
stateAfterInsert.order = stateAfterInsertOrder;
[9092] Fix | Delete
stateAfterInsert.tree = new Map(stateAfterInsert.tree);
[9093] Fix | Delete
Object.keys(nestedControllers).forEach(_key => {
[9094] Fix | Delete
const key = `controlled||${_key}`;
[9095] Fix | Delete
if (state.tree.has(key)) {
[9096] Fix | Delete
stateAfterInsert.tree.set(key, state.tree.get(key));
[9097] Fix | Delete
}
[9098] Fix | Delete
});
[9099] Fix | Delete
}
[9100] Fix | Delete
return stateAfterInsert;
[9101] Fix | Delete
};
[9102] Fix | Delete
[9103] Fix | Delete
/**
[9104] Fix | Delete
* Higher-order reducer which targets the combined blocks reducer and handles
[9105] Fix | Delete
* the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by
[9106] Fix | Delete
* regular reducers and needs a higher-order reducer since it needs access to
[9107] Fix | Delete
* both `byClientId` and `attributes` simultaneously.
[9108] Fix | Delete
*
[9109] Fix | Delete
* @param {Function} reducer Original reducer function.
[9110] Fix | Delete
*
[9111] Fix | Delete
* @return {Function} Enhanced reducer function.
[9112] Fix | Delete
*/
[9113] Fix | Delete
const withSaveReusableBlock = reducer => (state, action) => {
[9114] Fix | Delete
if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') {
[9115] Fix | Delete
const {
[9116] Fix | Delete
id,
[9117] Fix | Delete
updatedId
[9118] Fix | Delete
} = action;
[9119] Fix | Delete
[9120] Fix | Delete
// If a temporary reusable block is saved, we swap the temporary id with the final one.
[9121] Fix | Delete
if (id === updatedId) {
[9122] Fix | Delete
return state;
[9123] Fix | Delete
}
[9124] Fix | Delete
state = {
[9125] Fix | Delete
...state
[9126] Fix | Delete
};
[9127] Fix | Delete
state.attributes = new Map(state.attributes);
[9128] Fix | Delete
state.attributes.forEach((attributes, clientId) => {
[9129] Fix | Delete
const {
[9130] Fix | Delete
name
[9131] Fix | Delete
} = state.byClientId.get(clientId);
[9132] Fix | Delete
if (name === 'core/block' && attributes.ref === id) {
[9133] Fix | Delete
state.attributes.set(clientId, {
[9134] Fix | Delete
...attributes,
[9135] Fix | Delete
ref: updatedId
[9136] Fix | Delete
});
[9137] Fix | Delete
}
[9138] Fix | Delete
});
[9139] Fix | Delete
}
[9140] Fix | Delete
return reducer(state, action);
[9141] Fix | Delete
};
[9142] Fix | Delete
/**
[9143] Fix | Delete
* Higher-order reducer which removes blocks from state when switching parent block controlled state.
[9144] Fix | Delete
*
[9145] Fix | Delete
* @param {Function} reducer Original reducer function.
[9146] Fix | Delete
*
[9147] Fix | Delete
* @return {Function} Enhanced reducer function.
[9148] Fix | Delete
*/
[9149] Fix | Delete
const withResetControlledBlocks = reducer => (state, action) => {
[9150] Fix | Delete
if (action.type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
[9151] Fix | Delete
// when switching a block from controlled to uncontrolled or inverse,
[9152] Fix | Delete
// we need to remove its content first.
[9153] Fix | Delete
const tempState = reducer(state, {
[9154] Fix | Delete
type: 'REPLACE_INNER_BLOCKS',
[9155] Fix | Delete
rootClientId: action.clientId,
[9156] Fix | Delete
blocks: []
[9157] Fix | Delete
});
[9158] Fix | Delete
return reducer(tempState, action);
[9159] Fix | Delete
}
[9160] Fix | Delete
return reducer(state, action);
[9161] Fix | Delete
};
[9162] Fix | Delete
[9163] Fix | Delete
/**
[9164] Fix | Delete
* Reducer returning the blocks state.
[9165] Fix | Delete
*
[9166] Fix | Delete
* @param {Object} state Current state.
[9167] Fix | Delete
* @param {Object} action Dispatched action.
[9168] Fix | Delete
*
[9169] Fix | Delete
* @return {Object} Updated state.
[9170] Fix | Delete
*/
[9171] Fix | Delete
const blocks = (0,external_wp_compose_namespaceObject.pipe)(external_wp_data_namespaceObject.combineReducers, withSaveReusableBlock,
[9172] Fix | Delete
// Needs to be before withBlockCache.
[9173] Fix | Delete
withBlockTree,
[9174] Fix | Delete
// Needs to be before withInnerBlocksRemoveCascade.
[9175] Fix | Delete
withInnerBlocksRemoveCascade, withReplaceInnerBlocks,
[9176] Fix | Delete
// Needs to be after withInnerBlocksRemoveCascade.
[9177] Fix | Delete
withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
[9178] Fix | Delete
// The state is using a Map instead of a plain object for performance reasons.
[9179] Fix | Delete
// You can run the "./test/performance.js" unit test to check the impact
[9180] Fix | Delete
// code changes can have on this reducer.
[9181] Fix | Delete
byClientId(state = new Map(), action) {
[9182] Fix | Delete
switch (action.type) {
[9183] Fix | Delete
case 'RECEIVE_BLOCKS':
[9184] Fix | Delete
case 'INSERT_BLOCKS':
[9185] Fix | Delete
{
[9186] Fix | Delete
const newState = new Map(state);
[9187] Fix | Delete
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(([key, value]) => {
[9188] Fix | Delete
newState.set(key, value);
[9189] Fix | Delete
});
[9190] Fix | Delete
return newState;
[9191] Fix | Delete
}
[9192] Fix | Delete
case 'UPDATE_BLOCK':
[9193] Fix | Delete
{
[9194] Fix | Delete
// Ignore updates if block isn't known.
[9195] Fix | Delete
if (!state.has(action.clientId)) {
[9196] Fix | Delete
return state;
[9197] Fix | Delete
}
[9198] Fix | Delete
[9199] Fix | Delete
// Do nothing if only attributes change.
[9200] Fix | Delete
const {
[9201] Fix | Delete
attributes,
[9202] Fix | Delete
...changes
[9203] Fix | Delete
} = action.updates;
[9204] Fix | Delete
if (Object.values(changes).length === 0) {
[9205] Fix | Delete
return state;
[9206] Fix | Delete
}
[9207] Fix | Delete
const newState = new Map(state);
[9208] Fix | Delete
newState.set(action.clientId, {
[9209] Fix | Delete
...state.get(action.clientId),
[9210] Fix | Delete
...changes
[9211] Fix | Delete
});
[9212] Fix | Delete
return newState;
[9213] Fix | Delete
}
[9214] Fix | Delete
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
[9215] Fix | Delete
{
[9216] Fix | Delete
if (!action.blocks) {
[9217] Fix | Delete
return state;
[9218] Fix | Delete
}
[9219] Fix | Delete
const newState = new Map(state);
[9220] Fix | Delete
action.replacedClientIds.forEach(clientId => {
[9221] Fix | Delete
newState.delete(clientId);
[9222] Fix | Delete
});
[9223] Fix | Delete
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(([key, value]) => {
[9224] Fix | Delete
newState.set(key, value);
[9225] Fix | Delete
});
[9226] Fix | Delete
return newState;
[9227] Fix | Delete
}
[9228] Fix | Delete
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
[9229] Fix | Delete
{
[9230] Fix | Delete
const newState = new Map(state);
[9231] Fix | Delete
action.removedClientIds.forEach(clientId => {
[9232] Fix | Delete
newState.delete(clientId);
[9233] Fix | Delete
});
[9234] Fix | Delete
return newState;
[9235] Fix | Delete
}
[9236] Fix | Delete
}
[9237] Fix | Delete
return state;
[9238] Fix | Delete
},
[9239] Fix | Delete
// The state is using a Map instead of a plain object for performance reasons.
[9240] Fix | Delete
// You can run the "./test/performance.js" unit test to check the impact
[9241] Fix | Delete
// code changes can have on this reducer.
[9242] Fix | Delete
attributes(state = new Map(), action) {
[9243] Fix | Delete
switch (action.type) {
[9244] Fix | Delete
case 'RECEIVE_BLOCKS':
[9245] Fix | Delete
case 'INSERT_BLOCKS':
[9246] Fix | Delete
{
[9247] Fix | Delete
const newState = new Map(state);
[9248] Fix | Delete
getFlattenedBlockAttributes(action.blocks).forEach(([key, value]) => {
[9249] Fix | Delete
newState.set(key, value);
[9250] Fix | Delete
});
[9251] Fix | Delete
return newState;
[9252] Fix | Delete
}
[9253] Fix | Delete
case 'UPDATE_BLOCK':
[9254] Fix | Delete
{
[9255] Fix | Delete
// Ignore updates if block isn't known or there are no attribute changes.
[9256] Fix | Delete
if (!state.get(action.clientId) || !action.updates.attributes) {
[9257] Fix | Delete
return state;
[9258] Fix | Delete
}
[9259] Fix | Delete
const newState = new Map(state);
[9260] Fix | Delete
newState.set(action.clientId, {
[9261] Fix | Delete
...state.get(action.clientId),
[9262] Fix | Delete
...action.updates.attributes
[9263] Fix | Delete
});
[9264] Fix | Delete
return newState;
[9265] Fix | Delete
}
[9266] Fix | Delete
case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
[9267] Fix | Delete
case 'UPDATE_BLOCK_ATTRIBUTES':
[9268] Fix | Delete
{
[9269] Fix | Delete
// Avoid a state change if none of the block IDs are known.
[9270] Fix | Delete
if (action.clientIds.every(id => !state.get(id))) {
[9271] Fix | Delete
return state;
[9272] Fix | Delete
}
[9273] Fix | Delete
let hasChange = false;
[9274] Fix | Delete
const newState = new Map(state);
[9275] Fix | Delete
for (const clientId of action.clientIds) {
[9276] Fix | Delete
var _action$attributes;
[9277] Fix | Delete
const updatedAttributeEntries = Object.entries(action.uniqueByBlock ? action.attributes[clientId] : (_action$attributes = action.attributes) !== null && _action$attributes !== void 0 ? _action$attributes : {});
[9278] Fix | Delete
if (updatedAttributeEntries.length === 0) {
[9279] Fix | Delete
continue;
[9280] Fix | Delete
}
[9281] Fix | Delete
let hasUpdatedAttributes = false;
[9282] Fix | Delete
const existingAttributes = state.get(clientId);
[9283] Fix | Delete
const newAttributes = {};
[9284] Fix | Delete
updatedAttributeEntries.forEach(([key, value]) => {
[9285] Fix | Delete
if (existingAttributes[key] !== value) {
[9286] Fix | Delete
hasUpdatedAttributes = true;
[9287] Fix | Delete
newAttributes[key] = value;
[9288] Fix | Delete
}
[9289] Fix | Delete
});
[9290] Fix | Delete
hasChange = hasChange || hasUpdatedAttributes;
[9291] Fix | Delete
if (hasUpdatedAttributes) {
[9292] Fix | Delete
newState.set(clientId, {
[9293] Fix | Delete
...existingAttributes,
[9294] Fix | Delete
...newAttributes
[9295] Fix | Delete
});
[9296] Fix | Delete
}
[9297] Fix | Delete
}
[9298] Fix | Delete
return hasChange ? newState : state;
[9299] Fix | Delete
}
[9300] Fix | Delete
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
[9301] Fix | Delete
{
[9302] Fix | Delete
if (!action.blocks) {
[9303] Fix | Delete
return state;
[9304] Fix | Delete
}
[9305] Fix | Delete
const newState = new Map(state);
[9306] Fix | Delete
action.replacedClientIds.forEach(clientId => {
[9307] Fix | Delete
newState.delete(clientId);
[9308] Fix | Delete
});
[9309] Fix | Delete
getFlattenedBlockAttributes(action.blocks).forEach(([key, value]) => {
[9310] Fix | Delete
newState.set(key, value);
[9311] Fix | Delete
});
[9312] Fix | Delete
return newState;
[9313] Fix | Delete
}
[9314] Fix | Delete
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
[9315] Fix | Delete
{
[9316] Fix | Delete
const newState = new Map(state);
[9317] Fix | Delete
action.removedClientIds.forEach(clientId => {
[9318] Fix | Delete
newState.delete(clientId);
[9319] Fix | Delete
});
[9320] Fix | Delete
return newState;
[9321] Fix | Delete
}
[9322] Fix | Delete
}
[9323] Fix | Delete
return state;
[9324] Fix | Delete
},
[9325] Fix | Delete
// The state is using a Map instead of a plain object for performance reasons.
[9326] Fix | Delete
// You can run the "./test/performance.js" unit test to check the impact
[9327] Fix | Delete
// code changes can have on this reducer.
[9328] Fix | Delete
order(state = new Map(), action) {
[9329] Fix | Delete
switch (action.type) {
[9330] Fix | Delete
case 'RECEIVE_BLOCKS':
[9331] Fix | Delete
{
[9332] Fix | Delete
var _state$get;
[9333] Fix | Delete
const blockOrder = mapBlockOrder(action.blocks);
[9334] Fix | Delete
const newState = new Map(state);
[9335] Fix | Delete
blockOrder.forEach((order, clientId) => {
[9336] Fix | Delete
if (clientId !== '') {
[9337] Fix | Delete
newState.set(clientId, order);
[9338] Fix | Delete
}
[9339] Fix | Delete
});
[9340] Fix | Delete
newState.set('', ((_state$get = state.get('')) !== null && _state$get !== void 0 ? _state$get : []).concat(blockOrder['']));
[9341] Fix | Delete
return newState;
[9342] Fix | Delete
}
[9343] Fix | Delete
case 'INSERT_BLOCKS':
[9344] Fix | Delete
{
[9345] Fix | Delete
const {
[9346] Fix | Delete
rootClientId = ''
[9347] Fix | Delete
} = action;
[9348] Fix | Delete
const subState = state.get(rootClientId) || [];
[9349] Fix | Delete
const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
[9350] Fix | Delete
const {
[9351] Fix | Delete
index = subState.length
[9352] Fix | Delete
} = action;
[9353] Fix | Delete
const newState = new Map(state);
[9354] Fix | Delete
mappedBlocks.forEach((order, clientId) => {
[9355] Fix | Delete
newState.set(clientId, order);
[9356] Fix | Delete
});
[9357] Fix | Delete
newState.set(rootClientId, insertAt(subState, mappedBlocks.get(rootClientId), index));
[9358] Fix | Delete
return newState;
[9359] Fix | Delete
}
[9360] Fix | Delete
case 'MOVE_BLOCKS_TO_POSITION':
[9361] Fix | Delete
{
[9362] Fix | Delete
var _state$get$filter;
[9363] Fix | Delete
const {
[9364] Fix | Delete
fromRootClientId = '',
[9365] Fix | Delete
toRootClientId = '',
[9366] Fix | Delete
clientIds
[9367] Fix | Delete
} = action;
[9368] Fix | Delete
const {
[9369] Fix | Delete
index = state.get(toRootClientId).length
[9370] Fix | Delete
} = action;
[9371] Fix | Delete
[9372] Fix | Delete
// Moving inside the same parent block.
[9373] Fix | Delete
if (fromRootClientId === toRootClientId) {
[9374] Fix | Delete
const subState = state.get(toRootClientId);
[9375] Fix | Delete
const fromIndex = subState.indexOf(clientIds[0]);
[9376] Fix | Delete
const newState = new Map(state);
[9377] Fix | Delete
newState.set(toRootClientId, moveTo(state.get(toRootClientId), fromIndex, index, clientIds.length));
[9378] Fix | Delete
return newState;
[9379] Fix | Delete
}
[9380] Fix | Delete
[9381] Fix | Delete
// Moving from a parent block to another.
[9382] Fix | Delete
const newState = new Map(state);
[9383] Fix | Delete
newState.set(fromRootClientId, (_state$get$filter = state.get(fromRootClientId)?.filter(id => !clientIds.includes(id))) !== null && _state$get$filter !== void 0 ? _state$get$filter : []);
[9384] Fix | Delete
newState.set(toRootClientId, insertAt(state.get(toRootClientId), clientIds, index));
[9385] Fix | Delete
return newState;
[9386] Fix | Delete
}
[9387] Fix | Delete
case 'MOVE_BLOCKS_UP':
[9388] Fix | Delete
{
[9389] Fix | Delete
const {
[9390] Fix | Delete
clientIds,
[9391] Fix | Delete
rootClientId = ''
[9392] Fix | Delete
} = action;
[9393] Fix | Delete
const firstClientId = clientIds[0];
[9394] Fix | Delete
const subState = state.get(rootClientId);
[9395] Fix | Delete
if (!subState.length || firstClientId === subState[0]) {
[9396] Fix | Delete
return state;
[9397] Fix | Delete
}
[9398] Fix | Delete
const firstIndex = subState.indexOf(firstClientId);
[9399] Fix | Delete
const newState = new Map(state);
[9400] Fix | Delete
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex - 1, clientIds.length));
[9401] Fix | Delete
return newState;
[9402] Fix | Delete
}
[9403] Fix | Delete
case 'MOVE_BLOCKS_DOWN':
[9404] Fix | Delete
{
[9405] Fix | Delete
const {
[9406] Fix | Delete
clientIds,
[9407] Fix | Delete
rootClientId = ''
[9408] Fix | Delete
} = action;
[9409] Fix | Delete
const firstClientId = clientIds[0];
[9410] Fix | Delete
const lastClientId = clientIds[clientIds.length - 1];
[9411] Fix | Delete
const subState = state.get(rootClientId);
[9412] Fix | Delete
if (!subState.length || lastClientId === subState[subState.length - 1]) {
[9413] Fix | Delete
return state;
[9414] Fix | Delete
}
[9415] Fix | Delete
const firstIndex = subState.indexOf(firstClientId);
[9416] Fix | Delete
const newState = new Map(state);
[9417] Fix | Delete
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex + 1, clientIds.length));
[9418] Fix | Delete
return newState;
[9419] Fix | Delete
}
[9420] Fix | Delete
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
[9421] Fix | Delete
{
[9422] Fix | Delete
const {
[9423] Fix | Delete
clientIds
[9424] Fix | Delete
} = action;
[9425] Fix | Delete
if (!action.blocks) {
[9426] Fix | Delete
return state;
[9427] Fix | Delete
}
[9428] Fix | Delete
const mappedBlocks = mapBlockOrder(action.blocks);
[9429] Fix | Delete
const newState = new Map(state);
[9430] Fix | Delete
action.replacedClientIds.forEach(clientId => {
[9431] Fix | Delete
newState.delete(clientId);
[9432] Fix | Delete
});
[9433] Fix | Delete
mappedBlocks.forEach((order, clientId) => {
[9434] Fix | Delete
if (clientId !== '') {
[9435] Fix | Delete
newState.set(clientId, order);
[9436] Fix | Delete
}
[9437] Fix | Delete
});
[9438] Fix | Delete
newState.forEach((order, clientId) => {
[9439] Fix | Delete
const newSubOrder = Object.values(order).reduce((result, subClientId) => {
[9440] Fix | Delete
if (subClientId === clientIds[0]) {
[9441] Fix | Delete
return [...result, ...mappedBlocks.get('')];
[9442] Fix | Delete
}
[9443] Fix | Delete
if (clientIds.indexOf(subClientId) === -1) {
[9444] Fix | Delete
result.push(subClientId);
[9445] Fix | Delete
}
[9446] Fix | Delete
return result;
[9447] Fix | Delete
}, []);
[9448] Fix | Delete
newState.set(clientId, newSubOrder);
[9449] Fix | Delete
});
[9450] Fix | Delete
return newState;
[9451] Fix | Delete
}
[9452] Fix | Delete
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
[9453] Fix | Delete
{
[9454] Fix | Delete
const newState = new Map(state);
[9455] Fix | Delete
// Remove inner block ordering for removed blocks.
[9456] Fix | Delete
action.removedClientIds.forEach(clientId => {
[9457] Fix | Delete
newState.delete(clientId);
[9458] Fix | Delete
});
[9459] Fix | Delete
newState.forEach((order, clientId) => {
[9460] Fix | Delete
var _order$filter;
[9461] Fix | Delete
const newSubOrder = (_order$filter = order?.filter(id => !action.removedClientIds.includes(id))) !== null && _order$filter !== void 0 ? _order$filter : [];
[9462] Fix | Delete
if (newSubOrder.length !== order.length) {
[9463] Fix | Delete
newState.set(clientId, newSubOrder);
[9464] Fix | Delete
}
[9465] Fix | Delete
});
[9466] Fix | Delete
return newState;
[9467] Fix | Delete
}
[9468] Fix | Delete
}
[9469] Fix | Delete
return state;
[9470] Fix | Delete
},
[9471] Fix | Delete
// While technically redundant data as the inverse of `order`, it serves as
[9472] Fix | Delete
// an optimization for the selectors which derive the ancestry of a block.
[9473] Fix | Delete
parents(state = new Map(), action) {
[9474] Fix | Delete
switch (action.type) {
[9475] Fix | Delete
case 'RECEIVE_BLOCKS':
[9476] Fix | Delete
{
[9477] Fix | Delete
const newState = new Map(state);
[9478] Fix | Delete
mapBlockParents(action.blocks).forEach(([key, value]) => {
[9479] Fix | Delete
newState.set(key, value);
[9480] Fix | Delete
});
[9481] Fix | Delete
return newState;
[9482] Fix | Delete
}
[9483] Fix | Delete
case 'INSERT_BLOCKS':
[9484] Fix | Delete
{
[9485] Fix | Delete
const newState = new Map(state);
[9486] Fix | Delete
mapBlockParents(action.blocks, action.rootClientId || '').forEach(([key, value]) => {
[9487] Fix | Delete
newState.set(key, value);
[9488] Fix | Delete
});
[9489] Fix | Delete
return newState;
[9490] Fix | Delete
}
[9491] Fix | Delete
case 'MOVE_BLOCKS_TO_POSITION':
[9492] Fix | Delete
{
[9493] Fix | Delete
const newState = new Map(state);
[9494] Fix | Delete
action.clientIds.forEach(id => {
[9495] Fix | Delete
newState.set(id, action.toRootClientId || '');
[9496] Fix | Delete
});
[9497] Fix | Delete
return newState;
[9498] Fix | Delete
}
[9499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function