mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 05:48:59 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export type EmbedFigmaBlockUrlData = {
|
||||
title: string | null;
|
||||
description: string | null;
|
||||
};
|
||||
|
||||
export const EmbedFigmaStyles: EmbedCardStyle[] = ['figma'] as const;
|
||||
|
||||
export type EmbedFigmaBlockProps = {
|
||||
style: (typeof EmbedFigmaStyles)[number];
|
||||
url: string;
|
||||
caption: string | null;
|
||||
} & EmbedFigmaBlockUrlData;
|
||||
|
||||
export class EmbedFigmaModel extends defineEmbedModel<EmbedFigmaBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-figma': EmbedFigmaModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-figma': EmbedFigmaModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedFigmaBlockProps,
|
||||
EmbedFigmaModel,
|
||||
EmbedFigmaStyles,
|
||||
} from './figma-model.js';
|
||||
|
||||
const defaultEmbedFigmaProps: EmbedFigmaBlockProps = {
|
||||
style: EmbedFigmaStyles[0],
|
||||
url: '',
|
||||
caption: null,
|
||||
|
||||
title: null,
|
||||
description: null,
|
||||
};
|
||||
|
||||
export const EmbedFigmaBlockSchema = createEmbedBlockSchema({
|
||||
name: 'figma',
|
||||
version: 1,
|
||||
toModel: () => new EmbedFigmaModel(),
|
||||
props: (): EmbedFigmaBlockProps => defaultEmbedFigmaProps,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './figma-model.js';
|
||||
export * from './figma-schema.js';
|
||||
@@ -0,0 +1,46 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export type EmbedGithubBlockUrlData = {
|
||||
image: string | null;
|
||||
status: string | null;
|
||||
statusReason: string | null;
|
||||
title: string | null;
|
||||
description: string | null;
|
||||
createdAt: string | null;
|
||||
assignees: string[] | null;
|
||||
};
|
||||
|
||||
export const EmbedGithubStyles: EmbedCardStyle[] = [
|
||||
'vertical',
|
||||
'horizontal',
|
||||
'list',
|
||||
'cube',
|
||||
] as const;
|
||||
|
||||
export type EmbedGithubBlockProps = {
|
||||
style: (typeof EmbedGithubStyles)[number];
|
||||
owner: string;
|
||||
repo: string;
|
||||
githubType: 'issue' | 'pr';
|
||||
githubId: string;
|
||||
url: string;
|
||||
caption: string | null;
|
||||
} & EmbedGithubBlockUrlData;
|
||||
|
||||
export class EmbedGithubModel extends defineEmbedModel<EmbedGithubBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-github': EmbedGithubModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-github': EmbedGithubModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedGithubBlockProps,
|
||||
EmbedGithubModel,
|
||||
EmbedGithubStyles,
|
||||
} from './github-model.js';
|
||||
|
||||
const defaultEmbedGithubProps: EmbedGithubBlockProps = {
|
||||
style: EmbedGithubStyles[1],
|
||||
owner: '',
|
||||
repo: '',
|
||||
githubType: 'issue',
|
||||
githubId: '',
|
||||
url: '',
|
||||
caption: null,
|
||||
|
||||
image: null,
|
||||
status: null,
|
||||
statusReason: null,
|
||||
title: null,
|
||||
description: null,
|
||||
createdAt: null,
|
||||
assignees: null,
|
||||
};
|
||||
|
||||
export const EmbedGithubBlockSchema = createEmbedBlockSchema({
|
||||
name: 'github',
|
||||
version: 1,
|
||||
toModel: () => new EmbedGithubModel(),
|
||||
props: (): EmbedGithubBlockProps => defaultEmbedGithubProps,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './github-model.js';
|
||||
export * from './github-schema.js';
|
||||
@@ -0,0 +1,28 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export const EmbedHtmlStyles: EmbedCardStyle[] = ['html'] as const;
|
||||
|
||||
export type EmbedHtmlBlockProps = {
|
||||
style: (typeof EmbedHtmlStyles)[number];
|
||||
caption: string | null;
|
||||
html?: string;
|
||||
design?: string;
|
||||
};
|
||||
|
||||
export class EmbedHtmlModel extends defineEmbedModel<EmbedHtmlBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-html': EmbedHtmlModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-html': EmbedHtmlModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedHtmlBlockProps,
|
||||
EmbedHtmlModel,
|
||||
EmbedHtmlStyles,
|
||||
} from './html-model.js';
|
||||
|
||||
const defaultEmbedHtmlProps: EmbedHtmlBlockProps = {
|
||||
style: EmbedHtmlStyles[0],
|
||||
caption: null,
|
||||
html: undefined,
|
||||
design: undefined,
|
||||
};
|
||||
|
||||
export const EmbedHtmlBlockSchema = createEmbedBlockSchema({
|
||||
name: 'html',
|
||||
version: 1,
|
||||
toModel: () => new EmbedHtmlModel(),
|
||||
props: (): EmbedHtmlBlockProps => defaultEmbedHtmlProps,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './html-model.js';
|
||||
export * from './html-schema.js';
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './figma/index.js';
|
||||
export * from './github/index.js';
|
||||
export * from './html/index.js';
|
||||
export * from './linked-doc/index.js';
|
||||
export * from './loom/index.js';
|
||||
export * from './synced-doc/index.js';
|
||||
export * from './youtube/index.js';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './linked-doc-model.js';
|
||||
export * from './linked-doc-schema.js';
|
||||
@@ -0,0 +1,33 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { ReferenceInfo } from '../../../consts/doc.js';
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export const EmbedLinkedDocStyles: EmbedCardStyle[] = [
|
||||
'vertical',
|
||||
'horizontal',
|
||||
'list',
|
||||
'cube',
|
||||
'horizontalThin',
|
||||
];
|
||||
|
||||
export type EmbedLinkedDocBlockProps = {
|
||||
style: EmbedCardStyle;
|
||||
caption: string | null;
|
||||
} & ReferenceInfo;
|
||||
|
||||
export class EmbedLinkedDocModel extends defineEmbedModel<EmbedLinkedDocBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-linked-doc': EmbedLinkedDocModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-linked-doc': EmbedLinkedDocModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedLinkedDocBlockProps,
|
||||
EmbedLinkedDocModel,
|
||||
EmbedLinkedDocStyles,
|
||||
} from './linked-doc-model.js';
|
||||
|
||||
const defaultEmbedLinkedDocBlockProps: EmbedLinkedDocBlockProps = {
|
||||
pageId: '',
|
||||
style: EmbedLinkedDocStyles[1],
|
||||
caption: null,
|
||||
// title & description aliases
|
||||
title: undefined,
|
||||
description: undefined,
|
||||
};
|
||||
|
||||
export const EmbedLinkedDocBlockSchema = createEmbedBlockSchema({
|
||||
name: 'linked-doc',
|
||||
version: 1,
|
||||
toModel: () => new EmbedLinkedDocModel(),
|
||||
props: (): EmbedLinkedDocBlockProps => defaultEmbedLinkedDocBlockProps,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './loom-model.js';
|
||||
export * from './loom-schema.js';
|
||||
@@ -0,0 +1,34 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export type EmbedLoomBlockUrlData = {
|
||||
videoId: string | null;
|
||||
image: string | null;
|
||||
title: string | null;
|
||||
description: string | null;
|
||||
};
|
||||
|
||||
export const EmbedLoomStyles: EmbedCardStyle[] = ['video'] as const;
|
||||
|
||||
export type EmbedLoomBlockProps = {
|
||||
style: (typeof EmbedLoomStyles)[number];
|
||||
url: string;
|
||||
caption: string | null;
|
||||
} & EmbedLoomBlockUrlData;
|
||||
|
||||
export class EmbedLoomModel extends defineEmbedModel<EmbedLoomBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-loom': EmbedLoomModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-loom': EmbedLoomModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedLoomBlockProps,
|
||||
EmbedLoomModel,
|
||||
EmbedLoomStyles,
|
||||
} from './loom-model.js';
|
||||
|
||||
const defaultEmbedLoomProps: EmbedLoomBlockProps = {
|
||||
style: EmbedLoomStyles[0],
|
||||
url: '',
|
||||
caption: null,
|
||||
|
||||
image: null,
|
||||
title: null,
|
||||
description: null,
|
||||
videoId: null,
|
||||
};
|
||||
|
||||
export const EmbedLoomBlockSchema = createEmbedBlockSchema({
|
||||
name: 'loom',
|
||||
version: 1,
|
||||
toModel: () => new EmbedLoomModel(),
|
||||
props: (): EmbedLoomBlockProps => defaultEmbedLoomProps,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './synced-doc-model.js';
|
||||
export * from './synced-doc-schema.js';
|
||||
@@ -0,0 +1,28 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { ReferenceInfo } from '../../../consts/doc.js';
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export const EmbedSyncedDocStyles: EmbedCardStyle[] = ['syncedDoc'];
|
||||
|
||||
export type EmbedSyncedDocBlockProps = {
|
||||
style: EmbedCardStyle;
|
||||
caption?: string | null;
|
||||
scale?: number;
|
||||
} & ReferenceInfo;
|
||||
|
||||
export class EmbedSyncedDocModel extends defineEmbedModel<EmbedSyncedDocBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-synced-doc': EmbedSyncedDocModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-synced-doc': EmbedSyncedDocModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedSyncedDocBlockProps,
|
||||
EmbedSyncedDocModel,
|
||||
EmbedSyncedDocStyles,
|
||||
} from './synced-doc-model.js';
|
||||
|
||||
export const defaultEmbedSyncedDocBlockProps: EmbedSyncedDocBlockProps = {
|
||||
pageId: '',
|
||||
style: EmbedSyncedDocStyles[0],
|
||||
caption: undefined,
|
||||
scale: undefined,
|
||||
// title & description aliases
|
||||
title: undefined,
|
||||
description: undefined,
|
||||
};
|
||||
|
||||
export const EmbedSyncedDocBlockSchema = createEmbedBlockSchema({
|
||||
name: 'synced-doc',
|
||||
version: 1,
|
||||
toModel: () => new EmbedSyncedDocModel(),
|
||||
props: (): EmbedSyncedDocBlockProps => defaultEmbedSyncedDocBlockProps,
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './youtube-model.js';
|
||||
export * from './youtube-schema.js';
|
||||
@@ -0,0 +1,37 @@
|
||||
import { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import type { EmbedCardStyle } from '../../../utils/index.js';
|
||||
import { defineEmbedModel } from '../../../utils/index.js';
|
||||
|
||||
export type EmbedYoutubeBlockUrlData = {
|
||||
videoId: string | null;
|
||||
image: string | null;
|
||||
title: string | null;
|
||||
description: string | null;
|
||||
creator: string | null;
|
||||
creatorUrl: string | null;
|
||||
creatorImage: string | null;
|
||||
};
|
||||
|
||||
export const EmbedYoutubeStyles: EmbedCardStyle[] = ['video'] as const;
|
||||
|
||||
export type EmbedYoutubeBlockProps = {
|
||||
style: (typeof EmbedYoutubeStyles)[number];
|
||||
url: string;
|
||||
caption: string | null;
|
||||
} & EmbedYoutubeBlockUrlData;
|
||||
|
||||
export class EmbedYoutubeModel extends defineEmbedModel<EmbedYoutubeBlockProps>(
|
||||
BlockModel
|
||||
) {}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface EdgelessBlockModelMap {
|
||||
'affine:embed-youtube': EmbedYoutubeModel;
|
||||
}
|
||||
interface BlockModels {
|
||||
'affine:embed-youtube': EmbedYoutubeModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createEmbedBlockSchema } from '../../../utils/index.js';
|
||||
import {
|
||||
type EmbedYoutubeBlockProps,
|
||||
EmbedYoutubeModel,
|
||||
EmbedYoutubeStyles,
|
||||
} from './youtube-model.js';
|
||||
|
||||
const defaultEmbedYoutubeProps: EmbedYoutubeBlockProps = {
|
||||
style: EmbedYoutubeStyles[0],
|
||||
url: '',
|
||||
caption: null,
|
||||
|
||||
image: null,
|
||||
title: null,
|
||||
description: null,
|
||||
creator: null,
|
||||
creatorUrl: null,
|
||||
creatorImage: null,
|
||||
videoId: null,
|
||||
};
|
||||
|
||||
export const EmbedYoutubeBlockSchema = createEmbedBlockSchema({
|
||||
name: 'youtube',
|
||||
version: 1,
|
||||
toModel: () => new EmbedYoutubeModel(),
|
||||
props: (): EmbedYoutubeBlockProps => defaultEmbedYoutubeProps,
|
||||
});
|
||||
Reference in New Issue
Block a user