Skip to content

Commit 3c0d71a

Browse files
committed
fix: rich text empty line breaks support
1 parent f2c55e8 commit 3c0d71a

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

packages/pluggableWidgets/rich-text-web/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
99
### Added
1010

1111
- We added support to choose image from entity using external widget.
12+
- We added support to keep image ratio when resizing images.
13+
14+
### Fixed
15+
16+
- We fixed issue when empty paragraph do not shown as line break in html viewer by adding empty space content ` `.
1217

1318
## [4.7.0] - 2025-06-02
1419

packages/pluggableWidgets/rich-text-web/src/components/ModalDialog/Dialog.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
.code-input {
2929
min-height: 50vh;
30+
31+
.cm-editor {
32+
width: 100%;
33+
}
3034
}
3135
}
3236

packages/pluggableWidgets/rich-text-web/src/utils/customPluginRegisters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Formula from "./formats/formula";
1515
import QuillResize from "quill-resize-module";
1616
import QuillTableBetter from "./formats/quill-table-better/quill-table-better";
1717
import MxUploader from "./modules/uploader";
18+
import MxBlock from "./formats/block";
1819

1920
class Empty {
2021
doSomething(): string {
@@ -36,6 +37,7 @@ Quill.register(IndentLeftStyle, true);
3637
Quill.register(IndentRightStyle, true);
3738
Quill.register(Formula, true);
3839
Quill.register(Button, true);
40+
Quill.register(MxBlock, true);
3941
Quill.register({ "modules/uploader": MxUploader }, true);
4042
Quill.register("modules/resize", QuillResize, true);
4143
// add empty handler for view code, this format is handled by toolbar's custom config via ViewCodeDialog
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Block from "quill/blots/block";
2+
3+
class MxBlock extends Block {
4+
html(): string {
5+
// quill return empty paragraph when there is no content (just empty line)
6+
// to preserve the line breaks, we add empty space
7+
const htmlContent = this.domNode.outerHTML;
8+
if (this.domNode.childElementCount === 1 && this.domNode.children[0] instanceof HTMLBRElement) {
9+
return htmlContent.replace(/<br>/g, "&nbsp;");
10+
}
11+
return this.domNode.outerHTML;
12+
}
13+
}
14+
export default MxBlock;

0 commit comments

Comments
 (0)