mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-26 14:58:55 +08:00
1f45cc5dec
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
31 lines
766 B
TypeScript
31 lines
766 B
TypeScript
import { focusTextModel } from '@blocksuite/affine-rich-text';
|
|
import { getLastNoteBlock } from '@blocksuite/affine-shared/utils';
|
|
import type { Command } from '@blocksuite/std';
|
|
import { Text } from '@blocksuite/store';
|
|
|
|
/**
|
|
* Append a paragraph block at the end of the whole page.
|
|
*/
|
|
export const appendParagraphCommand: Command<{ text?: string }> = (
|
|
ctx,
|
|
next
|
|
) => {
|
|
const { std, text = '' } = ctx;
|
|
const { store } = std;
|
|
if (!store.root) return;
|
|
|
|
const note = getLastNoteBlock(store);
|
|
let noteId = note?.id;
|
|
if (!noteId) {
|
|
noteId = store.addBlock('affine:note', {}, store.root.id);
|
|
}
|
|
const id = store.addBlock(
|
|
'affine:paragraph',
|
|
{ text: new Text(text) },
|
|
noteId
|
|
);
|
|
|
|
focusTextModel(std, id, text.length);
|
|
next();
|
|
};
|