mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(core): avoid side effects (#8245)
This commit is contained in:
@@ -1,6 +1,3 @@
|
|||||||
import '@affine/component/theme/global.css';
|
|
||||||
import '@affine/component/theme/theme.css';
|
|
||||||
|
|
||||||
import { AffineContext } from '@affine/component/context';
|
import { AffineContext } from '@affine/component/context';
|
||||||
import { GlobalLoading } from '@affine/component/global-loading';
|
import { GlobalLoading } from '@affine/component/global-loading';
|
||||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import './setup';
|
import './setup';
|
||||||
import './global.css';
|
|
||||||
|
|
||||||
import { appConfigProxy } from '@affine/core/components/hooks/use-app-config-storage';
|
import { appConfigProxy } from '@affine/core/components/hooks/use-app-config-storage';
|
||||||
import { apis, appInfo, events } from '@affine/electron-api';
|
import { apis, appInfo, events } from '@affine/electron-api';
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { setupBlocksuite, setupElectron } from '@affine/core/bootstrap';
|
import '@affine/component/theme';
|
||||||
|
import './global.css';
|
||||||
|
|
||||||
|
import { setupElectron } from '@affine/core/bootstrap';
|
||||||
|
|
||||||
setupElectron();
|
setupElectron();
|
||||||
setupBlocksuite();
|
|
||||||
|
|||||||
42
packages/frontend/apps/electron/renderer/shell/app.tsx
Normal file
42
packages/frontend/apps/electron/renderer/shell/app.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { ThemeProvider } from '@affine/component/theme-provider';
|
||||||
|
import { ShellAppFallback } from '@affine/core/components/affine/app-container';
|
||||||
|
import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper';
|
||||||
|
import {
|
||||||
|
AppTabsHeader,
|
||||||
|
configureAppTabsHeaderModule,
|
||||||
|
} from '@affine/core/modules/app-tabs-header';
|
||||||
|
import { configureElectronStateStorageImpls } from '@affine/core/modules/storage';
|
||||||
|
import { SplitViewFallback } from '@affine/core/modules/workbench/view/split-view/split-view';
|
||||||
|
import {
|
||||||
|
configureGlobalStorageModule,
|
||||||
|
Framework,
|
||||||
|
FrameworkRoot,
|
||||||
|
} from '@toeverything/infra';
|
||||||
|
|
||||||
|
import * as styles from './app.css';
|
||||||
|
|
||||||
|
const framework = new Framework();
|
||||||
|
configureGlobalStorageModule(framework);
|
||||||
|
configureElectronStateStorageImpls(framework);
|
||||||
|
configureAppTabsHeaderModule(framework);
|
||||||
|
const frameworkProvider = framework.provider();
|
||||||
|
|
||||||
|
export function App() {
|
||||||
|
const { appSettings } = useAppSettingHelper();
|
||||||
|
const translucent =
|
||||||
|
BUILD_CONFIG.isElectron &&
|
||||||
|
environment.isMacOs &&
|
||||||
|
appSettings.enableBlurBackground;
|
||||||
|
return (
|
||||||
|
<FrameworkRoot framework={frameworkProvider}>
|
||||||
|
<ThemeProvider>
|
||||||
|
<div className={styles.root} data-translucent={translucent}>
|
||||||
|
<AppTabsHeader mode="shell" className={styles.appTabsHeader} />
|
||||||
|
<ShellAppFallback className={styles.fallbackRoot}>
|
||||||
|
<SplitViewFallback className={styles.splitViewFallback} />
|
||||||
|
</ShellAppFallback>
|
||||||
|
</div>
|
||||||
|
</ThemeProvider>
|
||||||
|
</FrameworkRoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,34 +1,17 @@
|
|||||||
import '@affine/component/theme/global.css';
|
|
||||||
import '@affine/component/theme/theme.css';
|
|
||||||
import '../global.css';
|
|
||||||
import './setup';
|
import './setup';
|
||||||
|
|
||||||
import { ThemeProvider } from '@affine/component/theme-provider';
|
|
||||||
import { configureAppTabsHeaderModule } from '@affine/core/modules/app-tabs-header';
|
|
||||||
import { configureElectronStateStorageImpls } from '@affine/core/modules/storage';
|
|
||||||
import { apis, events } from '@affine/electron-api';
|
import { apis, events } from '@affine/electron-api';
|
||||||
import { createI18n, setUpLanguage } from '@affine/i18n';
|
import { createI18n, setUpLanguage } from '@affine/i18n';
|
||||||
import {
|
|
||||||
configureGlobalStorageModule,
|
|
||||||
Framework,
|
|
||||||
FrameworkRoot,
|
|
||||||
} from '@toeverything/infra';
|
|
||||||
import { StrictMode } from 'react';
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
|
|
||||||
import { ShellRoot } from './shell';
|
import { App } from './app';
|
||||||
|
|
||||||
const framework = new Framework();
|
function loadLanguage() {
|
||||||
configureGlobalStorageModule(framework);
|
|
||||||
configureElectronStateStorageImpls(framework);
|
|
||||||
configureAppTabsHeaderModule(framework);
|
|
||||||
const frameworkProvider = framework.provider();
|
|
||||||
|
|
||||||
async function loadLanguage() {
|
|
||||||
const i18n = createI18n();
|
const i18n = createI18n();
|
||||||
document.documentElement.lang = i18n.language;
|
document.documentElement.lang = i18n.language;
|
||||||
|
|
||||||
await setUpLanguage(i18n);
|
setUpLanguage(i18n).catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -48,7 +31,7 @@ async function main() {
|
|||||||
events?.ui.onFullScreen(handleFullscreen);
|
events?.ui.onFullScreen(handleFullscreen);
|
||||||
events?.ui.onTabShellViewActiveChange(handleActive);
|
events?.ui.onTabShellViewActiveChange(handleActive);
|
||||||
|
|
||||||
await loadLanguage();
|
loadLanguage();
|
||||||
mountApp();
|
mountApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,11 +42,7 @@ function mountApp() {
|
|||||||
}
|
}
|
||||||
createRoot(root).render(
|
createRoot(root).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<FrameworkRoot framework={frameworkProvider}>
|
<App />
|
||||||
<ThemeProvider>
|
|
||||||
<ShellRoot />
|
|
||||||
</ThemeProvider>
|
|
||||||
</FrameworkRoot>
|
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import '@affine/component/theme';
|
||||||
|
import '../global.css';
|
||||||
|
|
||||||
import { setupElectron } from '@affine/core/bootstrap';
|
import { setupElectron } from '@affine/core/bootstrap';
|
||||||
|
|
||||||
setupElectron();
|
setupElectron();
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
import { ShellAppFallback } from '@affine/core/components/affine/app-container';
|
|
||||||
import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper';
|
|
||||||
import { AppTabsHeader } from '@affine/core/modules/app-tabs-header';
|
|
||||||
import { SplitViewFallback } from '@affine/core/modules/workbench/view/split-view/split-view';
|
|
||||||
|
|
||||||
import * as styles from './shell.css';
|
|
||||||
|
|
||||||
export function ShellRoot() {
|
|
||||||
const { appSettings } = useAppSettingHelper();
|
|
||||||
const translucent =
|
|
||||||
BUILD_CONFIG.isElectron &&
|
|
||||||
environment.isMacOs &&
|
|
||||||
appSettings.enableBlurBackground;
|
|
||||||
return (
|
|
||||||
<div className={styles.root} data-translucent={translucent}>
|
|
||||||
<AppTabsHeader mode="shell" className={styles.appTabsHeader} />
|
|
||||||
<ShellAppFallback className={styles.fallbackRoot}>
|
|
||||||
<SplitViewFallback className={styles.splitViewFallback} />
|
|
||||||
</ShellAppFallback>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
import '@affine/component/theme/global.css';
|
|
||||||
import '@affine/component/theme/theme.css';
|
|
||||||
import '@affine/core/mobile/styles/mobile.css';
|
|
||||||
|
|
||||||
import { AffineContext } from '@affine/component/context';
|
import { AffineContext } from '@affine/component/context';
|
||||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||||
import { Telemetry } from '@affine/core/components/telemetry';
|
import { Telemetry } from '@affine/core/components/telemetry';
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { setupBlocksuite, setupBrowser } from '@affine/core/bootstrap';
|
import '@affine/component/theme';
|
||||||
|
import '@affine/core/mobile/styles/mobile.css';
|
||||||
|
|
||||||
|
import { setupBrowser } from '@affine/core/bootstrap';
|
||||||
|
|
||||||
await setupBrowser();
|
await setupBrowser();
|
||||||
setupBlocksuite();
|
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import '@affine/component/theme/global.css';
|
|
||||||
import '@affine/component/theme/theme.css';
|
|
||||||
|
|
||||||
import { AffineContext } from '@affine/component/context';
|
import { AffineContext } from '@affine/component/context';
|
||||||
import { GlobalLoading } from '@affine/component/global-loading';
|
import { GlobalLoading } from '@affine/component/global-loading';
|
||||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { setupBlocksuite, setupBrowser } from '@affine/core/bootstrap';
|
import '@affine/component/theme';
|
||||||
|
|
||||||
|
import { setupBrowser } from '@affine/core/bootstrap';
|
||||||
|
|
||||||
await setupBrowser();
|
await setupBrowser();
|
||||||
setupBlocksuite();
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
"./theme/*": "./src/theme/*",
|
"./theme": "./src/theme/index.ts",
|
||||||
"./ui/*": "./src/ui/*/index.ts",
|
"./ui/*": "./src/ui/*/index.ts",
|
||||||
"./*": "./src/components/*/index.tsx"
|
"./*": "./src/components/*/index.tsx"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
@import './fonts.css';
|
|
||||||
@import '@toeverything/theme/style.css';
|
|
||||||
|
|
||||||
* {
|
* {
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
|
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
|
||||||
|
|||||||
4
packages/frontend/component/src/theme/index.ts
Normal file
4
packages/frontend/component/src/theme/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import '@toeverything/theme/style.css';
|
||||||
|
import './fonts.css';
|
||||||
|
import './global.css';
|
||||||
|
import './theme.css';
|
||||||
@@ -6,9 +6,3 @@ globalStyle('body', {
|
|||||||
fontFamily: cssVar('fontFamily'),
|
fontFamily: cssVar('fontFamily'),
|
||||||
fontSize: cssVar('fontBase'),
|
fontSize: cssVar('fontBase'),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
globalStyle('.undefined', {
|
|
||||||
border: '5px solid red !important',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { createLitPortal, HoverController } from '@blocksuite/blocks';
|
|||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import { flip, offset } from '@floating-ui/dom';
|
import { flip, offset } from '@floating-ui/dom';
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property, query } from 'lit/decorators.js';
|
import { property, query } from 'lit/decorators.js';
|
||||||
import { ref } from 'lit/directives/ref.js';
|
import { ref } from 'lit/directives/ref.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
@@ -38,7 +38,6 @@ export type AskAIButtonOptions = {
|
|||||||
panelWidth?: number;
|
panelWidth?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement('ask-ai-button')
|
|
||||||
export class AskAIButton extends WithDisposable(LitElement) {
|
export class AskAIButton extends WithDisposable(LitElement) {
|
||||||
get _edgeless() {
|
get _edgeless() {
|
||||||
const rootService = getRootService(this.host);
|
const rootService = getRootService(this.host);
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ import {
|
|||||||
scrollbarStyle,
|
scrollbarStyle,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { getRootService } from '../../utils/selection-utils';
|
import { getRootService } from '../../utils/selection-utils';
|
||||||
|
|
||||||
@customElement('ask-ai-panel')
|
|
||||||
export class AskAIPanel extends WithDisposable(LitElement) {
|
export class AskAIPanel extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import type {
|
|||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
import { type ImageSelection, NotificationProvider } from '@blocksuite/blocks';
|
import { type ImageSelection, NotificationProvider } from '@blocksuite/blocks';
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import { insertBelow } from '../../utils/editor-actions';
|
import { insertBelow } from '../../utils/editor-actions';
|
||||||
import type { ChatAction } from '../chat-actions-handle';
|
import type { ChatAction } from '../chat-actions-handle';
|
||||||
|
|
||||||
@customElement('chat-action-list')
|
|
||||||
export class ChatActionList extends LitElement {
|
export class ChatActionList extends LitElement {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.actions-container {
|
.actions-container {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { noop } from '@blocksuite/global/utils';
|
import { noop } from '@blocksuite/global/utils';
|
||||||
import { css, html, LitElement, nothing, type PropertyValues } from 'lit';
|
import { css, html, LitElement, nothing, type PropertyValues } from 'lit';
|
||||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import { type ChatAction } from '../../_common/chat-actions-handle';
|
import { type ChatAction } from '../../_common/chat-actions-handle';
|
||||||
@@ -20,7 +20,6 @@ import { copyText } from '../../utils/editor-actions';
|
|||||||
|
|
||||||
noop(Tooltip);
|
noop(Tooltip);
|
||||||
|
|
||||||
@customElement('chat-copy-more')
|
|
||||||
export class ChatCopyMore extends WithDisposable(LitElement) {
|
export class ChatCopyMore extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.copy-more {
|
.copy-more {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { WithDisposable } from '@blocksuite/block-std';
|
import { WithDisposable } from '@blocksuite/block-std';
|
||||||
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
||||||
import { customElement, property, state } from 'lit/decorators.js';
|
import { property, state } from 'lit/decorators.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
@@ -59,7 +59,6 @@ const icons: Record<string, TemplateResult<1>> = {
|
|||||||
'Convert to sticker': AIImageIcon,
|
'Convert to sticker': AIImageIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement('action-wrapper')
|
|
||||||
export class ActionWrapper extends WithDisposable(LitElement) {
|
export class ActionWrapper extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.action-name {
|
.action-name {
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ import './action-wrapper';
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
||||||
import { html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { createTextRenderer } from '../../messages/text';
|
import { createTextRenderer } from '../../messages/text';
|
||||||
import { renderImages } from '../components/images';
|
import { renderImages } from '../components/images';
|
||||||
@customElement('chat-text')
|
|
||||||
export class ChatText extends WithDisposable(ShadowlessElement) {
|
export class ChatText extends WithDisposable(ShadowlessElement) {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor host!: EditorHost;
|
accessor host!: EditorHost;
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ import './action-wrapper';
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
||||||
import { html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
import { renderImages } from '../components/images';
|
import { renderImages } from '../components/images';
|
||||||
|
|
||||||
@customElement('action-image-to-text')
|
|
||||||
export class ActionImageToText extends WithDisposable(ShadowlessElement) {
|
export class ActionImageToText extends WithDisposable(ShadowlessElement) {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor item!: ChatAction;
|
accessor item!: ChatAction;
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ import './action-wrapper';
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
||||||
import { html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
import { renderImages } from '../components/images';
|
import { renderImages } from '../components/images';
|
||||||
|
|
||||||
@customElement('action-image')
|
|
||||||
export class ActionImage extends WithDisposable(ShadowlessElement) {
|
export class ActionImage extends WithDisposable(ShadowlessElement) {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor item!: ChatAction;
|
accessor item!: ChatAction;
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ import './action-wrapper';
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { createIframeRenderer } from '../../messages/wrapper';
|
import { createIframeRenderer } from '../../messages/wrapper';
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
|
|
||||||
@customElement('action-make-real')
|
|
||||||
export class ActionMakeReal extends WithDisposable(ShadowlessElement) {
|
export class ActionMakeReal extends WithDisposable(ShadowlessElement) {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor item!: ChatAction;
|
accessor item!: ChatAction;
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
|||||||
import { MiniMindmapPreview } from '@blocksuite/blocks';
|
import { MiniMindmapPreview } from '@blocksuite/blocks';
|
||||||
import { noop } from '@blocksuite/global/utils';
|
import { noop } from '@blocksuite/global/utils';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
|
|
||||||
noop(MiniMindmapPreview);
|
noop(MiniMindmapPreview);
|
||||||
|
|
||||||
@customElement('action-mindmap')
|
|
||||||
export class ActionMindmap extends WithDisposable(ShadowlessElement) {
|
export class ActionMindmap extends WithDisposable(ShadowlessElement) {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor item!: ChatAction;
|
accessor item!: ChatAction;
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ import '../../messages/slides-renderer';
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
|
||||||
import { html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
|
|
||||||
@customElement('action-slides')
|
|
||||||
export class ActionSlides extends WithDisposable(ShadowlessElement) {
|
export class ActionSlides extends WithDisposable(ShadowlessElement) {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor item!: ChatAction;
|
accessor item!: ChatAction;
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ import './action-wrapper';
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import { WithDisposable } from '@blocksuite/block-std';
|
import { WithDisposable } from '@blocksuite/block-std';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { createTextRenderer } from '../../messages/text';
|
import { createTextRenderer } from '../../messages/text';
|
||||||
import type { ChatAction } from '../chat-context';
|
import type { ChatAction } from '../chat-context';
|
||||||
|
|
||||||
@customElement('action-text')
|
|
||||||
export class ActionText extends WithDisposable(LitElement) {
|
export class ActionText extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.original-text {
|
.original-text {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { WithDisposable } from '@blocksuite/block-std';
|
import { WithDisposable } from '@blocksuite/block-std';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { AIStarIconWithAnimation } from '../_common/icons';
|
import { AIStarIconWithAnimation } from '../_common/icons';
|
||||||
|
|
||||||
@customElement('ai-loading')
|
|
||||||
export class AILoading extends WithDisposable(LitElement) {
|
export class AILoading extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
type PropertyValues,
|
type PropertyValues,
|
||||||
type TemplateResult,
|
type TemplateResult,
|
||||||
} from 'lit';
|
} from 'lit';
|
||||||
import { customElement, property, state } from 'lit/decorators.js';
|
import { property, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
@@ -94,7 +94,6 @@ type Card = CardText | CardImage | CardBlock;
|
|||||||
|
|
||||||
const MAX_CARDS = 3;
|
const MAX_CARDS = 3;
|
||||||
|
|
||||||
@customElement('chat-cards')
|
|
||||||
export class ChatCards extends WithDisposable(LitElement) {
|
export class ChatCards extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { WithDisposable } from '@blocksuite/block-std';
|
|||||||
import { type AIError, openFileOrFiles } from '@blocksuite/blocks';
|
import { type AIError, openFileOrFiles } from '@blocksuite/blocks';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +25,6 @@ function getFirstTwoLines(text: string) {
|
|||||||
return lines.slice(0, 2);
|
return lines.slice(0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement('chat-panel-input')
|
|
||||||
export class ChatPanelInput extends WithDisposable(LitElement) {
|
export class ChatPanelInput extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.chat-panel-input {
|
.chat-panel-input {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
UnauthorizedError,
|
UnauthorizedError,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { css, html, nothing, type PropertyValues } from 'lit';
|
import { css, html, nothing, type PropertyValues } from 'lit';
|
||||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
@@ -38,7 +38,6 @@ import type { ChatContextValue, ChatItem, ChatMessage } from './chat-context';
|
|||||||
import { HISTORY_IMAGE_ACTIONS } from './const';
|
import { HISTORY_IMAGE_ACTIONS } from './const';
|
||||||
import { AIPreloadConfig } from './preload-config';
|
import { AIPreloadConfig } from './preload-config';
|
||||||
|
|
||||||
@customElement('chat-panel-messages')
|
|
||||||
export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
chat-panel-messages {
|
chat-panel-messages {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { NotificationProvider } from '@blocksuite/blocks';
|
|||||||
import { debounce } from '@blocksuite/global/utils';
|
import { debounce } from '@blocksuite/global/utils';
|
||||||
import type { Doc } from '@blocksuite/store';
|
import type { Doc } from '@blocksuite/store';
|
||||||
import { css, html, type PropertyValues } from 'lit';
|
import { css, html, type PropertyValues } from 'lit';
|
||||||
import { customElement, property, state } from 'lit/decorators.js';
|
import { property, state } from 'lit/decorators.js';
|
||||||
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
|
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
|
||||||
|
|
||||||
import { AIHelpIcon, SmallHintIcon } from '../_common/icons';
|
import { AIHelpIcon, SmallHintIcon } from '../_common/icons';
|
||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
import type { ChatAction, ChatContextValue, ChatItem } from './chat-context';
|
import type { ChatAction, ChatContextValue, ChatItem } from './chat-context';
|
||||||
import type { ChatPanelMessages } from './chat-panel-messages';
|
import type { ChatPanelMessages } from './chat-panel-messages';
|
||||||
|
|
||||||
@customElement('chat-panel')
|
|
||||||
export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
chat-panel {
|
chat-panel {
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ export * from './entries/index';
|
|||||||
export * from './messages/index';
|
export * from './messages/index';
|
||||||
export { AIChatBlockPeekViewTemplate } from './peek-view/chat-block-peek-view';
|
export { AIChatBlockPeekViewTemplate } from './peek-view/chat-block-peek-view';
|
||||||
export * from './provider';
|
export * from './provider';
|
||||||
|
export * from './setup';
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import {
|
|||||||
UnauthorizedError,
|
UnauthorizedError,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { html, LitElement, nothing, type TemplateResult } from 'lit';
|
import { html, LitElement, nothing, type TemplateResult } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { ErrorTipIcon } from '../_common/icons';
|
import { ErrorTipIcon } from '../_common/icons';
|
||||||
import { AIProvider } from '../provider';
|
import { AIProvider } from '../provider';
|
||||||
|
|
||||||
@customElement('ai-error-wrapper')
|
export class AIErrorWrapper extends WithDisposable(LitElement) {
|
||||||
class AIErrorWrapper extends WithDisposable(LitElement) {
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor text!: TemplateResult<1>;
|
accessor text!: TemplateResult<1>;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { AffineSchemas } from '@blocksuite/blocks/schemas';
|
|||||||
import type { Doc } from '@blocksuite/store';
|
import type { Doc } from '@blocksuite/store';
|
||||||
import { DocCollection, Schema } from '@blocksuite/store';
|
import { DocCollection, Schema } from '@blocksuite/store';
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property, query } from 'lit/decorators.js';
|
import { property, query } from 'lit/decorators.js';
|
||||||
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
|
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
|
||||||
|
|
||||||
import { getAIPanel } from '../ai-panel';
|
import { getAIPanel } from '../ai-panel';
|
||||||
@@ -48,7 +48,6 @@ export const createSlidesRenderer: (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement('ai-slides-renderer')
|
|
||||||
export class AISlidesRenderer extends WithDisposable(LitElement) {
|
export class AISlidesRenderer extends WithDisposable(LitElement) {
|
||||||
static override styles = css``;
|
static override styles = css``;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { BlockViewType, type Doc, type Query } from '@blocksuite/store';
|
import { BlockViewType, type Doc, type Query } from '@blocksuite/store';
|
||||||
import { css, html, LitElement, type PropertyValues } from 'lit';
|
import { css, html, LitElement, type PropertyValues } from 'lit';
|
||||||
import { customElement, property, query } from 'lit/decorators.js';
|
import { property, query } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { keyed } from 'lit/directives/keyed.js';
|
import { keyed } from 'lit/directives/keyed.js';
|
||||||
|
|
||||||
@@ -75,7 +75,6 @@ type TextRendererOptions = {
|
|||||||
customHeading?: boolean;
|
customHeading?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement('ai-answer-text')
|
|
||||||
export class AIAnswerText extends WithDisposable(LitElement) {
|
export class AIAnswerText extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
.ai-answer-text-editor.affine-page-viewport {
|
.ai-answer-text-editor.affine-page-viewport {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import type { AffineAIPanelWidgetConfig } from '@blocksuite/blocks';
|
import type { AffineAIPanelWidgetConfig } from '@blocksuite/blocks';
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { getAIPanel } from '../ai-panel';
|
import { getAIPanel } from '../ai-panel';
|
||||||
import { preprocessHtml } from '../utils/html';
|
import { preprocessHtml } from '../utils/html';
|
||||||
@@ -10,7 +10,6 @@ type AIAnswerWrapperOptions = {
|
|||||||
height: number;
|
height: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement('ai-answer-wrapper')
|
|
||||||
export class AIAnswerWrapper extends LitElement {
|
export class AIAnswerWrapper extends LitElement {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { EditorHost } from '@blocksuite/block-std';
|
|||||||
import { type AIError, openFileOrFiles } from '@blocksuite/blocks';
|
import { type AIError, openFileOrFiles } from '@blocksuite/blocks';
|
||||||
import { type ChatMessage } from '@blocksuite/presets';
|
import { type ChatMessage } from '@blocksuite/presets';
|
||||||
import { css, html, LitElement, nothing } from 'lit';
|
import { css, html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
@@ -20,7 +20,6 @@ import type { ChatContext } from './types';
|
|||||||
|
|
||||||
const MaximumImageCount = 8;
|
const MaximumImageCount = 8;
|
||||||
|
|
||||||
@customElement('chat-block-input')
|
|
||||||
export class ChatBlockInput extends LitElement {
|
export class ChatBlockInput extends LitElement {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
ChatMessagesSchema,
|
ChatMessagesSchema,
|
||||||
} from '@blocksuite/presets';
|
} from '@blocksuite/presets';
|
||||||
import { html, LitElement, nothing } from 'lit';
|
import { html, LitElement, nothing } from 'lit';
|
||||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
@@ -35,7 +35,6 @@ import { PeekViewStyles } from './styles';
|
|||||||
import type { ChatContext } from './types';
|
import type { ChatContext } from './types';
|
||||||
import { calcChildBound } from './utils';
|
import { calcChildBound } from './utils';
|
||||||
|
|
||||||
@customElement('ai-chat-block-peek-view')
|
|
||||||
export class AIChatBlockPeekView extends LitElement {
|
export class AIChatBlockPeekView extends LitElement {
|
||||||
static override styles = PeekViewStyles;
|
static override styles = PeekViewStyles;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { i18nTime } from '@affine/i18n';
|
import { i18nTime } from '@affine/i18n';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
@customElement('date-time')
|
|
||||||
export class DateTime extends LitElement {
|
export class DateTime extends LitElement {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
50
packages/frontend/core/src/blocksuite/presets/ai/setup.ts
Normal file
50
packages/frontend/core/src/blocksuite/presets/ai/setup.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { AskAIButton } from './_common/components/ask-ai-button';
|
||||||
|
import { AskAIPanel } from './_common/components/ask-ai-panel';
|
||||||
|
import { ChatActionList } from './_common/components/chat-action-list';
|
||||||
|
import { ChatCopyMore } from './_common/components/copy-more';
|
||||||
|
import { ChatPanel } from './chat-panel';
|
||||||
|
import { ActionWrapper } from './chat-panel/actions/action-wrapper';
|
||||||
|
import { ChatText } from './chat-panel/actions/chat-text';
|
||||||
|
import { ActionImage } from './chat-panel/actions/image';
|
||||||
|
import { ActionImageToText } from './chat-panel/actions/image-to-text';
|
||||||
|
import { ActionMakeReal } from './chat-panel/actions/make-real';
|
||||||
|
import { ActionMindmap } from './chat-panel/actions/mindmap';
|
||||||
|
import { ActionSlides } from './chat-panel/actions/slides';
|
||||||
|
import { ActionText } from './chat-panel/actions/text';
|
||||||
|
import { AILoading } from './chat-panel/ai-loading';
|
||||||
|
import { ChatCards } from './chat-panel/chat-cards';
|
||||||
|
import { ChatPanelInput } from './chat-panel/chat-panel-input';
|
||||||
|
import { ChatPanelMessages } from './chat-panel/chat-panel-messages';
|
||||||
|
import { AIAnswerText, AIAnswerWrapper } from './messages';
|
||||||
|
import { AIErrorWrapper } from './messages/error';
|
||||||
|
import { AISlidesRenderer } from './messages/slides-renderer';
|
||||||
|
import { ChatBlockInput } from './peek-view/chat-block-input';
|
||||||
|
import { AIChatBlockPeekView } from './peek-view/chat-block-peek-view';
|
||||||
|
import { DateTime } from './peek-view/date-time';
|
||||||
|
|
||||||
|
export function registerAICustomComponents() {
|
||||||
|
customElements.define('ask-ai-button', AskAIButton);
|
||||||
|
customElements.define('ask-ai-panel', AskAIPanel);
|
||||||
|
customElements.define('chat-action-list', ChatActionList);
|
||||||
|
customElements.define('chat-copy-more', ChatCopyMore);
|
||||||
|
customElements.define('action-wrapper', ActionWrapper);
|
||||||
|
customElements.define('chat-text', ChatText);
|
||||||
|
customElements.define('action-image-to-text', ActionImageToText);
|
||||||
|
customElements.define('action-image', ActionImage);
|
||||||
|
customElements.define('action-make-real', ActionMakeReal);
|
||||||
|
customElements.define('action-mindmap', ActionMindmap);
|
||||||
|
customElements.define('action-slides', ActionSlides);
|
||||||
|
customElements.define('action-text', ActionText);
|
||||||
|
customElements.define('ai-loading', AILoading);
|
||||||
|
customElements.define('chat-cards', ChatCards);
|
||||||
|
customElements.define('chat-panel-input', ChatPanelInput);
|
||||||
|
customElements.define('chat-panel-messages', ChatPanelMessages);
|
||||||
|
customElements.define('chat-panel', ChatPanel);
|
||||||
|
customElements.define('ai-error-wrapper', AIErrorWrapper);
|
||||||
|
customElements.define('ai-slides-renderer', AISlidesRenderer);
|
||||||
|
customElements.define('ai-answer-wrapper', AIAnswerWrapper);
|
||||||
|
customElements.define('ai-answer-text', AIAnswerText);
|
||||||
|
customElements.define('chat-block-input', ChatBlockInput);
|
||||||
|
customElements.define('ai-chat-block-peek-view', AIChatBlockPeekView);
|
||||||
|
customElements.define('date-time', DateTime);
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import { builtInTemplates as builtInEdgelessTemplates } from '@affine/templates/edgeless';
|
|
||||||
import { builtInTemplates as builtInStickersTemplates } from '@affine/templates/stickers';
|
|
||||||
import type { TemplateManager } from '@blocksuite/blocks';
|
|
||||||
import { EdgelessTemplatePanel } from '@blocksuite/blocks';
|
|
||||||
|
|
||||||
export function setupBlocksuite() {
|
|
||||||
EdgelessTemplatePanel.templates.extend(
|
|
||||||
builtInStickersTemplates as TemplateManager
|
|
||||||
);
|
|
||||||
EdgelessTemplatePanel.templates.extend(
|
|
||||||
builtInEdgelessTemplates as TemplateManager
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -12,5 +12,3 @@ export async function setupBrowser() {
|
|||||||
await polyfillBrowser();
|
await polyfillBrowser();
|
||||||
setupEnvironment();
|
setupEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
export { setupBlocksuite } from './blocksuite';
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Skeleton } from '@affine/component';
|
import { Skeleton } from '@affine/component';
|
||||||
import { getFontConfigExtension } from '@affine/core/components/blocksuite/block-suite-editor';
|
|
||||||
import type { EditorSettingSchema } from '@affine/core/modules/editor-settting';
|
import type { EditorSettingSchema } from '@affine/core/modules/editor-settting';
|
||||||
import { EditorSettingService } from '@affine/core/modules/editor-settting';
|
import { EditorSettingService } from '@affine/core/modules/editor-settting';
|
||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
@@ -72,10 +71,7 @@ export const EdgelessSnapshot = (props: Props) => {
|
|||||||
|
|
||||||
const editorHost = new BlockStdScope({
|
const editorHost = new BlockStdScope({
|
||||||
doc,
|
doc,
|
||||||
extensions: [
|
extensions: SpecProvider.getInstance().getSpec('edgeless:preview').value,
|
||||||
...SpecProvider.getInstance().getSpec('edgeless:preview').value,
|
|
||||||
getFontConfigExtension(),
|
|
||||||
],
|
|
||||||
}).render();
|
}).render();
|
||||||
docRef.current = doc;
|
docRef.current = doc;
|
||||||
editorHostRef.current = editorHost;
|
editorHostRef.current = editorHost;
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
export * from './blocksuite-editor';
|
import { registerAICustomComponents } from '@affine/core/blocksuite/presets/ai';
|
||||||
export { getFontConfigExtension } from './specs/font-extension';
|
|
||||||
|
|
||||||
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
|
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
|
||||||
import { effects as presetsEffects } from '@blocksuite/presets/effects';
|
import { effects as presetsEffects } from '@blocksuite/presets/effects';
|
||||||
|
|
||||||
import { setupAIProvider } from './ai/setup-provider';
|
import { setupAIProvider } from './ai/setup-provider';
|
||||||
|
import { effects as edgelessEffects } from './specs/edgeless';
|
||||||
import { effects as patchEffects } from './specs/preview';
|
import { effects as patchEffects } from './specs/preview';
|
||||||
|
|
||||||
blocksEffects();
|
blocksEffects();
|
||||||
presetsEffects();
|
presetsEffects();
|
||||||
patchEffects();
|
patchEffects();
|
||||||
setupAIProvider();
|
setupAIProvider();
|
||||||
|
edgelessEffects();
|
||||||
|
registerAICustomComponents();
|
||||||
|
|
||||||
|
export * from './blocksuite-editor';
|
||||||
@@ -55,6 +55,7 @@ export function createPageRootBlockSpec(
|
|||||||
return [
|
return [
|
||||||
enableAI ? AIPageRootBlockSpec : PageRootBlockSpec,
|
enableAI ? AIPageRootBlockSpec : PageRootBlockSpec,
|
||||||
FontLoaderService,
|
FontLoaderService,
|
||||||
|
getFontConfigExtension(),
|
||||||
getTelemetryExtension(),
|
getTelemetryExtension(),
|
||||||
getEditorConfigExtension(framework),
|
getEditorConfigExtension(framework),
|
||||||
].flat();
|
].flat();
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
import { builtInTemplates as builtInEdgelessTemplates } from '@affine/templates/edgeless';
|
||||||
|
import { builtInTemplates as builtInStickersTemplates } from '@affine/templates/stickers';
|
||||||
import type { ExtensionType } from '@blocksuite/block-std';
|
import type { ExtensionType } from '@blocksuite/block-std';
|
||||||
|
import type { TemplateManager } from '@blocksuite/blocks';
|
||||||
import {
|
import {
|
||||||
EdgelessNoteBlockSpec,
|
EdgelessNoteBlockSpec,
|
||||||
EdgelessSurfaceBlockSpec,
|
EdgelessSurfaceBlockSpec,
|
||||||
EdgelessSurfaceRefBlockSpec,
|
EdgelessSurfaceRefBlockSpec,
|
||||||
|
EdgelessTemplatePanel,
|
||||||
EdgelessTextBlockSpec,
|
EdgelessTextBlockSpec,
|
||||||
FrameBlockSpec,
|
FrameBlockSpec,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
@@ -26,3 +30,12 @@ export function createEdgelessModeSpecs(
|
|||||||
createEdgelessRootBlockSpec(framework, enableAI),
|
createEdgelessRootBlockSpec(framework, enableAI),
|
||||||
].flat();
|
].flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function effects() {
|
||||||
|
EdgelessTemplatePanel.templates.extend(
|
||||||
|
builtInStickersTemplates as TemplateManager
|
||||||
|
);
|
||||||
|
EdgelessTemplatePanel.templates.extend(
|
||||||
|
builtInEdgelessTemplates as TemplateManager
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ import type { ExtensionType } from '@blocksuite/block-std';
|
|||||||
import { SpecProvider } from '@blocksuite/blocks';
|
import { SpecProvider } from '@blocksuite/blocks';
|
||||||
import { AIChatBlockSpec } from '@blocksuite/presets';
|
import { AIChatBlockSpec } from '@blocksuite/presets';
|
||||||
|
|
||||||
const CustomSpecs: ExtensionType[] = [AIChatBlockSpec].flat();
|
import { getFontConfigExtension } from './font-extension';
|
||||||
|
|
||||||
|
const CustomSpecs: ExtensionType[] = [
|
||||||
|
AIChatBlockSpec,
|
||||||
|
getFontConfigExtension(),
|
||||||
|
].flat();
|
||||||
|
|
||||||
function patchPreviewSpec(id: string, specs: ExtensionType[]) {
|
function patchPreviewSpec(id: string, specs: ExtensionType[]) {
|
||||||
const specProvider = SpecProvider.getInstance();
|
const specProvider = SpecProvider.getInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user