mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user