mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
feat(editor): add embed iframe provider excalidraw (#10997)
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
import { EmbedIframeConfigExtension } from '../../extension/embed-iframe-config';
|
||||||
|
import {
|
||||||
|
type EmbedIframeUrlValidationOptions,
|
||||||
|
validateEmbedIframeUrl,
|
||||||
|
} from '../../utils';
|
||||||
|
|
||||||
|
const EXCALIDRAW_DEFAULT_WIDTH_IN_SURFACE = 640;
|
||||||
|
const EXCALIDRAW_DEFAULT_HEIGHT_IN_SURFACE = 480;
|
||||||
|
const EXCALIDRAW_DEFAULT_HEIGHT_IN_NOTE = 480;
|
||||||
|
const EXCALIDRAW_DEFAULT_WIDTH_PERCENT = 100;
|
||||||
|
|
||||||
|
const excalidrawUrlValidationOptions: EmbedIframeUrlValidationOptions = {
|
||||||
|
protocols: ['https:'],
|
||||||
|
hostnames: ['excalidraw.com'],
|
||||||
|
};
|
||||||
|
|
||||||
|
const excalidrawConfig = {
|
||||||
|
name: 'excalidraw',
|
||||||
|
match: (url: string) =>
|
||||||
|
validateEmbedIframeUrl(url, excalidrawUrlValidationOptions),
|
||||||
|
buildOEmbedUrl: (url: string) => {
|
||||||
|
const match = validateEmbedIframeUrl(url, excalidrawUrlValidationOptions);
|
||||||
|
if (!match) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
},
|
||||||
|
useOEmbedUrlDirectly: true,
|
||||||
|
options: {
|
||||||
|
widthInSurface: EXCALIDRAW_DEFAULT_WIDTH_IN_SURFACE,
|
||||||
|
heightInSurface: EXCALIDRAW_DEFAULT_HEIGHT_IN_SURFACE,
|
||||||
|
heightInNote: EXCALIDRAW_DEFAULT_HEIGHT_IN_NOTE,
|
||||||
|
widthPercent: EXCALIDRAW_DEFAULT_WIDTH_PERCENT,
|
||||||
|
allow: 'clipboard-read; clipboard-write',
|
||||||
|
style: 'border: 0; border-radius: 8px;',
|
||||||
|
allowFullscreen: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ExcalidrawEmbedConfig =
|
||||||
|
EmbedIframeConfigExtension(excalidrawConfig);
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ExcalidrawEmbedConfig } from './excalidraw';
|
||||||
import { GoogleDriveEmbedConfig } from './google-drive';
|
import { GoogleDriveEmbedConfig } from './google-drive';
|
||||||
import { MiroEmbedConfig } from './miro';
|
import { MiroEmbedConfig } from './miro';
|
||||||
import { SpotifyEmbedConfig } from './spotify';
|
import { SpotifyEmbedConfig } from './spotify';
|
||||||
@@ -6,4 +7,5 @@ export const EmbedIframeConfigExtensions = [
|
|||||||
SpotifyEmbedConfig,
|
SpotifyEmbedConfig,
|
||||||
GoogleDriveEmbedConfig,
|
GoogleDriveEmbedConfig,
|
||||||
MiroEmbedConfig,
|
MiroEmbedConfig,
|
||||||
|
ExcalidrawEmbedConfig,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const miroConfig = {
|
|||||||
heightInSurface: MIRO_DEFAULT_HEIGHT_IN_SURFACE,
|
heightInSurface: MIRO_DEFAULT_HEIGHT_IN_SURFACE,
|
||||||
heightInNote: MIRO_DEFAULT_HEIGHT_IN_NOTE,
|
heightInNote: MIRO_DEFAULT_HEIGHT_IN_NOTE,
|
||||||
widthPercent: MIRO_DEFAULT_WIDTH_PERCENT,
|
widthPercent: MIRO_DEFAULT_WIDTH_PERCENT,
|
||||||
allow: 'fullscreen; clipboard-read; clipboard-write',
|
allow: 'clipboard-read; clipboard-write',
|
||||||
style: 'border: 0; border-radius: 8px;',
|
style: 'border: 0; border-radius: 8px;',
|
||||||
allowFullscreen: true,
|
allowFullscreen: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user