You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With both lists selected, liftListItem doesn't work, since it uses blockRange to find a single NodeRange over a list covering the whole current selection. Since liftListItem is the primitive operation exported by prosemirror-schema-list, this limitation means the behavior has to be re-implemented by client-code if it should cover the case I described.
The text was updated successfully, but these errors were encountered:
I believe this was hard to get right, the last time I tried, or raised some hard-to-answer questions, so I omitted it. Unfortunately, I don't remember the precise issue. If you want to make the default implementation handle this, and can do so without introducing anything problematic, I'd be okay with that.
For anyone who comes across this, I put together a hack-around for flattening the entire list that seems to do the job (at the very least, it handles the case in the description). It could certainly be modified to just lift one level at a time, but figured I would share it here in case others come across a need to do this before it gets fully integrated into this library.
// Some error checking/handling has been omitted
// Assume selection here either is or has been expanded to cover the whole list you want to flatten
const selectedContents = selection.content();
const selectedNodes = selectedContents.content.content;
// Not always necessarily paragraphs, but always necessarily NOT lists
const generateNewParagraphNode = node => {
const type = node.type;
// Assume these point to the actual schema NodeTypes that they correspond with
if (type === ol || type === ul || type === li) {
const childContents = node.content.content || [];
const wrappedChildren = childContents.map(generateNewParagraphNode);
return wrappedChildren;
} else {
return node;
}
};
const liftedContents = selectedNodes.map(generateNewParagraphNode);
// Not sure how well Slice handles nested arrays, so I flatten here with a simple JS function
const flatContents = flattenArray(liftedContents);
const newSlice = new Slice(Fragment.fromArray(flatContents), selectedContents.openStart, selectedContents.openEnd);
transaction = editorView.state.tr.replaceSelection(newSlice);
editorView.dispatch(transaction);
Given the following doc:
With both lists selected, liftListItem doesn't work, since it uses
blockRange
to find a singleNodeRange
over a list covering the whole current selection. SinceliftListItem
is the primitive operation exported byprosemirror-schema-list
, this limitation means the behavior has to be re-implemented by client-code if it should cover the case I described.The text was updated successfully, but these errors were encountered: