Skip to content

Commit 2a02f99

Browse files
committed
[fix]: prevent block element splitting when applying inline styles (#1281)
1 parent 20a4751 commit 2a02f99

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/core/selection/style/transactions.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,28 @@ export const transactions: IStyleTransactions = {
147147
const suit = suitableClosest(style, element, jodit.editor);
148148
assert(suit, 'This place should have an element');
149149

150-
if (!style.elementIsBlock) {
151-
extractSelectedPart(suit, element, jodit);
150+
// If we're applying inline styles to a block element, don't split the block
151+
const isApplyingInlineStyle =
152+
!style.elementIsBlock && style.options.attributes?.style;
153+
const shouldNotSplitBlock =
154+
isApplyingInlineStyle && Dom.isBlock(suit);
155+
156+
if (!shouldNotSplitBlock) {
157+
if (!style.elementIsBlock) {
158+
extractSelectedPart(suit, element, jodit);
159+
}
160+
161+
return {
162+
...value,
163+
element: suit,
164+
next: states.ELEMENT
165+
};
152166
}
153167

168+
// Create a new wrapper instead of splitting the block
154169
return {
155170
...value,
156-
element: suit,
157-
next: states.ELEMENT
171+
next: states.WRAP
158172
};
159173
}
160174
},

0 commit comments

Comments
 (0)