Skip to content

Commit d18953e

Browse files
committed
fix(track-changes): allow linked style changes in suggesting mode (SD-2182)
Heading/paragraph style changes were silently blocked in suggesting mode. tr.setNodeMarkup() produces a ReplaceAroundStep which was being dropped by the track changes handler. This detects node markup changes (same structure, different attrs) and allows them through. Also removes the empty selection guard from toggleLinkedStyle so keyboard shortcuts work. Note: style changes are applied directly without tracked change marks. Tracked change decoration for paragraph styles is a follow-up.
1 parent 0132d0e commit d18953e

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

packages/super-editor/src/extensions/linked-styles/linked-styles.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,11 @@ export const LinkedStyles = Extension.create({
6161
* @example
6262
* const style = editor.helpers.linkedStyles.getStyleById('Heading1');
6363
* editor.commands.toggleLinkedStyle(style)
64-
* @note If selection is empty, returns false
64+
* @note Works with both cursor position and text selection
6565
* @note Removes style if already applied, applies it if not
6666
*/
6767
toggleLinkedStyle: (style) => (params) => {
6868
const { tr } = params;
69-
if (tr.selection.empty) {
70-
return false;
71-
}
7269
let node = tr.doc.nodeAt(tr.selection.$from.pos);
7370

7471
if (node && node.type.name !== 'paragraph') {

packages/super-editor/src/extensions/track-changes/trackChangesHelpers/replaceAroundStep.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ export const replaceAroundStep = ({
9494
return;
9595
}
9696

97+
// Detect setNodeMarkup steps: they preserve the node type and content,
98+
// only changing attributes (e.g. paragraph styleId for heading changes).
99+
// These are safe to apply — they don't alter document structure.
100+
const isNodeMarkupChange = step.structure && step.gapFrom === step.from + 1 && step.gapTo === step.to - 1;
101+
102+
if (isNodeMarkupChange) {
103+
newTr.step(step);
104+
return;
105+
}
106+
97107
const inputType = tr.getMeta('inputType');
98108
const isBackspace = inputType === 'deleteContentBackward';
99109

0 commit comments

Comments
 (0)