feat(editor): autofill turn-into-linked-doc modal with fisrt paragraph (#12032)

Close [BS-3288](https://linear.app/affine-design/issue/BS-3288/从note转换-linked-doc-时,默认把note的第一行填入doc拟定的标题)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - When converting a note block to a linked document, the initial document title now uses the first paragraph in the note (if available) as a placeholder.
- **Tests**
  - Updated tests to verify that the linked document creation modal pre-fills the title with the note's first paragraph and checks for correct paragraph order.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
L-Sun
2025-04-30 04:55:04 +00:00
parent 9f4800ffba
commit 0d6c595adf
2 changed files with 28 additions and 11 deletions
@@ -23,12 +23,16 @@ import {
ImageBlockModel,
isExternalEmbedModel,
NoteBlockModel,
ParagraphBlockModel,
} from '@blocksuite/affine-model';
import type {
ToolbarActions,
ToolbarContext,
} from '@blocksuite/affine-shared/services';
import { type ReorderingType } from '@blocksuite/affine-shared/utils';
import {
matchModels,
type ReorderingType,
} from '@blocksuite/affine-shared/utils';
import { Bound, getCommonBoundWithRotation } from '@blocksuite/global/gfx';
import {
ArrowDownBigBottomIcon,
@@ -219,8 +223,18 @@ export const moreActions = [
const model = ctx.getCurrentModelByType(NoteBlockModel);
if (!model) return;
let placeholder = '';
for (const child of model.children) {
if (matchModels(child, [ParagraphBlockModel])) {
if (child.props.text.length === 0) continue;
placeholder = child.props.text.toString();
break;
}
break;
}
const create = async () => {
const title = await promptDocTitle(ctx.std);
const title = await promptDocTitle(ctx.std, placeholder);
if (title === null) return;
const edgeless = getEdgelessWith(ctx);