mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
feat(editor): add inline packages (#11048)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';
|
||||
import type { AffineInlineEditor } from '@blocksuite/affine-shared/types';
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user