Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat: add zero width paragraph break implementation (#3958)

Ran Luo6142b0711526
diff --git a/mockdata/src/docs/default-document-data-cn.ts b/mockdata/src/docs/default-document-data-cn.ts
index af2f6c22cb..d4a5207c45 100644
--- a/mockdata/src/docs/default-document-data-cn.ts
+++ b/mockdata/src/docs/default-document-data-cn.ts
@@ -613,6 +613,7 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
marginRight: ptToPixel(50),
marginLeft: ptToPixel(50),
renderConfig: {
+ zeroWidthParagraphBreak: BooleanNumber.TRUE,
vertexAngle: 0,
centerAngle: 0,
background: {
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts
index 213fb87006..d429c3dc52 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts
@@ -14,20 +14,20 @@
* limitations under the License.
*/
-import { DataStreamTreeTokenType, PositionedObjectLayoutType, Tools } from '@univerjs/core';
import type { IBullet, IDocDrawingBase, IDrawings, Nullable } from '@univerjs/core';
-import { BreakType } from '../../../../../basics/i-document-skeleton-cached';
-import { createSkeletonPage } from '../../model/page';
-import { setColumnFullState } from '../../model/section';
-import { getLastNotFullColumnInfo } from '../../tools';
-import { dealWithBullet } from './bullet';
-import { layoutParagraph } from './layout-ruler';
import type { IDocumentSkeletonBullet, IDocumentSkeletonDrawing, IDocumentSkeletonPage, IDocumentSkeletonTable } from '../../../../../basics/i-document-skeleton-cached';
import type { IParagraphConfig, ISectionBreakConfig } from '../../../../../basics/interfaces';
import type { DataStreamTreeNode } from '../../../view-model/data-stream-tree-node';
import type { DocumentViewModel } from '../../../view-model/document-view-model';
import type { ILayoutContext } from '../../tools';
import type { IShapedText } from './shaping';
+import { DataStreamTreeTokenType, PositionedObjectLayoutType, Tools } from '@univerjs/core';
+import { BreakType } from '../../../../../basics/i-document-skeleton-cached';
+import { createSkeletonPage } from '../../model/page';
+import { setColumnFullState } from '../../model/section';
+import { getLastNotFullColumnInfo } from '../../tools';
+import { dealWithBullet } from './bullet';
+import { layoutParagraph } from './layout-ruler';
function _getListLevelAncestors(
bullet?: IBullet,
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/shaping.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/shaping.ts
index 02aa052352..0bf9158ebb 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/shaping.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/shaping.ts
@@ -245,6 +245,14 @@ export function shaping(
if (char === DataStreamTreeTokenType.TAB) {
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
newGlyph = createSkeletonTabGlyph(config, charSpaceApply);
+ } else if (char === DataStreamTreeTokenType.PARAGRAPH) {
+ const zeroWidthParagraphBreak = sectionBreakConfig.renderConfig?.zeroWidthParagraphBreak;
+
+ if (zeroWidthParagraphBreak === BooleanNumber.TRUE) {
+ newGlyph = createSkeletonLetterGlyph(char, config, 0);
+ } else {
+ newGlyph = createSkeletonLetterGlyph(char, config);
+ }
} else {
newGlyph = createSkeletonLetterGlyph(char, config);
}