mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import type { ReferenceInfo } from '@blocksuite/affine-model';
|
||||
import cloneDeep from 'lodash.clonedeep';
|
||||
|
||||
/**
|
||||
* Clones reference info.
|
||||
*/
|
||||
export function cloneReferenceInfo({
|
||||
pageId,
|
||||
params,
|
||||
title,
|
||||
description,
|
||||
}: ReferenceInfo) {
|
||||
const info: ReferenceInfo = { pageId };
|
||||
if (params) info.params = cloneDeep(params);
|
||||
if (title) info.title = title;
|
||||
if (description) info.description = description;
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if it is a link to block or element.
|
||||
*/
|
||||
export function referenceToNode({ params }: ReferenceInfo) {
|
||||
if (!params) return false;
|
||||
if (!params.mode) return false;
|
||||
const { blockIds, elementIds, databaseId, databaseRowId } = params;
|
||||
if (blockIds && blockIds.length > 0) return true;
|
||||
if (elementIds && elementIds.length > 0) return true;
|
||||
if (databaseId || databaseRowId) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones reference info without the aliases.
|
||||
* In `EmbedSyncedDocModel`, the aliases are not needed at the moment.
|
||||
*/
|
||||
export function cloneReferenceInfoWithoutAliases({
|
||||
pageId,
|
||||
params,
|
||||
}: ReferenceInfo) {
|
||||
const info: ReferenceInfo = { pageId };
|
||||
if (params) info.params = cloneDeep(params);
|
||||
return info;
|
||||
}
|
||||
Reference in New Issue
Block a user