refactor: image preview plugin (#3457)

This commit is contained in:
Alex Yang
2023-07-29 00:18:28 -07:00
committed by GitHub
parent be3909370e
commit 52809a2783
18 changed files with 129 additions and 45 deletions

View File

@@ -81,6 +81,9 @@ export const createGlobalThis = () => {
TextDecoder: globalThis.TextDecoder,
Request: globalThis.Request,
Error: globalThis.Error,
// bookmark uses these
Blob: globalThis.Blob,
ClipboardItem: globalThis.ClipboardItem,
// fixme: use our own db api
indexedDB: globalThis.indexedDB,

View File

@@ -37,6 +37,7 @@ const builtinPluginUrl = new Set([
'/plugins/bookmark',
'/plugins/copilot',
'/plugins/hello-world',
'/plugins/image-preview',
]);
const logger = new DebugLogger('register-plugins');

View File

@@ -1,11 +1,13 @@
import { BlockHubWrapper } from '@affine/component/block-hub';
import { BlockSuiteEditor } from '@affine/component/block-suite-editor';
import { ImagePreviewModal } from '@affine/component/image-preview-modal';
import { initEmptyPage } from '@affine/env/blocksuite';
import { WorkspaceFlavour } from '@affine/env/workspace';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { ImagePreviewModal } from '@affine/image-preview-plugin/src/component';
import { rootBlockHubAtom } from '@affine/workspace/atom';
import { getOrCreateWorkspace } from '@affine/workspace/manager';
import type { Meta } from '@storybook/react';
import { createPortal } from 'react-dom';
export default {
title: 'Component/ImagePreviewModal',
@@ -52,6 +54,10 @@ export const Default = () => {
}}
>
<BlockSuiteEditor mode="page" page={page} onInit={initEmptyPage} />
{createPortal(
<ImagePreviewModal pageId={page.id} workspace={page.workspace} />,
document.body
)}
</div>
<BlockHubWrapper
style={{

View File

@@ -18,6 +18,9 @@
{
"path": "../../packages/workspace"
},
{
"path": "../../plugins/image-preview"
},
{
"path": "./tsconfig.node.json"
}