mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
refactor(infra): directory structure (#4615)
This commit is contained in:
26
packages/plugins/hello-world/package.json
Normal file
26
packages/plugins/hello-world/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@affine/hello-world-plugin",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"description": "Hello world plugin",
|
||||
"version": "0.10.0-canary.1",
|
||||
"scripts": {
|
||||
"dev": "af dev",
|
||||
"build": "af build"
|
||||
},
|
||||
"affinePlugin": {
|
||||
"release": false,
|
||||
"entry": {
|
||||
"core": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@affine/component": "workspace:*",
|
||||
"@affine/sdk": "workspace:*",
|
||||
"@blocksuite/icons": "2.1.34",
|
||||
"@toeverything/components": "^0.0.45"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine/plugin-cli": "workspace:*"
|
||||
}
|
||||
}
|
||||
26
packages/plugins/hello-world/project.json
Normal file
26
packages/plugins/hello-world/project.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@affine/hello-world-plugin",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"namedInputs": {
|
||||
"default": [
|
||||
"{projectRoot}/**/*",
|
||||
"{workspaceRoot}/tools/plugin-cli/src/**/*",
|
||||
"sharedGlobals"
|
||||
]
|
||||
},
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "nx:run-script",
|
||||
"options": {
|
||||
"script": "build"
|
||||
},
|
||||
"dependsOn": ["^build"],
|
||||
"inputs": ["default"],
|
||||
"outputs": [
|
||||
"{workspaceRoot}/packages/frontend/core/public/plugins/hello-world",
|
||||
"{workspaceRoot}/packages/frontend/electron/dist/plugins/hello-world"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tags": ["plugin"]
|
||||
}
|
||||
18
packages/plugins/hello-world/src/app.tsx
Normal file
18
packages/plugins/hello-world/src/app.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Logo1Icon } from '@blocksuite/icons';
|
||||
import { IconButton } from '@toeverything/components/button';
|
||||
import { Tooltip } from '@toeverything/components/tooltip';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const HeaderItem = () => {
|
||||
return (
|
||||
<Tooltip content="Plugin Enabled">
|
||||
<IconButton
|
||||
onClick={useCallback(() => {
|
||||
console.log('clicked hello world!');
|
||||
}, [])}
|
||||
>
|
||||
<Logo1Icon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
32
packages/plugins/hello-world/src/index.ts
Normal file
32
packages/plugins/hello-world/src/index.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { PluginContext } from '@affine/sdk/entry';
|
||||
import { createElement } from 'react';
|
||||
import { lazy } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
const HeaderItem = lazy(() =>
|
||||
import('./app').then(({ HeaderItem }) => ({ default: HeaderItem }))
|
||||
);
|
||||
|
||||
export const entry = (context: PluginContext) => {
|
||||
console.log('register');
|
||||
console.log('hello, world!');
|
||||
context.register('headerItem', div => {
|
||||
const root = createRoot(div);
|
||||
root.render(createElement(HeaderItem));
|
||||
return () => {
|
||||
root.unmount();
|
||||
};
|
||||
});
|
||||
|
||||
context.register('formatBar', div => {
|
||||
const root = createRoot(div);
|
||||
root.render(createElement(HeaderItem));
|
||||
return () => {
|
||||
root.unmount();
|
||||
};
|
||||
});
|
||||
|
||||
return () => {
|
||||
console.log('unregister');
|
||||
};
|
||||
};
|
||||
17
packages/plugins/hello-world/tsconfig.json
Normal file
17
packages/plugins/hello-world/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"include": ["./src"],
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"outDir": "lib",
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../../common/sdk"
|
||||
},
|
||||
{
|
||||
"path": "../../frontend/component"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user