mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-01 22:29:44 +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`
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { EmbedIframeBlockSchema } from '@blocksuite/affine-model';
|
|
import { BlockMarkdownAdapterExtension } from '@blocksuite/affine-shared/adapters';
|
|
|
|
import { createEmbedBlockMarkdownAdapterMatcher } from '../../common/adapters/markdown.js';
|
|
|
|
export const embedIframeBlockMarkdownAdapterMatcher =
|
|
createEmbedBlockMarkdownAdapterMatcher(EmbedIframeBlockSchema.model.flavour, {
|
|
fromBlockSnapshot: {
|
|
enter: (o, context) => {
|
|
const { walkerContext } = context;
|
|
// Parse as link
|
|
if (
|
|
typeof o.node.props.title !== 'string' ||
|
|
typeof o.node.props.url !== 'string'
|
|
) {
|
|
return;
|
|
}
|
|
walkerContext
|
|
.openNode(
|
|
{
|
|
type: 'paragraph',
|
|
children: [],
|
|
},
|
|
'children'
|
|
)
|
|
.openNode(
|
|
{
|
|
type: 'link',
|
|
url: o.node.props.url,
|
|
children: [
|
|
{
|
|
type: 'text',
|
|
value: o.node.props.title,
|
|
},
|
|
],
|
|
},
|
|
'children'
|
|
)
|
|
.closeNode()
|
|
.closeNode();
|
|
},
|
|
},
|
|
});
|
|
|
|
export const EmbedIframeBlockMarkdownAdapterExtension =
|
|
BlockMarkdownAdapterExtension(embedIframeBlockMarkdownAdapterMatcher);
|