mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
23 lines
569 B
TypeScript
23 lines
569 B
TypeScript
import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';
|
|
|
|
import { type AffineInlineEditor } from './inline/index.js';
|
|
|
|
export function insertLinkedNode({
|
|
inlineEditor,
|
|
docId,
|
|
}: {
|
|
inlineEditor: AffineInlineEditor;
|
|
docId: string;
|
|
}) {
|
|
if (!inlineEditor) return;
|
|
const inlineRange = inlineEditor.getInlineRange();
|
|
if (!inlineRange) return;
|
|
inlineEditor.insertText(inlineRange, REFERENCE_NODE, {
|
|
reference: { type: 'LinkedPage', pageId: docId },
|
|
});
|
|
inlineEditor.setInlineRange({
|
|
index: inlineRange.index + 1,
|
|
length: 0,
|
|
});
|
|
}
|