From d73eb2f2141490f696b35903493b1b1222088200 Mon Sep 17 00:00:00 2001 From: Yifeng Wang Date: Thu, 16 Jan 2025 14:49:26 +0800 Subject: [PATCH] feat: optimize granularity --- blocksuite/playground/examples/renderer/canvas.worker.ts | 2 +- blocksuite/playground/examples/renderer/main.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/blocksuite/playground/examples/renderer/canvas.worker.ts b/blocksuite/playground/examples/renderer/canvas.worker.ts index 6446c29596c95..d2bc1494df480 100644 --- a/blocksuite/playground/examples/renderer/canvas.worker.ts +++ b/blocksuite/playground/examples/renderer/canvas.worker.ts @@ -2,7 +2,7 @@ import { type ParagraphData } from './types.js'; function segmentWords(text: string): string[] { const segmenter = new Intl.Segmenter(void 0, { - granularity: 'word', + granularity: 'sentence', }); return Array.from(segmenter.segment(text)).map(({ segment }) => segment); } diff --git a/blocksuite/playground/examples/renderer/main.ts b/blocksuite/playground/examples/renderer/main.ts index 46264a84235d4..99499ef0b7f63 100644 --- a/blocksuite/playground/examples/renderer/main.ts +++ b/blocksuite/playground/examples/renderer/main.ts @@ -31,5 +31,8 @@ addParagraph('Hello World!'); addParagraph( 'Hello World! Lorem ipsum dolor sit amet. Consectetur adipiscing elit. Sed do eiusmod tempor incididunt.' ); +addParagraph( + '你好这是测试,这是一个为了换行而写的中文段落。这个段落会自动换行。' +); initToCanvasSync();