Skip to content

Commit

Permalink
🔨 fix alignment reset
Browse files Browse the repository at this point in the history
  • Loading branch information
winetree94 committed May 8, 2024
1 parent 5d37ddd commit 9864d33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions packages/core/src/commands/clear-marks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { Command } from 'prosemirror-state';
*/
export const clearMarks = (): Command => (state, dispatch) => {
const { from, to } = state.selection;
const tr = state.tr;
tr.removeMark(from, to);
tr.setStoredMarks([]);
if (dispatch) {
dispatch(tr);
let tr = state.tr;
tr = tr.removeMark(from, to);
tr = tr.setStoredMarks([]);
if (!tr.docChanged) {
return false;
}
dispatch?.(tr);
return true;
};
5 changes: 4 additions & 1 deletion packages/core/src/commands/transform-range-to-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export const transformRangeToBlock =
if (!nodeType.validContent(node.content)) {
return tr;
}
tr.setBlockType(pos, pos + node.nodeSize, nodeType, attrs);
tr.setBlockType(pos, pos + node.nodeSize, nodeType, {
...node.attrs,
...attrs,
});
return tr;
}, tr);
selection = state.selection.map(tr.doc, tr.mapping);
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/utils/get-block-container-children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ export const getBlockContainerChildren = (
) => {
const nodes: NodePair[] = [];
doc.nodesBetween(from, to, (node, pos, parent) => {
if (
parent?.type.spec.group?.includes('block-container') &&
node.type.name !== 'table'
) {
if (parent?.type.spec.group?.includes('block-container')) {
nodes.push({ node, pos, parent });
return false;
}
Expand Down

0 comments on commit 9864d33

Please sign in to comment.