mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
205cd7a86d
Closes: BS-2946
21 lines
697 B
TypeScript
21 lines
697 B
TypeScript
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
|
import { StdIdentifier } from '@blocksuite/std';
|
|
import { InlineSpecExtension } from '@blocksuite/std/inline';
|
|
import { html } from 'lit';
|
|
import { z } from 'zod';
|
|
|
|
export const LinkInlineSpecExtension =
|
|
InlineSpecExtension<AffineTextAttributes>('link', provider => {
|
|
const std = provider.get(StdIdentifier);
|
|
return {
|
|
name: 'link',
|
|
schema: z.string().optional().nullable().catch(undefined),
|
|
match: delta => {
|
|
return !!delta.attributes?.link;
|
|
},
|
|
renderer: ({ delta }) => {
|
|
return html`<affine-link .std=${std} .delta=${delta}></affine-link>`;
|
|
},
|
|
};
|
|
});
|