Table improvements (#6958)
* Header toggling, resizable columns * Allow all blocks in table cells, disable column resizing in read-only * Fixed dynamic scroll shadows * Refactor, scroll styling * fix scrolling, tweaks * fix: Table layout lost on sort * fix: Caching of grip decorators * refactor * stash * fix first render shadows * stash * First add column grip, styles * Just add column/row click handlers left * fix: isTableSelected for single cell table * Refactor mousedown handlers * fix: 'Add row before' command missing on first row * fix overflow on rhs * fix: Error clicking column grip when menu is open * Hide table controls when printing * Restore table header background * fix: Header behavior when adding columns and rows at the edges * Tweak header styling * fix: Serialize and parsing of column attributes when copy/pasting fix: Column width is lost when changing column alignment
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
import { Command, Transaction } from "prosemirror-state";
|
||||
|
||||
export default function chainTransactions(...commands: Command[]): Command {
|
||||
/**
|
||||
* Chain multiple commands into a single command and collects state as it goes.
|
||||
*
|
||||
* @param commands The commands to chain
|
||||
* @returns The chained command
|
||||
*/
|
||||
export function chainTransactions(
|
||||
...commands: (Command | undefined)[]
|
||||
): Command {
|
||||
return (state, dispatch): boolean => {
|
||||
const dispatcher = (tr: Transaction): void => {
|
||||
state = state.apply(tr);
|
||||
dispatch?.(tr);
|
||||
};
|
||||
const last = commands.pop();
|
||||
const reduced = commands.reduce(
|
||||
(result, command) => result || command(state, dispatcher),
|
||||
false
|
||||
);
|
||||
return reduced && last !== undefined && last(state, dispatch);
|
||||
commands.map((command) => command?.(state, dispatcher));
|
||||
return last !== undefined && last(state, dispatch);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user