Skip to content

Commit e12141a

Browse files
fix: preserving inline styles
1 parent 28e1c01 commit e12141a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/web/pmPlugins/TextShortcutsPlugin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ function tryParagraphShortcut(
150150

151151
if (isFormatBlocked(style, editor, htmlStyle)) continue;
152152

153+
const marksToPreserve = view.state.selection.$from.marks();
154+
153155
// Delete the prefix that is already in the doc (the last char - text -
154156
// hasn't been inserted yet, so we only remove the prefix portion).
155157
const { tr } = view.state;
@@ -158,6 +160,10 @@ function tryParagraphShortcut(
158160
}
159161
view.dispatch(tr);
160162

163+
if (marksToPreserve.length > 0) {
164+
view.dispatch(view.state.tr.setStoredMarks(marksToPreserve));
165+
}
166+
161167
applyParagraphCommand(style, editor);
162168
return true;
163169
}
@@ -258,7 +264,7 @@ function tryInlineShortcut(
258264
tr.setSelection(TextSelection.create(tr.doc, finalEnd));
259265

260266
view.dispatch(tr);
261-
view.dispatch(view.state.tr.setStoredMarks([]));
267+
view.dispatch(view.state.tr.removeStoredMark(markType));
262268
return true;
263269
}
264270

0 commit comments

Comments
 (0)