There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor(core): migrate ai preset to AFFiNE (#7219)
L-Sunb3ec3a2b3efc
diff --git a/package.json b/package.jsonindex cb5143de7f..d580e69d3e 100644--- a/package.json+++ b/package.json@@ -102,6 +102,7 @@"string-width": "^7.1.0","ts-node": "^10.9.2","typescript": "^5.4.5",+ "unplugin-swc": "^1.4.5","vite": "^5.2.8","vite-plugin-istanbul": "^6.0.0","vite-plugin-static-copy": "^1.0.2",diff --git a/packages/common/env/package.json b/packages/common/env/package.jsonindex 74efba3b75..de870055e2 100644--- a/packages/common/env/package.json+++ b/packages/common/env/package.json@@ -27,4 +27,4 @@"zod": "^3.22.4"},"version": "0.14.0"-}+}\ No newline at end of filediff --git a/packages/common/infra/package.json b/packages/common/infra/package.jsonindex b8cae96566..d4b78aca8b 100644--- a/packages/common/infra/package.json+++ b/packages/common/infra/package.json@@ -68,4 +68,4 @@}},"version": "0.14.0"-}+}\ No newline at end of filediff --git a/packages/frontend/component/package.json b/packages/frontend/component/package.jsonindex a9a35b5eb9..55051b8e53 100644--- a/packages/frontend/component/package.json+++ b/packages/frontend/component/package.json@@ -109,4 +109,4 @@"yjs": "^13.6.14"},"version": "0.14.0"-}+}\ No newline at end of filediff --git a/packages/frontend/core/package.json b/packages/frontend/core/package.jsonindex ab065af531..9f947efec3 100644--- a/packages/frontend/core/package.json+++ b/packages/frontend/core/package.json@@ -33,10 +33,12 @@"@dnd-kit/modifiers": "^7.0.0","@dnd-kit/sortable": "^8.0.0","@dnd-kit/utilities": "^3.2.2",+ "@dotlottie/player-component": "^2.7.12","@emotion/cache": "^11.11.0","@emotion/react": "^11.11.4","@emotion/server": "^11.11.0","@emotion/styled": "^11.11.5",+ "@floating-ui/dom": "^1.6.5","@juggle/resize-observer": "^3.4.0","@marsidev/react-turnstile": "^0.7.0","@radix-ui/react-collapsible": "^1.0.3",@@ -69,7 +71,7 @@"jotai-devtools": "^0.10.0","jotai-effect": "^1.0.0","jotai-scope": "^0.6.0",- "lit": "^3.1.2",+ "lit": "^3.1.3","lodash-es": "^4.17.21","lottie-react": "^2.4.0","lottie-web": "^5.12.2",@@ -113,4 +115,4 @@"mime-types": "^2.1.35","vitest": "1.6.0"}-}+}\ No newline at end of filediff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/components/ask-ai-button.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/components/ask-ai-button.tsnew file mode 100644index 0000000000..22f35a6444--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/components/ask-ai-button.ts@@ -0,0 +1,210 @@+import './ask-ai-panel.js';++import { type EditorHost, WithDisposable } from '@blocksuite/block-std';+import {+ type AIItemGroupConfig,+ AIStarIcon,+ EdgelessRootService,+} from '@blocksuite/blocks';+import { createLitPortal, HoverController } from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import { flip, offset } from '@floating-ui/dom';+import { css, html, LitElement, nothing } from 'lit';+import { customElement, property, query } from 'lit/decorators.js';+import { ref } from 'lit/directives/ref.js';+import { styleMap } from 'lit/directives/style-map.js';++import { getRootService } from '../../utils/selection-utils.js';++type buttonSize = 'small' | 'middle' | 'large';+type toggleType = 'hover' | 'click';++const buttonWidthMap: Record<buttonSize, string> = {+ small: '72px',+ middle: '76px',+ large: '82px',+};++const buttonHeightMap: Record<buttonSize, string> = {+ small: '24px',+ middle: '32px',+ large: '32px',+};++export type AskAIButtonOptions = {+ size: buttonSize;+ backgroundColor?: string;+ boxShadow?: string;+ panelWidth?: number;+};++@customElement('ask-ai-button')+export class AskAIButton extends WithDisposable(LitElement) {+ get _edgeless() {+ const rootService = getRootService(this.host);+ if (rootService instanceof EdgelessRootService) {+ return rootService;+ }+ return null;+ }++ static override styles = css`+ .ask-ai-button {+ border-radius: 4px;+ position: relative;+ }++ .ask-ai-icon-button {+ display: flex;+ align-items: center;+ justify-content: center;+ color: var(--affine-brand-color);+ font-size: var(--affine-font-sm);+ font-weight: 500;+ }++ .ask-ai-icon-button.small {+ font-size: var(--affine-font-xs);+ svg {+ scale: 0.8;+ margin-right: 2px;+ }+ }++ .ask-ai-icon-button.large {+ font-size: var(--affine-font-md);+ svg {+ scale: 1.2;+ }+ }++ .ask-ai-icon-button span {+ line-height: 22px;+ }++ .ask-ai-icon-button svg {+ margin-right: 4px;+ color: var(--affine-brand-color);+ }+ `;++ @query('.ask-ai-button')+ private accessor _askAIButton!: HTMLDivElement;++ private _abortController: AbortController | null = null;++ private readonly _whenHover = new HoverController(+ this,+ ({ abortController }) => {+ return {+ template: html`<ask-ai-panel+ .host=${this.host}+ .actionGroups=${this.actionGroups}+ .abortController=${abortController}+ ></ask-ai-panel>`,+ computePosition: {+ referenceElement: this,+ placement: 'top-start',+ middleware: [flip(), offset(-40)],+ autoUpdate: true,+ },+ };+ },+ { allowMultiple: true }+ );++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor actionGroups!: AIItemGroupConfig[];++ @property({ attribute: false })+ accessor toggleType: toggleType = 'hover';++ @property({ attribute: false })+ accessor options: AskAIButtonOptions = {+ size: 'middle',+ backgroundColor: undefined,+ boxShadow: undefined,+ panelWidth: 330,+ };++ private readonly _clearAbortController = () => {+ if (this._abortController) {+ this._abortController.abort();+ this._abortController = null;+ }+ };++ private readonly _toggleAIPanel = () => {+ if (this.toggleType !== 'click') {+ return;+ }++ if (this._abortController) {+ this._clearAbortController();+ return;+ }++ this._abortController = new AbortController();+ assertExists(this._askAIButton);+ const panelMinWidth = this.options.panelWidth || 330;+ createLitPortal({+ template: html`<ask-ai-panel+ .host=${this.host}+ .actionGroups=${this.actionGroups}+ .minWidth=${panelMinWidth}+ ></ask-ai-panel>`,+ container: this._askAIButton,+ computePosition: {+ referenceElement: this._askAIButton,+ placement: 'bottom-start',+ middleware: [flip(), offset(4)],+ autoUpdate: true,+ },+ abortController: this._abortController,+ closeOnClickAway: true,+ });+ };++ override firstUpdated() {+ this.disposables.add(() => {+ this._edgeless?.tool.setEdgelessTool({ type: 'default' });+ });+ }++ override disconnectedCallback() {+ super.disconnectedCallback();+ this._clearAbortController();+ }++ override render() {+ const { size = 'small', backgroundColor, boxShadow } = this.options;+ const { toggleType } = this;+ const buttonStyles = styleMap({+ backgroundColor: backgroundColor || 'transparent',+ boxShadow: boxShadow || 'none',+ });+ return html`<div+ class="ask-ai-button"+ style=${buttonStyles}+ ${toggleType === 'hover' ? ref(this._whenHover.setReference) : nothing}+ @click=${this._toggleAIPanel}+ >+ <icon-button+ class="ask-ai-icon-button ${size}"+ width=${buttonWidthMap[size]}+ height=${buttonHeightMap[size]}+ >+ ${AIStarIcon} <span>Ask AI</span></icon-button+ >+ </div>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'ask-ai-button': AskAIButton;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/components/ask-ai-panel.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/components/ask-ai-panel.tsnew file mode 100644index 0000000000..17421c8e4e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/components/ask-ai-panel.ts@@ -0,0 +1,100 @@+import { type EditorHost, WithDisposable } from '@blocksuite/block-std';+import {+ type AIItemGroupConfig,+ EdgelessRootService,+} from '@blocksuite/blocks';+import { css, html, LitElement } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import { getRootService } from '../../utils/selection-utils.js';++@customElement('ask-ai-panel')+export class AskAIPanel extends WithDisposable(LitElement) {+ static override styles = css`+ :host {+ position: absolute;+ }++ .ask-ai-panel {+ box-sizing: border-box;+ padding: 8px;+ max-height: 374px;+ overflow-y: auto;+ background: var(--affine-background-overlay-panel-color);+ box-shadow: var(--affine-shadow-2);+ border-radius: 8px;+ z-index: var(--affine-z-index-popover);+ }++ .ask-ai-panel::-webkit-scrollbar {+ width: 5px;+ max-height: 100px;+ }+ .ask-ai-panel::-webkit-scrollbar-thumb {+ border-radius: 20px;+ }+ .ask-ai-panel:hover::-webkit-scrollbar-thumb {+ background-color: var(--affine-black-30);+ }+ .ask-ai-panel::-webkit-scrollbar-corner {+ display: none;+ }+ `;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor actionGroups!: AIItemGroupConfig[];++ @property({ attribute: false })+ accessor abortController: AbortController | null = null;++ @property({ attribute: false })+ accessor minWidth = 330;++ get _edgeless() {+ const rootService = getRootService(this.host);+ if (rootService instanceof EdgelessRootService) {+ return rootService;+ }+ return null;+ }++ get _actionGroups() {+ const filteredConfig = this.actionGroups+ .map(group => ({+ ...group,+ items: group.items.filter(item =>+ item.showWhen+ ? item.showWhen(+ this.host.command.chain(),+ this._edgeless ? 'edgeless' : 'page',+ this.host+ )+ : true+ ),+ }))+ .filter(group => group.items.length > 0);+ return filteredConfig;+ }++ override render() {+ const style = styleMap({+ minWidth: `${this.minWidth}px`,+ });+ return html`<div class="ask-ai-panel" style=${style}>+ <ai-item-list+ .host=${this.host}+ .groups=${this._actionGroups}+ ></ai-item-list>+ </div>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'ask-ai-panel': AskAIPanel;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/config.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/config.tsnew file mode 100644index 0000000000..6bcc85c55c--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/config.ts@@ -0,0 +1,521 @@+import type { Chain, EditorHost, InitCommandCtx } from '@blocksuite/block-std';+import {+ type AIItemGroupConfig,+ type AISubItemConfig,+ type CopilotSelectionController,+ EDGELESS_ELEMENT_TOOLBAR_WIDGET,+ type EdgelessElementToolbarWidget,+ matchFlavours,+} from '@blocksuite/blocks';+import type { TemplateResult } from 'lit';++import { actionToHandler } from '../actions/doc-handler.js';+import { actionToHandler as edgelessActionToHandler } from '../actions/edgeless-handler.js';+import {+ imageFilterStyles,+ imageProcessingTypes,+ textTones,+ translateLangs,+} from '../actions/types.js';+import { getAIPanel } from '../ai-panel.js';+import { AIProvider } from '../provider.js';+import {+ getSelectedImagesAsBlobs,+ getSelectedTextContent,+ getSelections,+} from '../utils/selection-utils.js';+import {+ AIDoneIcon,+ AIImageIcon,+ AIImageIconWithAnimation,+ AIMindMapIcon,+ AIPenIcon,+ AIPenIconWithAnimation,+ AIPresentationIcon,+ AIPresentationIconWithAnimation,+ AISearchIcon,+ AIStarIconWithAnimation,+ ChatWithAIIcon,+ ExplainIcon,+ ImproveWritingIcon,+ LanguageIcon,+ LongerIcon,+ MakeItRealIcon,+ MakeItRealIconWithAnimation,+ SelectionIcon,+ ShorterIcon,+ ToneIcon,+} from './icons.js';++export const translateSubItem: AISubItemConfig[] = translateLangs.map(lang => {+ return {+ type: lang,+ handler: actionToHandler('translate', AIStarIconWithAnimation, { lang }),+ };+});++export const toneSubItem: AISubItemConfig[] = textTones.map(tone => {+ return {+ type: tone,+ handler: actionToHandler('changeTone', AIStarIconWithAnimation, { tone }),+ };+});++export function createImageFilterSubItem(+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return imageFilterStyles.map(style => {+ return {+ type: style,+ handler: edgelessHandler(+ 'filterImage',+ AIImageIconWithAnimation,+ {+ style,+ },+ trackerOptions+ ),+ };+ });+}++export function createImageProcessingSubItem(+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return imageProcessingTypes.map(type => {+ return {+ type,+ handler: edgelessHandler(+ 'processImage',+ AIImageIconWithAnimation,+ {+ type,+ },+ trackerOptions+ ),+ };+ });+}++const blockActionTrackerOptions: BlockSuitePresets.TrackerOptions = {+ control: 'block-action-bar',+ where: 'ai-panel',+};++const textBlockShowWhen = (chain: Chain<InitCommandCtx>) => {+ const [_, ctx] = chain+ .getSelectedModels({+ types: ['block', 'text'],+ })+ .run();+ const { selectedModels } = ctx;+ if (!selectedModels || selectedModels.length === 0) return false;++ return selectedModels.some(model =>+ matchFlavours(model, ['affine:paragraph', 'affine:list'])+ );+};++const codeBlockShowWhen = (chain: Chain<InitCommandCtx>) => {+ const [_, ctx] = chain+ .getSelectedModels({+ types: ['block', 'text'],+ })+ .run();+ const { selectedModels } = ctx;+ if (!selectedModels || selectedModels.length > 1) return false;++ const model = selectedModels[0];+ return matchFlavours(model, ['affine:code']);+};++const imageBlockShowWhen = (chain: Chain<InitCommandCtx>) => {+ const [_, ctx] = chain+ .getSelectedModels({+ types: ['block'],+ })+ .run();+ const { selectedModels } = ctx;+ if (!selectedModels || selectedModels.length > 1) return false;++ const model = selectedModels[0];+ return matchFlavours(model, ['affine:image']);+};++const EditAIGroup: AIItemGroupConfig = {+ name: 'edit with ai',+ items: [+ {+ name: 'Translate to',+ icon: LanguageIcon,+ showWhen: textBlockShowWhen,+ subItem: translateSubItem,+ },+ {+ name: 'Change tone to',+ icon: ToneIcon,+ showWhen: textBlockShowWhen,+ subItem: toneSubItem,+ },+ {+ name: 'Improve writing',+ icon: ImproveWritingIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('improveWriting', AIStarIconWithAnimation),+ },+ {+ name: 'Make it longer',+ icon: LongerIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('makeLonger', AIStarIconWithAnimation),+ },+ {+ name: 'Make it shorter',+ icon: ShorterIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('makeShorter', AIStarIconWithAnimation),+ },+ {+ name: 'Continue writing',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('continueWriting', AIPenIconWithAnimation),+ },+ ],+};++const DraftAIGroup: AIItemGroupConfig = {+ name: 'draft with ai',+ items: [+ {+ name: 'Write an article about this',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('writeArticle', AIPenIconWithAnimation),+ },+ {+ name: 'Write a tweet about this',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('writeTwitterPost', AIPenIconWithAnimation),+ },+ {+ name: 'Write a poem about this',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('writePoem', AIPenIconWithAnimation),+ },+ {+ name: 'Write a blog post about this',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('writeBlogPost', AIPenIconWithAnimation),+ },+ {+ name: 'Brainstorm ideas about this',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('brainstorm', AIPenIconWithAnimation),+ },+ ],+};++// actions that initiated from a note in edgeless mode+// 1. when running in doc mode, call requestRunInEdgeless (let affine to show toast)+// 2. when running in edgeless mode+// a. get selected in the note and let the edgeless action to handle it+// b. insert the result using the note shape+function edgelessHandler<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ generatingIcon: TemplateResult<1>,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return (host: EditorHost) => {+ if (host.doc.root?.id === undefined) return;+ const edgeless = (+ host.view.getWidget(+ EDGELESS_ELEMENT_TOOLBAR_WIDGET,+ host.doc.root.id+ ) as EdgelessElementToolbarWidget+ )?.edgeless;++ if (!edgeless) {+ AIProvider.slots.requestRunInEdgeless.emit({ host });+ } else {+ edgeless.tools.setEdgelessTool({ type: 'copilot' });+ const currentController = edgeless.tools.controllers[+ 'copilot'+ ] as CopilotSelectionController;+ const selectedElements = edgeless.service.selection.selectedElements;+ currentController.updateDragPointsWith(selectedElements, 10);+ currentController.draggingAreaUpdated.emit(false); // do not show edgeless panel++ return edgelessActionToHandler(+ id,+ generatingIcon,+ variants,+ async () => {+ const selections = getSelections(host);+ const [markdown, attachments] = await Promise.all([+ getSelectedTextContent(host),+ getSelectedImagesAsBlobs(host),+ ]);+ // for now if there are more than one selected blocks, we will not omit the attachments+ const sendAttachments =+ selections?.selectedBlocks?.length === 1 && attachments.length > 0;+ return {+ attachments: sendAttachments ? attachments : undefined,+ content: sendAttachments ? '' : markdown,+ };+ },+ trackerOptions+ )(host);+ }+ };+}++const ReviewWIthAIGroup: AIItemGroupConfig = {+ name: 'review with ai',+ items: [+ {+ name: 'Fix spelling',+ icon: AIDoneIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('fixSpelling', AIStarIconWithAnimation),+ },+ {+ name: 'Fix grammar',+ icon: AIDoneIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('improveGrammar', AIStarIconWithAnimation),+ },+ {+ name: 'Explain this image',+ icon: AIPenIcon,+ showWhen: imageBlockShowWhen,+ handler: actionToHandler('explainImage', AIStarIconWithAnimation),+ },+ {+ name: 'Explain this code',+ icon: ExplainIcon,+ showWhen: codeBlockShowWhen,+ handler: actionToHandler('explainCode', AIStarIconWithAnimation),+ },+ {+ name: 'Check code error',+ icon: ExplainIcon,+ showWhen: codeBlockShowWhen,+ handler: actionToHandler('checkCodeErrors', AIStarIconWithAnimation),+ },+ {+ name: 'Explain selection',+ icon: SelectionIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('explain', AIStarIconWithAnimation),+ },+ ],+};++const GenerateWithAIGroup: AIItemGroupConfig = {+ name: 'generate with ai',+ items: [+ {+ name: 'Summarize',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('summary', AIPenIconWithAnimation),+ },+ {+ name: 'Generate headings',+ icon: AIPenIcon,+ beta: true,+ handler: actionToHandler('createHeadings', AIPenIconWithAnimation),+ showWhen: chain => {+ const [_, ctx] = chain+ .getSelectedModels({+ types: ['block', 'text'],+ })+ .run();+ const { selectedModels } = ctx;+ if (!selectedModels || selectedModels.length === 0) return false;++ return selectedModels.every(+ model =>+ matchFlavours(model, ['affine:paragraph', 'affine:list']) &&+ !model.type.startsWith('h')+ );+ },+ },+ {+ name: 'Generate an image',+ icon: AIImageIcon,+ showWhen: textBlockShowWhen,+ handler: edgelessHandler('createImage', AIImageIconWithAnimation),+ },+ {+ name: 'Generate outline',+ icon: AIPenIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('writeOutline', AIPenIconWithAnimation),+ },+ {+ name: 'Brainstorm ideas with mind map',+ icon: AIMindMapIcon,+ showWhen: textBlockShowWhen,+ handler: edgelessHandler('brainstormMindmap', AIPenIconWithAnimation),+ },+ {+ name: 'Generate presentation',+ icon: AIPresentationIcon,+ showWhen: textBlockShowWhen,+ handler: edgelessHandler('createSlides', AIPresentationIconWithAnimation),+ beta: true,+ },+ {+ name: 'Make it real',+ icon: MakeItRealIcon,+ beta: true,+ showWhen: textBlockShowWhen,+ handler: edgelessHandler('makeItReal', MakeItRealIconWithAnimation),+ },+ {+ name: 'Find actions',+ icon: AISearchIcon,+ showWhen: textBlockShowWhen,+ handler: actionToHandler('findActions', AIStarIconWithAnimation),+ beta: true,+ },+ ],+};++const OthersAIGroup: AIItemGroupConfig = {+ name: 'Others',+ items: [+ {+ name: 'Open AI Chat',+ icon: ChatWithAIIcon,+ handler: host => {+ const panel = getAIPanel(host);+ AIProvider.slots.requestContinueInChat.emit({+ host: host,+ show: true,+ });+ panel.hide();+ },+ },+ ],+};++export const AIItemGroups: AIItemGroupConfig[] = [+ ReviewWIthAIGroup,+ EditAIGroup,+ GenerateWithAIGroup,+ DraftAIGroup,+ OthersAIGroup,+];++export function buildAIImageItemGroups(): AIItemGroupConfig[] {+ return [+ {+ name: 'edit with ai',+ items: [+ {+ name: 'Explain this image',+ icon: ExplainIcon,+ showWhen: () => true,+ handler: actionToHandler(+ 'explainImage',+ AIStarIconWithAnimation,+ undefined,+ blockActionTrackerOptions+ ),+ },+ ],+ },+ {+ name: 'generate with ai',+ items: [+ {+ name: 'Generate an image',+ icon: AIImageIcon,+ showWhen: () => true,+ handler: edgelessHandler(+ 'createImage',+ AIImageIconWithAnimation,+ undefined,+ blockActionTrackerOptions+ ),+ },+ {+ name: 'AI image filter',+ icon: ImproveWritingIcon,+ showWhen: (_, __, host) =>+ !!host.doc.awarenessStore.getFlag('enable_new_image_actions'),+ subItem: createImageFilterSubItem(blockActionTrackerOptions),+ subItemOffset: [12, -4],+ beta: true,+ },+ {+ name: 'Image processing',+ icon: AIImageIcon,+ showWhen: (_, __, host) =>+ !!host.doc.awarenessStore.getFlag('enable_new_image_actions'),+ subItem: createImageProcessingSubItem(blockActionTrackerOptions),+ subItemOffset: [12, -6],+ beta: true,+ },+ {+ name: 'Generate a caption',+ icon: AIPenIcon,+ showWhen: (_, __, host) =>+ !!host.doc.awarenessStore.getFlag('enable_new_image_actions'),+ beta: true,+ handler: actionToHandler(+ 'generateCaption',+ AIStarIconWithAnimation,+ undefined,+ blockActionTrackerOptions+ ),+ },+ ],+ },+ OthersAIGroup,+ ];+}++export function buildAICodeItemGroups(): AIItemGroupConfig[] {+ return [+ {+ name: 'edit with ai',+ items: [+ {+ name: 'Explain this code',+ icon: ExplainIcon,+ showWhen: () => true,+ handler: actionToHandler(+ 'explainCode',+ AIStarIconWithAnimation,+ undefined,+ blockActionTrackerOptions+ ),+ },+ {+ name: 'Check code error',+ icon: ExplainIcon,+ showWhen: () => true,+ handler: actionToHandler(+ 'checkCodeErrors',+ AIStarIconWithAnimation,+ undefined,+ blockActionTrackerOptions+ ),+ },+ ],+ },+ OthersAIGroup,+ ];+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.tsnew file mode 100644index 0000000000..bf0029bd59--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/icons.ts@@ -0,0 +1,1063 @@+import '@dotlottie/player-component';++import { html } from 'lit';++export const AIStarIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_7444_26654)">+ <path+ d="M9.40033 4.57585C9.36627 4.27519 9.11207 4.04792 8.80948 4.04761C8.50689 4.0473 8.25223 4.27405 8.21756 4.57465C7.99211 6.52928 7.40771 7.90373 6.46492 8.84651C5.52213 9.7893 4.14769 10.3737 2.19305 10.5991C1.89246 10.6338 1.66571 10.8885 1.66602 11.1911C1.66633 11.4937 1.8936 11.7479 2.19426 11.7819C4.11659 11.9997 5.52025 12.5838 6.48542 13.5315C7.44696 14.4757 8.04356 15.8498 8.21597 17.7908C8.24327 18.0981 8.50096 18.3337 8.80954 18.3333C9.11813 18.333 9.37528 18.0969 9.40189 17.7894C9.56714 15.8804 10.1632 14.4774 11.1295 13.5111C12.0958 12.5448 13.4988 11.9487 15.4078 11.7835C15.7153 11.7569 15.9514 11.4997 15.9517 11.1911C15.9521 10.8825 15.7165 10.6249 15.4092 10.5976C13.4683 10.4252 12.0941 9.82855 11.15 8.86701C10.2022 7.90184 9.61807 6.49818 9.40033 4.57585Z"+ fill="#1E96EB"+ />+ <path+ d="M15.7849 1.87208C15.7717 1.75516 15.6728 1.66678 15.5551 1.66666C15.4375 1.66654 15.3384 1.75472 15.3249 1.87162C15.2373 2.63175 15.01 3.16626 14.6434 3.5329C14.2767 3.89954 13.7422 4.1268 12.9821 4.21448C12.8652 4.22796 12.777 4.327 12.7771 4.44467C12.7772 4.56234 12.8656 4.6612 12.9826 4.67445C13.7301 4.75912 14.276 4.9863 14.6513 5.35485C15.0253 5.72203 15.2573 6.25642 15.3243 7.01121C15.335 7.13075 15.4352 7.22235 15.5552 7.22221C15.6752 7.22208 15.7752 7.13025 15.7855 7.01069C15.8498 6.26831 16.0816 5.72268 16.4574 5.3469C16.8332 4.97111 17.3788 4.73932 18.1212 4.67505C18.2407 4.6647 18.3325 4.5647 18.3327 4.44469C18.3328 4.32469 18.2412 4.22448 18.1217 4.21386C17.3669 4.14681 16.8325 3.9148 16.4653 3.54087C16.0968 3.16552 15.8696 2.61966 15.7849 1.87208Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_7444_26654">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg>`;++export const AIStarIconWithAnimation = html`<dotlottie-player+ src='{"v":"5.12.1","fr":120,"ip":0,"op":239,"w":240,"h":240,"nm":"ai","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"big 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":38,"s":[80]},{"t":76,"s":[100]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[107.859,132.143,0],"ix":2,"l":2},"a":{"a":0,"k":[8.572,11.429,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.5,0.5,0.5],"y":[1,1,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":38,"s":[0,0,100]},{"t":76,"s":[1005,1005,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.261,2.307],[0.363,0],[0.041,-0.361],[1.131,-1.132],[2.346,-0.271],[-0.001,-0.363],[-0.361,-0.041],[-1.158,-1.137],[-0.207,-2.329],[-0.37,0],[-0.032,0.369],[-1.16,1.16],[-2.291,0.198],[-0.001,0.371],[0.368,0.033],[1.133,1.154]],"o":[[-0.041,-0.361],[-0.363,0],[-0.271,2.345],[-1.132,1.131],[-0.36,0.042],[0,0.363],[2.307,0.262],[1.154,1.133],[0.033,0.369],[0.37,0],[0.198,-2.29],[1.16,-1.159],[0.369,-0.032],[0,-0.37],[-2.329,-0.207],[-1.138,-1.158]],"v":[[0.71,-7.937],[0.001,-8.571],[-0.709,-7.938],[-2.812,-2.812],[-7.939,-0.709],[-8.571,0.001],[-7.937,0.71],[-2.788,2.81],[-0.711,7.921],[0.001,8.572],[0.712,7.919],[2.785,2.785],[7.919,0.712],[8.572,0.001],[7.921,-0.711],[2.81,-2.788]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[8.572,11.429],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"big","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[100]},{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":15,"s":[80]},{"t":38,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[107.859,132.143,0],"ix":2,"l":2},"a":{"a":0,"k":[8.572,11.429,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.5,0.5,0.5],"y":[1,1,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":0,"s":[1005,1005,100]},{"i":{"x":[0.5,0.5,0.5],"y":[1,1,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":15,"s":[1035,1035,100]},{"t":38,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.261,2.307],[0.363,0],[0.041,-0.361],[1.131,-1.132],[2.346,-0.271],[-0.001,-0.363],[-0.361,-0.041],[-1.158,-1.137],[-0.207,-2.329],[-0.37,0],[-0.032,0.369],[-1.16,1.16],[-2.291,0.198],[-0.001,0.371],[0.368,0.033],[1.133,1.154]],"o":[[-0.041,-0.361],[-0.363,0],[-0.271,2.345],[-1.132,1.131],[-0.36,0.042],[0,0.363],[2.307,0.262],[1.154,1.133],[0.033,0.369],[0.37,0],[0.198,-2.29],[1.16,-1.159],[0.369,-0.032],[0,-0.37],[-2.329,-0.207],[-1.138,-1.158]],"v":[[0.71,-7.937],[0.001,-8.571],[-0.709,-7.938],[-2.812,-2.812],[-7.939,-0.709],[-8.571,0.001],[-7.937,0.71],[-2.788,2.81],[-0.711,7.921],[0.001,8.572],[0.712,7.919],[2.785,2.785],[7.919,0.712],[8.572,0.001],[7.921,-0.711],[2.81,-2.788]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[8.572,11.429],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"small 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":48.074,"s":[80]},{"t":85.07421875,"s":[100]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[183,56.999,0],"ix":2,"l":2},"a":{"a":0,"k":[16.667,3.333,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.5,0.5,0.5],"y":[1,1,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":48,"s":[0,0,100]},{"t":85.07421875,"s":[1005,1005,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.102,0.897],[0.141,0.001],[0.016,-0.14],[0.44,-0.44],[0.912,-0.105],[0,-0.141],[-0.14,-0.016],[-0.451,-0.442],[-0.08,-0.906],[-0.144,0],[-0.013,0.144],[-0.451,0.451],[-0.89,0.077],[0,0.144],[0.143,0.013],[0.441,0.448]],"o":[[-0.016,-0.14],[-0.141,0],[-0.105,0.913],[-0.44,0.44],[-0.141,0.016],[0,0.141],[0.897,0.101],[0.448,0.441],[0.013,0.143],[0.144,0],[0.077,-0.891],[0.451,-0.451],[0.144,-0.013],[0,-0.144],[-0.906,-0.08],[-0.442,-0.451]],"v":[[0.276,-3.087],[0,-3.334],[-0.276,-3.088],[-1.094,-1.094],[-3.087,-0.276],[-3.333,0],[-3.087,0.276],[-1.084,1.092],[-0.277,3.08],[0,3.333],[0.277,3.079],[1.083,1.083],[3.079,0.277],[3.333,0],[3.08,-0.277],[1.092,-1.084]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[16.667,3.333],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"small","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":10.074,"s":[100]},{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":25.074,"s":[80]},{"t":48.07421875,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[183,56.999,0],"ix":2,"l":2},"a":{"a":0,"k":[16.667,3.333,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.5,0.5,0.5],"y":[1,1,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":10.074,"s":[1005,1005,100]},{"i":{"x":[0.5,0.5,0.5],"y":[1,1,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":25.074,"s":[1235,1235,100]},{"t":48,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.102,0.897],[0.141,0.001],[0.016,-0.14],[0.44,-0.44],[0.912,-0.105],[0,-0.141],[-0.14,-0.016],[-0.451,-0.442],[-0.08,-0.906],[-0.144,0],[-0.013,0.144],[-0.451,0.451],[-0.89,0.077],[0,0.144],[0.143,0.013],[0.441,0.448]],"o":[[-0.016,-0.14],[-0.141,0],[-0.105,0.913],[-0.44,0.44],[-0.141,0.016],[0,0.141],[0.897,0.101],[0.448,0.441],[0.013,0.143],[0.144,0],[0.077,-0.891],[0.451,-0.451],[0.144,-0.013],[0,-0.144],[-0.906,-0.08],[-0.442,-0.451]],"v":[[0.276,-3.087],[0,-3.334],[-0.276,-3.088],[-1.094,-1.094],[-3.087,-0.276],[-3.333,0],[-3.087,0.276],[-1.084,1.092],[-0.277,3.08],[0,3.333],[0.277,3.079],[1.083,1.083],[3.079,0.277],[3.333,0],[3.08,-0.277],[1.092,-1.084]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[16.667,3.333],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'+ background="transparent"+ speed="1"+ style="width: 20px; height: 20px;"+ loop+ autoplay+></dotlottie-player>`;++export const SmallHintIcon = html`<svg+ width="16"+ height="16"+ viewBox="0 0 16 16"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M8.00008 3.16699C5.33071 3.16699 3.16675 5.33095 3.16675 8.00033C3.16675 10.6697 5.33071 12.8337 8.00008 12.8337C10.6695 12.8337 12.8334 10.6697 12.8334 8.00033C12.8334 5.33095 10.6695 3.16699 8.00008 3.16699ZM2.16675 8.00033C2.16675 4.77866 4.77842 2.16699 8.00008 2.16699C11.2217 2.16699 13.8334 4.77866 13.8334 8.00033C13.8334 11.222 11.2217 13.8337 8.00008 13.8337C4.77842 13.8337 2.16675 11.222 2.16675 8.00033ZM8.00008 5.12996C8.27622 5.12996 8.50008 5.35381 8.50008 5.62996V8.00033C8.50008 8.27647 8.27622 8.50033 8.00008 8.50033C7.72394 8.50033 7.50008 8.27647 7.50008 8.00033V5.62996C7.50008 5.35381 7.72394 5.12996 8.00008 5.12996ZM7.50008 10.3707C7.50008 10.0946 7.72394 9.8707 8.00008 9.8707H8.00601C8.28215 9.8707 8.50601 10.0946 8.50601 10.3707C8.50601 10.6468 8.28215 10.8707 8.00601 10.8707H8.00008C7.72394 10.8707 7.50008 10.6468 7.50008 10.3707Z"+ fill="#77757D"+ fill-opacity="0.6"+ />+</svg> `;++export const AIHelpIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_17283_108071)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M3.125 10C3.125 6.20304 6.20304 3.125 10 3.125C13.797 3.125 16.875 6.20304 16.875 10C16.875 13.797 13.797 16.875 10 16.875C6.20304 16.875 3.125 13.797 3.125 10ZM10 1.875C5.51269 1.875 1.875 5.51269 1.875 10C1.875 14.4873 5.51269 18.125 10 18.125C14.4873 18.125 18.125 14.4873 18.125 10C18.125 5.51269 14.4873 1.875 10 1.875ZM10.1988 9.15283C9.42973 9.75667 9.16199 10.1383 9.16199 10.8105C9.16199 11.1751 9.38985 11.4486 9.80571 11.4486C10.2045 11.4486 10.3526 11.2207 10.495 10.8846C10.626 10.4061 10.814 10.2067 11.3666 9.78516C12.0957 9.24398 12.58 8.75977 12.58 7.87679C12.58 6.60645 11.5375 5.82601 10.0393 5.82601C9.23035 5.82601 8.60942 6.03678 8.19356 6.38997C7.85177 6.69189 7.6296 7.09066 7.6296 7.46663C7.6296 7.77995 7.82898 8.0363 8.18787 8.0363C8.42712 8.0363 8.56384 7.92806 8.74044 7.6945C9.01388 7.22738 9.38985 7.0166 9.93673 7.0166C10.5634 7.0166 11.059 7.38688 11.059 7.94515C11.059 8.44645 10.7513 8.71989 10.1988 9.15283ZM9.80571 12.2575C9.33289 12.2575 8.94552 12.5879 8.94552 13.0607C8.94552 13.5335 9.33289 13.8639 9.80571 13.8639C10.2785 13.8639 10.6716 13.5335 10.6716 13.0607C10.6716 12.5879 10.2785 12.2575 9.80571 12.2575Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_17283_108071">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AffineIcon = (color: string) =>+ html`<svg+ width="63"+ height="62"+ viewBox="0 0 63 62"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <g filter="url(#filter0_dd_5885_200419)">+ <rect+ x="9.5"+ y="3"+ width="44"+ height="44"+ rx="8"+ fill="var(--affine-white)"+ />+ <rect+ x="10"+ y="3.5"+ width="43"+ height="43"+ rx="7.5"+ stroke="var(--affine-border-color)"+ />+ <g clip-path="url(#clip0_5885_200419)">+ <path+ d="M30.6764 17.5421C30.6296 17.1287 30.2801 16.8162 29.864 16.8158C29.448 16.8154 29.0978 17.1272 29.0501 17.5405C28.7401 20.2281 27.9366 22.118 26.6402 23.4143C25.3439 24.7106 23.454 25.5142 20.7664 25.8242C20.3531 25.8718 20.0413 26.222 20.0417 26.6381C20.0422 27.0541 20.3547 27.4037 20.7681 27.4505C23.4113 27.7499 25.3413 28.5531 26.6684 29.8562C27.9905 31.1544 28.8109 33.0439 29.0479 35.7126C29.0855 36.1353 29.4398 36.4591 29.8641 36.4587C30.2884 36.4582 30.642 36.1335 30.6786 35.7108C30.9058 33.0859 31.7254 31.1568 33.054 29.8281C34.3827 28.4994 36.3119 27.6798 38.9367 27.4526C39.3595 27.416 39.6841 27.0625 39.6846 26.6382C39.6851 26.2138 39.3612 25.8595 38.9386 25.822C36.2698 25.5849 34.3804 24.7646 33.0822 23.4425C31.779 22.1154 30.9758 20.1853 30.6764 17.5421Z"+ fill=${color}+ />+ <path+ d="M39.4552 13.8245C39.437 13.6637 39.3011 13.5422 39.1393 13.542C38.9775 13.5418 38.8413 13.6631 38.8228 13.8238C38.7022 14.869 38.3897 15.6039 37.8856 16.1081C37.3815 16.6122 36.6465 16.9247 35.6013 17.0452C35.4406 17.0638 35.3194 17.2 35.3195 17.3618C35.3197 17.5236 35.4412 17.6595 35.602 17.6777C36.6299 17.7941 37.3805 18.1065 37.8966 18.6133C38.4107 19.1181 38.7297 19.8529 38.8219 20.8908C38.8365 21.0551 38.9743 21.1811 39.1393 21.1809C39.3043 21.1807 39.4418 21.0544 39.4561 20.89C39.5444 19.8693 39.8632 19.119 40.3799 18.6023C40.8966 18.0856 41.6468 17.7669 42.6676 17.6785C42.832 17.6643 42.9582 17.5268 42.9584 17.3618C42.9586 17.1968 42.8327 17.059 42.6683 17.0444C41.6304 16.9522 40.8957 16.6332 40.3908 16.119C39.884 15.6029 39.5717 14.8524 39.4552 13.8245Z"+ fill=${color}+ />+ </g>+ </g>+ <defs>+ <filter+ id="filter0_dd_5885_200419"+ x="0.5"+ y="0"+ width="62"+ height="62"+ filterUnits="userSpaceOnUse"+ color-interpolation-filters="sRGB"+ >+ <feFlood flood-opacity="0" result="BackgroundImageFix" />+ <feColorMatrix+ in="SourceAlpha"+ type="matrix"+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"+ result="hardAlpha"+ />+ <feMorphology+ radius="2"+ operator="erode"+ in="SourceAlpha"+ result="effect1_dropShadow_5885_200419"+ />+ <feOffset dy="4" />+ <feGaussianBlur stdDeviation="2" />+ <feColorMatrix+ type="matrix"+ values="0 0 0 0 0.258824 0 0 0 0 0.254902 0 0 0 0 0.286275 0 0 0 0.1 0"+ />+ <feBlend+ mode="normal"+ in2="BackgroundImageFix"+ result="effect1_dropShadow_5885_200419"+ />+ <feColorMatrix+ in="SourceAlpha"+ type="matrix"+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"+ result="hardAlpha"+ />+ <feMorphology+ radius="1"+ operator="dilate"+ in="SourceAlpha"+ result="effect2_dropShadow_5885_200419"+ />+ <feOffset dy="6" />+ <feGaussianBlur stdDeviation="4" />+ <feColorMatrix+ type="matrix"+ values="0 0 0 0 0.258824 0 0 0 0 0.254902 0 0 0 0 0.286275 0 0 0 0.05 0"+ />+ <feBlend+ mode="normal"+ in2="effect1_dropShadow_5885_200419"+ result="effect2_dropShadow_5885_200419"+ />+ <feBlend+ mode="normal"+ in="SourceGraphic"+ in2="effect2_dropShadow_5885_200419"+ result="shape"+ />+ </filter>+ <clipPath id="clip0_5885_200419">+ <rect+ width="27.5"+ height="27.5"+ fill="white"+ transform="translate(17.75 11.25)"+ />+ </clipPath>+ </defs>+ </svg> `;++export const ChatClearIcon = html`<svg+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_7034_11049)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M19.3144 5.1023C19.5618 5.34971 19.5618 5.75083 19.3144 5.99823L13.5075 11.8052C14.5763 13.2524 14.6251 15.25 13.564 16.76L11.1633 20.1764C10.9886 20.4249 10.6461 20.486 10.3964 20.3131C7.93754 18.6108 5.80584 16.4791 4.10358 14.0203C3.93067 13.7705 3.99171 13.4281 4.24025 13.2534L7.65663 10.8527C9.16673 9.79155 11.1643 9.84036 12.6116 10.9092L18.4185 5.1023C18.6659 4.8549 19.067 4.8549 19.3144 5.1023ZM10.5405 18.8589L12.5273 16.0316C12.535 16.0205 12.5427 16.0095 12.5502 15.9984C11.6977 15.6645 10.8371 15.096 10.0789 14.3378C9.3207 13.5796 8.75224 12.719 8.4183 11.8664C8.4072 11.874 8.39613 11.8816 8.38511 11.8894L5.55779 13.8761C6.96005 15.777 8.63969 17.4566 10.5405 18.8589ZM9.59298 11.3911C9.85414 12.0639 10.3184 12.7855 10.9748 13.4419C11.6312 14.0983 12.3528 14.5626 13.0255 14.8237C13.1835 13.8976 12.8979 12.9206 12.197 12.2197C11.4961 11.5187 10.5191 11.2331 9.59298 11.3911Z"+ fill="#A9A9AD"+ />+ </g>+ <defs>+ <clipPath id="clip0_7034_11049">+ <rect width="20" height="20" fill="white" transform="translate(2 2)" />+ </clipPath>+ </defs>+</svg> `;++export const ChatSendIcon = html`<svg+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <rect width="24" height="24" rx="4" fill="#A9A9AD" />+ <g clip-path="url(#clip0_7455_53584)">+ <path+ d="M18.7402 5.45305C18.7402 5.45305 20.2433 4.8669 20.1175 6.2903C20.0761 6.87646 19.7005 8.92818 19.408 11.147L18.4059 17.7205C18.4059 17.7205 18.3223 18.6835 17.5706 18.851C16.8192 19.0181 15.6918 18.2648 15.4829 18.0973C15.3157 17.9716 12.3513 16.0874 11.3074 15.1665C11.015 14.9151 10.6807 14.4129 11.3492 13.8267L15.7332 9.63969C16.2342 9.1375 16.7353 7.96519 14.6475 9.38859L8.8015 13.3659C8.8015 13.3659 8.13333 13.7849 6.88093 13.4081L4.16645 12.5705C4.16645 12.5705 3.16438 11.9425 4.87641 11.3146C9.05221 9.34681 14.1883 7.33725 18.7394 5.45305H18.7402Z"+ fill="white"+ />+ </g>+ <defs>+ <clipPath id="clip0_7455_53584">+ <rect width="20" height="20" fill="white" transform="translate(2 2)" />+ </clipPath>+ </defs>+</svg> `;++export const ChatAbortIcon = html`<svg+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_12965_7241)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M19.0833 11.9993C19.0833 15.9114 15.912 19.0827 12 19.0827C8.08798 19.0827 4.91667 15.9114 4.91667 11.9993C4.91667 8.08733 8.08798 4.91602 12 4.91602C15.912 4.91602 19.0833 8.08733 19.0833 11.9993ZM20.3333 11.9993C20.3333 16.6017 16.6024 20.3327 12 20.3327C7.39763 20.3327 3.66667 16.6017 3.66667 11.9993C3.66667 7.39698 7.39763 3.66602 12 3.66602C16.6024 3.66602 20.3333 7.39698 20.3333 11.9993ZM10.3333 8.66602C9.41286 8.66602 8.66667 9.41221 8.66667 10.3327V13.666C8.66667 14.5865 9.41286 15.3327 10.3333 15.3327H13.6667C14.5871 15.3327 15.3333 14.5865 15.3333 13.666V10.3327C15.3333 9.41221 14.5871 8.66602 13.6667 8.66602H10.3333Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_12965_7241">+ <rect width="20" height="20" fill="white" transform="translate(2 2)" />+ </clipPath>+ </defs>+</svg> `;++export const CurrentSelectionIcon = html`<svg+ width="16"+ height="17"+ viewBox="0 0 16 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_7289_18670)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M1.89392 3.54492C1.61778 3.54492 1.39392 3.76878 1.39392 4.04492V5.37826C1.39392 5.6544 1.61778 5.87826 1.89392 5.87826C2.17006 5.87826 2.39392 5.6544 2.39392 5.37826V4.54492H4.66665V11.5449H3.34847C3.07232 11.5449 2.84847 11.7688 2.84847 12.0449C2.84847 12.3211 3.07232 12.5449 3.34847 12.5449H5.16665H6.98483C7.26097 12.5449 7.48483 12.3211 7.48483 12.0449C7.48483 11.7688 7.26097 11.5449 6.98483 11.5449H5.66665V4.54492H7.93938V5.37826C7.93938 5.6544 8.16323 5.87826 8.43937 5.87826C8.71552 5.87826 8.93937 5.6544 8.93937 5.37826V4.04492C8.93937 3.76878 8.71552 3.54492 8.43937 3.54492H5.16665H1.89392ZM10.403 3.54492C10.1269 3.54492 9.90299 3.76878 9.90299 4.04492C9.90299 4.32106 10.1269 4.54492 10.403 4.54492H14.0394C14.3155 4.54492 14.5394 4.32106 14.5394 4.04492C14.5394 3.76878 14.3155 3.54492 14.0394 3.54492H10.403ZM9.90299 8.04492C9.90299 7.76878 10.1269 7.54492 10.403 7.54492H14.0394C14.3155 7.54492 14.5394 7.76878 14.5394 8.04492C14.5394 8.32106 14.3155 8.54492 14.0394 8.54492H10.403C10.1269 8.54492 9.90299 8.32106 9.90299 8.04492ZM10.403 11.5449C10.1269 11.5449 9.90299 11.7688 9.90299 12.0449C9.90299 12.3211 10.1269 12.5449 10.403 12.5449H14.0394C14.3155 12.5449 14.5394 12.3211 14.5394 12.0449C14.5394 11.7688 14.3155 11.5449 14.0394 11.5449H10.403Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_7289_18670">+ <rect+ width="16"+ height="16"+ fill="white"+ transform="translate(0 0.0449219)"+ />+ </clipPath>+ </defs>+</svg> `;++export const ImageIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.99992 2.7085C3.73427 2.7085 2.70825 3.73451 2.70825 5.00016V13.3335V15.0002C2.70825 16.2658 3.73427 17.2918 4.99992 17.2918H14.9999C16.2656 17.2918 17.2916 16.2658 17.2916 15.0002V11.6668V5.00016C17.2916 3.73451 16.2656 2.7085 14.9999 2.7085H4.99992ZM3.95825 15.0002V13.5924L7.59668 9.95395C8.00348 9.54715 8.66303 9.54715 9.06982 9.95395L11.2246 12.1088L12.8913 13.7754C13.1354 14.0195 13.5311 14.0195 13.7752 13.7754C14.0193 13.5314 14.0193 13.1356 13.7752 12.8916L12.5505 11.6668L13.43 10.7873C13.8368 10.3805 14.4964 10.3805 14.9032 10.7873L16.0416 11.9257V15.0002C16.0416 15.5755 15.5752 16.0418 14.9999 16.0418H4.99992C4.42462 16.0418 3.95825 15.5755 3.95825 15.0002ZM9.9537 9.07007L11.6666 10.7829L12.5461 9.9034C13.4411 9.00845 14.8921 9.00845 15.787 9.9034L16.0416 10.1579V5.00016C16.0416 4.42487 15.5752 3.9585 14.9999 3.9585H4.99992C4.42462 3.9585 3.95825 4.42487 3.95825 5.00016V11.8246L6.7128 9.07007C7.60775 8.17512 9.05875 8.17511 9.9537 9.07007ZM11.6666 7.50016C12.1268 7.50016 12.4999 7.12707 12.4999 6.66683C12.4999 6.20659 12.1268 5.8335 11.6666 5.8335C11.2063 5.8335 10.8333 6.20659 10.8333 6.66683C10.8333 7.12707 11.2063 7.50016 11.6666 7.50016Z"+ fill="#77757D"+ />+</svg> `;++export const SmallImageIcon = html`<svg+ width="16"+ height="17"+ viewBox="0 0 16 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_7289_20293)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4 2.6665C2.98748 2.6665 2.16666 3.48732 2.16666 4.49984V11.1665V12.4998C2.16666 13.5124 2.98748 14.3332 4 14.3332H12C13.0125 14.3332 13.8333 13.5124 13.8333 12.4998V9.83317V4.49984C13.8333 3.48732 13.0125 2.6665 12 2.6665H4ZM3.16666 12.4998V11.3736L6.07741 8.46287C6.40284 8.13743 6.93048 8.13743 7.25592 8.46287L8.97978 10.1867L10.3131 11.5201C10.5084 11.7153 10.825 11.7153 11.0202 11.5201C11.2155 11.3248 11.2155 11.0082 11.0202 10.813L10.0404 9.83317L10.7441 9.12953C11.0695 8.8041 11.5971 8.8041 11.9226 9.12953L12.8333 10.0403V12.4998C12.8333 12.9601 12.4602 13.3332 12 13.3332H4C3.53976 13.3332 3.16666 12.9601 3.16666 12.4998ZM7.96303 7.75576L9.33333 9.12606L10.037 8.42243C10.7529 7.70647 11.9137 7.70646 12.6297 8.42243L12.8333 8.62606V4.49984C12.8333 4.0396 12.4602 3.6665 12 3.6665H4C3.53976 3.6665 3.16666 4.0396 3.16666 4.49984V9.9594L5.3703 7.75576C6.08626 7.0398 7.24706 7.0398 7.96303 7.75576ZM9.33333 6.49984C9.70152 6.49984 10 6.20136 10 5.83317C10 5.46498 9.70152 5.1665 9.33333 5.1665C8.96514 5.1665 8.66666 5.46498 8.66666 5.83317C8.66666 6.20136 8.96514 6.49984 9.33333 6.49984Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_7289_20293">+ <rect width="16" height="16" fill="white" transform="translate(0 0.5)" />+ </clipPath>+ </defs>+</svg> `;++export const DocIcon = html`<svg+ width="16"+ height="17"+ viewBox="0 0 16 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_7289_21903)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.66667 2.6665C3.65415 2.6665 2.83334 3.48732 2.83334 4.49984V12.4998C2.83334 13.5124 3.65415 14.3332 4.66667 14.3332H11.3333C12.3459 14.3332 13.1667 13.5124 13.1667 12.4998V4.49984C13.1667 3.48732 12.3459 2.6665 11.3333 2.6665H4.66667ZM3.83334 4.49984C3.83334 4.0396 4.20643 3.6665 4.66667 3.6665H11.3333C11.7936 3.6665 12.1667 4.0396 12.1667 4.49984V12.4998C12.1667 12.9601 11.7936 13.3332 11.3333 13.3332H4.66667C4.20643 13.3332 3.83334 12.9601 3.83334 12.4998V4.49984ZM6 5.33317C5.72386 5.33317 5.5 5.55703 5.5 5.83317C5.5 6.10931 5.72386 6.33317 6 6.33317H8.33334C8.60948 6.33317 8.83334 6.10931 8.83334 5.83317C8.83334 5.55703 8.60948 5.33317 8.33334 5.33317H6ZM5.5 8.1665C5.5 7.89036 5.72386 7.6665 6 7.6665H10C10.2761 7.6665 10.5 7.89036 10.5 8.1665C10.5 8.44265 10.2761 8.6665 10 8.6665H6C5.72386 8.6665 5.5 8.44265 5.5 8.1665ZM6 9.99984C5.72386 9.99984 5.5 10.2237 5.5 10.4998C5.5 10.776 5.72386 10.9998 6 10.9998H9.33334C9.60948 10.9998 9.83334 10.776 9.83334 10.4998C9.83334 10.2237 9.60948 9.99984 9.33334 9.99984H6Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_7289_21903">+ <rect width="16" height="16" fill="white" transform="translate(0 0.5)" />+ </clipPath>+ </defs>+</svg> `;++export const DownArrowIcon = html`<svg+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M17.5073 13.0032C17.2022 12.723 16.7278 12.7432 16.4476 13.0483L12.75 17.0745L12.75 5C12.75 4.58579 12.4142 4.25 12 4.25C11.5858 4.25 11.25 4.58579 11.25 5L11.25 17.0745L7.55239 13.0483C7.27222 12.7432 6.79777 12.723 6.49269 13.0032C6.18761 13.2833 6.16742 13.7578 6.4476 14.0629L11.4476 19.5073C11.5896 19.662 11.79 19.75 12 19.75C12.21 19.75 12.4104 19.662 12.5524 19.5073L17.5524 14.0629C17.8326 13.7578 17.8124 13.2833 17.5073 13.0032Z"+ fill="#77757D"+ />+</svg> `;++export const CloseIcon = html`<svg+ width="12"+ height="12"+ viewBox="0 0 12 12"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M2.73483 2.73483C2.88128 2.58839 3.11872 2.58839 3.26517 2.73483L6 5.46967L8.73484 2.73484C8.88128 2.58839 9.11872 2.58839 9.26516 2.73484C9.41161 2.88128 9.41161 3.11872 9.26516 3.26517L6.53033 6L9.26516 8.73484C9.41161 8.88128 9.41161 9.11872 9.26516 9.26516C9.11872 9.41161 8.88128 9.41161 8.73483 9.26516L6 6.53033L3.26517 9.26516C3.11872 9.41161 2.88128 9.41161 2.73483 9.26516C2.58839 9.11872 2.58839 8.88128 2.73483 8.73484L5.46967 6L2.73483 3.26516C2.58839 3.11872 2.58839 2.88128 2.73483 2.73483Z"+ fill="#77757D"+ />+</svg> `;++export const ReplaceIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M14.8142 11.2536C14.6948 11.3846 14.5255 11.4588 14.3483 11.4577C14.1712 11.4566 14.0028 11.3803 13.885 11.2479L12.0332 9.16458C11.8039 8.90659 11.8271 8.51154 12.0851 8.28222C12.3431 8.05289 12.7381 8.07613 12.9675 8.33412L13.7272 9.18881V4.99935C13.7272 4.88429 13.6339 4.79102 13.5188 4.79102H8.33366C7.98849 4.79102 7.70866 4.51119 7.70866 4.16602C7.70866 3.82084 7.98849 3.54102 8.33366 3.54102H13.5188C14.3243 3.54102 14.9772 4.19393 14.9772 4.99935V9.2187L15.7883 8.32842C16.0208 8.07326 16.4161 8.05488 16.6713 8.28735C16.9264 8.51982 16.9448 8.91513 16.7123 9.17028L14.8142 11.2536ZM5.60315 8.74508C5.72248 8.61411 5.8918 8.53994 6.06898 8.54103C6.24616 8.54212 6.41456 8.61836 6.53227 8.75079L8.38413 10.8341C8.61345 11.0921 8.59021 11.4872 8.33222 11.7165C8.07423 11.9458 7.67919 11.9226 7.44987 11.6646L6.69014 10.8099V14.9993C6.69014 15.1144 6.78342 15.2077 6.89848 15.2077H12.0837C12.4288 15.2077 12.7087 15.4875 12.7087 15.8327C12.7087 16.1779 12.4288 16.4577 12.0837 16.4577H6.89848C6.09306 16.4577 5.44014 15.8048 5.44014 14.9993V10.78L4.62899 11.6703C4.39652 11.9254 4.00122 11.9438 3.74607 11.7113C3.49091 11.4789 3.47252 11.0836 3.705 10.8284L5.60315 8.74508Z"+ />+</svg> `;++export const InsertBelowIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M3.54199 5.41602C3.54199 5.07084 3.82181 4.79102 4.16699 4.79102H15.8337C16.1788 4.79102 16.4587 5.07084 16.4587 5.41602C16.4587 5.76119 16.1788 6.04102 15.8337 6.04102H4.16699C3.82181 6.04102 3.54199 5.76119 3.54199 5.41602ZM3.54199 8.33268C3.54199 7.9875 3.82181 7.70768 4.16699 7.70768H15.8337C16.1788 7.70768 16.4587 7.9875 16.4587 8.33268C16.4587 8.67786 16.1788 8.95768 15.8337 8.95768H4.16699C3.82181 8.95768 3.54199 8.67786 3.54199 8.33268ZM10.8337 10.6243C10.4885 10.6243 10.2087 10.9042 10.2087 11.2493C10.2087 11.5945 10.4885 11.8743 10.8337 11.8743H15.8337C16.1788 11.8743 16.4587 11.5945 16.4587 11.2493C16.4587 10.9042 16.1788 10.6243 15.8337 10.6243H10.8337ZM10.2087 14.166C10.2087 13.8208 10.4885 13.541 10.8337 13.541H15.8337C16.1788 13.541 16.4587 13.8208 16.4587 14.166C16.4587 14.5112 16.1788 14.791 15.8337 14.791H10.8337C10.4885 14.791 10.2087 14.5112 10.2087 14.166ZM5.20866 10.8327C5.20866 10.4875 4.92884 10.2077 4.58366 10.2077C4.23848 10.2077 3.95866 10.4875 3.95866 10.8327V13.3327C3.95866 13.6779 4.23848 13.9577 4.58366 13.9577H6.87533V14.5827C6.87533 14.8355 7.0276 15.0634 7.26115 15.1601C7.49469 15.2568 7.76352 15.2034 7.94227 15.0246L9.19227 13.7746C9.43635 13.5305 9.43635 13.1348 9.19227 12.8907L7.94227 11.6407C7.76352 11.462 7.49469 11.4085 7.26115 11.5053C7.0276 11.602 6.87533 11.8299 6.87533 12.0827V12.7077H5.20866V10.8327Z"+ />+</svg> `;++export const InsertTopIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M5.20833 9.16668C5.20833 9.51186 4.92851 9.79168 4.58333 9.79168C4.23816 9.79168 3.95833 9.51186 3.95833 9.16668V6.66668C3.95833 6.32151 4.23816 6.04168 4.58333 6.04168H6.875V5.41668C6.875 5.1639 7.02728 4.936 7.26082 4.83926C7.49437 4.74252 7.76319 4.79599 7.94194 4.97474L9.19194 6.22474C9.43602 6.46882 9.43602 6.86455 9.19194 7.10863L7.94194 8.35863C7.76319 8.53738 7.49437 8.59085 7.26082 8.49411C7.02728 8.39737 6.875 8.16947 6.875 7.91668V7.29168H5.20833V9.16668ZM10.2083 5.83335C10.2083 5.48817 10.4882 5.20835 10.8333 5.20835H15.8333C16.1785 5.20835 16.4583 5.48817 16.4583 5.83335C16.4583 6.17853 16.1785 6.45835 15.8333 6.45835H10.8333C10.4882 6.45835 10.2083 6.17853 10.2083 5.83335ZM10.2083 8.75002C10.2083 8.40484 10.4882 8.12502 10.8333 8.12502H15.8333C16.1785 8.12502 16.4583 8.40484 16.4583 8.75002C16.4583 9.0952 16.1785 9.37502 15.8333 9.37502H10.8333C10.4882 9.37502 10.2083 9.0952 10.2083 8.75002ZM4.16667 11.0417C3.82149 11.0417 3.54167 11.3215 3.54167 11.6667C3.54167 12.0119 3.82149 12.2917 4.16667 12.2917H15.8333C16.1785 12.2917 16.4583 12.0119 16.4583 11.6667C16.4583 11.3215 16.1785 11.0417 15.8333 11.0417H4.16667ZM3.54167 14.5834C3.54167 14.2382 3.82149 13.9584 4.16667 13.9584H15.8333C16.1785 13.9584 16.4583 14.2382 16.4583 14.5834C16.4583 14.9285 16.1785 15.2084 15.8333 15.2084H4.16667C3.82149 15.2084 3.54167 14.9285 3.54167 14.5834Z"+ />+</svg>`;++export const NewBlockIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_9809_47818)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M9.74916 2.34342C9.90886 2.27355 10.0905 2.27355 10.2502 2.34342L16.9169 5.26008C17.1443 5.35961 17.2913 5.58437 17.2913 5.83268V14.166C17.2913 14.4143 17.1443 14.6391 16.9169 14.7386L10.2502 17.6553C10.0905 17.7251 9.90886 17.7251 9.74916 17.6553L3.0825 14.7386C2.855 14.6391 2.70801 14.4143 2.70801 14.166V5.83268C2.70801 5.58437 2.855 5.35961 3.0825 5.26008L9.74916 2.34342ZM3.95801 6.78832V13.7573L9.37467 16.127V9.15811L3.95801 6.78832ZM10.6247 9.15811V16.127L16.0413 13.7573V6.78832L10.6247 9.15811ZM15.107 5.83268L9.99967 8.06715L4.89232 5.83268L9.99967 3.59821L15.107 5.83268Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_9809_47818">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const CreateIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_9809_87475)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M5.83366 2.70898C4.56801 2.70898 3.54199 3.735 3.54199 5.00065V15.0007C3.54199 16.2663 4.56801 17.2923 5.83366 17.2923H14.167C15.4326 17.2923 16.4587 16.2663 16.4587 15.0007V5.00065C16.4587 3.735 15.4326 2.70898 14.167 2.70898H5.83366ZM4.79199 5.00065C4.79199 4.42535 5.25836 3.95898 5.83366 3.95898H14.167C14.7423 3.95898 15.2087 4.42535 15.2087 5.00065V15.0007C15.2087 15.5759 14.7423 16.0423 14.167 16.0423H5.83366C5.25836 16.0423 4.79199 15.5759 4.79199 15.0007V5.00065ZM7.50033 6.04232C7.15515 6.04232 6.87533 6.32214 6.87533 6.66732C6.87533 7.0125 7.15515 7.29232 7.50033 7.29232H10.417C10.7622 7.29232 11.042 7.0125 11.042 6.66732C11.042 6.32214 10.7622 6.04232 10.417 6.04232H7.50033ZM6.87533 9.58398C6.87533 9.23881 7.15515 8.95898 7.50033 8.95898H12.5003C12.8455 8.95898 13.1253 9.23881 13.1253 9.58398C13.1253 9.92916 12.8455 10.209 12.5003 10.209H7.50033C7.15515 10.209 6.87533 9.92916 6.87533 9.58398ZM7.50033 11.8757C7.15515 11.8757 6.87533 12.1555 6.87533 12.5007C6.87533 12.8458 7.15515 13.1257 7.50033 13.1257H11.667C12.0122 13.1257 12.292 12.8458 12.292 12.5007C12.292 12.1555 12.0122 11.8757 11.667 11.8757H7.50033Z"+ />+ </g>+ <defs>+ <clipPath id="clip0_9809_87475">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AffineAvatarIcon = html`<svg+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ d="M11.2812 5.49104C11.2403 5.13024 10.9353 4.85751 10.5722 4.85714C10.2091 4.85677 9.90345 5.12887 9.86185 5.48959C9.59131 7.83515 8.89003 9.48448 7.75868 10.6158C6.62734 11.7472 4.97801 12.4485 2.63244 12.719C2.27173 12.7606 1.99963 13.0662 2 13.4293C2.00037 13.7924 2.2731 14.0975 2.63389 14.1383C4.94069 14.3996 6.62508 15.1006 7.78328 16.2379C8.93713 17.3709 9.65305 19.0198 9.85994 21.3489C9.89271 21.7178 10.2019 22.0004 10.5722 22C10.9425 21.9996 11.2511 21.7162 11.2831 21.3473C11.4813 19.0565 12.1966 17.3729 13.3562 16.2133C14.5157 15.0537 16.1994 14.3385 18.4902 14.1402C18.8591 14.1083 19.1424 13.7997 19.1429 13.4294C19.1433 13.0591 18.8606 12.7499 18.4918 12.7171C16.1627 12.5102 14.5137 11.7943 13.3807 10.6404C12.2435 9.48222 11.5425 7.79783 11.2812 5.49104Z"+ fill="#1E96EB"+ />+ <path+ d="M18.9427 2.24651C18.9268 2.1062 18.8082 2.00014 18.667 2C18.5257 1.99986 18.4069 2.10567 18.3907 2.24595C18.2855 3.15811 18.0128 3.79952 17.5728 4.23949C17.1329 4.67946 16.4914 4.95218 15.5793 5.05739C15.439 5.07356 15.3332 5.19241 15.3333 5.33362C15.3335 5.47482 15.4395 5.59345 15.5798 5.60935C16.4769 5.71096 17.132 5.98357 17.5824 6.42584C18.0311 6.86644 18.3095 7.50771 18.39 8.41347C18.4027 8.55691 18.523 8.66683 18.667 8.66667C18.811 8.6665 18.931 8.55632 18.9434 8.41284C19.0205 7.52199 19.2987 6.86723 19.7496 6.41629C20.2006 5.96534 20.8553 5.68719 21.7462 5.61008C21.8896 5.59766 21.9998 5.47765 22 5.33365C22.0002 5.18964 21.8902 5.06939 21.7468 5.05664C20.841 4.97619 20.1998 4.69777 19.7592 4.24905C19.3169 3.79864 19.0443 3.1436 18.9427 2.24651Z"+ fill="#1E96EB"+ />+</svg> `;++export const ActionIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M7.50002 1.875C7.84519 1.875 8.12502 2.15482 8.12502 2.5V3.54167H10.6141C10.6215 3.54154 10.6289 3.54154 10.6363 3.54167H12.5C12.8452 3.54167 13.125 3.82149 13.125 4.16667C13.125 4.51184 12.8452 4.79167 12.5 4.79167H11.1457C10.6638 7.16518 9.64425 9.34282 8.21994 11.1922C8.50418 11.4886 8.80693 11.7614 9.12502 12C9.40116 12.2071 9.45712 12.5989 9.25002 12.875C9.04291 13.1511 8.65116 13.2071 8.37502 13C8.0371 12.7466 7.71603 12.4624 7.41396 12.1563C6.10806 13.5972 4.53708 14.7931 2.77816 15.6672C2.46905 15.8208 2.09393 15.6947 1.94032 15.3856C1.7867 15.0765 1.91276 14.7014 2.22187 14.5478C3.88548 13.721 5.36607 12.5816 6.58683 11.2065C5.71204 10.0729 5.07099 8.78956 4.74363 7.67633C4.64624 7.34517 4.83575 6.99777 5.16691 6.90039C5.49807 6.80301 5.84547 6.99252 5.94285 7.32367C6.20868 8.22765 6.71757 9.2665 7.39878 10.2054C8.57204 8.61888 9.42653 6.78272 9.86785 4.79167H2.91668C2.5715 4.79167 2.29168 4.51184 2.29168 4.16667C2.29168 3.82149 2.5715 3.54167 2.91668 3.54167H6.87502V2.5C6.87502 2.15482 7.15484 1.875 7.50002 1.875ZM13.3333 8.54167C13.5701 8.54167 13.7865 8.67542 13.8924 8.88716L16.8034 14.7093C16.8075 14.7169 16.8114 14.7247 16.8151 14.7326L18.059 17.2205C18.2134 17.5292 18.0883 17.9046 17.7795 18.059C17.4708 18.2134 17.0954 18.0882 16.941 17.7795L15.8637 15.625H10.803L9.7257 17.7795C9.57133 18.0882 9.19591 18.2134 8.88717 18.059C8.57844 17.9046 8.4533 17.5292 8.60767 17.2205L9.85161 14.7326C9.85535 14.7247 9.85924 14.7169 9.86328 14.7093L12.7743 8.88716C12.8802 8.67542 13.0966 8.54167 13.3333 8.54167ZM11.428 14.375H15.2387L13.3333 10.5642L11.428 14.375Z"+ />+</svg> `;++export const LanguageIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M7.50014 1.875C7.84532 1.875 8.12514 2.15482 8.12514 2.5V3.54167H10.6143C10.6216 3.54154 10.629 3.54154 10.6364 3.54167H12.5001C12.8453 3.54167 13.1251 3.82149 13.1251 4.16667C13.1251 4.51184 12.8453 4.79167 12.5001 4.79167H11.1458C10.6639 7.16518 9.64438 9.34282 8.22006 11.1922C8.5043 11.4886 8.80705 11.7614 9.12514 12C9.40128 12.2071 9.45724 12.5989 9.25014 12.875C9.04303 13.1511 8.65128 13.2071 8.37514 13C8.03723 12.7466 7.71615 12.4624 7.41408 12.1563C6.10818 13.5972 4.5372 14.7931 2.77828 15.6672C2.46917 15.8208 2.09406 15.6947 1.94044 15.3856C1.78683 15.0765 1.91288 14.7014 2.22199 14.5478C3.88561 13.721 5.36619 12.5816 6.58695 11.2065C5.71216 10.0729 5.07111 8.78956 4.74375 7.67633C4.64637 7.34517 4.83588 6.99777 5.16703 6.90039C5.49819 6.80301 5.84559 6.99252 5.94297 7.32367C6.2088 8.22765 6.71769 9.26651 7.3989 10.2054C8.57216 8.61889 9.42665 6.78272 9.86797 4.79167H2.9168C2.57163 4.79167 2.2918 4.51184 2.2918 4.16667C2.2918 3.82149 2.57163 3.54167 2.9168 3.54167H6.87514V2.5C6.87514 2.15482 7.15496 1.875 7.50014 1.875ZM13.3335 8.54167C13.5702 8.54167 13.7866 8.67542 13.8925 8.88716L16.8035 14.7093C16.8076 14.7169 16.8115 14.7247 16.8152 14.7326L18.0592 17.2205C18.2135 17.5292 18.0884 17.9046 17.7796 18.059C17.4709 18.2134 17.0955 18.0882 16.9411 17.7795L15.8639 15.625H10.8031L9.72582 17.7795C9.57145 18.0882 9.19603 18.2134 8.8873 18.059C8.57856 17.9046 8.45342 17.5292 8.60779 17.2205L9.85174 14.7326C9.85547 14.7247 9.85936 14.7169 9.86341 14.7093L12.7745 8.88716C12.8803 8.67542 13.0967 8.54167 13.3335 8.54167ZM11.4281 14.375H15.2389L13.3335 10.5642L11.4281 14.375Z"+ />+</svg> `;++export const ImproveWritingIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M8.54167 2.5C8.54167 2.15482 8.26184 1.875 7.91667 1.875C7.57149 1.875 7.29167 2.15482 7.29167 2.5V5C7.29167 5.34518 7.57149 5.625 7.91667 5.625C8.26184 5.625 8.54167 5.34518 8.54167 5V2.5ZM8.54167 10.8333C8.54167 10.4882 8.26184 10.2083 7.91667 10.2083C7.57149 10.2083 7.29167 10.4882 7.29167 10.8333V13.3333C7.29167 13.6785 7.57149 13.9583 7.91667 13.9583C8.26184 13.9583 8.54167 13.6785 8.54167 13.3333V10.8333ZM5.625 7.91667C5.625 8.26184 5.34518 8.54167 5 8.54167H2.5C2.15482 8.54167 1.875 8.26184 1.875 7.91667C1.875 7.57149 2.15482 7.29167 2.5 7.29167H5C5.34518 7.29167 5.625 7.57149 5.625 7.91667ZM13.3333 8.54167C13.6785 8.54167 13.9583 8.26184 13.9583 7.91667C13.9583 7.57149 13.6785 7.29167 13.3333 7.29167H10.8333C10.4882 7.29167 10.2083 7.57149 10.2083 7.91667C10.2083 8.26184 10.4882 8.54167 10.8333 8.54167H13.3333ZM6.29623 6.29623C6.05215 6.54031 5.65642 6.54031 5.41235 6.29623L3.64458 4.52846C3.4005 4.28439 3.4005 3.88866 3.64458 3.64458C3.88866 3.4005 4.28439 3.4005 4.52846 3.64458L6.29623 5.41235C6.54031 5.65642 6.54031 6.05215 6.29623 6.29623ZM15.8081 16.6919C16.0521 16.936 16.4479 16.936 16.6919 16.6919C16.936 16.4479 16.936 16.0521 16.6919 15.8081L10.421 9.53712C10.1769 9.29304 9.7812 9.29304 9.53712 9.53712C9.29304 9.7812 9.29304 10.1769 9.53712 10.421L15.8081 16.6919ZM6.29623 9.5371C6.54031 9.78118 6.54031 10.1769 6.29623 10.421L4.52846 12.1888C4.28439 12.4328 3.88866 12.4328 3.64458 12.1888C3.4005 11.9447 3.4005 11.5489 3.64458 11.3049L5.41235 9.5371C5.65642 9.29303 6.05215 9.29303 6.29623 9.5371ZM12.1888 4.52845C12.4328 4.28437 12.4328 3.88864 12.1888 3.64457C11.9447 3.40049 11.549 3.40049 11.3049 3.64457L9.53712 5.41233C9.29304 5.65641 9.29304 6.05214 9.53712 6.29622C9.7812 6.54029 10.1769 6.54029 10.421 6.29622L12.1888 4.52845Z"+ />+</svg> `;++export const AIDoneIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M16.2751 5.39143C16.5192 5.63551 16.5192 6.03124 16.2751 6.27532L7.94178 14.6086C7.6977 14.8527 7.30197 14.8527 7.0579 14.6086L3.72456 11.2753C3.48048 11.0312 3.48048 10.6355 3.72456 10.3914C3.96864 10.1474 4.36437 10.1474 4.60845 10.3914L7.49984 13.2828L15.3912 5.39143C15.6353 5.14735 16.031 5.14735 16.2751 5.39143Z"+ />+</svg> `;++export const ShorterIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.1665 4.79163C3.82133 4.79163 3.5415 5.07145 3.5415 5.41663C3.5415 5.7618 3.82133 6.04163 4.1665 6.04163H15.8332C16.1783 6.04163 16.4582 5.7618 16.4582 5.41663C16.4582 5.07145 16.1783 4.79163 15.8332 4.79163H4.1665ZM4.1665 7.70829C3.82133 7.70829 3.5415 7.98811 3.5415 8.33329C3.5415 8.67847 3.82133 8.95829 4.1665 8.95829H9.99984C10.345 8.95829 10.6248 8.67847 10.6248 8.33329C10.6248 7.98811 10.345 7.70829 9.99984 7.70829H4.1665Z"+ />+</svg> `;++export const LongerIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.1665 4.79163C3.82133 4.79163 3.5415 5.07145 3.5415 5.41663C3.5415 5.7618 3.82133 6.04163 4.1665 6.04163H15.8332C16.1783 6.04163 16.4582 5.7618 16.4582 5.41663C16.4582 5.07145 16.1783 4.79163 15.8332 4.79163H4.1665ZM4.1665 7.70829C3.82133 7.70829 3.5415 7.98811 3.5415 8.33329C3.5415 8.67847 3.82133 8.95829 4.1665 8.95829H15.8332C16.1783 8.95829 16.4582 8.67847 16.4582 8.33329C16.4582 7.98811 16.1783 7.70829 15.8332 7.70829H4.1665ZM3.5415 11.25C3.5415 10.9048 3.82133 10.625 4.1665 10.625H15.8332C16.1783 10.625 16.4582 10.9048 16.4582 11.25C16.4582 11.5951 16.1783 11.875 15.8332 11.875H4.1665C3.82133 11.875 3.5415 11.5951 3.5415 11.25ZM4.1665 13.5416C3.82133 13.5416 3.5415 13.8214 3.5415 14.1666C3.5415 14.5118 3.82133 14.7916 4.1665 14.7916H9.99984C10.345 14.7916 10.6248 14.5118 10.6248 14.1666C10.6248 13.8214 10.345 13.5416 9.99984 13.5416H4.1665Z"+ />+</svg> `;++export const ExplainIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.1665 4.375C3.82133 4.375 3.5415 4.65482 3.5415 5V15C3.5415 15.3452 3.82133 15.625 4.1665 15.625H5.83317C6.17835 15.625 6.45817 15.3452 6.45817 15C6.45817 14.6548 6.17835 14.375 5.83317 14.375H4.7915V5.625H5.83317C6.17835 5.625 6.45817 5.34518 6.45817 5C6.45817 4.65482 6.17835 4.375 5.83317 4.375H4.1665ZM15.8332 4.375C16.1783 4.375 16.4582 4.65482 16.4582 5V15C16.4582 15.3452 16.1783 15.625 15.8332 15.625H14.1665C13.8213 15.625 13.5415 15.3452 13.5415 15C13.5415 14.6548 13.8213 14.375 14.1665 14.375H15.2082V5.625H14.1665C13.8213 5.625 13.5415 5.34518 13.5415 5C13.5415 4.65482 13.8213 4.375 14.1665 4.375H15.8332Z"+ />+</svg> `;++export const AIExplainIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_38120)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.1665 4.375C3.82133 4.375 3.5415 4.65482 3.5415 5V15C3.5415 15.3452 3.82133 15.625 4.1665 15.625H5.83317C6.17835 15.625 6.45817 15.3452 6.45817 15C6.45817 14.6548 6.17835 14.375 5.83317 14.375H4.7915V5.625H5.83317C6.17835 5.625 6.45817 5.34518 6.45817 5C6.45817 4.65482 6.17835 4.375 5.83317 4.375H4.1665ZM15.8332 4.375C16.1783 4.375 16.4582 4.65482 16.4582 5V15C16.4582 15.3452 16.1783 15.625 15.8332 15.625H14.1665C13.8213 15.625 13.5415 15.3452 13.5415 15C13.5415 14.6548 13.8213 14.375 14.1665 14.375H15.2082V5.625H14.1665C13.8213 5.625 13.5415 5.34518 13.5415 5C13.5415 4.65482 13.8213 4.375 14.1665 4.375H15.8332Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_38120">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const SelectionIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M5.00016 2.70837C3.73451 2.70837 2.7085 3.73439 2.7085 5.00004V15C2.7085 16.2657 3.73451 17.2917 5.00016 17.2917H9.16683C9.51201 17.2917 9.79183 17.0119 9.79183 16.6667C9.79183 16.3215 9.51201 16.0417 9.16683 16.0417H5.00016C4.42487 16.0417 3.9585 15.5753 3.9585 15V5.00004C3.9585 4.42474 4.42487 3.95837 5.00016 3.95837H15.0002C15.5755 3.95837 16.0418 4.42474 16.0418 5.00004V9.16671C16.0418 9.51189 16.3217 9.79171 16.6668 9.79171C17.012 9.79171 17.2918 9.51189 17.2918 9.16671V5.00004C17.2918 3.73439 16.2658 2.70837 15.0002 2.70837H5.00016ZM11.616 11.076C11.2776 10.9436 10.9438 11.2775 11.0762 11.6159L13.54 17.9123C13.6801 18.2704 14.1891 18.2637 14.3198 17.9021L15.2048 15.4548C15.2469 15.3384 15.3385 15.2467 15.4549 15.2046L17.9023 14.3197C18.2639 14.1889 18.2705 13.68 17.9124 13.5398L11.616 11.076Z"+ />+</svg>`;++export const AIExplainSelectionIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_32480)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M5.00016 2.70837C3.73451 2.70837 2.7085 3.73439 2.7085 5.00004V15C2.7085 16.2657 3.73451 17.2917 5.00016 17.2917H9.16683C9.51201 17.2917 9.79183 17.0119 9.79183 16.6667C9.79183 16.3215 9.51201 16.0417 9.16683 16.0417H5.00016C4.42487 16.0417 3.9585 15.5753 3.9585 15V5.00004C3.9585 4.42474 4.42487 3.95837 5.00016 3.95837H15.0002C15.5755 3.95837 16.0418 4.42474 16.0418 5.00004V9.16671C16.0418 9.51189 16.3217 9.79171 16.6668 9.79171C17.012 9.79171 17.2918 9.51189 17.2918 9.16671V5.00004C17.2918 3.73439 16.2658 2.70837 15.0002 2.70837H5.00016ZM11.616 11.076C11.2776 10.9436 10.9438 11.2775 11.0762 11.6159L13.54 17.9123C13.6801 18.2704 14.1891 18.2637 14.3198 17.9021L15.2048 15.4548C15.2469 15.3384 15.3385 15.2467 15.4549 15.2046L17.9023 14.3197C18.2639 14.1889 18.2705 13.68 17.9124 13.5398L11.616 11.076Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_32480">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const ToneIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M7.6411 7.08838L6.71487 9.4857C6.60938 9.75873 6.34683 9.93875 6.05413 9.93875H3.3335C2.98832 9.93875 2.7085 9.65893 2.7085 9.31375C2.7085 8.96857 2.98832 8.68875 3.3335 8.68875H5.68272L7.09896 5.02319C7.34911 4.37576 8.28457 4.43706 8.44809 5.11159L10.0805 11.8452L11.5785 7.1197C11.7512 6.57492 12.4648 6.44842 12.8142 6.90064L14.196 8.68875H16.6668C17.012 8.68875 17.2918 8.96857 17.2918 9.31375C17.2918 9.65893 17.012 9.93875 16.6668 9.93875H13.93C13.7106 9.93875 13.5036 9.83711 13.3695 9.66353L12.4575 8.48336L10.6861 14.0712C10.4695 14.7545 9.49134 14.7206 9.32248 14.024L7.6411 7.08838Z"+ />+</svg> `;++export const AIChangeToneIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_43808)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M7.6411 7.08838L6.71487 9.4857C6.60938 9.75873 6.34683 9.93875 6.05413 9.93875H3.3335C2.98832 9.93875 2.7085 9.65893 2.7085 9.31375C2.7085 8.96857 2.98832 8.68875 3.3335 8.68875H5.68272L7.09896 5.02319C7.34911 4.37576 8.28457 4.43706 8.44809 5.11159L10.0805 11.8452L11.5785 7.1197C11.7512 6.57492 12.4648 6.44842 12.8142 6.90064L14.196 8.68875H16.6668C17.012 8.68875 17.2918 8.96857 17.2918 9.31375C17.2918 9.65893 17.012 9.93875 16.6668 9.93875H13.93C13.7106 9.93875 13.5036 9.83711 13.3695 9.66353L12.4575 8.48336L10.6861 14.0712C10.4695 14.7545 9.49134 14.7206 9.32248 14.024L7.6411 7.08838Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_43808">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AISearchIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M3.125 7.91667C3.125 5.2703 5.2703 3.125 7.91667 3.125C10.563 3.125 12.7083 5.2703 12.7083 7.91667C12.7083 10.563 10.563 12.7083 7.91667 12.7083C5.2703 12.7083 3.125 10.563 3.125 7.91667ZM7.91667 1.875C4.57995 1.875 1.875 4.57995 1.875 7.91667C1.875 11.2534 4.57995 13.9583 7.91667 13.9583C9.35991 13.9583 10.685 13.4523 11.724 12.6079L16.2247 17.1086C16.4688 17.3527 16.8645 17.3527 17.1086 17.1086C17.3527 16.8645 17.3527 16.4688 17.1086 16.2247L12.6079 11.724C13.4523 10.685 13.9583 9.35991 13.9583 7.91667C13.9583 4.57995 11.2534 1.875 7.91667 1.875Z"+ />+</svg> `;++export const AIImproveWritingIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_43819)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M8.54167 2.5C8.54167 2.15482 8.26184 1.875 7.91667 1.875C7.57149 1.875 7.29167 2.15482 7.29167 2.5V5C7.29167 5.34518 7.57149 5.625 7.91667 5.625C8.26184 5.625 8.54167 5.34518 8.54167 5V2.5ZM8.54167 10.8333C8.54167 10.4882 8.26184 10.2083 7.91667 10.2083C7.57149 10.2083 7.29167 10.4882 7.29167 10.8333V13.3333C7.29167 13.6785 7.57149 13.9583 7.91667 13.9583C8.26184 13.9583 8.54167 13.6785 8.54167 13.3333V10.8333ZM5.625 7.91667C5.625 8.26184 5.34518 8.54167 5 8.54167H2.5C2.15482 8.54167 1.875 8.26184 1.875 7.91667C1.875 7.57149 2.15482 7.29167 2.5 7.29167H5C5.34518 7.29167 5.625 7.57149 5.625 7.91667ZM13.3333 8.54167C13.6785 8.54167 13.9583 8.26184 13.9583 7.91667C13.9583 7.57149 13.6785 7.29167 13.3333 7.29167H10.8333C10.4882 7.29167 10.2083 7.57149 10.2083 7.91667C10.2083 8.26184 10.4882 8.54167 10.8333 8.54167H13.3333ZM6.29623 6.29623C6.05215 6.54031 5.65642 6.54031 5.41235 6.29623L3.64458 4.52846C3.4005 4.28439 3.4005 3.88866 3.64458 3.64458C3.88866 3.4005 4.28439 3.4005 4.52846 3.64458L6.29623 5.41235C6.54031 5.65642 6.54031 6.05215 6.29623 6.29623ZM15.8081 16.6919C16.0521 16.936 16.4479 16.936 16.6919 16.6919C16.936 16.4479 16.936 16.0521 16.6919 15.8081L10.421 9.53712C10.1769 9.29304 9.7812 9.29304 9.53712 9.53712C9.29304 9.7812 9.29304 10.1769 9.53712 10.421L15.8081 16.6919ZM6.29623 9.5371C6.54031 9.78118 6.54031 10.1769 6.29623 10.421L4.52846 12.1888C4.28439 12.4328 3.88866 12.4328 3.64458 12.1888C3.4005 11.9447 3.4005 11.5489 3.64458 11.3049L5.41235 9.5371C5.65642 9.29303 6.05215 9.29303 6.29623 9.5371ZM12.1888 4.52845C12.4328 4.28437 12.4328 3.88864 12.1888 3.64457C11.9447 3.40049 11.549 3.40049 11.3049 3.64457L9.53712 5.41233C9.29304 5.65641 9.29304 6.05214 9.53712 6.29622C9.7812 6.54029 10.1769 6.54029 10.421 6.29622L12.1888 4.52845Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_43819">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIMakeLongerIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_61753)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.1665 4.79163C3.82133 4.79163 3.5415 5.07145 3.5415 5.41663C3.5415 5.7618 3.82133 6.04163 4.1665 6.04163H15.8332C16.1783 6.04163 16.4582 5.7618 16.4582 5.41663C16.4582 5.07145 16.1783 4.79163 15.8332 4.79163H4.1665ZM4.1665 7.70829C3.82133 7.70829 3.5415 7.98811 3.5415 8.33329C3.5415 8.67847 3.82133 8.95829 4.1665 8.95829H15.8332C16.1783 8.95829 16.4582 8.67847 16.4582 8.33329C16.4582 7.98811 16.1783 7.70829 15.8332 7.70829H4.1665ZM3.5415 11.25C3.5415 10.9048 3.82133 10.625 4.1665 10.625H15.8332C16.1783 10.625 16.4582 10.9048 16.4582 11.25C16.4582 11.5951 16.1783 11.875 15.8332 11.875H4.1665C3.82133 11.875 3.5415 11.5951 3.5415 11.25ZM4.1665 13.5416C3.82133 13.5416 3.5415 13.8214 3.5415 14.1666C3.5415 14.5118 3.82133 14.7916 4.1665 14.7916H9.99984C10.345 14.7916 10.6248 14.5118 10.6248 14.1666C10.6248 13.8214 10.345 13.5416 9.99984 13.5416H4.1665Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_61753">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIMakeShorterIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_16541)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M4.1665 4.79163C3.82133 4.79163 3.5415 5.07145 3.5415 5.41663C3.5415 5.7618 3.82133 6.04163 4.1665 6.04163H15.8332C16.1783 6.04163 16.4582 5.7618 16.4582 5.41663C16.4582 5.07145 16.1783 4.79163 15.8332 4.79163H4.1665ZM4.1665 7.70829C3.82133 7.70829 3.5415 7.98811 3.5415 8.33329C3.5415 8.67847 3.82133 8.95829 4.1665 8.95829H9.99984C10.345 8.95829 10.6248 8.67847 10.6248 8.33329C10.6248 7.98811 10.345 7.70829 9.99984 7.70829H4.1665Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_16541">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIMakeRealIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_13930_69049)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M1.89506 9.08921C1.36098 9.7358 1.85634 10.708 2.69338 10.656L5.70784 10.4686L7.3281 13.0175C7.77801 13.7253 8.85573 13.5546 9.06491 12.7424L9.63712 10.5208L15.8083 16.6919C16.0524 16.936 16.4481 16.936 16.6922 16.6919C16.9362 16.4479 16.9362 16.0521 16.6922 15.8081L10.5208 9.63666L12.743 9.0643C13.5552 8.85512 13.7259 7.7774 13.0181 7.32749L10.4692 5.70723L10.6566 2.69278C10.7086 1.85574 9.73642 1.36036 9.08982 1.89445L6.76121 3.81789L3.9522 2.70817C3.17221 2.40003 2.40064 3.17159 2.70878 3.95159L3.8185 6.7606L1.89506 9.08921ZM5.80215 9.21036L3.28715 9.36669L4.8919 7.42389C5.11419 7.15478 5.17258 6.7861 5.04433 6.46147L4.11848 4.11787L6.46208 5.04372C6.78671 5.17197 7.15539 5.11358 7.4245 4.89129L9.36729 3.28654L9.21097 5.80154C9.18931 6.14991 9.35878 6.48251 9.65335 6.66975L11.7799 8.02156L9.33969 8.65007C9.00168 8.73713 8.73774 9.00107 8.65068 9.33909L8.02217 11.7793L6.67036 9.65274C6.48312 9.35817 6.15052 9.18871 5.80215 9.21036Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_13930_69049">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIPenIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M16.0654 3.93417C15.5409 3.41078 14.6902 3.41078 14.1658 3.93417L13.4285 4.67003L15.3263 6.56414L16.0654 5.82654C16.5891 5.30384 16.5891 4.45687 16.0654 3.93417ZM14.4416 7.44716L12.5437 5.55304L3.5415 14.5375V16.4583H5.41262L14.4416 7.44716ZM13.2828 3.04941C14.2951 2.03903 15.936 2.03903 16.9484 3.04941C17.9614 4.06047 17.9614 5.70024 16.9484 6.7113L6.11265 17.5257C5.99547 17.6427 5.83669 17.7083 5.67114 17.7083H2.9165C2.57133 17.7083 2.2915 17.4285 2.2915 17.0833V14.2783C2.2915 14.1123 2.35752 13.9532 2.475 13.8359L13.2828 3.04941Z"+ />+</svg> `;++export const AIPenIconWithAnimation = html`<dotlottie-player+ src='{"v":"5.12.1","fr":120,"ip":0,"op":151,"w":300,"h":300,"nm":"Pen","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Pen 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.207],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":48,"s":[-89]},{"t":98,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.207,"y":1},"o":{"x":0.5,"y":0},"t":48,"s":[258.044,260.849,0],"to":[0,0,0],"ti":[0,0,0]},{"t":98,"s":[42.044,260.849,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0.75,19.25,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,1.017]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":48,"s":[1178,1178,100]},{"i":{"x":[0.403,0.403,0],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.017]},"t":72.324,"s":[975,975,100]},{"t":98,"s":[1178,1178,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[2.371,-5.714],[5.71,-2.38],[6.77,-3.443],[3.431,-6.775]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-9.402,8.652],[-7.902,8.652],[-7.902,5.286],[-9.402,5.286]],"c":true},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0]],"o":[[0,0]],"v":[[-9.402,5.286]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ind":3,"ty":"sh","ix":4,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[3.788,-8.189],[-9.182,4.755],[-8.122,5.816],[4.847,-7.128]],"c":true},"ix":2},"nm":"路径 4","mn":"ADBE Vector Shape - Group","hd":false},{"ind":4,"ty":"sh","ix":5,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-5.346,7.902],[-8.652,7.902],[-8.652,9.402],[-5.346,9.402]],"c":true},"ix":2},"nm":"路径 5","mn":"ADBE Vector Shape - Group","hd":false},{"ind":5,"ty":"sh","ix":6,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[7.127,-4.857],[-5.876,8.12],[-4.816,9.182],[8.186,-3.794]],"c":true},"ix":2},"nm":"路径 6","mn":"ADBE Vector Shape - Group","hd":false},{"ind":6,"ty":"sh","ix":7,"ks":{"a":0,"k":{"i":[[0,0],[0.628,-0.627],[0,0],[1.216,1.214]],"o":[[0.628,0.627],[0,0],[1.216,-1.214],[0,0]],"v":[[7.127,-7.128],[7.127,-4.857],[8.186,-3.794],[8.186,-8.189]],"c":true},"ix":2},"nm":"路径 7","mn":"ADBE Vector Shape - Group","hd":false},{"ind":7,"ty":"sh","ix":8,"ks":{"a":0,"k":{"i":[[0,0],[-0.629,-0.628],[0,0],[1.215,-1.212]],"o":[[0.63,-0.628],[0,0],[-1.214,-1.212],[0,0]],"v":[[4.847,-7.128],[7.127,-7.128],[8.186,-8.189],[3.788,-8.189]],"c":true},"ix":2},"nm":"路径 8","mn":"ADBE Vector Shape - Group","hd":false},{"ind":8,"ty":"sh","ix":9,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,-0.199]],"o":[[0,0],[-0.141,0.141],[0,0]],"v":[[-8.652,5.286],[-9.182,4.755],[-9.402,5.286]],"c":true},"ix":2},"nm":"路径 9","mn":"ADBE Vector Shape - Group","hd":false},{"ind":9,"ty":"sh","ix":10,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-0.414,0]],"o":[[0,0],[0,0.414],[0,0]],"v":[[-8.652,8.652],[-9.402,8.652],[-8.652,9.402]],"c":true},"ix":2},"nm":"路径 10","mn":"ADBE Vector Shape - Group","hd":false},{"ind":10,"ty":"sh","ix":11,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-0.141,0.14]],"o":[[0,0],[0.198,0],[0,0]],"v":[[-5.346,8.652],[-5.346,9.402],[-4.816,9.182]],"c":true},"ix":2},"nm":"路径 11","mn":"ADBE Vector Shape - Group","hd":false},{"ind":11,"ty":"sh","ix":12,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[7.657,-7.659],[8.186,-8.189]],"c":true},"ix":2},"nm":"路径 12","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"合并路径 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[10.152,9.848],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":14,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":48,"op":8416,"st":16,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Pen","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.67],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[0]},{"t":48,"s":[-89]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.5,"y":0},"t":0,"s":[38.998,260.999,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.67,"y":1},"o":{"x":0.167,"y":0.167},"t":24,"s":[150.369,238.999,0],"to":[0,0,0],"ti":[0,0,0]},{"t":48,"s":[258.965,260.999,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0.75,19.25,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,1]},"o":{"x":[0.5,0.5,0.5],"y":[0,0,0]},"t":0,"s":[1200,1200,100]},{"i":{"x":[0.67,0.67,0.67],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0]},"t":24,"s":[787,787,100]},{"t":48,"s":[1178,1178,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[2.371,-5.714],[5.71,-2.38],[6.77,-3.443],[3.431,-6.775]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-9.402,8.652],[-7.902,8.652],[-7.902,5.286],[-9.402,5.286]],"c":true},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0]],"o":[[0,0]],"v":[[-9.402,5.286]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ind":3,"ty":"sh","ix":4,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[3.788,-8.189],[-9.182,4.755],[-8.122,5.816],[4.847,-7.128]],"c":true},"ix":2},"nm":"路径 4","mn":"ADBE Vector Shape - Group","hd":false},{"ind":4,"ty":"sh","ix":5,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-5.346,7.902],[-8.652,7.902],[-8.652,9.402],[-5.346,9.402]],"c":true},"ix":2},"nm":"路径 5","mn":"ADBE Vector Shape - Group","hd":false},{"ind":5,"ty":"sh","ix":6,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[7.127,-4.857],[-5.876,8.12],[-4.816,9.182],[8.186,-3.794]],"c":true},"ix":2},"nm":"路径 6","mn":"ADBE Vector Shape - Group","hd":false},{"ind":6,"ty":"sh","ix":7,"ks":{"a":0,"k":{"i":[[0,0],[0.628,-0.627],[0,0],[1.216,1.214]],"o":[[0.628,0.627],[0,0],[1.216,-1.214],[0,0]],"v":[[7.127,-7.128],[7.127,-4.857],[8.186,-3.794],[8.186,-8.189]],"c":true},"ix":2},"nm":"路径 7","mn":"ADBE Vector Shape - Group","hd":false},{"ind":7,"ty":"sh","ix":8,"ks":{"a":0,"k":{"i":[[0,0],[-0.629,-0.628],[0,0],[1.215,-1.212]],"o":[[0.63,-0.628],[0,0],[-1.214,-1.212],[0,0]],"v":[[4.847,-7.128],[7.127,-7.128],[8.186,-8.189],[3.788,-8.189]],"c":true},"ix":2},"nm":"路径 8","mn":"ADBE Vector Shape - Group","hd":false},{"ind":8,"ty":"sh","ix":9,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,-0.199]],"o":[[0,0],[-0.141,0.141],[0,0]],"v":[[-8.652,5.286],[-9.182,4.755],[-9.402,5.286]],"c":true},"ix":2},"nm":"路径 9","mn":"ADBE Vector Shape - Group","hd":false},{"ind":9,"ty":"sh","ix":10,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-0.414,0]],"o":[[0,0],[0,0.414],[0,0]],"v":[[-8.652,8.652],[-9.402,8.652],[-8.652,9.402]],"c":true},"ix":2},"nm":"路径 10","mn":"ADBE Vector Shape - Group","hd":false},{"ind":10,"ty":"sh","ix":11,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-0.141,0.14]],"o":[[0,0],[0.198,0],[0,0]],"v":[[-5.346,8.652],[-5.346,9.402],[-4.816,9.182]],"c":true},"ix":2},"nm":"路径 11","mn":"ADBE Vector Shape - Group","hd":false},{"ind":11,"ty":"sh","ix":12,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[7.657,-7.659],[8.186,-8.189]],"c":true},"ix":2},"nm":"路径 12","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"合并路径 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[10.152,9.848],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":14,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"line 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[49.5,252.5,0],"ix":2,"l":2},"a":{"a":0,"k":[-104,104,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-79,104],[98,104]],"c":false}]},{"t":38,"s":[{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-105,104],[98,104]],"c":false}]}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":17,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[100]},{"t":38,"s":[0]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"line","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[49.5,252.5,0],"ix":2,"l":2},"a":{"a":0,"k":[-104,104,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-94,104],[98,104]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":17,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.575],"y":[1]},"o":{"x":[0.429],"y":[0]},"t":48,"s":[100]},{"t":88,"s":[0]}],"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'+ background="transparent"+ speed="1"+ style="width: 20px; height: 20px;"+ loop+ autoplay+></dotlottie-player>`;++export const AIPresentationIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_14287_43677)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M1.875 5.41663C1.875 4.38109 2.71447 3.54163 3.75 3.54163H16.25C17.2855 3.54163 18.125 4.38109 18.125 5.41663V14.5833C18.125 15.6188 17.2855 16.4583 16.25 16.4583H3.75C2.71447 16.4583 1.875 15.6188 1.875 14.5833V5.41663ZM3.75 4.79163C3.40482 4.79163 3.125 5.07145 3.125 5.41663V14.5833C3.125 14.9285 3.40482 15.2083 3.75 15.2083H16.25C16.5952 15.2083 16.875 14.9285 16.875 14.5833V5.41663C16.875 5.07145 16.5952 4.79163 16.25 4.79163H3.75ZM4.79167 7.08329C4.79167 6.73811 5.07149 6.45829 5.41667 6.45829H6.25C6.59518 6.45829 6.875 6.73811 6.875 7.08329C6.875 7.42847 6.59518 7.70829 6.25 7.70829H5.41667C5.07149 7.70829 4.79167 7.42847 4.79167 7.08329ZM5.41667 9.37496C5.07149 9.37496 4.79167 9.65478 4.79167 9.99996C4.79167 10.3451 5.07149 10.625 5.41667 10.625H10.8333C11.1785 10.625 11.4583 10.3451 11.4583 9.99996C11.4583 9.65478 11.1785 9.37496 10.8333 9.37496H5.41667ZM12.2917 9.99996C12.2917 9.65478 12.5715 9.37496 12.9167 9.37496H14.5833C14.9285 9.37496 15.2083 9.65478 15.2083 9.99996C15.2083 10.3451 14.9285 10.625 14.5833 10.625H12.9167C12.5715 10.625 12.2917 10.3451 12.2917 9.99996ZM5.41667 12.2916C5.07149 12.2916 4.79167 12.5714 4.79167 12.9166C4.79167 13.2618 5.07149 13.5416 5.41667 13.5416H14.5833C14.9285 13.5416 15.2083 13.2618 15.2083 12.9166C15.2083 12.5714 14.9285 12.2916 14.5833 12.2916H5.41667Z"+ />+ </g>+ <defs>+ <clipPath id="clip0_14287_43677">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIPresentationIconWithAnimation = html`<dotlottie-player+ src='{"v":"5.12.1","fr":120,"ip":0,"op":150,"w":240,"h":240,"nm":"ppt","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"“图层 2”轮廓","parent":5,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[6.5,15.5,0],"ix":2,"l":2},"a":{"a":0,"k":[6.5,15.5,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[6.5,15.5],[17.5,15.5]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.7],"y":[1]},"o":{"x":[0.3],"y":[0]},"t":59,"s":[0]},{"t":85.21875,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"“图层 3”轮廓","parent":5,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[15.5,12,0],"ix":2,"l":2},"a":{"a":0,"k":[15.5,12,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[15.5,12],[17.5,12]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.7],"y":[1]},"o":{"x":[0.3],"y":[0]},"t":39,"s":[0]},{"t":65.23046875,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"“图层 4”轮廓","parent":5,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[6.5,12,0],"ix":2,"l":2},"a":{"a":0,"k":[6.5,12,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[6.5,12],[13,12]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.7],"y":[1]},"o":{"x":[0.3],"y":[0]},"t":27.332,"s":[0]},{"t":53.55078125,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"“图层 5”轮廓","parent":5,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[6.5,8.5,0],"ix":2,"l":2},"a":{"a":0,"k":[6.5,8.5,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[6.5,8.5],[7.5,8.5]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"“图层 6”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":22.332,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":29.832,"s":[3]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":37.332,"s":[-3]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":44.832,"s":[3]},{"t":52.33203125,"s":[0]}],"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[12,12,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-0.828,0],[0,0],[0,-0.828],[0,0],[0.828,0],[0,0],[0,0.828]],"o":[[0,-0.828],[0,0],[0.828,0],[0,0],[0,0.828],[0,0],[-0.828,0],[0,0]],"v":[[-9,-5.5],[-7.5,-7],[7.5,-7],[9,-5.5],[9,5.5],[7.5,7],[-7.5,7],[-9,5.5]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,12],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'+ background="transparent"+ speed="1"+ style="width: 20px; height: 20px;"+ loop+ autoplay+></dotlottie-player>`;++export const AIMindMapIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_14287_43617)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M8.71486 4.95829H8.12484C6.97424 4.95829 6.0415 5.89103 6.0415 7.04163C6.0415 8.0372 5.60504 8.93084 4.91302 9.54163H8.62426C8.87653 8.67493 9.67672 8.04158 10.6248 8.04158H15.2082C16.3588 8.04158 17.2915 8.97433 17.2915 10.1249C17.2915 11.2755 16.3588 12.2083 15.2082 12.2083H10.6248C9.70741 12.2083 8.92849 11.6152 8.65047 10.7916H4.91302C5.60504 11.4024 6.0415 12.296 6.0415 13.2916C6.0415 14.4422 6.97424 15.375 8.12484 15.375H8.58318C8.77621 14.424 9.61694 13.7083 10.6248 13.7083H15.2082C16.3588 13.7083 17.2915 14.641 17.2915 15.7916C17.2915 16.9422 16.3588 17.875 15.2082 17.875H10.6248C9.77054 17.875 9.03634 17.3608 8.71485 16.625H8.12484C6.28389 16.625 4.7915 15.1326 4.7915 13.2916C4.7915 12.141 3.85876 11.2083 2.70817 11.2083H1.6665V10.375V9.95829V9.12496H2.70817C3.85876 9.12496 4.7915 8.19222 4.7915 7.04163C4.7915 5.20068 6.28389 3.70829 8.12484 3.70829H8.58318C8.77621 2.75736 9.61694 2.04163 10.6248 2.04163H15.2082C16.3588 2.04163 17.2915 2.97437 17.2915 4.12496C17.2915 5.27555 16.3588 6.20829 15.2082 6.20829H10.6248C9.77054 6.20829 9.03634 5.69409 8.71486 4.95829ZM9.7915 4.12496C9.7915 3.66472 10.1646 3.29163 10.6248 3.29163H15.2082C15.6684 3.29163 16.0415 3.66472 16.0415 4.12496C16.0415 4.5852 15.6684 4.95829 15.2082 4.95829H10.6248C10.1646 4.95829 9.7915 4.5852 9.7915 4.12496ZM9.7915 10.1249C9.7915 9.66468 10.1646 9.29158 10.6248 9.29158H15.2082C15.6684 9.29158 16.0415 9.66468 16.0415 10.1249C16.0415 10.5852 15.6684 10.9583 15.2082 10.9583H10.6248C10.1646 10.9583 9.7915 10.5852 9.7915 10.1249ZM10.6248 14.9583C10.1646 14.9583 9.7915 15.3314 9.7915 15.7916C9.7915 16.2519 10.1646 16.625 10.6248 16.625H15.2082C15.6684 16.625 16.0415 16.2519 16.0415 15.7916C16.0415 15.3314 15.6684 14.9583 15.2082 14.9583H10.6248Z"+ />+ </g>+ <defs>+ <clipPath id="clip0_14287_43617">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIMindMapIconWithAnimation = html`<dotlottie-player+ src='{"v":"5.12.1","fr":120,"ip":0,"op":150,"w":240,"h":240,"nm":"Mindmap","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"形状图层 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-95,1],[-11,1]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117646998985,0.588234994926,0.921568986481,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"形状图层 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,-100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-8.5,-0.25],[0,-7.778],[-3.135,-12.359],[-6.128,0],[-6.25,0]],"o":[[8.583,0],[7.775,0.229],[0,12.75],[1.507,5.94],[8.25,0],[0,0]],"v":[[-96,1.75],[-70.25,1.75],[-55,18.25],[-53.75,56.5],[-40.75,69.5],[-15.75,69.5]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117646998985,0.588234994926,0.921568986481,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-1.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"形状图层 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-8.5,-0.25],[0,-7.778],[-3.135,-12.359],[-6.128,0],[-6.25,0]],"o":[[8.583,0],[7.775,0.229],[0,12.75],[1.507,5.94],[8.25,0],[0,0]],"v":[[-96,1.75],[-70.25,1.75],[-55,18.25],[-53.75,56.5],[-40.75,69.5],[-15.75,69.5]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117646998985,0.588234994926,0.921568986481,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-1.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"“图层 5”轮廓 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[154,51.5,0],"ix":2,"l":2},"a":{"a":0,"k":[15.5,18.95,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.966,0],[0,0],[0,-0.966],[0.967,0],[0,0],[0,0.967]],"o":[[0,0],[0.967,0],[0,0.967],[0,0],[-0.966,0],[0,-0.966]],"v":[[-2.75,-1.75],[2.75,-1.75],[4.5,0],[2.75,1.75],[-2.75,1.75],[-4.5,0]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[15.5,18.95],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[38]},{"t":57,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[38]},{"t":57,"s":[0]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[180]},{"t":57,"s":[138]}],"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":10823,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"“图层 5”轮廓 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[154,120.5,0],"ix":2,"l":2},"a":{"a":0,"k":[15.5,18.95,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.966,0],[0,0],[0,-0.966],[0.967,0],[0,0],[0,0.967]],"o":[[0,0],[0.967,0],[0,0.967],[0,0],[-0.966,0],[0,-0.966]],"v":[[-2.75,-1.75],[2.75,-1.75],[4.5,0],[2.75,1.75],[-2.75,1.75],[-4.5,0]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[15.5,18.95],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":12,"s":[38]},{"t":69,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":12,"s":[38]},{"t":69,"s":[0]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":12,"s":[180]},{"t":69,"s":[138]}],"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":12,"op":10835,"st":12,"ct":1,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"“图层 5”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[154,189.5,0],"ix":2,"l":2},"a":{"a":0,"k":[15.5,18.95,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.966,0],[0,0],[0,-0.966],[0.967,0],[0,0],[0,0.967]],"o":[[0,0],[0.967,0],[0,0.967],[0,0],[-0.966,0],[0,-0.966]],"v":[[-2.75,-1.75],[2.75,-1.75],[4.5,0],[2.75,1.75],[-2.75,1.75],[-4.5,0]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[15.5,18.95],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":23,"s":[38]},{"t":80,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":23,"s":[38]},{"t":80,"s":[0]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":23,"s":[180]},{"t":80,"s":[138]}],"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":23,"op":10846,"st":23,"ct":1,"bm":0}],"markers":[],"props":{}}'+ background="transparent"+ speed="1"+ style="width: 20px; height: 20px;"+ loop+ autoplay+></dotlottie-player>`;++export const AIExpandMindMapIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_14287_43641)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M10.6248 3.75C9.67672 3.75 8.87653 4.38335 8.62426 5.25004H7.30376C6.03811 5.25004 5.01209 6.27605 5.01209 7.54171V8.37504C5.01209 8.95034 4.54572 9.41671 3.97043 9.41671H1.6665V10.6667H3.97043C4.54572 10.6667 5.01209 11.1331 5.01209 11.7084V12.5417C5.01209 13.8074 6.03811 14.8334 7.30376 14.8334H8.65047C8.92849 15.657 9.70741 16.25 10.6248 16.25H15.2082C16.3588 16.25 17.2915 15.3173 17.2915 14.1667C17.2915 13.0161 16.3588 12.0833 15.2082 12.0833H10.6248C9.67672 12.0833 8.87653 12.7167 8.62426 13.5834H7.30376C6.72846 13.5834 6.26209 13.117 6.26209 12.5417V11.7084C6.26209 11.0517 5.98589 10.4595 5.54332 10.0417C5.98589 9.62389 6.26209 9.03172 6.26209 8.37504V7.54171C6.26209 6.96641 6.72846 6.50004 7.30376 6.50004H8.65047C8.92849 7.32366 9.70741 7.91667 10.6248 7.91667H15.2082C16.3588 7.91667 17.2915 6.98393 17.2915 5.83333C17.2915 4.68274 16.3588 3.75 15.2082 3.75H10.6248ZM9.7915 5.83333C9.7915 5.3731 10.1646 5 10.6248 5H15.2082C15.6684 5 16.0415 5.3731 16.0415 5.83333C16.0415 6.29357 15.6684 6.66667 15.2082 6.66667H10.6248C10.1646 6.66667 9.7915 6.29357 9.7915 5.83333ZM9.7915 14.1667C9.7915 13.7064 10.1646 13.3333 10.6248 13.3333H15.2082C15.6684 13.3333 16.0415 13.7064 16.0415 14.1667C16.0415 14.6269 15.6684 15 15.2082 15H10.6248C10.1646 15 9.7915 14.6269 9.7915 14.1667Z"+ />+ </g>+ <defs>+ <clipPath id="clip0_14287_43641">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIFindActionsIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M3.125 7.91667C3.125 5.2703 5.2703 3.125 7.91667 3.125C10.563 3.125 12.7083 5.2703 12.7083 7.91667C12.7083 10.563 10.563 12.7083 7.91667 12.7083C5.2703 12.7083 3.125 10.563 3.125 7.91667ZM7.91667 1.875C4.57995 1.875 1.875 4.57995 1.875 7.91667C1.875 11.2534 4.57995 13.9583 7.91667 13.9583C9.35991 13.9583 10.685 13.4523 11.724 12.6079L16.2247 17.1086C16.4688 17.3527 16.8645 17.3527 17.1086 17.1086C17.3527 16.8645 17.3527 16.4688 17.1086 16.2247L12.6079 11.724C13.4523 10.685 13.9583 9.35991 13.9583 7.91667C13.9583 4.57995 11.2534 1.875 7.91667 1.875Z"+ />+</svg> `;++export const AIImageIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_14287_69586)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M5.00016 2.70837C3.73451 2.70837 2.7085 3.73439 2.7085 5.00004V13.3334V15C2.7085 16.2657 3.73451 17.2917 5.00016 17.2917H15.0002C16.2658 17.2917 17.2918 16.2657 17.2918 15V11.6667V5.00004C17.2918 3.73439 16.2658 2.70837 15.0002 2.70837H5.00016ZM3.9585 15V13.5923L7.59693 9.95383C8.00372 9.54703 8.66327 9.54703 9.07007 9.95383L11.2249 12.1086L12.8916 13.7753C13.1356 14.0194 13.5314 14.0194 13.7754 13.7753C14.0195 13.5312 14.0195 13.1355 13.7754 12.8914L12.5507 11.6667L13.4303 10.7872C13.8371 10.3804 14.4966 10.3804 14.9034 10.7872L16.0418 11.9256V15C16.0418 15.5753 15.5755 16.0417 15.0002 16.0417H5.00016C4.42487 16.0417 3.9585 15.5753 3.9585 15ZM9.95395 9.06994L11.6668 10.7828L12.5464 9.90328C13.4413 9.00833 14.8923 9.00832 15.7873 9.90328L16.0418 10.1578V5.00004C16.0418 4.42474 15.5755 3.95837 15.0002 3.95837H5.00016C4.42487 3.95837 3.9585 4.42474 3.9585 5.00004V11.8245L6.71304 9.06994C7.60799 8.17499 9.059 8.17499 9.95395 9.06994ZM11.6668 7.50004C12.1271 7.50004 12.5002 7.12694 12.5002 6.66671C12.5002 6.20647 12.1271 5.83337 11.6668 5.83337C11.2066 5.83337 10.8335 6.20647 10.8335 6.66671C10.8335 7.12694 11.2066 7.50004 11.6668 7.50004Z"+ fill="#1E96EB"+ />+ </g>+ <defs>+ <clipPath id="clip0_14287_69586">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const AIImageIconWithAnimation = html`<dotlottie-player+ src='{"v":"5.12.1","fr":120,"ip":0,"op":276,"w":240,"h":240,"nm":"Image","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"moon","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":49.984,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":61.34,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":157.852,"s":[100]},{"t":167.58203125,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":0.652},"o":{"x":0.333,"y":0},"t":42.684,"s":[145,145.5,0],"to":[0,-14.667,0],"ti":[0,12.917,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.595},"t":73.027,"s":[145,57.5,0],"to":[0,-12.917,0],"ti":[0,-1.75,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":84.047,"s":[145,68,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.405},"o":{"x":0.333,"y":0},"t":137.574,"s":[145,68,0],"to":[0,-1.75,0],"ti":[0,-12.917,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.348},"t":146.863,"s":[145,57.5,0],"to":[0,12.917,0],"ti":[0,-14.667,0]},{"t":172.44921875,"s":[145,145.5,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0.947,2,0],"ix":1,"l":2},"s":{"a":0,"k":[1800,1800,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.164,0.327],[0,0.567],[-0.016,0.08],[0.008,0],[0,-0.552],[-0.552,0]],"o":[[-0.517,-0.153],[0,-0.085],[-0.008,0],[-0.552,0],[0,0.553],[0.391,0]],"v":[[0.947,0.449],[0.053,-0.75],[0.078,-0.999],[0.053,-1],[-0.947,0],[0.053,1]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0.947,2],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"sun","parent":3,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":20.789,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":32.141,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":182.18,"s":[0]},{"t":195.96875,"s":[100]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":0.405},"o":{"x":0.333,"y":0},"t":7,"s":[11,5,0],"to":[0,-0.128,0],"ti":[0,-0.987,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.346},"t":16.234,"s":[11,4.231,0],"to":[0,0.987,0],"ti":[0,-1.115,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":41.875,"s":[11,10.923,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.654},"o":{"x":0.333,"y":0},"t":171.637,"s":[11,10.923,0],"to":[0,-1.115,0],"ti":[0,0.987,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.595},"t":202.051,"s":[11,4.231,0],"to":[0,-0.987,0],"ti":[0,-0.128,0]},{"t":213,"s":[11,5,0]}],"ix":2,"l":2},"a":{"a":0,"k":[11,5,0],"ix":1,"l":2},"s":{"a":0,"k":[134.615,134.615,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.552,0],[0,-0.552],[0.552,0],[0,0.552]],"o":[[0.552,0],[0,0.552],[-0.552,0],[0,-0.552]],"v":[[0,-1],[1,0],[0,1],[-1,0]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[11,5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8594,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"bg","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[9,9,0],"ix":1,"l":2},"s":{"a":0,"k":[1300,1300,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.105,0],[0,0],[0,1.105],[0,0],[1.105,0],[0,0],[0,-1.105],[0,0]],"o":[[0,0],[1.105,0],[0,0],[0,-1.105],[0,0],[-1.105,0],[0,0],[0,1.105]],"v":[[-6,8],[6,8],[8,6],[8,-6],[6,-8],[-6,-8],[-8,-6],[-8,6]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-0.781,-0.781],[0,0]],"o":[[0,0],[0.781,-0.781],[0,0],[0,0]],"v":[[2,2],[3.586,0.414],[6.414,0.414],[8,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-0.781,-0.781],[0,0]],"o":[[0,0],[0.781,-0.781],[0,0],[0,0]],"v":[[-8,4],[-3.414,-0.586],[-0.586,-0.586],[4,4]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"合并路径 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647058824,0.588235294118,0.921568627451,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[9,9],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":5,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":8400,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'+ background="transparent"+ speed="1"+ style="width: 20px; height: 20px;"+ loop+ autoplay+></dotlottie-player>`;++export const ChatWithAIIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M3.12926 6.59386C2.2839 5.82997 2.79173 4.375 3.97096 4.375H15.8351C16.8185 4.375 17.3998 5.44049 16.9328 6.27292L11.1139 16.6458C10.543 17.6636 9.04423 17.4269 8.78738 16.306L7.45823 10.5057L3.12926 6.59386ZM8.73556 10.4835L10.0058 16.0268C10.0075 16.0342 10.0092 16.0381 10.01 16.0396C10.011 16.0401 10.013 16.041 10.0161 16.0414C10.0172 16.0416 10.0182 16.0417 10.0191 16.0417C10.0202 16.0401 10.0218 16.0377 10.0238 16.0343L15.26 6.70001L8.73556 10.4835ZM14.622 5.625H3.97096C3.96952 5.625 3.96831 5.62504 3.96732 5.6251C3.96581 5.62713 3.96365 5.63059 3.96169 5.63585C3.95772 5.64646 3.95838 5.65425 3.95884 5.65639C3.95897 5.65699 3.95903 5.65711 3.95919 5.65738L3.9592 5.6574C3.95926 5.6575 3.961 5.66071 3.96732 5.66642L8.10424 9.40467L14.622 5.625Z"+ />+</svg> `;++export const MakeItRealIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M1.89506 9.08909C1.36098 9.73568 1.85634 10.7079 2.69338 10.6559L5.70784 10.4685L7.3281 13.0174C7.77801 13.7251 8.85573 13.5545 9.06491 12.7423L9.63712 10.5207L15.8083 16.6918C16.0524 16.9359 16.4481 16.9359 16.6922 16.6918C16.9362 16.4477 16.9362 16.052 16.6922 15.8079L10.5208 9.63654L12.743 9.06417C13.5552 8.855 13.7259 7.77728 13.0181 7.32737L10.4692 5.7071L10.6566 2.69265C10.7086 1.85562 9.73642 1.36024 9.08982 1.89433L6.76121 3.81777L3.9522 2.70805C3.17221 2.39991 2.40064 3.17147 2.70878 3.95147L3.8185 6.76048L1.89506 9.08909ZM5.80215 9.21024L3.28715 9.36656L4.8919 7.42377C5.11419 7.15466 5.17258 6.78598 5.04433 6.46135L4.11848 4.11775L6.46208 5.0436C6.78671 5.17185 7.15539 5.11346 7.4245 4.89117L9.36729 3.28642L9.21097 5.80142C9.18931 6.14979 9.35878 6.48238 9.65335 6.66963L11.7799 8.02144L9.33969 8.64995C9.00168 8.737 8.73774 9.00095 8.65068 9.33896L8.02217 11.7792L6.67036 9.65261C6.48312 9.35805 6.15052 9.18858 5.80215 9.21024Z"+ />+</svg> `;++export const MakeItRealIconWithAnimation = html`<dotlottie-player+ src='{"v":"5.12.1","fr":60,"ip":0,"op":120,"w":240,"h":240,"nm":"Make it real","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"“图层 2”轮廓 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[201.5,91.5,0],"ix":2,"l":2},"a":{"a":0,"k":[13,13,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":17,"s":[0,0,100]},{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":29,"s":[160,160,100]},{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":46,"s":[160,160,100]},{"t":61,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[-0.001,-13],[-2.04,-2.041],[-13.001,0.001],[-2.04,2.041],[-0.001,13],[2.04,2.041],[13.001,0.001],[2.04,-2.041]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647066303,0.588235294118,0.921568687289,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[13,13],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":17,"s":[0.376470595598,0.811764717102,0.980392158031,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":29,"s":[0.117647066303,0.588235294118,0.921568687289,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":46,"s":[0.117647066303,0.588235294118,0.921568687289,1]},{"t":61,"s":[0.376470595598,0.811764717102,0.980392158031,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 2","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":18060,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"“图层 2”轮廓 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[79,28,0],"ix":2,"l":2},"a":{"a":0,"k":[13,13,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":31,"s":[0,0,100]},{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":43,"s":[120,120,100]},{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":60,"s":[120,120,100]},{"t":75,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[-0.001,-13],[-2.04,-2.041],[-13.001,0.001],[-2.04,2.041],[-0.001,13],[2.04,2.041],[13.001,0.001],[2.04,-2.041]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.117647066303,0.588235294118,0.921568687289,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[13,13],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":31,"s":[0.376470595598,0.811764717102,0.980392158031,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":43,"s":[0.117647066303,0.588235294118,0.921568687289,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":60,"s":[0.117647066303,0.588235294118,0.921568687289,1]},{"t":75,"s":[0.376470595598,0.811764717102,0.980392158031,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 2","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":18060,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"“图层 2”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[47,191,0],"ix":2,"l":2},"a":{"a":0,"k":[13,13,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":10,"s":[0,0,100]},{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":22,"s":[200,200,100]},{"i":{"x":[0.7,0.7,0.7],"y":[1,1,1]},"o":{"x":[0.3,0.3,0.3],"y":[0,0,0]},"t":39,"s":[200,200,100]},{"t":54,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[-0.001,-13],[-2.04,-2.041],[-13.001,0.001],[-2.04,2.041],[-0.001,13],[2.04,2.041],[13.001,0.001],[2.04,-2.041]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":10,"s":[0.376470595598,0.811764717102,0.980392158031,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":22,"s":[0.117647066303,0.588235294118,0.921568687289,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":39,"s":[0.117647066303,0.588235294118,0.921568687289,1]},{"t":54,"s":[0.376470595598,0.811764717102,0.980392158031,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[13,13],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":18060,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"“图层 3”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.3],"y":[1]},"o":{"x":[0.167],"y":[0.099]},"t":0,"s":[0]},{"i":{"x":[0.3],"y":[1]},"o":{"x":[0.167],"y":[0.112]},"t":9.428,"s":[8]},{"i":{"x":[0.3],"y":[1]},"o":{"x":[0.167],"y":[0.124]},"t":21.215,"s":[-8]},{"i":{"x":[0.3],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":30.799,"s":[5]},{"i":{"x":[0.3],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":37.4,"s":[-3]},{"t":44,"s":[0]}],"ix":10},"p":{"a":0,"k":[198.999,200.999,0],"ix":2,"l":2},"a":{"a":0,"k":[19.5,19.5,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-0.223,0.27],[0,0],[0.054,0.135],[0,0],[-0.326,-0.129],[0,0],[-0.112,0.092],[0,0],[0.022,-0.349],[0,0],[-0.123,-0.078],[0,0],[0.339,-0.087],[0,0],[0.036,-0.141],[0,0],[0.188,0.295],[0,0],[0.145,-0.009]],"o":[[-0.349,0.022],[0,0],[0.092,-0.112],[0,0],[-0.129,-0.326],[0,0],[0.135,0.054],[0,0],[0.27,-0.223],[0,0],[-0.009,0.145],[0,0],[0.295,0.188],[0,0],[-0.141,0.036],[0,0],[-0.087,0.339],[0,0],[-0.078,-0.123],[0,0]],"v":[[-5.887,2.967],[-6.219,2.314],[-3.779,-0.641],[-3.717,-1.042],[-5.124,-4.605],[-4.605,-5.124],[-1.042,-3.717],[-0.641,-3.779],[2.314,-6.219],[2.967,-5.887],[2.73,-2.062],[2.915,-1.701],[6.148,0.355],[6.033,1.079],[2.322,2.036],[2.036,2.322],[1.079,6.033],[0.355,6.148],[-1.701,2.915],[-2.062,2.73]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647066303,0.588235294118,0.921568687289,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[9.072,9.071],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-3.762,-3.762],[3.762,3.762]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.117647066303,0.588235294118,0.921568687289,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[15.737,15.737],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":18060,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'+ background="transparent"+ speed="1"+ style="width: 20px; height: 20px;"+ loop+ autoplay+></dotlottie-player>`;++export const ArrowDownIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ d="M10.9581 12.6095C10.7175 13.0188 10.1159 13.0188 9.87523 12.6095L7.16803 8.00422C6.92739 7.59487 7.22819 7.08317 7.70947 7.08317L13.1239 7.08317C13.6051 7.08317 13.9059 7.59487 13.6653 8.00422L10.9581 12.6095Z"+ fill="#77757D"+ fill-opacity="0.6"+ />+</svg> `;++export const ArrowUpIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ d="M10.9581 6.97352C10.7175 6.56416 10.1159 6.56416 9.87523 6.97352L7.16803 11.5788C6.92739 11.9881 7.22819 12.4998 7.70947 12.4998H13.1239C13.6051 12.4998 13.9059 11.9881 13.6653 11.5788L10.9581 6.97352Z"+ fill="#77757D"+ fill-opacity="0.6"+ />+</svg> `;++export const DiscardIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M9.16667 1.87512C7.90101 1.87512 6.875 2.90114 6.875 4.16679V5.12504H3.33333C2.94213 5.12504 2.625 5.44217 2.625 5.83337C2.625 6.22458 2.94213 6.54171 3.33333 6.54171H3.59066L4.26602 15.9967C4.35168 17.196 5.34957 18.1251 6.55186 18.1251H13.4481C14.6504 18.1251 15.6483 17.196 15.734 15.9967L16.4093 6.54171H16.6667C17.0579 6.54171 17.375 6.22458 17.375 5.83337C17.375 5.44217 17.0579 5.12504 16.6667 5.12504H13.125V4.16679C13.125 2.90114 12.099 1.87512 10.8333 1.87512H9.16667ZM11.875 5.12504V4.16679C11.875 3.59149 11.4086 3.12512 10.8333 3.12512H9.16667C8.59137 3.12512 8.125 3.59149 8.125 4.16679V5.12504H11.875ZM15.1562 6.54171H4.84385L5.51285 15.9077C5.55178 16.4528 6.00537 16.8751 6.55186 16.8751H13.4481C13.9946 16.8751 14.4482 16.4528 14.4872 15.9077L15.1562 6.54171ZM8.95833 9.16679C8.95833 8.82161 8.67851 8.54179 8.33333 8.54179C7.98815 8.54179 7.70833 8.82161 7.70833 9.16679V14.1668C7.70833 14.512 7.98815 14.7918 8.33333 14.7918C8.67851 14.7918 8.95833 14.512 8.95833 14.1668V9.16679ZM11.6667 8.54179C12.0118 8.54179 12.2917 8.82161 12.2917 9.16679V14.1668C12.2917 14.512 12.0118 14.7918 11.6667 14.7918C11.3215 14.7918 11.0417 14.512 11.0417 14.1668V9.16679C11.0417 8.82161 11.3215 8.54179 11.6667 8.54179Z"+ />+</svg>`;++export const ErrorTipIcon = html`<svg+ width="16"+ height="16"+ viewBox="0 0 16 16"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M7.99984 3.16699C5.33046 3.16699 3.1665 5.33095 3.1665 8.00033C3.1665 10.6697 5.33046 12.8337 7.99984 12.8337C10.6692 12.8337 12.8332 10.6697 12.8332 8.00033C12.8332 5.33095 10.6692 3.16699 7.99984 3.16699ZM2.1665 8.00033C2.1665 4.77866 4.77818 2.16699 7.99984 2.16699C11.2215 2.16699 13.8332 4.77866 13.8332 8.00033C13.8332 11.222 11.2215 13.8337 7.99984 13.8337C4.77818 13.8337 2.1665 11.222 2.1665 8.00033ZM7.99984 5.12996C8.27598 5.12996 8.49984 5.35381 8.49984 5.62996V8.00033C8.49984 8.27647 8.27598 8.50033 7.99984 8.50033C7.72369 8.50033 7.49984 8.27647 7.49984 8.00033V5.62996C7.49984 5.35381 7.72369 5.12996 7.99984 5.12996ZM7.49984 10.3707C7.49984 10.0946 7.72369 9.8707 7.99984 9.8707H8.00576C8.28191 9.8707 8.50576 10.0946 8.50576 10.3707C8.50576 10.6468 8.28191 10.8707 8.00576 10.8707H7.99984C7.72369 10.8707 7.49984 10.6468 7.49984 10.3707Z"+ fill="#EB4335"+ />+</svg>`;++export const CopyIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_9512_250387)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M2.70801 4.99967C2.70801 3.73402 3.73402 2.70801 4.99967 2.70801H11.6663C12.932 2.70801 13.958 3.73402 13.958 4.99967V6.04134H14.9997C16.2653 6.04134 17.2913 7.06736 17.2913 8.33301V14.9997C17.2913 16.2653 16.2653 17.2913 14.9997 17.2913H8.33301C7.06736 17.2913 6.04134 16.2653 6.04134 14.9997V13.958H4.99967C3.73402 13.958 2.70801 12.932 2.70801 11.6663V4.99967ZM7.29134 14.9997C7.29134 15.575 7.75771 16.0413 8.33301 16.0413H14.9997C15.575 16.0413 16.0413 15.575 16.0413 14.9997V8.33301C16.0413 7.75771 15.575 7.29134 14.9997 7.29134H8.33301C7.75771 7.29134 7.29134 7.75771 7.29134 8.33301V14.9997ZM12.708 6.04134H8.33301C7.06736 6.04134 6.04134 7.06736 6.04134 8.33301V12.708H4.99967C4.42438 12.708 3.95801 12.2416 3.95801 11.6663V4.99967C3.95801 4.42438 4.42438 3.95801 4.99967 3.95801H11.6663C12.2416 3.95801 12.708 4.42438 12.708 4.99967V6.04134Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_9512_250387">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;++export const RetryIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+>+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M2.70837 9.99998C2.70837 5.9729 5.97296 2.70831 10 2.70831C11.8672 2.70831 13.5717 3.41091 14.8613 4.56514L14.8633 4.56693L16.0417 5.63077V3.33331C16.0417 2.98814 16.3215 2.70831 16.6667 2.70831C17.0119 2.70831 17.2917 2.98814 17.2917 3.33331V7.03702C17.2917 7.38219 17.0119 7.66202 16.6667 7.66202H12.963C12.6178 7.66202 12.338 7.38219 12.338 7.03702C12.338 6.69184 12.6178 6.41202 12.963 6.41202H15.0417L14.0277 5.49656C14.0273 5.49626 14.027 5.49597 14.0267 5.49567C12.9575 4.53915 11.5473 3.95831 10 3.95831C6.66332 3.95831 3.95837 6.66326 3.95837 9.99998C3.95837 13.3367 6.66332 16.0416 10 16.0416C12.8745 16.0416 15.2815 14.0336 15.892 11.3432C15.9684 11.0065 16.3032 10.7956 16.6398 10.872C16.9764 10.9483 17.1874 11.2831 17.111 11.6198C16.3742 14.8671 13.471 17.2916 10 17.2916C5.97296 17.2916 2.70837 14.0271 2.70837 9.99998Z"+ />+</svg> `;++export const MoreIcon = html`<svg+ width="20"+ height="20"+ viewBox="0 0 20 20"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+>+ <g clip-path="url(#clip0_12805_40201)">+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M3.75 9.99992C3.75 10.7965 4.39574 11.4422 5.19231 11.4422C5.98887 11.4422 6.63462 10.7965 6.63462 9.99992C6.63462 9.20336 5.98887 8.55762 5.19231 8.55762C4.39574 8.55762 3.75 9.20336 3.75 9.99992ZM10 11.4422C9.20343 11.4422 8.55769 10.7965 8.55769 9.99992C8.55769 9.20336 9.20343 8.55762 10 8.55762C10.7966 8.55762 11.4423 9.20336 11.4423 9.99992C11.4423 10.7965 10.7966 11.4422 10 11.4422ZM14.8077 11.4422C14.0111 11.4422 13.3654 10.7965 13.3654 9.99992C13.3654 9.20336 14.0111 8.55762 14.8077 8.55762C15.6043 8.55762 16.25 9.20336 16.25 9.99992C16.25 10.7965 15.6043 11.4422 14.8077 11.4422Z"+ fill="#77757D"+ />+ </g>+ <defs>+ <clipPath id="clip0_12805_40201">+ <rect width="20" height="20" fill="white" />+ </clipPath>+ </defs>+</svg> `;diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/markdown-utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/markdown-utils.tsnew file mode 100644index 0000000000..efd69d4b23--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/markdown-utils.ts@@ -0,0 +1,70 @@+import type { EditorHost } from '@blocksuite/block-std';+import { MarkdownAdapter, titleMiddleware } from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import { type BlockModel, Job, type Slice } from '@blocksuite/store';++export async function getMarkdownFromSlice(host: EditorHost, slice: Slice) {+ const job = new Job({+ collection: host.std.doc.collection,+ middlewares: [titleMiddleware],+ });+ const markdownAdapter = new MarkdownAdapter(job);+ const markdown = await markdownAdapter.fromSlice(slice);++ return markdown.file;+}+export const markdownToSnapshot = async (+ markdown: string,+ host: EditorHost+) => {+ const job = new Job({ collection: host.std.doc.collection });+ const markdownAdapter = new MarkdownAdapter(job);+ const { blockVersions, workspaceVersion, pageVersion } =+ host.std.doc.collection.meta;+ if (!blockVersions || !workspaceVersion || !pageVersion)+ throw new Error(+ 'Need blockVersions, workspaceVersion, pageVersion meta information to get slice'+ );++ const payload = {+ file: markdown,+ assets: job.assetsManager,+ blockVersions,+ pageVersion,+ workspaceVersion,+ workspaceId: host.std.doc.collection.id,+ pageId: host.std.doc.id,+ };++ const snapshot = await markdownAdapter.toSliceSnapshot(payload);+ assertExists(snapshot, 'import markdown failed, expected to get a snapshot');++ return {+ snapshot,+ job,+ };+};+export async function insertFromMarkdown(+ host: EditorHost,+ markdown: string,+ parent?: string,+ index?: number+) {+ const { snapshot, job } = await markdownToSnapshot(markdown, host);++ const snapshots = snapshot.content[0].children;++ const models: BlockModel[] = [];+ for (let i = 0; i < snapshots.length; i++) {+ const blockSnapshot = snapshots[i];+ const model = await job.snapshotToBlock(+ blockSnapshot,+ host.std.doc,+ parent,+ (index ?? 0) + i+ );+ models.push(model);+ }++ return models;+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/selection-utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/selection-utils.tsnew file mode 100644index 0000000000..66eddaf539--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/selection-utils.ts@@ -0,0 +1,117 @@+import type { EditorHost } from '@blocksuite/block-std';+import {+ BlocksUtils,+ EdgelessRootService,+ type FrameBlockModel,+ type ImageBlockModel,+ type SurfaceBlockComponent,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import { Slice } from '@blocksuite/store';++import { getMarkdownFromSlice } from './markdown-utils.js';++export const getRootService = (host: EditorHost) => {+ return host.std.spec.getService('affine:page');+};++export function getEdgelessRootFromEditor(editor: EditorHost) {+ const edgelessRoot = editor.getElementsByTagName('affine-edgeless-root')[0];+ if (!edgelessRoot) {+ alert('Please switch to edgeless mode');+ throw new Error('Please open switch to edgeless mode');+ }+ return edgelessRoot;+}+export function getEdgelessService(editor: EditorHost) {+ const rootService = editor.std.spec.getService('affine:page');+ if (rootService instanceof EdgelessRootService) {+ return rootService;+ }+ alert('Please switch to edgeless mode');+ throw new Error('Please open switch to edgeless mode');+}++export async function selectedToCanvas(editor: EditorHost) {+ const edgelessRoot = getEdgelessRootFromEditor(editor);+ const { notes, frames, shapes, images } = BlocksUtils.splitElements(+ edgelessRoot.service.selection.selectedElements+ );+ if (notes.length + frames.length + images.length + shapes.length === 0) {+ return;+ }+ const canvas = await edgelessRoot.clipboardController.toCanvas(+ [...notes, ...frames, ...images],+ shapes+ );+ if (!canvas) {+ return;+ }+ return canvas;+}++export async function frameToCanvas(+ frame: FrameBlockModel,+ editor: EditorHost+) {+ const edgelessRoot = getEdgelessRootFromEditor(editor);+ const { notes, frames, shapes, images } = BlocksUtils.splitElements(+ edgelessRoot.service.frame.getElementsInFrame(frame, true)+ );+ if (notes.length + frames.length + images.length + shapes.length === 0) {+ return;+ }+ const canvas = await edgelessRoot.clipboardController.toCanvas(+ [...notes, ...frames, ...images],+ shapes+ );+ if (!canvas) {+ return;+ }+ return canvas;+}++export async function selectedToPng(editor: EditorHost) {+ return (await selectedToCanvas(editor))?.toDataURL('image/png');+}++export async function getSelectedTextContent(editorHost: EditorHost) {+ const slice = Slice.fromModels(+ editorHost.std.doc,+ getRootService(editorHost).selectedModels+ );+ return getMarkdownFromSlice(editorHost, slice);+}++export const stopPropagation = (e: Event) => {+ e.stopPropagation();+};++export function getSurfaceElementFromEditor(editor: EditorHost) {+ const { doc } = editor;+ const surfaceModel = doc.getBlockByFlavour('affine:surface')[0];+ assertExists(surfaceModel);++ const surfaceId = surfaceModel.id;+ const surfaceElement = editor.querySelector(+ `affine-surface[data-block-id="${surfaceId}"]`+ ) as SurfaceBlockComponent;+ assertExists(surfaceElement);++ return surfaceElement;+}++export const getFirstImageInFrame = (+ frame: FrameBlockModel,+ editor: EditorHost+) => {+ const edgelessRoot = getEdgelessRootFromEditor(editor);+ const elements = edgelessRoot.service.frame.getElementsInFrame(frame, false);+ const image = elements.find(ele => {+ if (!BlocksUtils.isCanvasElement(ele)) {+ return ele.flavour === 'affine:image';+ }+ return false;+ }) as ImageBlockModel | undefined;+ return image?.id;+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/consts.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/consts.tsnew file mode 100644index 0000000000..f69ca9e0cc--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/consts.ts@@ -0,0 +1,29 @@+export const EXCLUDING_COPY_ACTIONS = [+ 'brainstormMindmap',+ 'expandMindmap',+ 'makeItReal',+ 'createSlides',+ 'createImage',+ 'findActions',+ 'filterImage',+ 'processImage',+];++export const EXCLUDING_INSERT_ACTIONS = ['generateCaption'];++export const IMAGE_ACTIONS = ['createImage', 'processImage', 'filterImage'];++const commonImageStages = ['Generating image', 'Rendering image'];++export const generatingStages: {+ [key in keyof Partial<BlockSuitePresets.AIActions>]: string[];+} = {+ makeItReal: ['Coding for you', 'Rendering the code'],+ brainstormMindmap: ['Thinking about this topic', 'Rendering mindmap'],+ createSlides: ['Thinking about this topic', 'Rendering slides'],+ createImage: commonImageStages,+ processImage: commonImageStages,+ filterImage: commonImageStages,+};++export const INSERT_ABOVE_ACTIONS = ['createHeadings'];diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.tsnew file mode 100644index 0000000000..215dd3648e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/doc-handler.ts@@ -0,0 +1,247 @@+import type { EditorHost } from '@blocksuite/block-std';+import type {+ AffineAIPanelWidget,+ AffineAIPanelWidgetConfig,+ AIError,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import type { TemplateResult } from 'lit';++import {+ buildCopyConfig,+ buildErrorConfig,+ buildFinishConfig,+ buildGeneratingConfig,+ getAIPanel,+} from '../ai-panel.js';+import { createTextRenderer } from '../messages/text.js';+import { AIProvider } from '../provider.js';+import { reportResponse } from '../utils/action-reporter.js';+import {+ getSelectedImagesAsBlobs,+ getSelectedTextContent,+ getSelections,+ selectAboveBlocks,+} from '../utils/selection-utils.js';++export function bindTextStream(+ stream: BlockSuitePresets.TextStream,+ {+ update,+ finish,+ signal,+ }: {+ update: (text: string) => void;+ finish: (state: 'success' | 'error' | 'aborted', err?: AIError) => void;+ signal?: AbortSignal;+ }+) {+ (async () => {+ let answer = '';+ signal?.addEventListener('abort', () => {+ finish('aborted');+ reportResponse('aborted:stop');+ });+ for await (const data of stream) {+ if (signal?.aborted) {+ return;+ }+ answer += data;+ update(answer);+ }+ finish('success');+ })().catch(err => {+ if (signal?.aborted) return;+ if (err.name === 'AbortError') {+ finish('aborted');+ } else {+ finish('error', err);+ }+ });+}++export function actionToStream<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ signal?: AbortSignal,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ const action = AIProvider.actions[id];+ if (!action || typeof action !== 'function') return;+ return (host: EditorHost): BlockSuitePresets.TextStream => {+ let stream: BlockSuitePresets.TextStream | undefined;+ return {+ async *[Symbol.asyncIterator]() {+ const { currentTextSelection, selectedBlocks } = getSelections(host);++ let markdown: string;+ let attachments: File[] = [];++ if (currentTextSelection?.isCollapsed()) {+ markdown = await selectAboveBlocks(host);+ } else {+ [markdown, attachments] = await Promise.all([+ getSelectedTextContent(host),+ getSelectedImagesAsBlobs(host),+ ]);+ }++ // for now if there are more than one selected blocks, we will not omit the attachments+ const sendAttachments =+ selectedBlocks?.length === 1 && attachments.length > 0;+ const models = selectedBlocks?.map(block => block.model);+ const control = trackerOptions?.control ?? 'format-bar';+ const where = trackerOptions?.where ?? 'ai-panel';+ const options = {+ ...variants,+ attachments: sendAttachments ? attachments : undefined,+ input: sendAttachments ? '' : markdown,+ stream: true,+ host,+ models,+ signal,+ control,+ where,+ docId: host.doc.id,+ workspaceId: host.doc.collection.id,+ } as Parameters<typeof action>[0];+ // @ts-expect-error todo: maybe fix this+ stream = action(options);+ if (!stream) return;+ yield* stream;+ },+ };+ };+}++export function actionToGenerateAnswer<+ T extends keyof BlockSuitePresets.AIActions,+>(+ id: T,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return (host: EditorHost) => {+ return ({+ signal,+ update,+ finish,+ }: {+ input: string;+ signal?: AbortSignal;+ update: (text: string) => void;+ finish: (state: 'success' | 'error' | 'aborted', err?: AIError) => void;+ }) => {+ const { selectedBlocks: blocks } = getSelections(host);+ if (!blocks || blocks.length === 0) return;+ const stream = actionToStream(+ id,+ signal,+ variants,+ trackerOptions+ )?.(host);+ if (!stream) return;+ bindTextStream(stream, { update, finish, signal });+ };+ };+}++/**+ * TODO: Should update config according to the action type+ * When support mind-map. generate image, generate slides on doc mode or in edgeless note block+ * Currently, only support text action+ */+function updateAIPanelConfig<T extends keyof BlockSuitePresets.AIActions>(+ aiPanel: AffineAIPanelWidget,+ id: T,+ generatingIcon: TemplateResult<1>,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ const { config, host } = aiPanel;+ assertExists(config);+ config.generateAnswer = actionToGenerateAnswer(+ id,+ variants,+ trackerOptions+ )(host);+ config.answerRenderer = createTextRenderer(host, { maxHeight: 320 });+ config.finishStateConfig = buildFinishConfig(aiPanel, id);+ config.generatingStateConfig = buildGeneratingConfig(generatingIcon);+ config.errorStateConfig = buildErrorConfig(aiPanel);+ config.copy = buildCopyConfig(aiPanel);+ config.discardCallback = () => {+ reportResponse('result:discard');+ };+}++export function actionToHandler<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ generatingIcon: TemplateResult<1>,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return (host: EditorHost) => {+ const aiPanel = getAIPanel(host);+ updateAIPanelConfig(aiPanel, id, generatingIcon, variants, trackerOptions);+ const { selectedBlocks: blocks } = getSelections(aiPanel.host);+ if (!blocks || blocks.length === 0) return;+ const block = blocks.at(-1);+ assertExists(block);+ aiPanel.toggle(block, 'placeholder');+ };+}++export function handleInlineAskAIAction(host: EditorHost) {+ const panel = getAIPanel(host);+ const selection = host.selection.find('text');+ const lastBlockPath = selection+ ? selection.to?.blockId ?? selection.blockId+ : null;+ if (!lastBlockPath) return;+ const block = host.view.getBlock(lastBlockPath);+ if (!block) return;+ const generateAnswer: AffineAIPanelWidgetConfig['generateAnswer'] = ({+ finish,+ input,+ signal,+ update,+ }) => {+ if (!AIProvider.actions.chat) return;++ // recover selection to get content from above blocks+ assertExists(selection);+ host.selection.set([selection]);++ selectAboveBlocks(host)+ .then(context => {+ assertExists(AIProvider.actions.chat);+ const stream = AIProvider.actions.chat({+ input: `${context}\n${input}`,+ stream: true,+ host,+ where: 'inline-chat-panel',+ control: 'chat-send',+ docId: host.doc.id,+ workspaceId: host.doc.collection.id,+ });+ bindTextStream(stream, { update, finish, signal });+ })+ .catch(console.error);+ };+ assertExists(panel.config);+ panel.config.generateAnswer = generateAnswer;+ panel.toggle(block);+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.tsnew file mode 100644index 0000000000..05ead0d531--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts@@ -0,0 +1,544 @@+import type { EditorHost } from '@blocksuite/block-std';+import type {+ AffineAIPanelWidget,+ AIError,+ EdgelessCopilotWidget,+ MindmapElementModel,+} from '@blocksuite/blocks';+import {+ BlocksUtils,+ EdgelessTextBlockModel,+ ImageBlockModel,+ NoteBlockModel,+ ShapeElementModel,+ TextElementModel,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import { Slice } from '@blocksuite/store';+import type { TemplateResult } from 'lit';++import { getAIPanel } from '../ai-panel.js';+import {+ createMindmapExecuteRenderer,+ createMindmapRenderer,+} from '../messages/mindmap.js';+import { createSlidesRenderer } from '../messages/slides-renderer.js';+import { createTextRenderer } from '../messages/text.js';+import {+ createIframeRenderer,+ createImageRenderer,+} from '../messages/wrapper.js';+import { AIProvider } from '../provider.js';+import { reportResponse } from '../utils/action-reporter.js';+import {+ getEdgelessCopilotWidget,+ isMindmapChild,+ isMindMapRoot,+} from '../utils/edgeless.js';+import { copyTextAnswer } from '../utils/editor-actions.js';+import { getContentFromSlice } from '../utils/markdown-utils.js';+import {+ getCopilotSelectedElems,+ getSelectedNoteAnchor,+ getSelections,+} from '../utils/selection-utils.js';+import { EXCLUDING_COPY_ACTIONS, IMAGE_ACTIONS } from './consts.js';+import { bindTextStream } from './doc-handler.js';+import {+ actionToErrorResponse,+ actionToGenerating,+ actionToResponse,+ getElementToolbar,+ responses,+} from './edgeless-response.js';+import type { CtxRecord } from './types.js';++type AnswerRenderer = NonNullable<+ AffineAIPanelWidget['config']+>['answerRenderer'];++function actionToRenderer<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ host: EditorHost,+ ctx: CtxRecord+): AnswerRenderer {+ if (id === 'brainstormMindmap') {+ const selectedElements = ctx.get()[+ 'selectedElements'+ ] as BlockSuite.EdgelessModelType[];++ if (+ isMindMapRoot(selectedElements[0] || isMindmapChild(selectedElements[0]))+ ) {+ const mindmap = selectedElements[0].group as MindmapElementModel;++ return createMindmapRenderer(host, ctx, mindmap.style);+ }++ return createMindmapRenderer(host, ctx);+ }++ if (id === 'expandMindmap') {+ return createMindmapExecuteRenderer(host, ctx, ctx => {+ responses['expandMindmap']?.(host, ctx);+ });+ }++ if (id === 'createSlides') {+ return createSlidesRenderer(host, ctx);+ }++ if (id === 'makeItReal') {+ return createIframeRenderer(host, { height: 300 });+ }++ if (IMAGE_ACTIONS.includes(id)) {+ return createImageRenderer(host, { height: 300 });+ }++ return createTextRenderer(host, { maxHeight: 320 });+}++async function getContentFromHubBlockModel(+ host: EditorHost,+ models: EdgelessTextBlockModel[] | NoteBlockModel[]+) {+ return (+ await Promise.all(+ models.map(model => {+ const slice = Slice.fromModels(host.doc, model.children);+ return getContentFromSlice(host, slice);+ })+ )+ )+ .map(content => content.trim())+ .filter(content => content.length);+}++export async function getContentFromSelected(+ host: EditorHost,+ selected: BlockSuite.EdgelessModelType[]+) {+ type RemoveUndefinedKey<T, K extends keyof T> = T & {+ [P in K]-?: Exclude<T[P], undefined>;+ };++ function isShapeWithText(+ el: ShapeElementModel+ ): el is RemoveUndefinedKey<ShapeElementModel, 'text'> {+ return el.text !== undefined && el.text.length !== 0;+ }++ function isImageWithCaption(+ el: ImageBlockModel+ ): el is RemoveUndefinedKey<ImageBlockModel, 'caption'> {+ return el.caption !== undefined && el.caption.length !== 0;+ }++ const { notes, texts, shapes, images, edgelessTexts } = selected.reduce<{+ notes: NoteBlockModel[];+ texts: TextElementModel[];+ shapes: RemoveUndefinedKey<ShapeElementModel, 'text'>[];+ images: RemoveUndefinedKey<ImageBlockModel, 'caption'>[];+ edgelessTexts: EdgelessTextBlockModel[];+ }>(+ (pre, cur) => {+ if (cur instanceof NoteBlockModel) {+ pre.notes.push(cur);+ } else if (cur instanceof TextElementModel) {+ pre.texts.push(cur);+ } else if (cur instanceof ShapeElementModel && isShapeWithText(cur)) {+ pre.shapes.push(cur);+ } else if (cur instanceof ImageBlockModel && isImageWithCaption(cur)) {+ pre.images.push(cur);+ } else if (cur instanceof EdgelessTextBlockModel) {+ pre.edgelessTexts.push(cur);+ }++ return pre;+ },+ { notes: [], texts: [], shapes: [], images: [], edgelessTexts: [] }+ );++ const noteContent = await getContentFromHubBlockModel(host, notes);+ const edgelessTextContent = await getContentFromHubBlockModel(+ host,+ edgelessTexts+ );++ return `${noteContent.join('\n')}+ ${edgelessTextContent.join('\n')}+${texts.map(text => text.text.toString()).join('\n')}+${shapes.map(shape => shape.text.toString()).join('\n')}+${images.map(image => image.caption.toString()).join('\n')}+`.trim();+}++function getTextFromSelected(host: EditorHost) {+ const selected = getCopilotSelectedElems(host);+ return getContentFromSelected(host, selected);+}++function actionToStream<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ signal?: AbortSignal,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ extract?: (+ host: EditorHost,+ ctx: CtxRecord+ ) => Promise<{+ content?: string;+ attachments?: (string | Blob)[];+ seed?: string;+ } | void>,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ const action = AIProvider.actions[id];++ if (!action || typeof action !== 'function') return;++ if (extract && typeof extract === 'function') {+ return (host: EditorHost, ctx: CtxRecord): BlockSuitePresets.TextStream => {+ let stream: BlockSuitePresets.TextStream | undefined;+ const control = trackerOptions?.control || 'format-bar';+ const where = trackerOptions?.where || 'ai-panel';+ return {+ async *[Symbol.asyncIterator]() {+ const models = getCopilotSelectedElems(host);+ const options = {+ ...variants,+ signal,+ input: '',+ stream: true,+ control,+ where,+ models,+ host,+ docId: host.doc.id,+ workspaceId: host.doc.collection.id,+ } as Parameters<typeof action>[0];++ const data = await extract(host, ctx);+ if (data) {+ Object.assign(options, data);+ }++ // @ts-expect-error todo: maybe fix this+ stream = action(options);+ if (!stream) return;+ yield* stream;+ },+ };+ };+ }++ return (host: EditorHost): BlockSuitePresets.TextStream => {+ let stream: BlockSuitePresets.TextStream | undefined;+ return {+ async *[Symbol.asyncIterator]() {+ const panel = getAIPanel(host);+ const models = getCopilotSelectedElems(host);+ const markdown = await getTextFromSelected(panel.host);++ const options = {+ ...variants,+ signal,+ input: markdown,+ stream: true,+ where: 'ai-panel',+ models,+ control: 'format-bar',+ host,+ docId: host.doc.id,+ workspaceId: host.doc.collection.id,+ } as Parameters<typeof action>[0];++ // @ts-expect-error todo: maybe fix this+ stream = action(options);+ if (!stream) return;+ yield* stream;+ },+ };+ };+}++function actionToGeneration<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ extract?: (+ host: EditorHost,+ ctx: CtxRecord+ ) => Promise<{+ content?: string;+ attachments?: (string | Blob)[];+ seed?: string;+ } | void>,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return (host: EditorHost, ctx: CtxRecord) => {+ return ({+ signal,+ update,+ finish,+ }: {+ input: string;+ signal?: AbortSignal;+ update: (text: string) => void;+ finish: (state: 'success' | 'error' | 'aborted', err?: AIError) => void;+ }) => {+ if (!extract) {+ const selectedElements = getCopilotSelectedElems(host);+ if (selectedElements.length === 0) return;+ }++ const stream = actionToStream(+ id,+ signal,+ variants,+ extract,+ trackerOptions+ )?.(host, ctx);++ if (!stream) return;++ bindTextStream(stream, { update, finish, signal });+ };+ };+}++function updateEdgelessAIPanelConfig<+ T extends keyof BlockSuitePresets.AIActions,+>(+ aiPanel: AffineAIPanelWidget,+ edgelessCopilot: EdgelessCopilotWidget,+ id: T,+ generatingIcon: TemplateResult<1>,+ ctx: CtxRecord,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ customInput?: (+ host: EditorHost,+ ctx: CtxRecord+ ) => Promise<{+ input?: string;+ content?: string;+ attachments?: (string | Blob)[];+ seed?: string;+ } | void>,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ const host = aiPanel.host;+ const { config } = aiPanel;+ assertExists(config);+ config.answerRenderer = actionToRenderer(id, host, ctx);+ config.generateAnswer = actionToGeneration(+ id,+ variants,+ customInput,+ trackerOptions+ )(host, ctx);+ config.finishStateConfig = actionToResponse(id, host, ctx, variants);+ config.generatingStateConfig = actionToGenerating(id, generatingIcon);+ config.errorStateConfig = actionToErrorResponse(+ aiPanel,+ id,+ host,+ ctx,+ variants+ );+ config.copy = {+ allowed: !EXCLUDING_COPY_ACTIONS.includes(id),+ onCopy: () => {+ return copyTextAnswer(aiPanel);+ },+ };+ config.discardCallback = () => {+ reportResponse('result:discard');+ };+ config.hideCallback = () => {+ aiPanel.updateComplete+ .finally(() => {+ edgelessCopilot.edgeless.service.tool.switchToDefaultMode({+ elements: [],+ editing: false,+ });+ host.selection.clear();+ edgelessCopilot.lockToolbar(false);+ })+ .catch(console.error);+ };+}++export function actionToHandler<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ generatingIcon: TemplateResult<1>,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >,+ customInput?: (+ host: EditorHost,+ ctx: CtxRecord+ ) => Promise<{+ input?: string;+ content?: string;+ attachments?: (string | Blob)[];+ seed?: string;+ } | void>,+ trackerOptions?: BlockSuitePresets.TrackerOptions+) {+ return (host: EditorHost) => {+ const aiPanel = getAIPanel(host);+ const edgelessCopilot = getEdgelessCopilotWidget(host);+ let internal: Record<string, unknown> = {};+ const selectedElements = getCopilotSelectedElems(host);+ const { selectedBlocks } = getSelections(host);+ const ctx = {+ get() {+ return {+ ...internal,+ selectedElements,+ };+ },+ set(data: Record<string, unknown>) {+ internal = data;+ },+ };++ edgelessCopilot.hideCopilotPanel();+ edgelessCopilot.lockToolbar(true);++ aiPanel.host = host;+ updateEdgelessAIPanelConfig(+ aiPanel,+ edgelessCopilot,+ id,+ generatingIcon,+ ctx,+ variants,+ customInput,+ trackerOptions+ );++ const elementToolbar = getElementToolbar(host);+ const isEmpty = selectedElements.length === 0;+ const isCreateImageAction = id === 'createImage';+ const isMakeItRealAction = !isCreateImageAction && id === 'makeItReal';+ let referenceElement = null;+ let togglePanel = () => Promise.resolve(isEmpty);++ if (selectedBlocks && selectedBlocks.length !== 0) {+ referenceElement = selectedBlocks.at(-1);+ } else if (edgelessCopilot.visible && edgelessCopilot.selectionElem) {+ referenceElement = edgelessCopilot.selectionElem;+ } else if (elementToolbar.toolbarVisible) {+ referenceElement = getElementToolbar(host);+ } else if (!isEmpty) {+ const lastSelected = selectedElements.at(-1)?.id;+ assertExists(lastSelected);+ referenceElement = getSelectedNoteAnchor(host, lastSelected);+ }++ if (!referenceElement) return;++ if (isCreateImageAction || isMakeItRealAction) {+ togglePanel = async () => {+ if (isEmpty) return true;+ const {+ notes,+ shapes,+ images,+ edgelessTexts,+ frames: _,+ } = BlocksUtils.splitElements(selectedElements);+ const blocks = [...notes, ...shapes, ...images, ...edgelessTexts];+ if (blocks.length === 0) return true;+ const content = await getContentFromSelected(host, blocks);+ ctx.set({+ content,+ });+ return content.length === 0;+ };+ }++ togglePanel()+ .then(isEmpty => {+ aiPanel.toggle(referenceElement, isEmpty ? undefined : 'placeholder');+ })+ .catch(console.error);+ };+}++export function noteBlockOrTextShowWhen(+ _: unknown,+ __: unknown,+ host: EditorHost+) {+ const selected = getCopilotSelectedElems(host);++ return selected.some(+ el =>+ el instanceof NoteBlockModel ||+ el instanceof TextElementModel ||+ el instanceof EdgelessTextBlockModel+ );+}++/**+ * Checks if the selected element is a NoteBlockModel with a single child element of code block.+ */+export function noteWithCodeBlockShowWen(+ _: unknown,+ __: unknown,+ host: EditorHost+) {+ const selected = getCopilotSelectedElems(host);+ if (!selected.length) return false;++ return (+ selected[0] instanceof NoteBlockModel &&+ selected[0].children.length === 1 &&+ BlocksUtils.matchFlavours(selected[0].children[0], ['affine:code'])+ );+}++export function mindmapChildShowWhen(+ _: unknown,+ __: unknown,+ host: EditorHost+) {+ const selected = getCopilotSelectedElems(host);++ return selected.length === 1 && isMindmapChild(selected[0]);+}++export function imageOnlyShowWhen(_: unknown, __: unknown, host: EditorHost) {+ const selected = getCopilotSelectedElems(host);++ return selected.length === 1 && selected[0] instanceof ImageBlockModel;+}++export function experimentalImageActionsShowWhen(+ _: unknown,+ __: unknown,+ host: EditorHost+) {+ return (+ !!host.doc.awarenessStore.getFlag('enable_new_image_actions') &&+ imageOnlyShowWhen(_, __, host)+ );+}++export function mindmapRootShowWhen(_: unknown, __: unknown, host: EditorHost) {+ const selected = getCopilotSelectedElems(host);++ return selected.length === 1 && isMindMapRoot(selected[0]);+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-response.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-response.tsnew file mode 100644index 0000000000..ab2d809687--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-response.ts@@ -0,0 +1,532 @@+import type { EditorHost } from '@blocksuite/block-std';+import type {+ AffineAIPanelWidget,+ AIItemConfig,+ EdgelessCopilotWidget,+ EdgelessElementToolbarWidget,+ EdgelessRootService,+ MindmapElementModel,+ ShapeElementModel,+ SurfaceBlockModel,+} from '@blocksuite/blocks';+import {+ DeleteIcon,+ EDGELESS_ELEMENT_TOOLBAR_WIDGET,+ EmbedHtmlBlockSpec,+ fitContent,+ ImageBlockModel,+ InsertBelowIcon,+ NoteDisplayMode,+ ResetIcon,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import type { TemplateResult } from 'lit';++import { AIPenIcon, ChatWithAIIcon } from '../_common/icons.js';+import { insertFromMarkdown } from '../_common/markdown-utils.js';+import { getSurfaceElementFromEditor } from '../_common/selection-utils.js';+import { getAIPanel } from '../ai-panel.js';+import { AIProvider } from '../provider.js';+import { reportResponse } from '../utils/action-reporter.js';+import {+ getEdgelessCopilotWidget,+ getService,+ isMindMapRoot,+} from '../utils/edgeless.js';+import { preprocessHtml } from '../utils/html.js';+import { fetchImageToFile } from '../utils/image.js';+import {+ getCopilotSelectedElems,+ getEdgelessRootFromEditor,+ getEdgelessService,+} from '../utils/selection-utils.js';+import { EXCLUDING_INSERT_ACTIONS, generatingStages } from './consts.js';+import type { CtxRecord } from './types.js';++type FinishConfig = Exclude<+ AffineAIPanelWidget['config'],+ null+>['finishStateConfig'];++type ErrorConfig = Exclude<+ AffineAIPanelWidget['config'],+ null+>['errorStateConfig'];++export function getElementToolbar(+ host: EditorHost+): EdgelessElementToolbarWidget {+ const rootBlockId = host.doc.root?.id as string;+ const elementToolbar = host.view.getWidget(+ EDGELESS_ELEMENT_TOOLBAR_WIDGET,+ rootBlockId+ ) as EdgelessElementToolbarWidget;++ return elementToolbar;+}++export function getTriggerEntry(host: EditorHost) {+ const copilotWidget = getEdgelessCopilotWidget(host);++ return copilotWidget.visible ? 'selection' : 'toolbar';+}++export function discard(+ panel: AffineAIPanelWidget,+ _: EdgelessCopilotWidget+): AIItemConfig {+ return {+ name: 'Discard',+ icon: DeleteIcon,+ showWhen: () => !!panel.answer,+ handler: () => {+ panel.discard();+ },+ };+}++export function retry(panel: AffineAIPanelWidget): AIItemConfig {+ return {+ name: 'Retry',+ icon: ResetIcon,+ handler: () => {+ reportResponse('result:retry');+ panel.generate();+ },+ };+}++export function createInsertResp<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ handler: (host: EditorHost, ctx: CtxRecord) => void,+ host: EditorHost,+ ctx: CtxRecord,+ buttonText: string = 'Insert below'+): AIItemConfig {+ return {+ name: buttonText,+ icon: InsertBelowIcon,+ showWhen: () => {+ const panel = getAIPanel(host);+ return !EXCLUDING_INSERT_ACTIONS.includes(id) && !!panel.answer;+ },+ handler: () => {+ reportResponse('result:insert');+ handler(host, ctx);+ const panel = getAIPanel(host);+ panel.hide();+ },+ };+}++export function asCaption<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ host: EditorHost+): AIItemConfig {+ return {+ name: 'Use as caption',+ icon: AIPenIcon,+ showWhen: () => {+ const panel = getAIPanel(host);+ return id === 'generateCaption' && !!panel.answer;+ },+ handler: () => {+ reportResponse('result:use-as-caption');+ const panel = getAIPanel(host);+ const caption = panel.answer;+ if (!caption) return;++ const selectedElements = getCopilotSelectedElems(host);+ if (selectedElements.length !== 1) return;++ const imageBlock = selectedElements[0];+ if (!(imageBlock instanceof ImageBlockModel)) return;++ host.doc.updateBlock(imageBlock, { caption });+ panel.hide();+ },+ };+}++type MindMapNode = {+ text: string;+ children: MindMapNode[];+};++const defaultHandler = (host: EditorHost) => {+ const doc = host.doc;+ const panel = getAIPanel(host);+ const edgelessCopilot = getEdgelessCopilotWidget(host);+ const bounds = edgelessCopilot.determineInsertionBounds(800, 95);++ doc.transact(() => {+ assertExists(doc.root);+ const noteBlockId = doc.addBlock(+ 'affine:note',+ {+ xywh: bounds.serialize(),+ displayMode: NoteDisplayMode.EdgelessOnly,+ },+ doc.root.id+ );++ assertExists(panel.answer);+ insertFromMarkdown(host, panel.answer, noteBlockId)+ .then(() => {+ const service = getService(host);++ service.selection.set({+ elements: [noteBlockId],+ editing: false,+ });+ })+ .catch(err => {+ console.error(err);+ });+ });+};++const imageHandler = (host: EditorHost) => {+ const aiPanel = getAIPanel(host);+ // `DataURL` or `URL`+ const data = aiPanel.answer;+ if (!data) return;++ const edgelessCopilot = getEdgelessCopilotWidget(host);+ const bounds = edgelessCopilot.determineInsertionBounds();++ edgelessCopilot.hideCopilotPanel();+ aiPanel.hide();++ const filename = 'image';+ const imageProxy = host.std.clipboard.configs.get('imageProxy');++ fetchImageToFile(data, filename, imageProxy)+ .then(img => {+ if (!img) return;++ const edgelessRoot = getEdgelessRootFromEditor(host);+ const { minX, minY } = bounds;+ const [x, y] = edgelessRoot.service.viewport.toViewCoord(minX, minY);++ host.doc.transact(() => {+ edgelessRoot.addImages([img], [x, y], true).catch(console.error);+ });+ })+ .catch(console.error);+};++export const responses: {+ [key in keyof Partial<BlockSuitePresets.AIActions>]: (+ host: EditorHost,+ ctx: CtxRecord+ ) => void;+} = {+ expandMindmap: (host, ctx) => {+ const [surface] = host.doc.getBlockByFlavour(+ 'affine:surface'+ ) as SurfaceBlockModel[];++ const elements = ctx.get()[+ 'selectedElements'+ ] as BlockSuite.EdgelessModelType[];+ const data = ctx.get() as {+ node: MindMapNode;+ };++ queueMicrotask(() => {+ getAIPanel(host).hide();+ });++ const mindmap = elements[0].group as MindmapElementModel;++ if (!data?.node) return;++ if (data.node.children) {+ data.node.children.forEach(childTree => {+ mindmap.addTree(elements[0].id, childTree);+ });++ const subtree = mindmap.getNode(elements[0].id);++ if (!subtree) return;++ surface.doc.transact(() => {+ const updateNodeSize = (node: typeof subtree) => {+ fitContent(node.element as ShapeElementModel);++ node.children.forEach(child => {+ updateNodeSize(child);+ });+ };++ updateNodeSize(subtree);+ });++ setTimeout(() => {+ const edgelessService = getEdgelessService(host);++ edgelessService.selection.set({+ elements: [subtree.element.id],+ editing: false,+ });+ });+ }+ },+ brainstormMindmap: (host, ctx) => {+ const aiPanel = getAIPanel(host);+ const edgelessService = getEdgelessService(host);+ const edgelessCopilot = getEdgelessCopilotWidget(host);+ const selectionRect = edgelessCopilot.selectionModelRect;+ const [surface] = host.doc.getBlockByFlavour(+ 'affine:surface'+ ) as SurfaceBlockModel[];+ const elements = ctx.get()[+ 'selectedElements'+ ] as BlockSuite.EdgelessModelType[];+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const data = ctx.get() as any;+ let newGenerated = true;++ // This means regenerate+ if (isMindMapRoot(elements[0])) {+ const mindmap = elements[0].group as MindmapElementModel;+ const xywh = mindmap.tree.element.xywh;++ surface.removeElement(mindmap.id);++ if (data.node) {+ data.node.xywh = xywh;+ newGenerated = false;+ }+ }++ edgelessCopilot.hideCopilotPanel();+ aiPanel.hide();++ const mindmapId = surface.addElement({+ type: 'mindmap',+ children: data.node,+ style: data.style,+ });+ const mindmap = surface.getElementById(mindmapId) as MindmapElementModel;++ host.doc.transact(() => {+ mindmap.childElements.forEach(shape => {+ fitContent(shape as ShapeElementModel);+ });+ });++ edgelessService.telemetryService?.track('CanvasElementAdded', {+ control: 'ai',+ page: 'whiteboard editor',+ module: 'toolbar',+ segment: 'toolbar',+ type: 'mindmap',+ });++ queueMicrotask(() => {+ if (newGenerated && selectionRect) {+ mindmap.moveTo([+ selectionRect.x,+ selectionRect.y,+ selectionRect.width,+ selectionRect.height,+ ]);+ }+ });++ // This is a workaround to make sure mindmap and other microtask are done+ setTimeout(() => {+ edgelessService.viewport.setViewportByBound(+ mindmap.elementBound,+ [20, 20, 20, 20],+ true+ );++ edgelessService.selection.set({+ elements: [mindmap.tree.element.id],+ editing: false,+ });+ });+ },+ makeItReal: (host, ctx) => {+ const aiPanel = getAIPanel(host);+ let html = aiPanel.answer;+ if (!html) return;+ html = preprocessHtml(html);++ const edgelessCopilot = getEdgelessCopilotWidget(host);+ const [surface] = host.doc.getBlockByFlavour(+ 'affine:surface'+ ) as SurfaceBlockModel[];++ const data = ctx.get();+ const bounds = edgelessCopilot.determineInsertionBounds(+ (data['width'] as number) || 800,+ (data['height'] as number) || 600+ );++ edgelessCopilot.hideCopilotPanel();+ aiPanel.hide();++ const edgelessRoot = getEdgelessRootFromEditor(host);++ host.doc.transact(() => {+ edgelessRoot.doc.addBlock(+ EmbedHtmlBlockSpec.schema.model.flavour as 'affine:embed-html',+ {+ html,+ design: 'ai:makeItReal', // as tag+ xywh: bounds.serialize(),+ },+ surface.id+ );+ });+ },+ createSlides: (host, ctx) => {+ const data = ctx.get();+ const contents = data.contents as unknown[];+ if (!contents) return;+ const images = data.images as { url: string; id: string }[][];+ const service = host.spec.getService<EdgelessRootService>('affine:page');++ (async function () {+ for (let i = 0; i < contents.length - 1; i++) {+ const image = images[i];+ const content = contents[i];+ const job = service.createTemplateJob('template');+ await Promise.all(+ image.map(({ id, url }) =>+ fetch(url)+ .then(res => res.blob())+ .then(blob => job.job.assets.set(id, blob))+ )+ );+ await job.insertTemplate(content);+ getSurfaceElementFromEditor(host).refresh();+ }+ })().catch(console.error);+ },+ createImage: imageHandler,+ processImage: imageHandler,+ filterImage: imageHandler,+};++const getButtonText: {+ [key in keyof Partial<BlockSuitePresets.AIActions>]: (+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[key]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >+ ) => string | undefined;+} = {+ brainstormMindmap: variants => {+ return variants?.regenerate ? 'Replace' : undefined;+ },+};++export function getInsertAndReplaceHandler<+ T extends keyof BlockSuitePresets.AIActions,+>(+ id: T,+ host: EditorHost,+ ctx: CtxRecord,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >+) {+ const handler = responses[id] ?? defaultHandler;+ const buttonText = getButtonText[id]?.(variants) ?? undefined;++ return createInsertResp(id, handler, host, ctx, buttonText);+}++export function actionToResponse<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ host: EditorHost,+ ctx: CtxRecord,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >+): FinishConfig {+ return {+ responses: [+ {+ name: 'Response',+ items: [+ {+ name: 'Continue in chat',+ icon: ChatWithAIIcon,+ handler: () => {+ reportResponse('result:continue-in-chat');+ const panel = getAIPanel(host);+ AIProvider.slots.requestContinueInChat.emit({+ host: host,+ show: true,+ });+ panel.hide();+ },+ },+ getInsertAndReplaceHandler(id, host, ctx, variants),+ asCaption(id, host),+ retry(getAIPanel(host)),+ discard(getAIPanel(host), getEdgelessCopilotWidget(host)),+ ],+ },+ ],+ actions: [],+ };+}++export function actionToGenerating<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ generatingIcon: TemplateResult<1>+) {+ return {+ generatingIcon,+ stages: generatingStages[id],+ };+}++export function actionToErrorResponse<+ T extends keyof BlockSuitePresets.AIActions,+>(+ panel: AffineAIPanelWidget,+ id: T,+ host: EditorHost,+ ctx: CtxRecord,+ variants?: Omit<+ Parameters<BlockSuitePresets.AIActions[T]>[0],+ keyof BlockSuitePresets.AITextActionOptions+ >+): ErrorConfig {+ return {+ upgrade: () => {+ AIProvider.slots.requestUpgradePlan.emit({ host: panel.host });+ panel.hide();+ },+ login: () => {+ AIProvider.slots.requestLogin.emit({ host: panel.host });+ panel.hide();+ },+ cancel: () => {+ panel.hide();+ },+ responses: [+ {+ name: 'Response',+ items: [getInsertAndReplaceHandler(id, host, ctx, variants)],+ },+ {+ name: '',+ items: [+ retry(getAIPanel(host)),+ discard(getAIPanel(host), getEdgelessCopilotWidget(host)),+ ],+ },+ ],+ };+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/index.tsnew file mode 100644index 0000000000..2c2fa246fd--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/index.ts@@ -0,0 +1,2 @@+export * from './doc-handler.js';+export * from './types.js';diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/types.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/types.tsnew file mode 100644index 0000000000..041b931953--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/types.ts@@ -0,0 +1,256 @@+import type { EditorHost } from '@blocksuite/block-std';+import type { BlockModel } from '@blocksuite/store';++export const translateLangs = [+ 'English',+ 'Spanish',+ 'German',+ 'French',+ 'Italian',+ 'Simplified Chinese',+ 'Traditional Chinese',+ 'Japanese',+ 'Russian',+ 'Korean',+] as const;++export const textTones = [+ 'Professional',+ 'Informal',+ 'Friendly',+ 'Critical',+ 'Humorous',+] as const;++export const imageFilterStyles = [+ 'Clay style',+ 'Sketch style',+ 'Anime style',+ 'Pixel style',+] as const;++export const imageProcessingTypes = [+ 'Clearer',+ 'Remove background',+ 'Convert to sticker',+] as const;++export type CtxRecord = {+ get(): Record<string, unknown>;+ set(data: Record<string, unknown>): void;+};++declare global {+ // eslint-disable-next-line @typescript-eslint/no-namespace+ namespace BlockSuitePresets {+ type TrackerControl =+ | 'format-bar'+ | 'slash-menu'+ | 'chat-send'+ | 'block-action-bar';++ type TrackerWhere = 'chat-panel' | 'inline-chat-panel' | 'ai-panel';++ interface TrackerOptions {+ control: TrackerControl;+ where: TrackerWhere;+ }++ interface AITextActionOptions {+ input?: string;+ stream?: boolean;+ attachments?: (string | File | Blob)[]; // blob could only be strings for the moments (url or data urls)+ signal?: AbortSignal;+ retry?: boolean;++ // action's context+ docId: string;+ workspaceId: string;++ // internal context+ host: EditorHost;+ models?: (BlockModel | BlockSuite.SurfaceElementModelType)[];+ control: TrackerControl;+ where: TrackerWhere;+ }++ interface AIImageActionOptions extends AITextActionOptions {+ content?: string;+ seed?: string;+ }++ interface FilterImageOptions extends AIImageActionOptions {+ style: (typeof imageFilterStyles)[number];+ }++ interface ProcessImageOptions extends AIImageActionOptions {+ type: (typeof imageProcessingTypes)[number];+ }++ type TextStream = {+ [Symbol.asyncIterator](): AsyncIterableIterator<string>;+ };++ type AIActionTextResponse<T extends AITextActionOptions> =+ T['stream'] extends true ? TextStream : Promise<string>;++ interface TranslateOptions extends AITextActionOptions {+ lang: (typeof translateLangs)[number];+ }++ interface ChangeToneOptions extends AITextActionOptions {+ tone: (typeof textTones)[number];+ }++ interface ExpandMindMap extends AITextActionOptions {+ mindmap: string;+ }++ interface BrainstormMindMap extends AITextActionOptions {+ regenerate?: boolean;+ }++ interface AIActions {+ // chat is a bit special because it's has a internally maintained session+ chat<T extends AITextActionOptions>(options: T): AIActionTextResponse<T>;++ summary<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ improveWriting<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ improveGrammar<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ fixSpelling<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ createHeadings<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ makeLonger<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ makeShorter<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ continueWriting<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ checkCodeErrors<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ explainCode<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ writeArticle<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ writeTwitterPost<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ writePoem<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ writeBlogPost<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ brainstorm<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ writeOutline<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;++ explainImage<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;++ findActions<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;++ // mindmap+ brainstormMindmap<T extends BrainstormMindMap>(+ options: T+ ): AIActionTextResponse<T>;+ expandMindmap<T extends ExpandMindMap>(+ options: T+ ): AIActionTextResponse<T>;++ // presentation+ createSlides<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;++ // explain this+ explain<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;++ // actions with variants+ translate<T extends TranslateOptions>(+ options: T+ ): AIActionTextResponse<T>;+ changeTone<T extends ChangeToneOptions>(+ options: T+ ): AIActionTextResponse<T>;++ // make it real, image to text+ makeItReal<T extends AIImageActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ createImage<T extends AIImageActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ processImage<T extends ProcessImageOptions>(+ options: T+ ): AIActionTextResponse<T>;+ filterImage<T extends FilterImageOptions>(+ options: T+ ): AIActionTextResponse<T>;+ generateCaption<T extends AITextActionOptions>(+ options: T+ ): AIActionTextResponse<T>;+ }++ // todo: should be refactored to get rid of implement details (like messages, action, role, etc.)+ interface AIHistory {+ sessionId: string;+ tokens: number;+ action: string;+ createdAt: string;+ messages: {+ content: string;+ createdAt: string;+ role: 'user' | 'assistant';+ }[];+ }++ interface AIHistoryService {+ // non chat histories+ actions: (+ workspaceId: string,+ docId?: string+ ) => Promise<AIHistory[] | undefined>;+ chats: (+ workspaceId: string,+ docId?: string+ ) => Promise<AIHistory[] | undefined>;+ cleanup: (+ workspaceId: string,+ docId: string,+ sessionIds: string[]+ ) => Promise<void>;+ }++ interface AIPhotoEngineService {+ searchImages(options: {+ width: number;+ height: number;+ query: string;+ }): Promise<string[]>;+ }+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.ts b/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.tsnew file mode 100644index 0000000000..12ccd4a94b--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.ts@@ -0,0 +1,394 @@+import type { EditorHost } from '@blocksuite/block-std';+import {+ AFFINE_AI_PANEL_WIDGET,+ AffineAIPanelWidget,+ type AffineAIPanelWidgetConfig,+ type AIItemConfig,+ Bound,+ ImageBlockModel,+ isInsideEdgelessEditor,+ matchFlavours,+ NoteDisplayMode,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import type { TemplateResult } from 'lit';++import {+ AIPenIcon,+ AIStarIconWithAnimation,+ ChatWithAIIcon,+ CreateIcon,+ DiscardIcon,+ InsertBelowIcon,+ InsertTopIcon,+ ReplaceIcon,+ RetryIcon,+} from './_common/icons.js';+import { INSERT_ABOVE_ACTIONS } from './actions/consts.js';+import { createTextRenderer } from './messages/text.js';+import { AIProvider } from './provider.js';+import { reportResponse } from './utils/action-reporter.js';+import { findNoteBlockModel, getService } from './utils/edgeless.js';+import {+ copyTextAnswer,+ insertAbove,+ insertBelow,+ replace,+} from './utils/editor-actions.js';+import { insertFromMarkdown } from './utils/markdown-utils.js';+import { getSelections } from './utils/selection-utils.js';++function getSelection(host: EditorHost) {+ const textSelection = host.selection.find('text');+ const mode = textSelection ? 'flat' : 'highest';+ const { selectedBlocks } = getSelections(host, mode);+ assertExists(selectedBlocks);+ const length = selectedBlocks.length;+ const firstBlock = selectedBlocks[0];+ const lastBlock = selectedBlocks[length - 1];+ const selectedModels = selectedBlocks.map(block => block.model);+ return {+ textSelection,+ selectedModels,+ firstBlock,+ lastBlock,+ };+}++function asCaption<T extends keyof BlockSuitePresets.AIActions>(+ host: EditorHost,+ id?: T+): AIItemConfig {+ return {+ name: 'Use as caption',+ icon: AIPenIcon,+ showWhen: () => {+ const panel = getAIPanel(host);+ return id === 'generateCaption' && !!panel.answer;+ },+ handler: () => {+ reportResponse('result:use-as-caption');+ const panel = getAIPanel(host);+ const caption = panel.answer;+ if (!caption) return;++ const { selectedBlocks } = getSelections(host);+ if (!selectedBlocks || selectedBlocks.length !== 1) return;++ const imageBlock = selectedBlocks[0].model;+ if (!(imageBlock instanceof ImageBlockModel)) return;++ host.doc.updateBlock(imageBlock, { caption });+ panel.hide();+ },+ };+}++function createNewNote(host: EditorHost): AIItemConfig {+ return {+ name: 'Create new note',+ icon: CreateIcon,+ showWhen: () => {+ const panel = getAIPanel(host);+ return !!panel.answer && isInsideEdgelessEditor(host);+ },+ handler: () => {+ reportResponse('result:add-note');+ // get the note block+ const { selectedBlocks } = getSelections(host);+ if (!selectedBlocks || !selectedBlocks.length) return;+ const firstBlock = selectedBlocks[0];+ const noteModel = findNoteBlockModel(firstBlock);+ if (!noteModel) return;++ // create a new note block at the left of the current note block+ const bound = Bound.deserialize(noteModel.xywh);+ const newBound = new Bound(bound.x - bound.w - 20, bound.y, bound.w, 72);+ const doc = host.doc;+ const panel = getAIPanel(host);+ const service = getService(host);+ doc.transact(() => {+ assertExists(doc.root);+ const noteBlockId = doc.addBlock(+ 'affine:note',+ {+ xywh: newBound.serialize(),+ displayMode: NoteDisplayMode.EdgelessOnly,+ index: service.generateIndex('affine:note'),+ },+ doc.root.id+ );++ assertExists(panel.answer);+ insertFromMarkdown(host, panel.answer, noteBlockId)+ .then(() => {+ service.selection.set({+ elements: [noteBlockId],+ editing: false,+ });++ // set the viewport to show the new note block and original note block+ const newNote = doc.getBlock(noteBlockId)?.model;+ if (!newNote || !matchFlavours(newNote, ['affine:note'])) return;+ const newNoteBound = Bound.deserialize(newNote.xywh);++ const bounds = [bound, newNoteBound];+ const { zoom, centerX, centerY } = service.getFitToScreenData(+ [20, 20, 20, 20],+ bounds+ );+ service.viewport.setViewport(zoom, [centerX, centerY]);+ })+ .catch(err => {+ console.error(err);+ });+ });+ // hide the panel+ panel.hide();+ },+ };+}++async function replaceWithAnswer(panel: AffineAIPanelWidget) {+ const { host } = panel;+ const selection = getSelection(host);+ if (!selection || !panel.answer) return;++ const { textSelection, firstBlock, selectedModels } = selection;+ await replace(host, panel.answer, firstBlock, selectedModels, textSelection);++ panel.hide();+}++async function insertAnswerBelow(panel: AffineAIPanelWidget) {+ const { host } = panel;+ const selection = getSelection(host);++ if (!selection || !panel.answer) {+ return;+ }++ const { lastBlock } = selection;+ await insertBelow(host, panel.answer, lastBlock);+ panel.hide();+}++async function insertAnswerAbove(panel: AffineAIPanelWidget) {+ const { host } = panel;+ const selection = getSelection(host);+ if (!selection || !panel.answer) return;++ const { firstBlock } = selection;+ await insertAbove(host, panel.answer, firstBlock);+ panel.hide();+}++export function buildTextResponseConfig<+ T extends keyof BlockSuitePresets.AIActions,+>(panel: AffineAIPanelWidget, id?: T) {+ const host = panel.host;++ return [+ {+ name: 'Response',+ items: [+ {+ name: 'Insert below',+ icon: InsertBelowIcon,+ showWhen: () =>+ !!panel.answer && (!id || !INSERT_ABOVE_ACTIONS.includes(id)),+ handler: () => {+ reportResponse('result:insert');+ insertAnswerBelow(panel).catch(console.error);+ },+ },+ {+ name: 'Insert above',+ icon: InsertTopIcon,+ showWhen: () =>+ !!panel.answer && !!id && INSERT_ABOVE_ACTIONS.includes(id),+ handler: () => {+ reportResponse('result:insert');+ insertAnswerAbove(panel).catch(console.error);+ },+ },+ asCaption(host, id),+ {+ name: 'Replace selection',+ icon: ReplaceIcon,+ showWhen: () => !!panel.answer,+ handler: () => {+ reportResponse('result:replace');+ replaceWithAnswer(panel).catch(console.error);+ },+ },+ createNewNote(host),+ ],+ },+ {+ name: '',+ items: [+ {+ name: 'Continue in chat',+ icon: ChatWithAIIcon,+ handler: () => {+ reportResponse('result:continue-in-chat');+ AIProvider.slots.requestContinueInChat.emit({+ host: panel.host,+ show: true,+ });+ panel.hide();+ },+ },+ {+ name: 'Regenerate',+ icon: RetryIcon,+ handler: () => {+ reportResponse('result:retry');+ panel.generate();+ },+ },+ {+ name: 'Discard',+ icon: DiscardIcon,+ handler: () => {+ panel.discard();+ },+ },+ ],+ },+ ];+}++export function buildErrorResponseConfig<+ T extends keyof BlockSuitePresets.AIActions,+>(panel: AffineAIPanelWidget, id?: T) {+ const host = panel.host;++ return [+ {+ name: 'Response',+ items: [+ {+ name: 'Replace selection',+ icon: ReplaceIcon,+ showWhen: () => !!panel.answer,+ handler: () => {+ replaceWithAnswer(panel).catch(console.error);+ },+ },+ {+ name: 'Insert below',+ icon: InsertBelowIcon,+ showWhen: () =>+ !!panel.answer && (!id || !INSERT_ABOVE_ACTIONS.includes(id)),+ handler: () => {+ insertAnswerBelow(panel).catch(console.error);+ },+ },+ {+ name: 'Insert above',+ icon: InsertTopIcon,+ showWhen: () =>+ !!panel.answer && !!id && INSERT_ABOVE_ACTIONS.includes(id),+ handler: () => {+ reportResponse('result:insert');+ insertAnswerAbove(panel).catch(console.error);+ },+ },+ asCaption(host, id),+ createNewNote(host),+ ],+ },+ {+ name: '',+ items: [+ {+ name: 'Retry',+ icon: RetryIcon,+ showWhen: () => true,+ handler: () => {+ reportResponse('result:retry');+ panel.generate();+ },+ },+ {+ name: 'Discard',+ icon: DiscardIcon,+ showWhen: () => !!panel.answer,+ handler: () => {+ panel.discard();+ },+ },+ ],+ },+ ];+}++export function buildFinishConfig<T extends keyof BlockSuitePresets.AIActions>(+ panel: AffineAIPanelWidget,+ id?: T+) {+ return {+ responses: buildTextResponseConfig(panel, id),+ actions: [],+ };+}++export function buildErrorConfig<T extends keyof BlockSuitePresets.AIActions>(+ panel: AffineAIPanelWidget,+ id?: T+) {+ return {+ upgrade: () => {+ AIProvider.slots.requestUpgradePlan.emit({ host: panel.host });+ panel.hide();+ },+ login: () => {+ AIProvider.slots.requestLogin.emit({ host: panel.host });+ panel.hide();+ },+ cancel: () => {+ panel.hide();+ },+ responses: buildErrorResponseConfig(panel, id),+ };+}++export function buildGeneratingConfig(generatingIcon?: TemplateResult<1>) {+ return {+ generatingIcon: generatingIcon ?? AIStarIconWithAnimation,+ };+}++export function buildCopyConfig(panel: AffineAIPanelWidget) {+ return {+ allowed: true,+ onCopy: () => {+ return copyTextAnswer(panel);+ },+ };+}++export function buildAIPanelConfig(+ panel: AffineAIPanelWidget+): AffineAIPanelWidgetConfig {+ return {+ answerRenderer: createTextRenderer(panel.host, { maxHeight: 320 }),+ finishStateConfig: buildFinishConfig(panel),+ generatingStateConfig: buildGeneratingConfig(),+ errorStateConfig: buildErrorConfig(panel),+ copy: buildCopyConfig(panel),+ };+}++export const getAIPanel = (host: EditorHost): AffineAIPanelWidget => {+ const rootBlockId = host.doc.root?.id;+ assertExists(rootBlockId);+ const aiPanel = host.view.getWidget(AFFINE_AI_PANEL_WIDGET, rootBlockId);+ assertExists(aiPanel);+ if (!(aiPanel instanceof AffineAIPanelWidget)) {+ throw new Error('AI panel not found');+ }+ return aiPanel;+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/ai-spec.ts b/packages/frontend/core/src/blocksuite/presets/ai/ai-spec.tsnew file mode 100644index 0000000000..1c89af9bf2--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/ai-spec.ts@@ -0,0 +1,156 @@+import type { BlockSpec } from '@blocksuite/block-std';+import {+ AFFINE_AI_PANEL_WIDGET,+ AFFINE_EDGELESS_COPILOT_WIDGET,+ AffineAIPanelWidget,+ AffineCodeToolbarWidget,+ AffineFormatBarWidget,+ AffineImageToolbarWidget,+ AffineSlashMenuWidget,+ CodeBlockSpec,+ EdgelessCopilotWidget,+ EdgelessElementToolbarWidget,+ EdgelessRootBlockSpec,+ ImageBlockSpec,+ PageRootBlockSpec,+ ParagraphBlockService,+ ParagraphBlockSpec,+} from '@blocksuite/blocks';+import { assertInstanceOf } from '@blocksuite/global/utils';+import { literal, unsafeStatic } from 'lit/static-html.js';++import { buildAIPanelConfig } from './ai-panel.js';+import { setupCodeToolbarEntry } from './entries/code-toolbar/setup-code-toolbar.js';+import {+ setupEdgelessCopilot,+ setupEdgelessElementToolbarEntry,+} from './entries/edgeless/index.js';+import { setupFormatBarEntry } from './entries/format-bar/setup-format-bar.js';+import { setupImageToolbarEntry } from './entries/image-toolbar/setup-image-toolbar.js';+import { setupSlashMenuEntry } from './entries/slash-menu/setup-slash-menu.js';+import { setupSpaceEntry } from './entries/space/setup-space.js';++export const AIPageRootBlockSpec: BlockSpec = {+ ...PageRootBlockSpec,+ view: {+ ...PageRootBlockSpec.view,+ widgets: {+ ...PageRootBlockSpec.view.widgets,+ [AFFINE_AI_PANEL_WIDGET]: literal`${unsafeStatic(+ AFFINE_AI_PANEL_WIDGET+ )}`,+ },+ },+ setup: (slots, disposableGroup) => {+ PageRootBlockSpec.setup?.(slots, disposableGroup);+ disposableGroup.add(+ slots.widgetConnected.on(view => {+ if (view.component instanceof AffineAIPanelWidget) {+ view.component.style.width = '630px';+ view.component.config = buildAIPanelConfig(view.component);+ setupSpaceEntry(view.component);+ }++ if (view.component instanceof AffineFormatBarWidget) {+ setupFormatBarEntry(view.component);+ }++ if (view.component instanceof AffineSlashMenuWidget) {+ setupSlashMenuEntry(view.component);+ }+ })+ );+ },+};++export const AIEdgelessRootBlockSpec: BlockSpec = {+ ...EdgelessRootBlockSpec,+ view: {+ ...EdgelessRootBlockSpec.view,+ widgets: {+ ...EdgelessRootBlockSpec.view.widgets,+ [AFFINE_EDGELESS_COPILOT_WIDGET]: literal`${unsafeStatic(+ AFFINE_EDGELESS_COPILOT_WIDGET+ )}`,+ [AFFINE_AI_PANEL_WIDGET]: literal`${unsafeStatic(+ AFFINE_AI_PANEL_WIDGET+ )}`,+ },+ },+ setup(slots, disposableGroup) {+ EdgelessRootBlockSpec.setup?.(slots, disposableGroup);+ slots.widgetConnected.on(view => {+ if (view.component instanceof AffineAIPanelWidget) {+ view.component.style.width = '430px';+ view.component.config = buildAIPanelConfig(view.component);+ setupSpaceEntry(view.component);+ }++ if (view.component instanceof EdgelessCopilotWidget) {+ setupEdgelessCopilot(view.component);+ }++ if (view.component instanceof EdgelessElementToolbarWidget) {+ setupEdgelessElementToolbarEntry(view.component);+ }++ if (view.component instanceof AffineFormatBarWidget) {+ setupFormatBarEntry(view.component);+ }++ if (view.component instanceof AffineSlashMenuWidget) {+ setupSlashMenuEntry(view.component);+ }+ });+ },+};++export const AIParagraphBlockSpec: BlockSpec = {+ ...ParagraphBlockSpec,+ setup(slots, disposableGroup) {+ ParagraphBlockSpec.setup?.(slots, disposableGroup);+ slots.mounted.on(({ service }) => {+ assertInstanceOf(service, ParagraphBlockService);+ service.placeholderGenerator = model => {+ if (model.type === 'text') {+ return "Type '/' for commands, 'space' for AI";+ }++ const placeholders = {+ h1: 'Heading 1',+ h2: 'Heading 2',+ h3: 'Heading 3',+ h4: 'Heading 4',+ h5: 'Heading 5',+ h6: 'Heading 6',+ quote: '',+ };+ return placeholders[model.type];+ };+ });+ },+};++export const AICodeBlockSpec: BlockSpec = {+ ...CodeBlockSpec,+ setup(slots, disposableGroup) {+ CodeBlockSpec.setup?.(slots, disposableGroup);+ slots.widgetConnected.on(view => {+ if (view.component instanceof AffineCodeToolbarWidget) {+ setupCodeToolbarEntry(view.component);+ }+ });+ },+};++export const AIImageBlockSpec: BlockSpec = {+ ...ImageBlockSpec,+ setup(slots, disposableGroup) {+ ImageBlockSpec.setup?.(slots, disposableGroup);+ slots.widgetConnected.on(view => {+ if (view.component instanceof AffineImageToolbarWidget) {+ setupImageToolbarEntry(view.component);+ }+ });+ },+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/action-wrapper.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/action-wrapper.tsnew file mode 100644index 0000000000..7c4a490229--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/action-wrapper.ts@@ -0,0 +1,166 @@+import type { EditorHost } from '@blocksuite/block-std';+import { WithDisposable } from '@blocksuite/block-std';+import { css, html, LitElement, nothing, type TemplateResult } from 'lit';+import { customElement, property, state } from 'lit/decorators.js';++import {+ ActionIcon,+ AIChangeToneIcon,+ AIDoneIcon,+ AIExpandMindMapIcon,+ AIExplainIcon,+ AIExplainSelectionIcon,+ AIFindActionsIcon,+ AIImageIcon,+ AIImproveWritingIcon,+ AIMakeLongerIcon,+ AIMakeRealIcon,+ AIMakeShorterIcon,+ AIMindMapIcon,+ AIPenIcon,+ AIPresentationIcon,+ ArrowDownIcon,+ ArrowUpIcon,+} from '../../_common/icons.js';+import { createTextRenderer } from '../../messages/text.js';+import type { ChatAction } from '../chat-context.js';+import { renderImages } from '../components/images.js';+import { HISTORY_IMAGE_ACTIONS } from '../const.js';++const icons: Record<string, TemplateResult<1>> = {+ 'Fix spelling for it': AIDoneIcon,+ 'Improve grammar for it': AIDoneIcon,+ 'Explain this code': AIExplainIcon,+ 'Check code error': AIExplainIcon,+ 'Explain this': AIExplainSelectionIcon,+ Translate: ActionIcon,+ 'Change tone': AIChangeToneIcon,+ 'Improve writing for it': AIImproveWritingIcon,+ 'Make it longer': AIMakeLongerIcon,+ 'Make it shorter': AIMakeShorterIcon,+ 'Continue writing': AIPenIcon,+ 'Make it real': AIMakeRealIcon,+ 'Find action items from it': AIFindActionsIcon,+ Summary: AIPenIcon,+ 'Create headings': AIPenIcon,+ 'Write outline': AIPenIcon,+ image: AIImageIcon,+ 'Brainstorm mindmap': AIMindMapIcon,+ 'Expand mind map': AIExpandMindMapIcon,+ 'Create a presentation': AIPresentationIcon,+ 'Write a poem about this': AIPenIcon,+ 'Write a blog post about this': AIPenIcon,+ 'AI image filter clay style': AIImageIcon,+ 'AI image filter sketch style': AIImageIcon,+ 'AI image filter anime style': AIImageIcon,+ 'AI image filter pixel style': AIImageIcon,+ Clearer: AIImageIcon,+ 'Remove background': AIImageIcon,+ 'Convert to sticker': AIImageIcon,+};++@customElement('action-wrapper')+export class ActionWrapper extends WithDisposable(LitElement) {+ static override styles = css`+ .action-name {+ display: flex;+ align-items: center;+ gap: 8px;+ height: 22px;+ margin-bottom: 12px;++ svg {+ color: var(--affine-primary-color);+ }++ div:last-child {+ cursor: pointer;+ display: flex;+ align-items: center;+ flex: 1;++ div:last-child svg {+ margin-left: auto;+ }+ }+ }++ .answer-prompt {+ padding: 8px;+ background-color: var(--affine-background-secondary-color);+ display: flex;+ flex-direction: column;+ gap: 4px;+ font-size: 14px;+ font-weight: 400;+ color: var(--affine-text-primary-color);++ .subtitle {+ font-size: 12px;+ font-weight: 500;+ color: var(--affine-text-secondary-color);+ height: 20px;+ line-height: 20px;+ }++ .prompt {+ margin-top: 12px;+ }+ }+ `;++ @state()+ accessor promptShow = false;++ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ protected override render() {+ const { item } = this;++ const originalText = item.messages[1].content;+ const answer = item.messages[2]?.content;+ const images = item.messages[1].attachments;++ return html`<style></style>+ <slot></slot>+ <div+ class="action-name"+ @click=${() => (this.promptShow = !this.promptShow)}+ >+ ${icons[item.action] ? icons[item.action] : ActionIcon}+ <div>+ <div>${item.action}</div>+ <div>${this.promptShow ? ArrowDownIcon : ArrowUpIcon}</div>+ </div>+ </div>+ ${this.promptShow+ ? html`+ <div class="answer-prompt">+ <div class="subtitle">Answer</div>+ ${HISTORY_IMAGE_ACTIONS.includes(item.action)+ ? images && renderImages(images)+ : nothing}+ ${answer+ ? createTextRenderer(this.host, { customHeading: true })(answer)+ : nothing}+ ${originalText+ ? html`<div class="subtitle prompt">Prompt</div>+ ${createTextRenderer(this.host, { customHeading: true })(+ item.messages[0].content + originalText+ )}`+ : nothing}+ </div>+ `+ : nothing} `;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-wrapper': ActionWrapper;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/actions-handle.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/actions-handle.tsnew file mode 100644index 0000000000..047f348777--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/actions-handle.ts@@ -0,0 +1,166 @@+import type {+ BlockSelection,+ EditorHost,+ TextSelection,+} from '@blocksuite/block-std';+import type {+ EdgelessRootService,+ ImageSelection,+ SerializedXYWH,+} from '@blocksuite/blocks';+import {+ BlocksUtils,+ Bound,+ getElementsBound,+ NoteDisplayMode,+} from '@blocksuite/blocks';++import {+ CreateIcon,+ InsertBelowIcon,+ ReplaceIcon,+} from '../../_common/icons.js';+import { reportResponse } from '../../utils/action-reporter.js';+import { insertBelow, replace } from '../../utils/editor-actions.js';+import { insertFromMarkdown } from '../../utils/markdown-utils.js';++const { matchFlavours } = BlocksUtils;++const CommonActions = [+ {+ icon: ReplaceIcon,+ title: 'Replace selection',+ handler: async (+ host: EditorHost,+ content: string,+ currentTextSelection?: TextSelection,+ currentBlockSelections?: BlockSelection[]+ ) => {+ const [_, data] = host.command+ .chain()+ .getSelectedBlocks({+ currentTextSelection,+ currentBlockSelections,+ })+ .run();+ if (!data.selectedBlocks) return;++ reportResponse('result:replace');++ if (currentTextSelection) {+ const { doc } = host;+ const block = doc.getBlock(currentTextSelection.blockId);+ if (matchFlavours(block?.model ?? null, ['affine:paragraph'])) {+ block?.model.text?.replace(+ currentTextSelection.from.index,+ currentTextSelection.from.length,+ content+ );+ return;+ }+ }++ await replace(+ host,+ content,+ data.selectedBlocks[0],+ data.selectedBlocks.map(block => block.model),+ currentTextSelection+ );+ },+ },+ {+ icon: InsertBelowIcon,+ title: 'Insert below',+ handler: async (+ host: EditorHost,+ content: string,+ currentTextSelection?: TextSelection,+ currentBlockSelections?: BlockSelection[],+ currentImageSelections?: ImageSelection[]+ ) => {+ const [_, data] = host.command+ .chain()+ .getSelectedBlocks({+ currentTextSelection,+ currentBlockSelections,+ currentImageSelections,+ })+ .run();+ if (!data.selectedBlocks) return;+ reportResponse('result:insert');+ await insertBelow(+ host,+ content,+ data.selectedBlocks[data.selectedBlocks?.length - 1]+ );+ },+ },+];++export const PageEditorActions = [+ ...CommonActions,+ {+ icon: CreateIcon,+ title: 'Create as a doc',+ handler: (host: EditorHost, content: string) => {+ reportResponse('result:add-page');+ const newDoc = host.doc.collection.createDoc();+ newDoc.load();+ const rootId = newDoc.addBlock('affine:page');+ newDoc.addBlock('affine:surface', {}, rootId);+ const noteId = newDoc.addBlock('affine:note', {}, rootId);++ host.spec.getService('affine:page').slots.docLinkClicked.emit({+ docId: newDoc.id,+ });+ let complete = false;+ (function addContent() {+ if (complete) return;+ const newHost = document.querySelector('editor-host');+ // FIXME: this is a hack to wait for the host to be ready, now we don't have a way to know if the new host is ready+ if (!newHost || newHost === host) {+ setTimeout(addContent, 100);+ return;+ }+ complete = true;+ insertFromMarkdown(newHost, content, noteId, 0).catch(console.error);+ })();+ },+ },+];++export const EdgelessEditorActions = [+ ...CommonActions,+ {+ icon: CreateIcon,+ title: 'Add to edgeless as note',+ handler: async (host: EditorHost, content: string) => {+ reportResponse('result:add-note');+ const { doc } = host;+ const service = host.spec.getService<EdgelessRootService>('affine:page');+ const elements = service.selection.selectedElements;++ const props: { displayMode: NoteDisplayMode; xywh?: SerializedXYWH } = {+ displayMode: NoteDisplayMode.EdgelessOnly,+ };++ if (elements.length > 0) {+ const bound = getElementsBound(+ elements.map(e => Bound.deserialize(e.xywh))+ );+ const newBound = new Bound(bound.x, bound.maxY + 10, bound.w);+ props.xywh = newBound.serialize();+ }++ const id = doc.addBlock('affine:note', props, doc.root?.id);++ await insertFromMarkdown(host, content, id, 0);++ service.selection.set({+ elements: [id],+ editing: false,+ });+ },+ },+];diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/chat-text.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/chat-text.tsnew file mode 100644index 0000000000..80db6d3b0e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/chat-text.ts@@ -0,0 +1,39 @@+import './action-wrapper.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { html, nothing } from 'lit';+import { customElement, property } from 'lit/decorators.js';++import { createTextRenderer } from '../../messages/text.js';+import { renderImages } from '../components/images.js';+@customElement('chat-text')+export class ChatText extends WithDisposable(ShadowlessElement) {+ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor attachments: string[] | undefined = undefined;++ @property({ attribute: false })+ accessor text!: string;++ @property({ attribute: false })+ accessor state: 'finished' | 'generating' = 'finished';++ protected override render() {+ const { attachments, text, host } = this;+ return html`${attachments && attachments.length > 0+ ? renderImages(attachments)+ : nothing}${createTextRenderer(host, { customHeading: true })(+ text,+ this.state+ )} `;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'chat-text': ChatText;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/copy-more.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/copy-more.tsnew file mode 100644index 0000000000..d7812437a4--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/copy-more.ts@@ -0,0 +1,226 @@+import type {+ BlockSelection,+ EditorHost,+ TextSelection,+} from '@blocksuite/block-std';+import { WithDisposable } from '@blocksuite/block-std';+import { type AIError, createButtonPopper, Tooltip } from '@blocksuite/blocks';+import { noop } from '@blocksuite/global/utils';+import { css, html, LitElement, nothing, type PropertyValues } from 'lit';+import { customElement, property, query, state } from 'lit/decorators.js';+import { repeat } from 'lit/directives/repeat.js';++import { CopyIcon, MoreIcon, RetryIcon } from '../../_common/icons.js';+import { AIProvider } from '../../provider.js';+import { copyText } from '../../utils/editor-actions.js';+import type { ChatContextValue, ChatMessage } from '../chat-context.js';+import { PageEditorActions } from './actions-handle.js';++noop(Tooltip);++@customElement('chat-copy-more')+export class ChatCopyMore extends WithDisposable(LitElement) {+ static override styles = css`+ .copy-more {+ display: flex;+ gap: 8px;+ height: 36px;+ justify-content: flex-end;+ align-items: center;+ margin-top: 8px;+ margin-bottom: 12px;++ div {+ cursor: pointer;+ border-radius: 4px;+ }++ div:hover {+ background-color: var(--affine-hover-color);+ }++ svg {+ color: var(--affine-icon-color);+ }+ }++ .more-menu {+ width: 226px;+ border-radius: 8px;+ background-color: var(--affine-background-overlay-panel-color);+ box-shadow: var(--affine-menu-shadow);+ display: flex;+ flex-direction: column;+ gap: 4px;+ position: absolute;+ z-index: 1;+ user-select: none;++ > div {+ height: 30px;+ display: flex;+ gap: 8px;+ align-items: center;+ cursor: pointer;++ svg {+ margin-left: 12px;+ }+ }++ > div:hover {+ background-color: var(--affine-hover-color);+ }+ }+ `;++ @state()+ private accessor _showMoreMenu = false;++ @query('.more-button')+ private accessor _moreButton!: HTMLDivElement;++ @query('.more-menu')+ private accessor _moreMenu!: HTMLDivElement;++ private _morePopper: ReturnType<typeof createButtonPopper> | null = null;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor content!: string;++ @property({ attribute: false })+ accessor isLast!: boolean;++ @property({ attribute: false })+ accessor curTextSelection: TextSelection | undefined = undefined;++ @property({ attribute: false })+ accessor curBlockSelections: BlockSelection[] | undefined = undefined;++ @property({ attribute: false })+ accessor chatContextValue!: ChatContextValue;++ @property({ attribute: false })+ accessor updateContext!: (context: Partial<ChatContextValue>) => void;++ private _toggle() {+ this._morePopper?.toggle();+ }++ private async _retry() {+ const { doc } = this.host;+ try {+ const abortController = new AbortController();++ const items = [...this.chatContextValue.items];+ const last = items[items.length - 1];+ if ('content' in last) {+ last.content = '';+ last.createdAt = new Date().toISOString();+ }+ this.updateContext({ items, status: 'loading', error: null });++ const stream = AIProvider.actions.chat?.({+ retry: true,+ docId: doc.id,+ workspaceId: doc.collection.id,+ host: this.host,+ stream: true,+ signal: abortController.signal,+ where: 'chat-panel',+ control: 'chat-send',+ });++ if (stream) {+ this.updateContext({ abortController });+ for await (const text of stream) {+ const items = [...this.chatContextValue.items];+ const last = items[items.length - 1] as ChatMessage;+ last.content += text;+ this.updateContext({ items, status: 'transmitting' });+ }++ this.updateContext({ status: 'success' });+ }+ } catch (error) {+ this.updateContext({ status: 'error', error: error as AIError });+ } finally {+ this.updateContext({ abortController: null });+ }+ }++ protected override updated(changed: PropertyValues): void {+ if (changed.has('isLast')) {+ if (this.isLast) {+ this._morePopper?.dispose();+ this._morePopper = null;+ } else if (!this._morePopper) {+ this._morePopper = createButtonPopper(+ this._moreButton,+ this._moreMenu,+ ({ display }) => (this._showMoreMenu = display === 'show')+ );+ }+ }+ }++ override render() {+ const { host, content, isLast } = this;+ return html`<style>+ .more-menu {+ padding: ${this._showMoreMenu ? '8px' : '0px'};+ }+ </style>+ <div class="copy-more">+ ${content+ ? html`<div @click=${() => copyText(host, content)}>+ ${CopyIcon}+ <affine-tooltip>Copy</affine-tooltip>+ </div>`+ : nothing}+ ${isLast+ ? html`<div @click=${() => this._retry()}>+ ${RetryIcon}+ <affine-tooltip>Retry</affine-tooltip>+ </div>`+ : nothing}+ ${isLast+ ? nothing+ : html`<div class="more-button" @click=${this._toggle}>+ ${MoreIcon}+ </div> `}+ </div>++ <div class="more-menu">+ ${this._showMoreMenu+ ? repeat(+ PageEditorActions,+ action => action.title,+ action => {+ return html`<div+ @click=${() =>+ action.handler(+ host,+ content,+ this.curTextSelection,+ this.curBlockSelections+ )}+ >+ ${action.icon}+ <div>${action.title}</div>+ </div>`;+ }+ )+ : nothing}+ </div>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'chat-copy-more': ChatCopyMore;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/image-to-text.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/image-to-text.tsnew file mode 100644index 0000000000..7d7173b578--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/image-to-text.ts@@ -0,0 +1,35 @@+import './action-wrapper.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { html, nothing } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import type { ChatAction } from '../chat-context.js';+import { renderImages } from '../components/images.js';++@customElement('action-image-to-text')+export class ActionImageToText extends WithDisposable(ShadowlessElement) {+ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ protected override render() {+ const answer = this.item.messages[1].attachments;++ return html`<action-wrapper .host=${this.host} .item=${this.item}>+ <div style=${styleMap({ marginBottom: '12px' })}>+ ${answer ? renderImages(answer) : nothing}+ </div>+ </action-wrapper>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-image-to-text': ActionImageToText;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/image.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/image.tsnew file mode 100644index 0000000000..ee7508d793--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/image.ts@@ -0,0 +1,35 @@+import './action-wrapper.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { html, nothing } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import type { ChatAction } from '../chat-context.js';+import { renderImages } from '../components/images.js';++@customElement('action-image')+export class ActionImage extends WithDisposable(ShadowlessElement) {+ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ protected override render() {+ const answer = this.item.messages[0].attachments;++ return html`<action-wrapper .host=${this.host} .item=${this.item}>+ <div style=${styleMap({ marginBottom: '12px' })}>+ ${answer ? renderImages(answer) : nothing}+ </div>+ </action-wrapper>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-image': ActionImage;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/make-real.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/make-real.tsnew file mode 100644index 0000000000..024637faf8--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/make-real.ts@@ -0,0 +1,34 @@+import './action-wrapper.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { html } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import { createIframeRenderer } from '../../messages/wrapper.js';+import type { ChatAction } from '../chat-context.js';++@customElement('action-make-real')+export class ActionMakeReal extends WithDisposable(ShadowlessElement) {+ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ protected override render() {+ const answer = this.item.messages[2].content;+ return html`<action-wrapper .host=${this.host} .item=${this.item}>+ <div style=${styleMap({ marginBottom: '12px' })}>+ ${createIframeRenderer(this.host)(answer, 'finished')}+ </div>+ </action-wrapper>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-make-real': ActionMakeReal;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/mindmap.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/mindmap.tsnew file mode 100644index 0000000000..dba11f5a5c--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/mindmap.ts@@ -0,0 +1,46 @@+import './action-wrapper.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { MiniMindmapPreview } from '@blocksuite/blocks';+import { noop } from '@blocksuite/global/utils';+import { html } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import type { ChatAction } from '../chat-context.js';++noop(MiniMindmapPreview);++@customElement('action-mindmap')+export class ActionMindmap extends WithDisposable(ShadowlessElement) {+ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ protected override render() {+ const answer = this.item.messages[2].content;+ return html`<action-wrapper .host=${this.host} .item=${this.item}>+ <div style=${styleMap({ marginBottom: '12px', height: '140px' })}>+ <mini-mindmap-preview+ .host=${this.host}+ .ctx=${{+ get: () => ({}),+ set: () => {},+ }}+ .answer=${answer}+ .templateShow=${false}+ .height=${140}+ ></mini-mindmap-preview>+ </div>+ </action-wrapper>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-mindmap': ActionMindmap;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/slides.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/slides.tsnew file mode 100644index 0000000000..aaf54022d6--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/slides.ts@@ -0,0 +1,39 @@+import './action-wrapper.js';+import '../../messages/slides-renderer.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { html, nothing } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import type { ChatAction } from '../chat-context.js';++@customElement('action-slides')+export class ActionSlides extends WithDisposable(ShadowlessElement) {+ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ protected override render() {+ const answer = this.item.messages[2]?.content;+ if (!answer) return nothing;++ return html`<action-wrapper .host=${this.host} .item=${this.item}>+ <div style=${styleMap({ marginBottom: '12px', height: '174px' })}>+ <ai-slides-renderer+ .text=${answer}+ .host=${this.host}+ ></ai-slides-renderer>+ </div>+ </action-wrapper>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-slides': ActionSlides;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/text.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/text.tsnew file mode 100644index 0000000000..e4f9d19684--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/actions/text.ts@@ -0,0 +1,57 @@+import './action-wrapper.js';++import type { EditorHost } from '@blocksuite/block-std';+import { WithDisposable } from '@blocksuite/block-std';+import { css, html, LitElement } from 'lit';+import { customElement, property } from 'lit/decorators.js';+import { styleMap } from 'lit/directives/style-map.js';++import { createTextRenderer } from '../../messages/text.js';+import type { ChatAction } from '../chat-context.js';++@customElement('action-text')+export class ActionText extends WithDisposable(LitElement) {+ static override styles = css`+ .original-text {+ border-radius: 4px;+ margin-bottom: 12px;+ font-size: var(--affine-font-sm);+ line-height: 22px;+ }+ `;++ @property({ attribute: false })+ accessor item!: ChatAction;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor isCode = false;++ protected override render() {+ const originalText = this.item.messages[1].content;+ const { isCode } = this;++ return html` <action-wrapper .host=${this.host} .item=${this.item}>+ <div+ style=${styleMap({+ padding: isCode ? '0' : '10px 16px',+ border: isCode ? 'none' : '1px solid var(--affine-border-color)',+ })}+ class="original-text"+ >+ ${createTextRenderer(this.host, {+ customHeading: true,+ maxHeight: 160,+ })(originalText)}+ </div>+ </action-wrapper>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'action-text': ActionText;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/ai-loading.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/ai-loading.tsnew file mode 100644index 0000000000..67744a6e5a--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/ai-loading.ts@@ -0,0 +1,65 @@+import { WithDisposable } from '@blocksuite/block-std';+import { css, html, LitElement } from 'lit';+import { customElement, property } from 'lit/decorators.js';++import { AIStarIconWithAnimation } from '../_common/icons.js';++@customElement('ai-loading')+export class AILoading extends WithDisposable(LitElement) {+ static override styles = css`+ :host {+ width: 100%;+ }++ .generating-tip {+ display: flex;+ width: 100%;+ height: 22px;+ align-items: center;+ gap: 8px;++ color: var(--light-brandColor, #1e96eb);++ .text {+ display: flex;+ align-items: flex-start;+ gap: 10px;+ flex: 1 0 0;++ /* light/smMedium */+ font-family: Inter;+ font-size: 14px;+ font-style: normal;+ font-weight: 500;+ line-height: 22px; /* 157.143% */+ }++ .left,+ .right {+ display: flex;+ width: 20px;+ height: 20px;+ justify-content: center;+ align-items: center;+ }+ }+ `;++ @property({ attribute: false })+ accessor stopGenerating!: () => void;++ override render() {+ return html`+ <div class="generating-tip">+ <div class="left">${AIStarIconWithAnimation}</div>+ <div class="text">AI is generating...</div>+ </div>+ `;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'ai-loading': AILoading;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.tsnew file mode 100644index 0000000000..d269692a4e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-cards.ts@@ -0,0 +1,359 @@+import type { BaseSelection, EditorHost } from '@blocksuite/block-std';+import { WithDisposable } from '@blocksuite/block-std';+import {+ type CopilotSelectionController,+ type ImageBlockModel,+ type NoteBlockModel,+ NoteDisplayMode,+} from '@blocksuite/blocks';+import { debounce } from '@blocksuite/global/utils';+import type { BlockModel } from '@blocksuite/store';+import { css, html, LitElement, nothing, type PropertyValues } from 'lit';+import { customElement, property, state } from 'lit/decorators.js';+import { repeat } from 'lit/directives/repeat.js';+import { styleMap } from 'lit/directives/style-map.js';++import {+ CurrentSelectionIcon,+ DocIcon,+ SmallImageIcon,+} from '../_common/icons.js';+import {+ getEdgelessRootFromEditor,+ getSelectedImagesAsBlobs,+ getSelectedTextContent,+ getTextContentFromBlockModels,+ selectedToCanvas,+} from '../utils/selection-utils.js';+import type { ChatContextValue } from './chat-context.js';++const cardsStyles = css`+ .card-wrapper {+ width: 90%;+ max-height: 76px;+ border-radius: 8px;+ border: 1px solid var(--affine-border-color);+ padding: 4px 12px;+ cursor: pointer;++ .card-title {+ display: flex;+ gap: 4px;+ height: 22px;+ margin-bottom: 2px;+ font-weight: 500;+ font-size: 14px;+ color: var(--affine-text-primary-color);+ }++ .second-text {+ font-size: 14px;+ font-weight: 400;+ color: var(--affine-text-secondary-color);+ }+ }+`;++const ChatCardsConfig = [+ {+ name: 'current-selection',+ render: (text?: string, _?: File, __?: string) => {+ if (!text) return nothing;++ const lines = text.split('\n');++ return html`<div class="card-wrapper">+ <div class="card-title">+ ${CurrentSelectionIcon}+ <div>Start with current selection</div>+ </div>+ <div class="second-text">+ ${repeat(+ lines.slice(0, 2),+ line => line,+ line => {+ return html`<div+ style=${styleMap({+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ })}+ >+ ${line}+ </div>`;+ }+ )}+ </div>+ </div> `;+ },+ handler: (+ updateContext: (context: Partial<ChatContextValue>) => void,+ text: string,+ markdown: string,+ images?: File[]+ ) => {+ const value: Partial<ChatContextValue> = {+ quote: text,+ markdown: markdown,+ };+ if (images) {+ value.images = images;+ }+ updateContext(value);+ },+ },+ {+ name: 'image',+ render: (_?: string, image?: File, caption?: string) => {+ if (!image) return nothing;++ return html`<div+ class="card-wrapper"+ style=${styleMap({+ display: 'flex',+ gap: '8px',+ justifyContent: 'space-between',+ })}+ >+ <div+ style=${styleMap({+ display: 'flex',+ flexDirection: 'column',+ })}+ >+ <div class="card-title">+ ${SmallImageIcon}+ <div>Start with this Image</div>+ </div>+ <div class="second-text">${caption ? caption : 'caption'}</div>+ </div>+ <img+ style=${styleMap({+ maxWidth: '72px',+ maxHeight: '46px',+ })}+ src="${URL.createObjectURL(image)}"+ />+ </div>`;+ },+ handler: (+ updateContext: (context: Partial<ChatContextValue>) => void,+ _: string,+ __: string,+ images?: File[]+ ) => {+ const value: Partial<ChatContextValue> = {};+ if (images) {+ value.images = images;+ }+ updateContext(value);+ },+ },+ {+ name: 'doc',+ render: () => {+ return html`+ <div class="card-wrapper">+ <div class="card-title">+ ${DocIcon}+ <div>Start with this doc</div>+ </div>+ <div class="second-text">you've chosen within the doc</div>+ </div>+ `;+ },+ handler: (+ updateContext: (context: Partial<ChatContextValue>) => void,+ text: string,+ markdown: string,+ images?: File[]+ ) => {+ const value: Partial<ChatContextValue> = {+ quote: text,+ markdown: markdown,+ };+ if (images) {+ value.images = images;+ }+ updateContext(value);+ },+ },+];++@customElement('chat-cards')+export class ChatCards extends WithDisposable(LitElement) {+ static override styles = css`+ ${cardsStyles}+ .cards-container {+ display: flex;+ flex-direction: column;+ gap: 12px;+ }+ `;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor chatContextValue!: ChatContextValue;++ @property({ attribute: false })+ accessor updateContext!: (context: Partial<ChatContextValue>) => void;++ @property({ attribute: false })+ accessor selectionValue: BaseSelection[] = [];++ @state()+ accessor text: string = '';++ @state()+ accessor markdown: string = '';++ @state()+ accessor images: File[] = [];++ @state()+ accessor caption: string = '';++ private _onEdgelessCopilotAreaUpdated() {+ if (!this.host.closest('edgeless-editor')) return;+ const edgeless = getEdgelessRootFromEditor(this.host);++ const copilotSelectionTool = edgeless.tools.controllers+ .copilot as CopilotSelectionController;++ this._disposables.add(+ copilotSelectionTool.draggingAreaUpdated.on(+ debounce(() => {+ selectedToCanvas(this.host)+ .then(canvas => {+ canvas?.toBlob(blob => {+ if (!blob) return;+ const file = new File([blob], 'selected.png');+ this.images = [file];+ });+ })+ .catch(console.error);+ }, 300)+ )+ );+ }++ private async _updateState() {+ if (+ this.selectionValue.some(+ selection => selection.is('text') || selection.is('image')+ )+ )+ return;+ this.text = await getSelectedTextContent(this.host, 'plain-text');+ this.markdown = await getSelectedTextContent(this.host, 'markdown');+ this.images = await getSelectedImagesAsBlobs(this.host);+ const [_, data] = this.host.command+ .chain()+ .tryAll(chain => [+ chain.getTextSelection(),+ chain.getBlockSelections(),+ chain.getImageSelections(),+ ])+ .getSelectedBlocks({+ types: ['image'],+ })+ .run();+ if (data.currentBlockSelections?.[0]) {+ this.caption =+ (+ this.host.doc.getBlock(data.currentBlockSelections[0].blockId)+ ?.model as ImageBlockModel+ ).caption ?? '';+ }+ }++ private async _handleDocSelection() {+ const notes = this.host.doc+ .getBlocksByFlavour('affine:note')+ .filter(+ note =>+ (note.model as NoteBlockModel).displayMode !==+ NoteDisplayMode.EdgelessOnly+ )+ .map(note => note.model as NoteBlockModel);+ const selectedModels = notes.reduce((acc, note) => {+ acc.push(...note.children);+ return acc;+ }, [] as BlockModel[]);+ const text = await getTextContentFromBlockModels(+ this.host,+ selectedModels,+ 'plain-text'+ );+ const markdown = await getTextContentFromBlockModels(+ this.host,+ selectedModels,+ 'markdown'+ );+ const blobs = await Promise.all(+ selectedModels.map(async s => {+ if (s.flavour !== 'affine:image') return null;+ const sourceId = (s as ImageBlockModel)?.sourceId;+ if (!sourceId) return null;+ const blob = await (sourceId+ ? this.host.doc.blobSync.get(sourceId)+ : null);+ if (!blob) return null;+ return new File([blob], sourceId);+ }) ?? []+ );+ const images = blobs.filter((blob): blob is File => !!blob);+ this.text = text;+ this.markdown = markdown;+ this.images = images;+ }++ protected override async updated(_changedProperties: PropertyValues) {+ if (_changedProperties.has('selectionValue')) {+ await this._updateState();+ }++ if (_changedProperties.has('host')) {+ this._onEdgelessCopilotAreaUpdated();+ }+ }++ protected override render() {+ return html`<div class="cards-container">+ ${repeat(+ ChatCardsConfig,+ card => card.name,+ card => {+ if (+ card.render(this.text, this.images[0], this.caption) !== nothing+ ) {+ return html`<div+ @click=${async () => {+ if (card.name === 'doc') {+ await this._handleDocSelection();+ }+ card.handler(+ this.updateContext,+ this.text,+ this.markdown,+ this.images+ );+ }}+ >+ ${card.render(this.text, this.images[0], this.caption)}+ </div> `;+ }+ return nothing;+ }+ )}+ </div>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'chat-cards': ChatCards;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-context.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-context.tsnew file mode 100644index 0000000000..7a4a708771--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-context.ts@@ -0,0 +1,34 @@+import type { AIError } from '@blocksuite/blocks';++export type ChatMessage = {+ content: string;+ role: 'user' | 'assistant';+ attachments?: string[];+ createdAt: string;+};++export type ChatAction = {+ action: string;+ messages: ChatMessage[];+ sessionId: string;+ createdAt: string;+};++export type ChatItem = ChatMessage | ChatAction;++export type ChatStatus =+ | 'loading'+ | 'success'+ | 'error'+ | 'idle'+ | 'transmitting';++export type ChatContextValue = {+ items: ChatItem[];+ status: ChatStatus;+ error: AIError | null;+ quote: string;+ markdown: string;+ images: File[];+ abortController: AbortController | null;+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.tsnew file mode 100644index 0000000000..9d90bbfa8d--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts@@ -0,0 +1,484 @@+import type { EditorHost } from '@blocksuite/block-std';+import { WithDisposable } from '@blocksuite/block-std';+import { type AIError, openFileOrFiles } from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import { css, html, LitElement, nothing } from 'lit';+import { customElement, property, query, state } from 'lit/decorators.js';+import { repeat } from 'lit/directives/repeat.js';++import {+ ChatAbortIcon,+ ChatClearIcon,+ ChatSendIcon,+ CloseIcon,+ ImageIcon,+} from '../_common/icons.js';+import { AIProvider } from '../provider.js';+import { reportResponse } from '../utils/action-reporter.js';+import { readBlobAsURL } from '../utils/image.js';+import type { ChatContextValue, ChatMessage } from './chat-context.js';++const MaximumImageCount = 8;++function getFirstTwoLines(text: string) {+ const lines = text.split('\n');+ return lines.slice(0, 2);+}++@customElement('chat-panel-input')+export class ChatPanelInput extends WithDisposable(LitElement) {+ static override styles = css`+ .chat-panel-input {+ display: flex;+ flex-direction: column;+ justify-content: space-between;+ gap: 12px;+ position: relative;+ margin-top: 12px;+ border-radius: 4px;+ padding: 8px;+ min-height: 94px;+ box-sizing: border-box;+ border-width: 1px;+ border-style: solid;++ .chat-selection-quote {+ padding: 4px 0px 8px 0px;+ padding-left: 15px;+ max-height: 56px;+ font-size: 14px;+ font-weight: 400;+ line-height: 22px;+ color: var(--affine-text-secondary-color);+ position: relative;++ div {+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }++ .chat-quote-close {+ position: absolute;+ right: 0;+ top: 0;+ cursor: pointer;+ display: none;+ width: 16px;+ height: 16px;+ border-radius: 4px;+ border: 1px solid var(--affine-border-color);+ background-color: var(--affine-white);+ }+ }++ .chat-selection-quote:hover .chat-quote-close {+ display: flex;+ justify-content: center;+ align-items: center;+ }++ .chat-selection-quote::after {+ content: '';+ width: 2px;+ height: calc(100% - 10px);+ margin-top: 5px;+ position: absolute;+ left: 0;+ top: 0;+ background: var(--affine-quote-color);+ border-radius: 18px;+ }+ }++ .chat-panel-input-actions {+ display: flex;+ gap: 8px;+ align-items: center;++ div {+ width: 24px;+ height: 24px;+ cursor: pointer;+ }++ div:nth-child(2) {+ margin-left: auto;+ }++ .chat-history-clear {+ background-color: var(--affine-white);+ }++ .image-upload {+ background-color: var(--affine-white);+ display: flex;+ justify-content: center;+ align-items: center;+ }+ }++ .chat-panel-input {+ textarea {+ width: 100%;+ padding: 0;+ margin: 0;+ border: none;+ line-height: 22px;+ font-size: var(--affine-font-sm);+ font-weight: 400;+ font-family: var(--affine-font-family);+ color: var(--affine-text-primary-color);+ box-sizing: border-box;+ resize: none;+ overflow-y: hidden;+ }++ textarea::placeholder {+ font-size: 14px;+ font-weight: 400;+ font-family: var(--affine-font-family);+ color: var(--affine-placeholder-color);+ }++ textarea:focus {+ outline: none;+ }+ }++ .chat-panel-images {+ display: flex;+ gap: 4px;+ flex-wrap: wrap;+ position: relative;++ .image-container {+ width: 58px;+ height: 58px;+ border-radius: 4px;+ border: 1px solid var(--affine-border-color);+ cursor: pointer;+ overflow: hidden;+ position: relative;+ display: flex;+ justify-content: center;+ align-items: center;++ img {+ max-width: 100%;+ max-height: 100%;+ width: auto;+ height: auto;+ }+ }+ }++ .close-wrapper {+ width: 16px;+ height: 16px;+ border-radius: 4px;+ border: 1px solid var(--affine-border-color);+ justify-content: center;+ align-items: center;+ display: none;+ position: absolute;+ background-color: var(--affine-white);+ z-index: 1;+ cursor: pointer;+ }++ .close-wrapper:hover {+ background-color: var(--affine-background-error-color);+ border: 1px solid var(--affine-error-color);+ }++ .close-wrapper:hover svg path {+ fill: var(--affine-error-color);+ }+ `;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @query('.chat-panel-images')+ accessor imagesWrapper!: HTMLDivElement;++ @query('textarea')+ accessor textarea!: HTMLTextAreaElement;++ @query('.close-wrapper')+ accessor closeWrapper!: HTMLDivElement;++ @state()+ accessor curIndex = -1;++ @state()+ accessor isInputEmpty = true;++ @state()+ accessor focused = false;++ @property({ attribute: false })+ accessor chatContextValue!: ChatContextValue;++ @property({ attribute: false })+ accessor updateContext!: (context: Partial<ChatContextValue>) => void;++ @property({ attribute: false })+ accessor cleanupHistories!: () => Promise<void>;++ private _addImages(images: File[]) {+ const oldImages = this.chatContextValue.images;+ this.updateContext({+ images: [...oldImages, ...images].slice(0, MaximumImageCount),+ });+ }++ private _renderImages(images: File[]) {+ return html`+ <div+ class="chat-panel-images"+ @mouseleave=${() => {+ this.closeWrapper.style.display = 'none';+ this.curIndex = -1;+ }}+ >+ ${repeat(+ images,+ image => image.name,+ (image, index) =>+ html`<div+ class="image-container"+ @mouseenter=${(evt: MouseEvent) => {+ const ele = evt.target as HTMLImageElement;+ const rect = ele.getBoundingClientRect();+ assertExists(ele.parentElement);+ const parentRect = ele.parentElement.getBoundingClientRect();+ const left = Math.abs(rect.right - parentRect.left) - 8;+ const top = Math.abs(parentRect.top - rect.top) - 8;+ this.curIndex = index;+ this.closeWrapper.style.display = 'flex';+ this.closeWrapper.style.left = left + 'px';+ this.closeWrapper.style.top = top + 'px';+ }}+ >+ <img src="${URL.createObjectURL(image)}" alt="${image.name}" />+ </div>`+ )}+ <div+ class="close-wrapper"+ @click=${() => {+ if (this.curIndex >= 0 && this.curIndex < images.length) {+ const newImages = [...images];+ newImages.splice(this.curIndex, 1);+ this.updateContext({ images: newImages });+ this.curIndex = -1;+ this.closeWrapper.style.display = 'none';+ }+ }}+ >+ ${CloseIcon}+ </div>+ </div>+ `;+ }++ protected override render() {+ const { images, status } = this.chatContextValue;+ const hasImages = images.length > 0;+ const maxHeight = hasImages ? 272 + 2 : 200 + 2;++ return html`<style>+ .chat-panel-send svg rect {+ fill: ${this.isInputEmpty && hasImages+ ? 'var(--affine-text-disable-color)'+ : 'var(--affine-primary-color)'};+ }++ .chat-panel-input {+ border-color: ${this.focused+ ? 'var(--affine-primary-color)'+ : 'var(--affine-border-color)'};+ box-shadow: ${this.focused ? 'var(--affine-active-shadow)' : 'none'};+ max-height: ${maxHeight}px !important;+ }+ </style>+ <div class="chat-panel-input">+ ${hasImages ? this._renderImages(images) : nothing}+ ${this.chatContextValue.quote+ ? html`<div class="chat-selection-quote">+ ${repeat(+ getFirstTwoLines(this.chatContextValue.quote),+ line => line,+ line => html`<div>${line}</div>`+ )}+ <div+ class="chat-quote-close"+ @click=${() => {+ this.updateContext({ quote: '', markdown: '' });+ }}+ >+ ${CloseIcon}+ </div>+ </div>`+ : nothing}+ <textarea+ rows="1"+ placeholder="What are your thoughts?"+ @input=${() => {+ const { textarea } = this;+ this.isInputEmpty = !textarea.value.trim();+ textarea.style.height = 'auto';+ textarea.style.height = textarea.scrollHeight + 'px';+ let imagesHeight = this.imagesWrapper?.scrollHeight ?? 0;+ if (imagesHeight) imagesHeight += 12;+ if (this.scrollHeight >= 200 + imagesHeight) {+ textarea.style.height = '148px';+ textarea.style.overflowY = 'scroll';+ }+ }}+ @keydown=${async (evt: KeyboardEvent) => {+ if (evt.key === 'Enter' && !evt.shiftKey && !evt.isComposing) {+ evt.preventDefault();+ await this.send();+ }+ }}+ @focus=${() => {+ this.focused = true;+ }}+ @blur=${() => {+ this.focused = false;+ }}+ @paste=${(event: ClipboardEvent) => {+ const items = event.clipboardData?.items;+ if (!items) return;++ for (const index in items) {+ const item = items[index];+ if (item.kind === 'file' && item.type.indexOf('image') >= 0) {+ const blob = item.getAsFile();+ if (!blob) continue;+ this._addImages([blob]);+ }+ }+ }}+ ></textarea>+ <div class="chat-panel-input-actions">+ <div+ class="chat-history-clear"+ @click=${async () => {+ await this.cleanupHistories();+ }}+ >+ ${ChatClearIcon}+ </div>+ ${images.length < MaximumImageCount+ ? html`<div+ class="image-upload"+ @click=${async () => {+ const images = await openFileOrFiles({+ acceptType: 'Images',+ multiple: true,+ });+ if (!images) return;+ this._addImages(images);+ }}+ >+ ${ImageIcon}+ </div>`+ : nothing}+ ${status === 'transmitting'+ ? html`<div+ @click=${() => {+ this.chatContextValue.abortController?.abort();+ this.updateContext({ status: 'success' });+ reportResponse('aborted:stop');+ }}+ >+ ${ChatAbortIcon}+ </div>`+ : html`<div @click="${this.send}" class="chat-panel-send">+ ${ChatSendIcon}+ </div>`}+ </div>+ </div>`;+ }++ send = async () => {+ const { status, markdown } = this.chatContextValue;+ if (status === 'loading' || status === 'transmitting') return;++ const text = this.textarea.value;+ const { images } = this.chatContextValue;+ if (!text && images.length === 0) {+ return;+ }+ const { doc } = this.host;+ this.textarea.value = '';+ this.isInputEmpty = true;+ this.updateContext({+ images: [],+ status: 'loading',+ error: null,+ quote: '',+ markdown: '',+ });++ const attachments = await Promise.all(+ images?.map(image => readBlobAsURL(image))+ );++ const content = (markdown ? `${markdown}\n` : '') + text;++ this.updateContext({+ items: [+ ...this.chatContextValue.items,+ {+ role: 'user',+ content: content,+ createdAt: new Date().toISOString(),+ attachments,+ },+ { role: 'assistant', content: '', createdAt: new Date().toISOString() },+ ],+ });++ try {+ const abortController = new AbortController();+ const stream = AIProvider.actions.chat?.({+ input: content,+ docId: doc.id,+ attachments: images,+ workspaceId: doc.collection.id,+ host: this.host,+ stream: true,+ signal: abortController.signal,+ where: 'chat-panel',+ control: 'chat-send',+ });++ if (stream) {+ this.updateContext({ abortController });++ for await (const text of stream) {+ const items = [...this.chatContextValue.items];+ const last = items[items.length - 1] as ChatMessage;+ last.content += text;+ this.updateContext({ items, status: 'transmitting' });+ }++ this.updateContext({ status: 'success' });+ }+ } catch (error) {+ this.updateContext({ status: 'error', error: error as AIError });+ } finally {+ this.updateContext({ abortController: null });+ }+ };+}++declare global {+ interface HTMLElementTagNameMap {+ 'chat-panel-input': ChatPanelInput;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.tsnew file mode 100644index 0000000000..a7553d802e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-messages.ts@@ -0,0 +1,523 @@+import '../messages/slides-renderer.js';+import './ai-loading.js';+import '../messages/text.js';+import './actions/text.js';+import './actions/action-wrapper.js';+import './actions/make-real.js';+import './actions/slides.js';+import './actions/mindmap.js';+import './actions/chat-text.js';+import './actions/copy-more.js';+import './actions/image-to-text.js';+import './actions/image.js';+import './chat-cards.js';++import type {+ BaseSelection,+ BlockSelection,+ EditorHost,+ TextSelection,+} from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import type { ImageSelection } from '@blocksuite/blocks';+import {+ isInsidePageEditor,+ PaymentRequiredError,+ UnauthorizedError,+} from '@blocksuite/blocks';+import { css, html, nothing, type PropertyValues } from 'lit';+import { customElement, property, query, state } from 'lit/decorators.js';+import { repeat } from 'lit/directives/repeat.js';+import { styleMap } from 'lit/directives/style-map.js';++import {+ AffineAvatarIcon,+ AffineIcon,+ DownArrowIcon,+} from '../_common/icons.js';+import {+ GeneralErrorRenderer,+ PaymentRequiredErrorRenderer,+} from '../messages/error.js';+import { AIProvider } from '../provider.js';+import { insertBelow } from '../utils/editor-actions.js';+import {+ EdgelessEditorActions,+ PageEditorActions,+} from './actions/actions-handle.js';+import type {+ ChatContextValue,+ ChatItem,+ ChatMessage,+} from './chat-context.js';+import { HISTORY_IMAGE_ACTIONS } from './const.js';++@customElement('chat-panel-messages')+export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {+ private get _currentTextSelection(): TextSelection | undefined {+ return this._selectionValue.find(v => v.type === 'text') as TextSelection;+ }++ private get _currentBlockSelections(): BlockSelection[] | undefined {+ return this._selectionValue.filter(v => v.type === 'block');+ }++ private get _currentImageSelections(): ImageSelection[] | undefined {+ return this._selectionValue.filter(v => v.type === 'image');+ }++ static override styles = css`+ chat-panel-messages {+ position: relative;+ }++ .chat-panel-messages {+ display: flex;+ flex-direction: column;+ gap: 24px;+ height: 100%;+ position: relative;+ overflow-y: auto;++ chat-cards {+ position: absolute;+ bottom: 0;+ width: 100%;+ }+ }++ .chat-panel-messages-placeholder {+ width: 100%;+ position: absolute;+ z-index: 1;+ top: 50%;+ left: 50%;+ transform: translate(-50%, -50%);+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 12px;+ }++ .item-wrapper {+ margin-left: 32px;+ }++ .user-info {+ display: flex;+ align-items: center;+ gap: 10px;+ margin-bottom: 4px;+ color: var(--affine-text-primary-color);+ font-size: 14px;+ font-weight: 500;+ user-select: none;+ }++ .avatar-container {+ width: 24px;+ height: 24px;+ }++ .avatar {+ width: 100%;+ height: 100%;+ border-radius: 50%;+ background-color: var(--affine-primary-color);+ }++ .avatar-container img {+ width: 100%;+ height: 100%;+ border-radius: 50%;+ object-fit: cover;+ }++ .down-indicator {+ position: absolute;+ left: 50%;+ transform: translate(-50%, 0);+ bottom: 24px;+ z-index: 1;+ border-radius: 50%;+ width: 32px;+ height: 32px;+ border: 0.5px solid var(--affine-border-color);+ background-color: var(--affine-background-primary-color);+ box-shadow: var(--affine-shadow-2);+ display: flex;+ justify-content: center;+ align-items: center;+ cursor: pointer;+ }+ `;++ private _selectionValue: BaseSelection[] = [];++ @state()+ accessor showDownIndicator = false;++ @state()+ accessor avatarUrl = '';++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor isLoading!: boolean;++ @property({ attribute: false })+ accessor chatContextValue!: ChatContextValue;++ @property({ attribute: false })+ accessor updateContext!: (context: Partial<ChatContextValue>) => void;++ @query('.chat-panel-messages')+ accessor messagesContainer!: HTMLDivElement;++ protected override updated(_changedProperties: PropertyValues) {+ if (_changedProperties.has('host')) {+ const { disposables } = this;++ disposables.add(+ this.host.selection.slots.changed.on(() => {+ this._selectionValue = this.host.selection.value;+ this.requestUpdate();+ })+ );+ const { docModeService } = this.host.spec.getService('affine:page');+ disposables.add(docModeService.onModeChange(() => this.requestUpdate()));+ }+ }++ protected override render() {+ const { items } = this.chatContextValue;+ const { isLoading } = this;+ const filteredItems = items.filter(item => {+ return (+ 'role' in item ||+ item.messages?.length === 3 ||+ (HISTORY_IMAGE_ACTIONS.includes(item.action) &&+ item.messages?.length === 2)+ );+ });++ return html`<style>+ .chat-panel-messages-placeholder div {+ color: ${isLoading+ ? 'var(--affine-text-secondary-color)'+ : 'var(--affine-text-primary-color)'};+ font-size: ${isLoading ? 'var(--affine-font-sm)' : '18px'};+ font-weight: 600;+ }+ </style>++ <div+ class="chat-panel-messages"+ @scroll=${(evt: Event) => {+ const element = evt.target as HTMLDivElement;+ this.showDownIndicator =+ element.scrollHeight - element.scrollTop - element.clientHeight >+ 200;+ }}+ >+ ${items.length === 0+ ? html`<div class="chat-panel-messages-placeholder">+ ${AffineIcon(+ isLoading+ ? 'var(--affine-icon-secondary)'+ : 'var(--affine-primary-color)'+ )}+ <div>+ ${this.isLoading+ ? 'AFFiNE AI is loading history...'+ : 'What can I help you with?'}+ </div>+ </div>+ <chat-cards+ .chatContextValue=${this.chatContextValue}+ .updateContext=${this.updateContext}+ .host=${this.host}+ .selectionValue=${this._selectionValue}+ ></chat-cards> `+ : repeat(filteredItems, (item, index) => {+ const isLast = index === filteredItems.length - 1;+ return html`<div class="message">+ ${this.renderAvatar(item)}+ <div class="item-wrapper">${this.renderItem(item, isLast)}</div>+ </div>`;+ })}+ </div>+ ${this.showDownIndicator+ ? html`<div class="down-indicator" @click=${() => this.scrollToDown()}>+ ${DownArrowIcon}+ </div>`+ : nothing} `;+ }++ override async connectedCallback() {+ super.connectedCallback();++ const res = await AIProvider.userInfo;+ this.avatarUrl = res?.avatarUrl ?? '';+ this.disposables.add(+ AIProvider.slots.userInfo.on(userInfo => {+ const { status, error } = this.chatContextValue;+ this.avatarUrl = userInfo?.avatarUrl ?? '';+ if (+ status === 'error' &&+ error instanceof UnauthorizedError &&+ userInfo+ ) {+ this.updateContext({ status: 'idle', error: null });+ }+ })+ );+ }++ renderError() {+ const { error } = this.chatContextValue;++ if (error instanceof PaymentRequiredError) {+ return PaymentRequiredErrorRenderer(this.host);+ } else if (error instanceof UnauthorizedError) {+ return GeneralErrorRenderer(+ html`You need to login to AFFiNE Cloud to continue using AFFiNE AI.`,+ html`<div+ style=${styleMap({+ padding: '4px 12px',+ borderRadius: '8px',+ border: '1px solid var(--affine-border-color)',+ cursor: 'pointer',+ backgroundColor: 'var(--affine-hover-color)',+ })}+ @click=${() =>+ AIProvider.slots.requestLogin.emit({ host: this.host })}+ >+ Login+ </div>`+ );+ } else {+ return GeneralErrorRenderer();+ }+ }++ renderItem(item: ChatItem, isLast: boolean) {+ const { status, error } = this.chatContextValue;++ if (isLast && status === 'loading') {+ return this.renderLoading();+ }++ if (+ isLast &&+ status === 'error' &&+ (error instanceof PaymentRequiredError ||+ error instanceof UnauthorizedError)+ ) {+ return this.renderError();+ }++ if ('role' in item) {+ const state = isLast+ ? status !== 'loading' && status !== 'transmitting'+ ? 'finished'+ : 'generating'+ : 'finished';+ return html`<chat-text+ .host=${this.host}+ .attachments=${item.attachments}+ .text=${item.content}+ .state=${state}+ ></chat-text>+ ${isLast && status === 'error' ? this.renderError() : nothing}+ ${this.renderEditorActions(item, isLast)}`;+ } else {+ switch (item.action) {+ case 'Create a presentation':+ return html`<action-slides+ .host=${this.host}+ .item=${item}+ ></action-slides>`;+ case 'Make it real':+ return html`<action-make-real+ .host=${this.host}+ .item=${item}+ ></action-make-real>`;+ case 'Brainstorm mindmap':+ return html`<action-mindmap+ .host=${this.host}+ .item=${item}+ ></action-mindmap>`;+ case 'Explain this image':+ case 'Generate a caption':+ return html`<action-image-to-text+ .host=${this.host}+ .item=${item}+ ></action-image-to-text>`;+ default:+ if (HISTORY_IMAGE_ACTIONS.includes(item.action)) {+ return html`<action-image+ .host=${this.host}+ .item=${item}+ ></action-image>`;+ }++ return html`<action-text+ .item=${item}+ .host=${this.host}+ .isCode=${item.action === 'Explain this code' ||+ item.action === 'Check code error'}+ ></action-text>`;+ }+ }+ }++ renderAvatar(item: ChatItem) {+ const isUser = 'role' in item && item.role === 'user';++ return html`<div class="user-info">+ ${isUser+ ? html`<div class="avatar-container">+ ${this.avatarUrl+ ? html`<img .src=${this.avatarUrl} />`+ : html`<div class="avatar"></div>`}+ </div>`+ : AffineAvatarIcon}+ ${isUser ? 'You' : 'AFFINE AI'}+ </div>`;+ }++ renderLoading() {+ return html` <ai-loading></ai-loading>`;+ }++ scrollToDown() {+ this.messagesContainer.scrollTo(0, this.messagesContainer.scrollHeight);+ }++ renderEditorActions(item: ChatMessage, isLast: boolean) {+ const { status } = this.chatContextValue;++ if (item.role !== 'assistant') return nothing;++ if (+ isLast &&+ status !== 'success' &&+ status !== 'idle' &&+ status !== 'error'+ )+ return nothing;++ const { host } = this;+ const { content } = item;+ const actions = isInsidePageEditor(host)+ ? PageEditorActions+ : EdgelessEditorActions;++ return html`+ <style>+ .actions-container {+ display: flex;+ flex-direction: column;+ align-items: flex-end;+ gap: 8px;+ margin-top: 8px;+ }++ .actions-container > div {+ display: flex;+ gap: 8px;+ }++ .action {+ width: fit-content;+ height: 32px;+ padding: 12px;+ border-radius: 8px;+ border: 1px solid var(--affine-border-color);+ background-color: var(--affine-white-10);+ display: flex;+ flex-direction: row;+ align-items: center;+ gap: 4px;+ font-size: 15px;+ font-weight: 500;+ color: var(--affine-text-primary-color);+ cursor: pointer;+ user-select: none;+ }++ .action svg {+ color: var(--affine-icon-color);+ }+ </style>+ <chat-copy-more+ .host=${host}+ .content=${content}+ .isLast=${isLast}+ .curTextSelection=${this._currentTextSelection}+ .curBlockSelections=${this._currentBlockSelections}+ .chatContextValue=${this.chatContextValue}+ .updateContext=${this.updateContext}+ ></chat-copy-more>+ ${isLast+ ? html`<div class="actions-container">+ ${repeat(+ actions.filter(action => {+ if (!content) return false;++ if (+ action.title === 'Replace selection' &&+ (!this._currentTextSelection ||+ this._currentTextSelection.from.length === 0) &&+ this._currentBlockSelections?.length === 0+ ) {+ return false;+ }+ return true;+ }),+ action => action.title,+ action => {+ return html`<div class="action">+ ${action.icon}+ <div+ @click=${async () => {+ if (+ action.title === 'Insert below' &&+ this._selectionValue.length === 1 &&+ this._selectionValue[0].type === 'database'+ ) {+ const element = this.host.view.getBlock(+ this._selectionValue[0].blockId+ );+ if (!element) return;+ await insertBelow(host, content, element);+ return;+ }++ await action.handler(+ host,+ content,+ this._currentTextSelection,+ this._currentBlockSelections,+ this._currentImageSelections+ );+ }}+ >+ ${action.title}+ </div>+ </div>`;+ }+ )}+ </div>`+ : nothing}+ `;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'chat-panel-messages': ChatPanelMessages;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/images.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/images.tsnew file mode 100644index 0000000000..67117233bc--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/images.ts@@ -0,0 +1,41 @@+import { html } from 'lit';+import { repeat } from 'lit/directives/repeat.js';++export const renderImages = (images: string[]) => {+ return html`<style>+ .images-container {+ display: flex;+ gap: 12px;+ flex-direction: column;+ margin-bottom: 8px;+ }+ .image-container {+ border-radius: 4px;+ overflow: hidden;+ position: relative;+ display: flex;+ justify-content: center;+ align-items: center;+ width: 70%;+ max-width: 320px;++ img {+ max-width: 100%;+ max-height: 100%;+ width: auto;+ height: auto;+ }+ }+ </style>+ <div class="images-container">+ ${repeat(+ images,+ image => image,+ image => {+ return html`<div class="image-container">+ <img src="${image}" />+ </div>`;+ }+ )}+ </div>`;+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.tsnew file mode 100644index 0000000000..bd5c350b37--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.ts@@ -0,0 +1,10 @@+export const HISTORY_IMAGE_ACTIONS = [+ 'image',+ 'AI image filter clay style',+ 'AI image filter sketch style',+ 'AI image filter anime style',+ 'AI image filter pixel style',+ 'Clearer',+ 'Remove background',+ 'Convert to sticker',+];diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.tsnew file mode 100644index 0000000000..a3c529705c--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/index.ts@@ -0,0 +1,278 @@+import './chat-panel-input.js';+import './chat-panel-messages.js';++import type { EditorHost } from '@blocksuite/block-std';+import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';+import { debounce } from '@blocksuite/global/utils';+import type { Doc } from '@blocksuite/store';+import { css, html, type PropertyValues } from 'lit';+import { customElement, property, state } from 'lit/decorators.js';+import { createRef, type Ref, ref } from 'lit/directives/ref.js';++import { AIHelpIcon, SmallHintIcon } from '../_common/icons.js';+import { AIProvider } from '../provider.js';+import {+ getSelectedImagesAsBlobs,+ getSelectedTextContent,+} from '../utils/selection-utils.js';+import type { ChatAction, ChatContextValue, ChatItem } from './chat-context.js';+import type { ChatPanelMessages } from './chat-panel-messages.js';++@customElement('chat-panel')+export class ChatPanel extends WithDisposable(ShadowlessElement) {+ static override styles = css`+ chat-panel {+ width: 100%;+ }++ .chat-panel-container {+ display: flex;+ flex-direction: column;+ padding: 0 12px;+ height: 100%;+ }++ .chat-panel-title {+ padding: 8px 0px;+ width: 100%;+ height: 36px;+ display: flex;+ justify-content: space-between;+ align-items: center;++ div:first-child {+ font-size: 14px;+ font-weight: 500;+ color: var(--affine-text-secondary-color);+ }++ div:last-child {+ width: 24px;+ height: 24px;+ display: flex;+ justify-content: center;+ align-items: center;+ cursor: pointer;+ }+ }++ chat-panel-messages {+ flex: 1;+ overflow-y: hidden;+ }++ .chat-panel-hints {+ margin: 0 4px;+ padding: 8px 12px;+ border-radius: 8px;+ border: 1px solid var(--affine-border-color);+ font-size: 14px;+ font-weight: 500;+ cursor: pointer;+ }++ .chat-panel-hints :first-child {+ color: var(--affine-text-primary-color);+ }++ .chat-panel-hints :nth-child(2) {+ color: var(--affine-text-secondary-color);+ }++ .chat-panel-footer {+ margin: 8px 0px;+ height: 20px;+ display: flex;+ gap: 4px;+ align-items: center;+ color: var(--affine-text-secondary-color);+ font-size: 12px;+ }+ `;++ private readonly _chatMessages: Ref<ChatPanelMessages> =+ createRef<ChatPanelMessages>();++ private _chatSessionId = '';++ private _resettingCounter = 0;++ private readonly _resetItems = debounce(() => {+ const counter = ++this._resettingCounter;+ this.isLoading = true;+ (async () => {+ const { doc } = this;++ const [histories, actions] = await Promise.all([+ AIProvider.histories?.chats(doc.collection.id, doc.id),+ AIProvider.histories?.actions(doc.collection.id, doc.id),+ ]);++ if (counter !== this._resettingCounter) return;++ const items: ChatItem[] = actions ? [...actions] : [];++ if (histories?.[0]) {+ this._chatSessionId = histories[0].sessionId;+ items.push(...histories[0].messages);+ }++ this.chatContextValue = {+ ...this.chatContextValue,+ items: items.sort((a, b) => {+ return (+ new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()+ );+ }),+ };++ this.isLoading = false;+ this.scrollToDown();+ })().catch(console.error);+ }, 200);++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor doc!: Doc;++ @state()+ accessor isLoading = false;++ @state()+ accessor chatContextValue: ChatContextValue = {+ quote: '',+ images: [],+ abortController: null,+ items: [],+ status: 'idle',+ error: null,+ markdown: '',+ };++ private readonly _cleanupHistories = async () => {+ const notification =+ this.host.std.spec.getService('affine:page').notificationService;+ if (!notification) return;++ if (+ await notification.confirm({+ title: 'Clear History',+ message:+ 'Are you sure you want to clear all history? This action will permanently delete all content, including all chat logs and data, and cannot be undone.',+ confirmText: 'Confirm',+ cancelText: 'Cancel',+ })+ ) {+ await AIProvider.histories?.cleanup(this.doc.collection.id, this.doc.id, [+ this._chatSessionId,+ ...(+ this.chatContextValue.items.filter(+ item => 'sessionId' in item+ ) as ChatAction[]+ ).map(item => item.sessionId),+ ]);+ notification.toast('History cleared');+ this._resetItems();+ }+ };++ protected override updated(_changedProperties: PropertyValues) {+ if (_changedProperties.has('doc')) {+ this._resetItems();+ }+ }++ override connectedCallback() {+ super.connectedCallback();+ if (!this.doc) throw new Error('doc is required');++ AIProvider.slots.actions.on(({ action, event }) => {+ const { status } = this.chatContextValue;+ if (+ action !== 'chat' &&+ event === 'finished' &&+ (status === 'idle' || status === 'success')+ ) {+ this._resetItems();+ }+ });++ AIProvider.slots.userInfo.on(userInfo => {+ if (userInfo) {+ this._resetItems();+ }+ });++ AIProvider.slots.requestContinueInChat.on(async ({ show }) => {+ if (show) {+ const text = await getSelectedTextContent(this.host, 'plain-text');+ const markdown = await getSelectedTextContent(this.host, 'markdown');+ const images = await getSelectedImagesAsBlobs(this.host);+ this.updateContext({+ quote: text,+ markdown: markdown,+ images: images,+ });+ }+ });+ }++ updateContext = (context: Partial<ChatContextValue>) => {+ this.chatContextValue = { ...this.chatContextValue, ...context };+ };++ continueInChat = async () => {+ const text = await getSelectedTextContent(this.host, 'plain-text');+ const markdown = await getSelectedTextContent(this.host, 'markdown');+ const images = await getSelectedImagesAsBlobs(this.host);+ this.updateContext({+ quote: text,+ markdown,+ images,+ });+ };++ scrollToDown() {+ requestAnimationFrame(() => this._chatMessages.value?.scrollToDown());+ }++ override render() {+ return html` <div class="chat-panel-container">+ <div class="chat-panel-title">+ <div>AFFINE AI</div>+ <div+ @click=${() => {+ AIProvider.toggleGeneralAIOnboarding?.(true);+ }}+ >+ ${AIHelpIcon}+ </div>+ </div>+ <chat-panel-messages+ ${ref(this._chatMessages)}+ .chatContextValue=${this.chatContextValue}+ .updateContext=${this.updateContext}+ .host=${this.host}+ .isLoading=${this.isLoading}+ ></chat-panel-messages>+ <chat-panel-input+ .chatContextValue=${this.chatContextValue}+ .updateContext=${this.updateContext}+ .host=${this.host}+ .cleanupHistories=${this._cleanupHistories}+ ></chat-panel-input>+ <div class="chat-panel-footer">+ ${SmallHintIcon}+ <div>AI outputs can be misleading or wrong</div>+ </div>+ </div>`;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'chat-panel': ChatPanel;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/utils.tsnew file mode 100644index 0000000000..ed8b30df4b--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/utils.ts@@ -0,0 +1,84 @@+import type { EditorHost } from '@blocksuite/block-std';+import type { EdgelessRootService } from '@blocksuite/blocks';+import type { BlockSnapshot } from '@blocksuite/store';++import { markdownToSnapshot } from '../_common/markdown-utils.js';+import { getSurfaceElementFromEditor } from '../_common/selection-utils.js';+import { basicTheme } from '../slides/template.js';++type PPTSection = {+ title: string;+ content: string;+ keywords: string;+};++type PPTDoc = {+ isCover: boolean;+ title: string;+ sections: PPTSection[];+};++export const PPTBuilder = (host: EditorHost) => {+ const service = host.spec.getService<EdgelessRootService>('affine:page');+ const docs: PPTDoc[] = [];+ let done = false;+ const addDoc = async (block: BlockSnapshot) => {+ const sections = block.children.map(v => {+ const title = getText(v);+ const keywords = getText(v.children[0]);+ const content = getText(v.children[1]);+ return {+ title,+ keywords,+ content,+ } satisfies PPTSection;+ });+ const doc: PPTDoc = {+ isCover: docs.length === 0,+ title: getText(block),+ sections,+ };+ docs.push(doc);++ if (doc.sections.length !== 3 || doc.isCover) return;+ if (done) return;+ done = true;+ const job = service.createTemplateJob('template');+ const { images, content } = await basicTheme(doc);++ if (images.length) {+ await Promise.all(+ images.map(({ id, url }) =>+ fetch(url)+ .then(res => res.blob())+ .then(blob => job.job.assets.set(id, blob))+ )+ );+ }+ await job.insertTemplate(content);+ getSurfaceElementFromEditor(host).refresh();+ };++ return {+ process: async (text: string) => {+ const snapshot = await markdownToSnapshot(text, host);++ const block = snapshot.snapshot.content[0];+ for (const child of block.children) {+ await addDoc(child);+ const { centerX, centerY, zoom } = service.getFitToScreenData();+ service.viewport.setViewport(zoom, [centerX, centerY]);+ }+ },+ done: async (text: string) => {+ const snapshot = await markdownToSnapshot(text, host);+ const block = snapshot.snapshot.content[0];+ await addDoc(block.children[block.children.length - 1]);+ },+ };+};++const getText = (block: BlockSnapshot) => {+ // @ts-expect-error allow+ return block.props.text?.delta?.[0]?.insert ?? '';+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/code-toolbar/setup-code-toolbar.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/code-toolbar/setup-code-toolbar.tsnew file mode 100644index 0000000000..6e1cc1fdea--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/code-toolbar/setup-code-toolbar.ts@@ -0,0 +1,55 @@+import '../../_common/components/ask-ai-button.js';++import type {+ AffineCodeToolbarWidget,+ CodeBlockComponent,+} from '@blocksuite/blocks';+import { html } from 'lit';++const AICodeItemGroups = buildAICodeItemGroups();+const buttonOptions: AskAIButtonOptions = {+ size: 'small',+ panelWidth: 240,+};++import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button.js';+import { buildAICodeItemGroups } from '../../_common/config.js';+import { AIStarIcon } from '../../_common/icons.js';++export function setupCodeToolbarEntry(codeToolbar: AffineCodeToolbarWidget) {+ const onAskAIClick = () => {+ const { host } = codeToolbar;+ const { selection } = host;+ const imageBlock = codeToolbar.blockElement;+ selection.setGroup('note', [+ selection.create('block', { blockId: imageBlock.blockId }),+ ]);+ };+ codeToolbar.setupDefaultConfig();+ codeToolbar.addItems(+ [+ {+ type: 'custom',+ name: 'Ask AI',+ tooltip: 'Ask AI',+ icon: AIStarIcon,+ showWhen: () => true,+ render(codeBlock: CodeBlockComponent, onClick?: () => void) {+ return html`<ask-ai-button+ class="code-toolbar-button ask-ai"+ .host=${codeBlock.host}+ .actionGroups=${AICodeItemGroups}+ .toggleType=${'click'}+ .options=${buttonOptions}+ @click=${(e: MouseEvent) => {+ e.stopPropagation();+ onAskAIClick();+ onClick?.();+ }}+ ></ask-ai-button>`;+ },+ },+ ],+ 0+ );+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/edgeless/actions-config.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/edgeless/actions-config.tsnew file mode 100644index 0000000000..bf61d403b4--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/edgeless/actions-config.ts@@ -0,0 +1,513 @@+import {+ type AIItemGroupConfig,+ AIStarIconWithAnimation,+ BlocksUtils,+ MindmapElementModel,+ ShapeElementModel,+ TextElementModel,+} from '@blocksuite/blocks';++import {+ AIExpandMindMapIcon,+ AIImageIcon,+ AIImageIconWithAnimation,+ AIMindMapIcon,+ AIMindMapIconWithAnimation,+ AIPenIcon,+ AIPenIconWithAnimation,+ AIPresentationIcon,+ AIPresentationIconWithAnimation,+ AISearchIcon,+ ChatWithAIIcon,+ ExplainIcon,+ ImproveWritingIcon,+ LanguageIcon,+ LongerIcon,+ MakeItRealIcon,+ MakeItRealIconWithAnimation,+ SelectionIcon,+ ShorterIcon,+ ToneIcon,+} from '../../_common/icons.js';+import {+ actionToHandler,+ experimentalImageActionsShowWhen,+ imageOnlyShowWhen,+ mindmapChildShowWhen,+ mindmapRootShowWhen,+ noteBlockOrTextShowWhen,+ noteWithCodeBlockShowWen,+} from '../../actions/edgeless-handler.js';+import {+ imageFilterStyles,+ imageProcessingTypes,+ textTones,+ translateLangs,+} from '../../actions/types.js';+import { getAIPanel } from '../../ai-panel.js';+import { AIProvider } from '../../provider.js';+import { mindMapToMarkdown } from '../../utils/edgeless.js';+import { canvasToBlob, randomSeed } from '../../utils/image.js';+import {+ getCopilotSelectedElems,+ getEdgelessRootFromEditor,+ imageCustomInput,+} from '../../utils/selection-utils.js';++const translateSubItem = translateLangs.map(lang => {+ return {+ type: lang,+ handler: actionToHandler('translate', AIStarIconWithAnimation, { lang }),+ };+});++const toneSubItem = textTones.map(tone => {+ return {+ type: tone,+ handler: actionToHandler('changeTone', AIStarIconWithAnimation, { tone }),+ };+});++export const imageFilterSubItem = imageFilterStyles.map(style => {+ return {+ type: style,+ handler: actionToHandler(+ 'filterImage',+ AIImageIconWithAnimation,+ {+ style,+ },+ imageCustomInput+ ),+ };+});++export const imageProcessingSubItem = imageProcessingTypes.map(type => {+ return {+ type,+ handler: actionToHandler(+ 'processImage',+ AIImageIconWithAnimation,+ {+ type,+ },+ imageCustomInput+ ),+ };+});++const othersGroup: AIItemGroupConfig = {+ name: 'others',+ items: [+ {+ name: 'Open AI Chat',+ icon: ChatWithAIIcon,+ showWhen: () => true,+ handler: host => {+ const panel = getAIPanel(host);+ AIProvider.slots.requestContinueInChat.emit({+ host: host,+ show: true,+ });+ panel.hide();+ },+ },+ ],+};++const editGroup: AIItemGroupConfig = {+ name: 'edit with ai',+ items: [+ {+ name: 'Translate to',+ icon: LanguageIcon,+ showWhen: noteBlockOrTextShowWhen,+ subItem: translateSubItem,+ },+ {+ name: 'Change tone to',+ icon: ToneIcon,+ showWhen: noteBlockOrTextShowWhen,+ subItem: toneSubItem,+ },+ {+ name: 'Improve writing',+ icon: ImproveWritingIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('improveWriting', AIStarIconWithAnimation),+ },++ {+ name: 'Make it longer',+ icon: LongerIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('makeLonger', AIStarIconWithAnimation),+ },+ {+ name: 'Make it shorter',+ icon: ShorterIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('makeShorter', AIStarIconWithAnimation),+ },+ {+ name: 'Continue writing',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('continueWriting', AIPenIconWithAnimation),+ },+ ],+};++const draftGroup: AIItemGroupConfig = {+ name: 'draft with ai',+ items: [+ {+ name: 'Write an article about this',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('writeArticle', AIPenIconWithAnimation),+ },+ {+ name: 'Write a tweet about this',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('writeTwitterPost', AIPenIconWithAnimation),+ },+ {+ name: 'Write a poem about this',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('writePoem', AIPenIconWithAnimation),+ },+ {+ name: 'Write a blog post about this',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('writeBlogPost', AIPenIconWithAnimation),+ },+ {+ name: 'Brainstorm ideas about this',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('brainstorm', AIPenIconWithAnimation),+ },+ ],+};++const reviewGroup: AIItemGroupConfig = {+ name: 'review with ai',+ items: [+ {+ name: 'Fix spelling',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('fixSpelling', AIStarIconWithAnimation),+ },+ {+ name: 'Fix grammar',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('improveGrammar', AIStarIconWithAnimation),+ },+ {+ name: 'Explain this image',+ icon: AIPenIcon,+ showWhen: imageOnlyShowWhen,+ handler: actionToHandler(+ 'explainImage',+ AIStarIconWithAnimation,+ undefined,+ imageCustomInput+ ),+ },+ {+ name: 'Explain this code',+ icon: ExplainIcon,+ showWhen: noteWithCodeBlockShowWen,+ handler: actionToHandler('explainCode', AIStarIconWithAnimation),+ },+ {+ name: 'Check code error',+ icon: ExplainIcon,+ showWhen: noteWithCodeBlockShowWen,+ handler: actionToHandler('checkCodeErrors', AIStarIconWithAnimation),+ },+ {+ name: 'Explain selection',+ icon: SelectionIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('explain', AIStarIconWithAnimation),+ },+ ],+};++const generateGroup: AIItemGroupConfig = {+ name: 'generate with ai',+ items: [+ {+ name: 'Summarize',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('summary', AIPenIconWithAnimation),+ },+ {+ name: 'Generate headings',+ icon: AIPenIcon,+ handler: actionToHandler('createHeadings', AIPenIconWithAnimation),+ showWhen: noteBlockOrTextShowWhen,+ beta: true,+ },+ {+ name: 'Generate an image',+ icon: AIImageIcon,+ showWhen: () => true,+ handler: actionToHandler(+ 'createImage',+ AIImageIconWithAnimation,+ undefined,+ async (host, ctx) => {+ const selectedElements = getCopilotSelectedElems(host);+ const len = selectedElements.length;++ const aiPanel = getAIPanel(host);+ // text to image+ // from user input+ if (len === 0) {+ const content = aiPanel.inputText?.trim();+ if (!content) return;+ return {+ content,+ };+ }++ let content = (ctx.get()['content'] as string) || '';++ // from user input+ if (content.length === 0) {+ content = aiPanel.inputText?.trim() || '';+ }++ const {+ images,+ shapes,+ notes: _,+ frames: __,+ } = BlocksUtils.splitElements(selectedElements);++ const pureShapes = shapes.filter(+ e =>+ !(+ e instanceof TextElementModel ||+ (e instanceof ShapeElementModel && e.text?.length)+ )+ );++ // text to image+ if (content.length && images.length + pureShapes.length === 0) {+ return {+ content,+ };+ }++ // image to image+ const edgelessRoot = getEdgelessRootFromEditor(host);+ const canvas = await edgelessRoot.clipboardController.toCanvas(+ images,+ pureShapes,+ {+ dpr: 1,+ padding: 0,+ background: 'white',+ }+ );+ if (!canvas) return;++ const png = await canvasToBlob(canvas);+ if (!png) return;+ return {+ content,+ attachments: [png],+ seed: String(randomSeed()),+ };+ }+ ),+ },+ {+ name: 'Generate outline',+ icon: AIPenIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('writeOutline', AIPenIconWithAnimation),+ },+ {+ name: 'Expand from this mind map node',+ icon: AIExpandMindMapIcon,+ showWhen: mindmapChildShowWhen,+ handler: actionToHandler(+ 'expandMindmap',+ AIMindMapIconWithAnimation,+ undefined,+ function (host) {+ const selected = getCopilotSelectedElems(host);+ const firstSelected = selected[0] as ShapeElementModel;+ const mindmap = firstSelected?.group;++ if (!(mindmap instanceof MindmapElementModel)) {+ return Promise.resolve({});+ }++ return Promise.resolve({+ input: firstSelected.text?.toString() ?? '',+ mindmap: mindMapToMarkdown(mindmap),+ });+ }+ ),+ beta: true,+ },+ {+ name: 'Brainstorm ideas with mind map',+ icon: AIMindMapIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('brainstormMindmap', AIMindMapIconWithAnimation),+ },+ {+ name: 'Regenerate mind map',+ icon: AIMindMapIcon,+ showWhen: mindmapRootShowWhen,+ handler: actionToHandler(+ 'brainstormMindmap',+ AIMindMapIconWithAnimation,+ {+ regenerate: true,+ }+ ),+ },+ {+ name: 'Generate presentation',+ icon: AIPresentationIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('createSlides', AIPresentationIconWithAnimation),+ beta: true,+ },+ {+ name: 'Make it real',+ icon: MakeItRealIcon,+ beta: true,+ showWhen: () => true,+ handler: actionToHandler(+ 'makeItReal',+ MakeItRealIconWithAnimation,+ undefined,+ async (host, ctx) => {+ const selectedElements = getCopilotSelectedElems(host);++ // from user input+ if (selectedElements.length === 0) {+ const aiPanel = getAIPanel(host);+ const content = aiPanel.inputText?.trim();+ if (!content) return;+ return {+ content,+ };+ }++ const { notes, frames, shapes, images, edgelessTexts } =+ BlocksUtils.splitElements(selectedElements);+ const f = frames.length;+ const i = images.length;+ const n = notes.length;+ const s = shapes.length;+ const e = edgelessTexts.length;++ if (f + i + n + s + e === 0) {+ return;+ }+ let content = (ctx.get()['content'] as string) || '';++ // single note, text+ if (+ i === 0 &&+ n + s + e === 1 &&+ (n === 1 ||+ e === 1 ||+ (s === 1 && shapes[0] instanceof TextElementModel))+ ) {+ return {+ content,+ };+ }++ // from user input+ if (content.length === 0) {+ const aiPanel = getAIPanel(host);+ content = aiPanel.inputText?.trim() || '';+ }++ const edgelessRoot = getEdgelessRootFromEditor(host);+ const canvas = await edgelessRoot.clipboardController.toCanvas(+ [...notes, ...frames, ...images],+ shapes,+ {+ dpr: 1,+ background: 'white',+ }+ );+ if (!canvas) return;+ const png = await canvasToBlob(canvas);+ if (!png) return;+ ctx.set({+ width: canvas.width,+ height: canvas.height,+ });++ return {+ content,+ attachments: [png],+ };+ }+ ),+ },+ {+ name: 'AI image filter',+ icon: ImproveWritingIcon,+ showWhen: experimentalImageActionsShowWhen,+ subItem: imageFilterSubItem,+ subItemOffset: [12, -4],+ beta: true,+ },+ {+ name: 'Image processing',+ icon: AIImageIcon,+ showWhen: experimentalImageActionsShowWhen,+ subItem: imageProcessingSubItem,+ subItemOffset: [12, -6],+ beta: true,+ },+ {+ name: 'Generate a caption',+ icon: AIPenIcon,+ showWhen: experimentalImageActionsShowWhen,+ beta: true,+ handler: actionToHandler(+ 'generateCaption',+ AIStarIconWithAnimation,+ undefined,+ imageCustomInput+ ),+ },+ {+ name: 'Find actions',+ icon: AISearchIcon,+ showWhen: noteBlockOrTextShowWhen,+ handler: actionToHandler('findActions', AIStarIconWithAnimation),+ beta: true,+ },+ ],+};++export const edgelessActionGroups = [+ reviewGroup,+ editGroup,+ generateGroup,+ draftGroup,+ othersGroup,+];diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/edgeless/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/edgeless/index.tsnew file mode 100644index 0000000000..d312336ea2--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/edgeless/index.ts@@ -0,0 +1,47 @@+import type {+ AIItemGroupConfig,+ EdgelessCopilotWidget,+ EdgelessElementToolbarWidget,+ EdgelessRootBlockComponent,+} from '@blocksuite/blocks';+import { EdgelessCopilotToolbarEntry } from '@blocksuite/blocks';+import { noop } from '@blocksuite/global/utils';+import { html } from 'lit';++import { edgelessActionGroups } from './actions-config.js';++noop(EdgelessCopilotToolbarEntry);++export function setupEdgelessCopilot(widget: EdgelessCopilotWidget) {+ widget.groups = edgelessActionGroups;+}++export function setupEdgelessElementToolbarEntry(+ widget: EdgelessElementToolbarWidget+) {+ widget.registerEntry({+ when: () => {+ return true;+ },+ render: (edgeless: EdgelessRootBlockComponent) => {+ const chain = edgeless.service.std.command.chain();+ const filteredGroups = edgelessActionGroups.reduce((pre, group) => {+ const filtered = group.items.filter(item =>+ item.showWhen?.(chain, 'edgeless', edgeless.host)+ );++ if (filtered.length > 0) pre.push({ ...group, items: filtered });++ return pre;+ }, [] as AIItemGroupConfig[]);++ if (filteredGroups.every(group => group.items.length === 0)) return null;++ return html`<edgeless-copilot-toolbar-entry+ .edgeless=${edgeless}+ .host=${edgeless.host}+ .groups=${edgelessActionGroups}+ ></edgeless-copilot-toolbar-entry>`;+ },+ });+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/format-bar/setup-format-bar.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/format-bar/setup-format-bar.tsnew file mode 100644index 0000000000..953829cca2--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/format-bar/setup-format-bar.ts@@ -0,0 +1,29 @@+import '../../_common/components/ask-ai-button.js';++import {+ type AffineFormatBarWidget,+ toolbarDefaultConfig,+} from '@blocksuite/blocks';+import { html, type TemplateResult } from 'lit';++import { AIItemGroups } from '../../_common/config.js';++export function setupFormatBarEntry(formatBar: AffineFormatBarWidget) {+ toolbarDefaultConfig(formatBar);+ formatBar.addRawConfigItems(+ [+ {+ type: 'custom' as const,+ render(formatBar: AffineFormatBarWidget): TemplateResult | null {+ return html` <ask-ai-button+ .host=${formatBar.host}+ .actionGroups=${AIItemGroups}+ .toggleType=${'hover'}+ ></ask-ai-button>`;+ },+ },+ { type: 'divider' },+ ],+ 0+ );+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/image-toolbar/setup-image-toolbar.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/image-toolbar/setup-image-toolbar.tsnew file mode 100644index 0000000000..1aa32d6db3--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/image-toolbar/setup-image-toolbar.ts@@ -0,0 +1,52 @@+import '../../_common/components/ask-ai-button.js';++import type {+ AffineImageToolbarWidget,+ ImageBlockComponent,+} from '@blocksuite/blocks';+import { html } from 'lit';++import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button.js';+import { buildAIImageItemGroups } from '../../_common/config.js';++const AIImageItemGroups = buildAIImageItemGroups();+const buttonOptions: AskAIButtonOptions = {+ size: 'small',+ backgroundColor: 'var(--affine-white)',+ panelWidth: 300,+};++export function setupImageToolbarEntry(imageToolbar: AffineImageToolbarWidget) {+ const onAskAIClick = () => {+ const { host } = imageToolbar;+ const { selection } = host;+ const imageBlock = imageToolbar.blockElement;+ selection.setGroup('note', [+ selection.create('image', { blockId: imageBlock.blockId }),+ ]);+ };+ imageToolbar.buildDefaultConfig();+ imageToolbar.addConfigItems(+ [+ {+ type: 'custom',+ render(imageBlock: ImageBlockComponent, onClick?: () => void) {+ return html`<ask-ai-button+ class="image-toolbar-button ask-ai"+ .host=${imageBlock.host}+ .actionGroups=${AIImageItemGroups}+ .toggleType=${'click'}+ .options=${buttonOptions}+ @click=${(e: MouseEvent) => {+ e.stopPropagation();+ onAskAIClick();+ onClick?.();+ }}+ ></ask-ai-button>`;+ },+ showWhen: () => true,+ },+ ],+ 0+ );+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/index.tsnew file mode 100644index 0000000000..a3c78cc140--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/index.ts@@ -0,0 +1,2 @@+export * from './format-bar/setup-format-bar.js';+export * from './space/setup-space.js';diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.tsnew file mode 100644index 0000000000..0c6b510c0a--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/slash-menu/setup-slash-menu.ts@@ -0,0 +1,138 @@+import type {+ AffineAIPanelWidget,+ AffineSlashMenuActionItem,+ AffineSlashMenuContext,+ AffineSlashMenuItem,+ AffineSlashSubMenu,+ AIItemConfig,+} from '@blocksuite/blocks';+import {+ AFFINE_AI_PANEL_WIDGET,+ AffineSlashMenuWidget,+ AIStarIcon,+ MoreHorizontalIcon,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import { html } from 'lit';++import { AIItemGroups } from '../../_common/config.js';+import { handleInlineAskAIAction } from '../../actions/doc-handler.js';+import { AIProvider } from '../../provider.js';++export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {+ const AIItems = AIItemGroups.map(group => group.items).flat();++ const iconWrapper = (icon: AIItemConfig['icon']) => {+ return html`<div style="color: var(--affine-primary-color)">+ ${typeof icon === 'function' ? html`${icon()}` : icon}+ </div>`;+ };++ const showWhenWrapper =+ (item?: AIItemConfig) =>+ ({ rootElement }: AffineSlashMenuContext) => {+ const affineAIPanelWidget = rootElement.host.view.getWidget(+ AFFINE_AI_PANEL_WIDGET,+ rootElement.model.id+ );+ if (affineAIPanelWidget === null) return false;++ const chain = rootElement.host.command.chain();+ const editorMode = rootElement.service.docModeService.getMode(+ rootElement.doc.id+ );++ return item?.showWhen?.(chain, editorMode, rootElement.host) ?? true;+ };++ const actionItemWrapper = (+ item: AIItemConfig+ ): AffineSlashMenuActionItem => ({+ ...basicItemConfig(item),+ action: ({ rootElement }: AffineSlashMenuContext) => {+ item?.handler?.(rootElement.host);+ },+ });++ const subMenuWrapper = (item: AIItemConfig): AffineSlashSubMenu => {+ assertExists(item.subItem);+ return {+ ...basicItemConfig(item),+ subMenu: item.subItem.map<AffineSlashMenuActionItem>(+ ({ type, handler }) => ({+ name: type,+ action: ({ rootElement }) => handler?.(rootElement.host),+ })+ ),+ };+ };++ const basicItemConfig = (item: AIItemConfig) => {+ return {+ name: item.name,+ icon: iconWrapper(item.icon),+ alias: ['ai'],+ showWhen: showWhenWrapper(item),+ };+ };++ const AIMenuItems: AffineSlashMenuItem[] = [+ { groupName: 'AFFiNE AI' },+ {+ name: 'Ask AI',+ icon: AIStarIcon,+ showWhen: showWhenWrapper(),+ action: ({ rootElement }) => {+ const view = rootElement.host.view;+ const affineAIPanelWidget = view.getWidget(+ AFFINE_AI_PANEL_WIDGET,+ rootElement.model.id+ ) as AffineAIPanelWidget;+ assertExists(affineAIPanelWidget);+ assertExists(AIProvider.actions.chat);+ assertExists(affineAIPanelWidget.host);+ handleInlineAskAIAction(affineAIPanelWidget.host);+ },+ },++ ...AIItems.filter(({ name }) =>+ ['Fix spelling', 'Fix grammar'].includes(name)+ ).map(item => ({+ ...actionItemWrapper(item),+ name: `${item.name} from above`,+ })),++ ...AIItems.filter(({ name }) =>+ ['Summarize', 'Continue writing'].includes(name)+ ).map(actionItemWrapper),++ {+ name: 'Action with above',+ icon: iconWrapper(MoreHorizontalIcon),+ subMenu: [+ { groupName: 'Action with above' },+ ...AIItems.filter(({ name }) =>+ ['Translate to', 'Change tone to'].includes(name)+ ).map(subMenuWrapper),++ ...AIItems.filter(({ name }) =>+ [+ 'Improve writing',+ 'Make it longer',+ 'Make it shorter',+ 'Generate outline',+ 'Find actions',+ ].includes(name)+ ).map(actionItemWrapper),+ ],+ },+ ];++ const menu = slashMenu.config.items.slice();+ menu.unshift(...AIMenuItems);++ slashMenu.config = {+ ...AffineSlashMenuWidget.DEFAULT_CONFIG,+ items: menu,+ };+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/entries/space/setup-space.ts b/packages/frontend/core/src/blocksuite/presets/ai/entries/space/setup-space.tsnew file mode 100644index 0000000000..5416983bfe--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/entries/space/setup-space.ts@@ -0,0 +1,25 @@+import type { AffineAIPanelWidget } from '@blocksuite/blocks';++import { handleInlineAskAIAction } from '../../actions/doc-handler.js';+import { AIProvider } from '../../provider.js';++export function setupSpaceEntry(panel: AffineAIPanelWidget) {+ panel.handleEvent('keyDown', ctx => {+ const host = panel.host;+ const keyboardState = ctx.get('keyboardState');+ if (+ AIProvider.actions.chat &&+ keyboardState.raw.key === ' ' &&+ !keyboardState.raw.isComposing+ ) {+ const selection = host.selection.find('text');+ if (selection && selection.isCollapsed() && selection.from.index === 0) {+ const block = host.view.getBlock(selection.blockId);+ if (!block?.model?.text || block.model.text?.length > 0) return;++ keyboardState.raw.preventDefault();+ handleInlineAskAIAction(host);+ }+ }+ });+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/index.tsnew file mode 100644index 0000000000..831844785f--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/index.ts@@ -0,0 +1,7 @@+export * from './actions/index.js';+export * from './ai-spec.js';+export { ChatPanel } from './chat-panel/index.js';+export * from './entries/edgeless/actions-config.js';+export * from './entries/index.js';+export * from './messages/index.js';+export * from './provider.js';diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/error.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/error.tsnew file mode 100644index 0000000000..179b6c7058--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/error.ts@@ -0,0 +1,114 @@+import { type EditorHost, WithDisposable } from '@blocksuite/block-std';+import { html, LitElement, nothing, type TemplateResult } from 'lit';+import { customElement, property } from 'lit/decorators.js';++import { ErrorTipIcon } from '../_common/icons.js';+import { AIProvider } from '../provider.js';++@customElement('ai-error-wrapper')+class AIErrorWrapper extends WithDisposable(LitElement) {+ @property({ attribute: false })+ accessor text!: TemplateResult<1>;++ protected override render() {+ return html` <style>+ .answer-tip {+ display: flex;+ flex-direction: column;+ justify-content: center;+ align-items: flex-start;+ gap: 4px;+ align-self: stretch;+ border-radius: 4px;+ padding: 8px;+ background-color: var(--affine-background-error-color);++ .bottom {+ align-items: flex-start;+ display: flex;+ gap: 8px;+ align-self: stretch;+ color: var(--affine-error-color, #eb4335);+ font-feature-settings:+ 'clig' off,+ 'liga' off;+ /* light/sm */+ font-size: var(--affine-font-sm);+ font-style: normal;+ font-weight: 400;+ line-height: 22px; /* 157.143% */+ margin-bottom: 4px;++ a {+ color: inherit;+ }++ div svg {+ position: relative;+ top: 3px;+ }+ }+ }+ </style>+ <div class="answer-tip">+ <div class="bottom">+ <div>${ErrorTipIcon}</div>+ <div>${this.text}</div>+ </div>+ <slot></slot>+ </div>`;+ }+}++export const PaymentRequiredErrorRenderer = (host: EditorHost) => html`+ <style>+ .upgrade {+ cursor: pointer;+ display: flex;+ padding: 4px 12px;+ justify-content: center;+ align-items: center;+ gap: 4px;+ border-radius: 8px;+ margin-left: auto;+ border: 1px solid var(--affine-border-color, #e3e2e4);+ background: var(--affine-primary-color);+ .content {+ display: flex;+ padding: 0px 4px;+ justify-content: center;+ align-items: center;+ color: var(--affine-pure-white);+ /* light/xsMedium */+ font-size: var(--affine-font-xs);+ font-style: normal;+ font-weight: 500;+ line-height: 20px; /* 166.667% */+ }+ }+ </style>+ <ai-error-wrapper+ .text=${html`You've reached the current usage cap for AFFiNE AI. You can+ subscribe to AFFiNE AI to continue the AI experience!`}+ >+ <div+ @click=${() => AIProvider.slots.requestUpgradePlan.emit({ host: host })}+ class="upgrade"+ >+ <div class="content">Upgrade</div>+ </div></ai-error-wrapper+ >+`;++export const GeneralErrorRenderer = (+ text: TemplateResult<1> = html`An error occurred, If this issue persists+ please let us know.+ <a href="mailto:[email protected]"> [email protected] </a>`,+ template: TemplateResult<1> = html`${nothing}`+) => html` <ai-error-wrapper .text=${text}>${template}</ai-error-wrapper>`;++declare global {+ interface HTMLElementTagNameMap {+ 'ai-error-wrapper': AIErrorWrapper;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/index.tsnew file mode 100644index 0000000000..18b83aab05--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/index.ts@@ -0,0 +1,2 @@+export * from './text.js';+export * from './wrapper.js';diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/mindmap.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/mindmap.tsnew file mode 100644index 0000000000..f93b05b9c1--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/mindmap.ts@@ -0,0 +1,79 @@+import type { EditorHost } from '@blocksuite/block-std';+import type {+ AffineAIPanelWidgetConfig,+ MindmapStyle,+} from '@blocksuite/blocks';+import { markdownToMindmap, MiniMindmapPreview } from '@blocksuite/blocks';+import { noop } from '@blocksuite/global/utils';+import { html, nothing } from 'lit';++import { getAIPanel } from '../ai-panel.js';++noop(MiniMindmapPreview);++export const createMindmapRenderer: (+ host: EditorHost,+ /**+ * Used to store data for later use during rendering.+ */+ ctx: {+ get: () => Record<string, unknown>;+ set: (data: Record<string, unknown>) => void;+ },+ style?: MindmapStyle+) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, ctx, style) => {+ return (answer, state) => {+ if (state === 'generating') {+ const panel = getAIPanel(host);+ panel.generatingElement?.updateLoadingProgress(2);+ }++ if (state !== 'finished' && state !== 'error') {+ return nothing;+ }++ return html`<mini-mindmap-preview+ .ctx=${ctx}+ .host=${host}+ .answer=${answer}+ .mindmapStyle=${style}+ .templateShow=${style === undefined}+ .height=${300}+ ></mini-mindmap-preview>`;+ };+};++/**+ * Creates a renderer for executing a handler.+ * The ai panel will not display anything after the answer is generated.+ */+export const createMindmapExecuteRenderer: (+ host: EditorHost,+ /**+ * Used to store data for later use during rendering.+ */+ ctx: {+ get: () => Record<string, unknown>;+ set: (data: Record<string, unknown>) => void;+ },+ handler: (ctx: {+ get: () => Record<string, unknown>;+ set: (data: Record<string, unknown>) => void;+ }) => void+) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, ctx, handler) => {+ return (answer, state) => {+ if (state !== 'finished') {+ const panel = getAIPanel(host);+ panel.generatingElement?.updateLoadingProgress(2);+ return nothing;+ }++ ctx.set({+ node: markdownToMindmap(answer, host.doc),+ });++ handler(ctx);++ return nothing;+ };+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.tsnew file mode 100644index 0000000000..585030f954--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/slides-renderer.ts@@ -0,0 +1,234 @@+import type { EditorHost } from '@blocksuite/block-std';+import { WithDisposable } from '@blocksuite/block-std';+import {+ type AffineAIPanelWidgetConfig,+ EdgelessEditorBlockSpecs,+} from '@blocksuite/blocks';+import { AffineSchemas } from '@blocksuite/blocks/schemas';+import type { Doc } from '@blocksuite/store';+import { DocCollection, Schema } from '@blocksuite/store';+import { css, html, LitElement, nothing } from 'lit';+import { customElement, property, query } from 'lit/decorators.js';+import { createRef, type Ref, ref } from 'lit/directives/ref.js';++import { getAIPanel } from '../ai-panel.js';+import { PPTBuilder } from '../slides/index.js';++export const createSlidesRenderer: (+ host: EditorHost,+ ctx: {+ get: () => Record<string, unknown>;+ set: (data: Record<string, unknown>) => void;+ }+) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, ctx) => {+ return (answer, state) => {+ if (state === 'generating') {+ const panel = getAIPanel(host);+ panel.generatingElement?.updateLoadingProgress(2);+ return nothing;+ }++ if (state !== 'finished' && state !== 'error') {+ return nothing;+ }++ return html`<style>+ .slides-container {+ width: 100%;+ height: 300px;+ }+ </style>+ <div class="slides-container">+ <ai-slides-renderer+ .host=${host}+ .ctx=${ctx}+ .text=${answer}+ ></ai-slides-renderer>+ </div>`;+ };+};++@customElement('ai-slides-renderer')+export class AISlidesRenderer extends WithDisposable(LitElement) {+ static override styles = css``;++ private readonly _editorContainer: Ref<HTMLDivElement> =+ createRef<HTMLDivElement>();++ private _doc!: Doc;++ @query('editor-host')+ private accessor _editorHost!: EditorHost;++ @property({ attribute: false })+ accessor text!: string;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor ctx:+ | {+ get(): Record<string, unknown>;+ set(data: Record<string, unknown>): void;+ }+ | undefined = undefined;++ protected override firstUpdated() {+ requestAnimationFrame(() => {+ if (!this._editorHost) return;+ PPTBuilder(this._editorHost)+ .process(this.text)+ .then(res => {+ if (this.ctx) {+ this.ctx.set({+ contents: res.contents,+ images: res.images,+ });+ }+ })+ .catch(console.error);+ });+ }++ protected override render() {+ return html`<style>+ .slides-container {+ position: relative;+ width: 100%;+ height: 100%;+ }++ .edgeless-container {+ width: 100%;+ height: 100%;+ border-radius: 4px;+ border: 1px solid var(--affine-border-color);+ }++ .mask {+ position: absolute;+ top: 0;+ left: 0;+ z-index: 1;+ background-color: transparent;+ width: 100%;+ height: 100%;+ }++ .edgeless-container affine-edgeless-zoom-toolbar-widget,+ edgeless-toolbar {+ display: none;+ }++ * {+ box-sizing: border-box;+ }++ .affine-edgeless-viewport {+ display: block;+ height: 100%;+ position: relative;+ overflow: hidden;+ container-name: viewport;+ container-type: inline-size;+ }++ .affine-edgeless-surface-block-container {+ position: absolute;+ width: 100%;+ height: 100%;+ }++ .affine-edgeless-surface-block-container canvas {+ width: 100%;+ height: 100%;+ position: relative;+ z-index: 1;+ pointer-events: none;+ }++ edgeless-block-portal-container {+ position: relative;+ box-sizing: border-box;+ overflow: hidden;+ display: block;+ height: 100%;+ font-family: var(--affine-font-family);+ font-size: var(--affine-font-base);+ line-height: var(--affine-line-height);+ color: var(--affine-text-primary-color);+ font-weight: 400;+ }++ .affine-block-children-container.edgeless {+ padding-left: 0;+ position: relative;+ overflow: hidden;+ height: 100%;+ touch-action: none;+ background-color: var(--affine-background-primary-color);+ background-image: radial-gradient(+ var(--affine-edgeless-grid-color) 1px,+ var(--affine-background-primary-color) 1px+ );+ z-index: 0;+ }++ .affine-edgeless-block-child {+ position: absolute;+ transform-origin: center;+ box-sizing: border-box;+ border: 2px solid var(--affine-white-10);+ border-radius: 8px;+ box-shadow: var(--affine-shadow-3);+ pointer-events: all;+ }++ affine-edgeless-image .resizable-img,+ affine-edgeless-image .resizable-img img {+ width: 100%;+ height: 100%;+ }++ .affine-edgeless-layer {+ position: absolute;+ top: 0;+ left: 0;+ contain: size layout style;+ }+ </style>+ <div class="slides-container">+ <div+ class="edgeless-container affine-edgeless-viewport"+ ${ref(this._editorContainer)}+ >+ ${this.host.renderSpecPortal(this._doc, EdgelessEditorBlockSpecs)}+ </div>+ <div class="mask"></div>+ </div>`;+ }++ override connectedCallback(): void {+ super.connectedCallback();++ const schema = new Schema().register(AffineSchemas);+ const collection = new DocCollection({ schema, id: 'SLIDES_PREVIEW' });+ collection.start();+ const doc = collection.createDoc();++ doc.load(() => {+ const pageBlockId = doc.addBlock('affine:page', {});+ doc.addBlock('affine:surface', {}, pageBlockId);+ });++ doc.resetHistory();+ this._doc = doc;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'ai-slides-renderer': AISlidesRenderer;+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/text.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/text.tsnew file mode 100644index 0000000000..e3e8b0868b--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/text.ts@@ -0,0 +1,298 @@+import { type EditorHost, WithDisposable } from '@blocksuite/block-std';+import type {+ AffineAIPanelState,+ AffineAIPanelWidgetConfig,+} from '@blocksuite/blocks';+import {+ BlocksUtils,+ CodeBlockComponent,+ DividerBlockComponent,+ ListBlockComponent,+ ParagraphBlockComponent,+} from '@blocksuite/blocks';+import { type BlockSelector, BlockViewType, type Doc } from '@blocksuite/store';+import { css, html, LitElement, type PropertyValues } from 'lit';+import { customElement, property, query } from 'lit/decorators.js';+import { classMap } from 'lit/directives/class-map.js';+import { keyed } from 'lit/directives/keyed.js';++import { CustomPageEditorBlockSpecs } from '../utils/custom-specs.js';+import { markDownToDoc } from '../utils/markdown-utils.js';++const textBlockStyles = css`+ ${ParagraphBlockComponent.styles}+ ${ListBlockComponent.styles}+ ${DividerBlockComponent.styles}+ ${CodeBlockComponent.styles}+`;++const customHeadingStyles = css`+ .custom-heading {+ .h1 {+ font-size: calc(var(--affine-font-h-1) - 2px);+ code {+ font-size: calc(var(--affine-font-base) + 6px);+ }+ }+ .h2 {+ font-size: calc(var(--affine-font-h-2) - 2px);+ code {+ font-size: calc(var(--affine-font-base) + 4px);+ }+ }+ .h3 {+ font-size: calc(var(--affine-font-h-3) - 2px);+ code {+ font-size: calc(var(--affine-font-base) + 2px);+ }+ }+ .h4 {+ font-size: calc(var(--affine-font-h-4) - 2px);+ code {+ font-size: var(--affine-font-base);+ }+ }+ .h5 {+ font-size: calc(var(--affine-font-h-5) - 2px);+ code {+ font-size: calc(var(--affine-font-base) - 2px);+ }+ }+ .h6 {+ font-size: calc(var(--affine-font-h-6) - 2px);+ code {+ font-size: calc(var(--affine-font-base) - 4px);+ }+ }+ }+`;++type TextRendererOptions = {+ maxHeight?: number;+ customHeading?: boolean;+};++@customElement('ai-answer-text')+export class AIAnswerText extends WithDisposable(LitElement) {+ static override styles = css`+ .ai-answer-text-editor.affine-page-viewport {+ background: transparent;+ font-family: var(--affine-font-family);+ margin-top: 0;+ margin-bottom: 0;+ }++ .ai-answer-text-editor .affine-page-root-block-container {+ padding: 0;+ line-height: var(--affine-line-height);+ color: var(--affine-text-primary-color);+ font-weight: 400;+ }++ .affine-paragraph-block-container {+ line-height: 22px;+ }++ .ai-answer-text-editor {+ .affine-note-block-container {+ > .affine-block-children-container {+ > :first-child,+ > :first-child * {+ margin-top: 0 !important;+ }+ > :last-child,+ > :last-child * {+ margin-top: 0 !important;+ }+ }+ }+ }++ .ai-answer-text-container {+ overflow-y: auto;+ overflow-x: hidden;+ padding: 0;+ overscroll-behavior-y: none;+ }+ .ai-answer-text-container.show-scrollbar::-webkit-scrollbar {+ width: 5px;+ height: 100px;+ }+ .ai-answer-text-container.show-scrollbar::-webkit-scrollbar-thumb {+ border-radius: 20px;+ }+ .ai-answer-text-container.show-scrollbar:hover::-webkit-scrollbar-thumb {+ background-color: var(--affine-black-30);+ }+ .ai-answer-text-container.show-scrollbar::-webkit-scrollbar-corner {+ display: none;+ }++ .ai-answer-text-container {+ rich-text .nowrap-lines v-text span,+ rich-text .nowrap-lines v-element span {+ white-space: pre;+ }+ editor-host:focus-visible {+ outline: none;+ }+ editor-host * {+ box-sizing: border-box;+ }+ }++ ${textBlockStyles}+ ${customHeadingStyles}+ `;++ @query('.ai-answer-text-container')+ private accessor _container!: HTMLDivElement;++ private _doc!: Doc;++ private _answers: string[] = [];++ private _timer?: ReturnType<typeof setInterval> | null = null;++ @property({ attribute: false })+ accessor host!: EditorHost;++ @property({ attribute: false })+ accessor answer!: string;++ @property({ attribute: false })+ accessor options!: TextRendererOptions;++ @property({ attribute: false })+ accessor state: AffineAIPanelState | undefined = undefined;++ private _onWheel(e: MouseEvent) {+ e.stopPropagation();+ if (this.state === 'generating') {+ e.preventDefault();+ }+ }++ private readonly _clearTimer = () => {+ if (this._timer) {+ clearInterval(this._timer);+ this._timer = null;+ }+ };++ private readonly _selector: BlockSelector = block =>+ BlocksUtils.matchFlavours(block.model, [+ 'affine:page',+ 'affine:note',+ 'affine:surface',+ 'affine:paragraph',+ 'affine:code',+ 'affine:list',+ 'affine:divider',+ ])+ ? BlockViewType.Display+ : BlockViewType.Hidden;++ private readonly _updateDoc = () => {+ if (this._answers.length > 0) {+ const latestAnswer = this._answers.pop();+ this._answers = [];+ if (latestAnswer) {+ markDownToDoc(this.host, latestAnswer)+ .then(doc => {+ this._doc = doc.blockCollection.getDoc({+ selector: this._selector,+ });+ this.disposables.add(() => {+ doc.blockCollection.clearSelector(this._selector);+ });+ this._doc.awarenessStore.setReadonly(+ this._doc.blockCollection,+ true+ );+ this.requestUpdate();+ if (this.state !== 'generating') {+ this._clearTimer();+ }+ })+ .catch(console.error);+ }+ }+ };++ override shouldUpdate(changedProperties: PropertyValues) {+ if (changedProperties.has('answer')) {+ this._answers.push(this.answer);+ return false;+ }++ return true;+ }++ override connectedCallback() {+ super.connectedCallback();+ this._answers.push(this.answer);++ this._updateDoc();+ if (this.state === 'generating') {+ this._timer = setInterval(this._updateDoc, 600);+ }+ }++ override disconnectedCallback() {+ super.disconnectedCallback();+ this._clearTimer();+ }++ override updated(changedProperties: PropertyValues) {+ super.updated(changedProperties);+ requestAnimationFrame(() => {+ if (!this._container) return;+ this._container.scrollTop = this._container.scrollHeight;+ });+ }++ override render() {+ const { maxHeight, customHeading } = this.options;+ const classes = classMap({+ 'ai-answer-text-container': true,+ 'show-scrollbar': !!maxHeight,+ 'custom-heading': !!customHeading,+ });+ return html`+ <style>+ .ai-answer-text-container {+ max-height: ${maxHeight ? Math.max(maxHeight, 200) + 'px' : ''};+ }+ </style>+ <div class=${classes} @wheel=${this._onWheel}>+ ${keyed(+ this._doc,+ html`<div class="ai-answer-text-editor affine-page-viewport">+ ${this.host.renderSpecPortal(this._doc, CustomPageEditorBlockSpecs)}+ </div>`+ )}+ </div>+ `;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'ai-answer-text': AIAnswerText;+ }+}++export const createTextRenderer: (+ host: EditorHost,+ options: TextRendererOptions+) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => {+ return (answer, state) => {+ return html`<ai-answer-text+ .host=${host}+ .answer=${answer}+ .state=${state}+ .options=${options}+ ></ai-answer-text>`;+ };+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/messages/wrapper.ts b/packages/frontend/core/src/blocksuite/presets/ai/messages/wrapper.tsnew file mode 100644index 0000000000..3ae585473e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/messages/wrapper.ts@@ -0,0 +1,119 @@+import type { EditorHost } from '@blocksuite/block-std';+import type { AffineAIPanelWidgetConfig } from '@blocksuite/blocks';+import { css, html, LitElement, nothing } from 'lit';+import { customElement, property } from 'lit/decorators.js';++import { getAIPanel } from '../ai-panel.js';+import { preprocessHtml } from '../utils/html.js';++type AIAnswerWrapperOptions = {+ height: number;+};++@customElement('ai-answer-wrapper')+export class AIAnswerWrapper extends LitElement {+ static override styles = css`+ :host {+ display: block;+ width: 100%;+ box-sizing: border-box;+ border-radius: 4px;+ border: 1px solid var(--affine-border-color);+ box-shadow: var(--affine-shadow-1);+ background: var(--affine-background-secondary-color);+ overflow: hidden;+ }++ ::slotted(.ai-answer-iframe) {+ width: 100%;+ height: 100%;+ border: none;+ }++ ::slotted(.ai-answer-image) {+ width: 100%;+ height: 100%;+ }+ `;++ @property({ attribute: false })+ accessor options: AIAnswerWrapperOptions | undefined = undefined;++ protected override render() {+ return html`<style>+ :host {+ height: ${this.options?.height+ ? this.options?.height + 'px'+ : '100%'};+ }+ </style>+ <slot></slot> `;+ }+}++declare global {+ interface HTMLElementTagNameMap {+ 'ai-answer-wrapper': AIAnswerWrapper;+ }+}++export const createIframeRenderer: (+ host: EditorHost,+ options?: AIAnswerWrapperOptions+) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => {+ return (answer, state) => {+ if (state === 'generating') {+ const panel = getAIPanel(host);+ panel.generatingElement?.updateLoadingProgress(2);+ return nothing;+ }++ if (state !== 'finished' && state !== 'error') {+ return nothing;+ }++ const template = html`<iframe+ class="ai-answer-iframe"+ sandbox="allow-scripts"+ scrolling="no"+ allowfullscreen+ .srcdoc=${preprocessHtml(answer)}+ >+ </iframe>`;+ return html`<ai-answer-wrapper .options=${options}+ >${template}</ai-answer-wrapper+ >`;+ };+};++export const createImageRenderer: (+ host: EditorHost,+ options?: AIAnswerWrapperOptions+) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => {+ return (answer, state) => {+ if (state === 'generating') {+ const panel = getAIPanel(host);+ panel.generatingElement?.updateLoadingProgress(2);+ return nothing;+ }++ if (state !== 'finished' && state !== 'error') {+ return nothing;+ }++ const template = html`<style>+ .ai-answer-image img{+ width: 100%;+ height: 100%;+ object-fit: contain;+ }+ </style>+ <div class="ai-answer-image">+ <img src=${answer}></img>+ </div>`;++ return html`<ai-answer-wrapper .options=${options}+ >${template}</ai-answer-wrapper+ >`;+ };+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/provider.ts b/packages/frontend/core/src/blocksuite/presets/ai/provider.tsnew file mode 100644index 0000000000..d6b54edd97--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/provider.ts@@ -0,0 +1,252 @@+import type { EditorHost } from '@blocksuite/block-std';+import { PaymentRequiredError, UnauthorizedError } from '@blocksuite/blocks';+import { Slot } from '@blocksuite/store';++export interface AIUserInfo {+ id: string;+ email: string;+ name: string;+ avatarUrl: string | null;+}++export type ActionEventType =+ | 'started'+ | 'finished'+ | 'error'+ | 'aborted:paywall'+ | 'aborted:login-required'+ | 'aborted:server-error'+ | 'aborted:stop'+ | 'result:insert'+ | 'result:replace'+ | 'result:use-as-caption'+ | 'result:add-page'+ | 'result:add-note'+ | 'result:continue-in-chat'+ | 'result:discard'+ | 'result:retry';++/**+ * AI provider for the block suite+ *+ * To use it, downstream (affine) has to provide AI actions implementation,+ * user info etc+ *+ * todo: breakdown into different parts?+ */+export class AIProvider {+ static get slots() {+ return AIProvider.instance.slots;+ }++ static get actions() {+ return AIProvider.instance.actions;+ }++ static get userInfo() {+ return AIProvider.instance.userInfoFn();+ }++ static get photoEngine() {+ return AIProvider.instance.photoEngine;+ }++ static get histories() {+ return AIProvider.instance.histories;+ }++ static get actionHistory() {+ return AIProvider.instance.actionHistory;+ }++ static get toggleGeneralAIOnboarding() {+ return AIProvider.instance.toggleGeneralAIOnboarding;+ }++ private static readonly instance = new AIProvider();++ static LAST_ACTION_SESSIONID = '';++ static MAX_LOCAL_HISTORY = 10;++ private readonly actions: Partial<BlockSuitePresets.AIActions> = {};++ private photoEngine: BlockSuitePresets.AIPhotoEngineService | null = null;++ private histories: BlockSuitePresets.AIHistoryService | null = null;++ private toggleGeneralAIOnboarding: ((value: boolean) => void) | null = null;++ private readonly slots = {+ // use case: when user selects "continue in chat" in an ask ai result panel+ // do we need to pass the context to the chat panel?+ requestContinueInChat: new Slot<{ host: EditorHost; show: boolean }>(),+ requestLogin: new Slot<{ host: EditorHost }>(),+ requestUpgradePlan: new Slot<{ host: EditorHost }>(),+ // when an action is requested to run in edgeless mode (show a toast in affine)+ requestRunInEdgeless: new Slot<{ host: EditorHost }>(),+ // stream of AI actions triggered by users+ actions: new Slot<{+ action: keyof BlockSuitePresets.AIActions;+ options: BlockSuitePresets.AITextActionOptions;+ event: ActionEventType;+ }>(),+ // downstream can emit this slot to notify ai presets that user info has been updated+ userInfo: new Slot<AIUserInfo | null>(),+ // add more if needed+ };++ // track the history of triggered actions (in memory only)+ private readonly actionHistory: {+ action: keyof BlockSuitePresets.AIActions;+ options: BlockSuitePresets.AITextActionOptions;+ }[] = [];++ private userInfoFn: () => AIUserInfo | Promise<AIUserInfo> | null = () =>+ null;++ private provideAction<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ action: (+ ...options: Parameters<BlockSuitePresets.AIActions[T]>+ ) => ReturnType<BlockSuitePresets.AIActions[T]>+ ): void {+ if (this.actions[id]) {+ console.warn(`AI action ${id} is already provided`);+ }++ // @ts-expect-error todo: maybe fix this+ this.actions[id] = (+ ...args: Parameters<BlockSuitePresets.AIActions[T]>+ ) => {+ const options = args[0];+ const slots = this.slots;+ slots.actions.emit({+ action: id,+ options,+ event: 'started',+ });+ this.actionHistory.push({ action: id, options });+ if (this.actionHistory.length > AIProvider.MAX_LOCAL_HISTORY) {+ this.actionHistory.shift();+ }+ // wrap the action with slot actions+ const result: BlockSuitePresets.TextStream | Promise<string> = action(+ ...args+ );+ const isTextStream = (+ m: BlockSuitePresets.TextStream | Promise<string>+ ): m is BlockSuitePresets.TextStream =>+ Reflect.has(m, Symbol.asyncIterator);+ if (isTextStream(result)) {+ return {+ [Symbol.asyncIterator]: async function* () {+ try {+ yield* result;+ slots.actions.emit({+ action: id,+ options,+ event: 'finished',+ });+ } catch (err) {+ slots.actions.emit({+ action: id,+ options,+ event: 'error',+ });+ if (err instanceof PaymentRequiredError) {+ slots.actions.emit({+ action: id,+ options,+ event: 'aborted:paywall',+ });+ } else if (err instanceof UnauthorizedError) {+ slots.actions.emit({+ action: id,+ options,+ event: 'aborted:login-required',+ });+ } else {+ slots.actions.emit({+ action: id,+ options,+ event: 'aborted:server-error',+ });+ }+ throw err;+ }+ },+ };+ } else {+ return result+ .then(result => {+ slots.actions.emit({+ action: id,+ options,+ event: 'finished',+ });+ return result;+ })+ .catch(err => {+ slots.actions.emit({+ action: id,+ options,+ event: 'error',+ });+ if (err instanceof PaymentRequiredError) {+ slots.actions.emit({+ action: id,+ options,+ event: 'aborted:paywall',+ });+ }+ throw err;+ });+ }+ };+ }++ static provide(+ id: 'userInfo',+ fn: () => AIUserInfo | Promise<AIUserInfo> | null+ ): void;++ static provide(+ id: 'histories',+ service: BlockSuitePresets.AIHistoryService+ ): void;++ static provide(+ id: 'photoEngine',+ engine: BlockSuitePresets.AIPhotoEngineService+ ): void;++ static provide(id: 'onboarding', fn: (value: boolean) => void): void;++ // actions:+ static provide<T extends keyof BlockSuitePresets.AIActions>(+ id: T,+ action: (+ ...options: Parameters<BlockSuitePresets.AIActions[T]>+ ) => ReturnType<BlockSuitePresets.AIActions[T]>+ ): void;++ static provide(id: unknown, action: unknown) {+ if (id === 'userInfo') {+ AIProvider.instance.userInfoFn = action as () => AIUserInfo;+ } else if (id === 'histories') {+ AIProvider.instance.histories =+ action as BlockSuitePresets.AIHistoryService;+ } else if (id === 'photoEngine') {+ AIProvider.instance.photoEngine =+ action as BlockSuitePresets.AIPhotoEngineService;+ } else if (id === 'onboarding') {+ AIProvider.instance.toggleGeneralAIOnboarding = action as (+ value: boolean+ ) => void;+ } else {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ AIProvider.instance.provideAction(id as any, action as any);+ }+ }+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/index.ts b/packages/frontend/core/src/blocksuite/presets/ai/slides/index.tsnew file mode 100644index 0000000000..c4825adf2b--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/index.ts@@ -0,0 +1,84 @@+import type { EditorHost } from '@blocksuite/block-std';+import type { EdgelessRootService } from '@blocksuite/blocks';+import type { BlockSnapshot } from '@blocksuite/store';++import { markdownToSnapshot } from '../_common/markdown-utils.js';+import { getSurfaceElementFromEditor } from '../_common/selection-utils.js';+import {+ basicTheme,+ type PPTDoc,+ type PPTSection,+ type TemplateImage,+} from './template.js';++export const PPTBuilder = (host: EditorHost) => {+ const service = host.spec.getService<EdgelessRootService>('affine:page');+ const docs: PPTDoc[] = [];+ const contents: unknown[] = [];+ const allImages: TemplateImage[][] = [];++ const addDoc = async (block: BlockSnapshot) => {+ const sections = block.children.map(v => {+ const title = getText(v);+ const keywords = getText(v.children[0]);+ const content = getText(v.children[1]);+ return {+ title,+ keywords,+ content,+ } satisfies PPTSection;+ });+ const doc: PPTDoc = {+ isCover: docs.length === 0,+ title: getText(block),+ sections,+ };+ docs.push(doc);++ if (doc.isCover) return;+ const job = service.createTemplateJob('template');+ const { images, content } = await basicTheme(doc);+ contents.push(content);+ allImages.push(images);+ if (images.length) {+ await Promise.all(+ images.map(({ id, url }) =>+ fetch(url)+ .then(res => res.blob())+ .then(blob => job.job.assets.set(id, blob))+ )+ );+ }+ await job.insertTemplate(content);+ getSurfaceElementFromEditor(host).refresh();+ };++ return {+ process: async (text: string) => {+ try {+ const snapshot = await markdownToSnapshot(text, host);++ const block = snapshot.snapshot.content[0];+ for (const child of block.children) {+ await addDoc(child);+ const { centerX, centerY, zoom } = service.getFitToScreenData();+ service.viewport.setViewport(zoom, [centerX, centerY]);+ }+ } catch (e) {+ console.error(e);+ }++ return { contents, images: allImages };+ },+ done: async (text: string) => {+ const snapshot = await markdownToSnapshot(text, host);+ const block = snapshot.snapshot.content[0];+ await addDoc(block.children[block.children.length - 1]);+ },+ };+};++const getText = (block: BlockSnapshot) => {+ // @ts-expect-error allow+ return block.props.text?.delta?.[0]?.insert ?? '';+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/template.ts b/packages/frontend/core/src/blocksuite/presets/ai/slides/template.tsnew file mode 100644index 0000000000..05af834ec0--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/template.ts@@ -0,0 +1,321 @@+import { Bound } from '@blocksuite/blocks';+import { nanoid } from '@blocksuite/store';++import { AIProvider } from '../provider.js';++// eslint-disable-next-line @typescript-eslint/no-explicit-any+const replaceText = (text: Record<string, string>, template: any) => {+ if (template != null && typeof template === 'object') {+ if (Array.isArray(template)) {+ template.forEach(v => replaceText(text, v));+ return;+ }+ if (typeof template.insert === 'string') {+ template.insert = text[template.insert] ?? template.insert;+ }+ Object.values(template).forEach(v => replaceText(text, v));+ return;+ }+};++function seededRNG(seed: string) {+ const a = 1664525;+ const c = 1013904223;+ const m = 2 ** 32;+ const seededNumber = stringToNumber(seed);+ return ((a * seededNumber + c) % m) / m;++ function stringToNumber(str: string) {+ let res = 0;+ for (let i = 0; i < str.length; i++) {+ const character = str.charCodeAt(i);+ res += character;+ }+ return res;+ }+}++const getImageUrlByKeyword =+ (keyword: string) =>+ async (w: number, h: number): Promise<string> => {+ const photos = await AIProvider.photoEngine?.searchImages({+ query: keyword,+ width: w,+ height: h,+ });++ if (photos == null || photos.length === 0) {+ return ''; // fixme: give a default image+ }++ // use a stable random seed+ const rng = seededRNG(`${w}.${h}.${keyword}`);+ return photos[Math.floor(rng * photos.length)];+ };++const getImages = async (+ images: Record<string, (w: number, h: number) => Promise<string> | string>,+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ template: any+): Promise<TemplateImage[]> => {+ const imgs: Record<+ string,+ {+ id: string;+ width: number;+ height: number;+ }+ > = {};+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const run = (data: any) => {+ if (data != null && typeof data === 'object') {+ if (Array.isArray(data)) {+ data.forEach(v => run(v));+ return;+ }+ if (typeof data.caption === 'string') {+ const bound = Bound.deserialize(data.xywh);+ const id = nanoid();+ data.sourceId = id;+ imgs[data.caption] = {+ id: id,+ width: bound.w,+ height: bound.h,+ };+ delete data.caption;+ }+ Object.values(data).forEach(v => run(v));+ return;+ }+ };+ run(template);+ const list = await Promise.all(+ Object.entries(imgs).map(async ([name, data]) => {+ const getImage = images[name];+ if (!getImage) {+ return;+ }+ const url = await getImage(data.width, data.height);+ return {+ id: data.id,+ url,+ } satisfies TemplateImage;+ })+ );+ const notNull = (v?: TemplateImage): v is TemplateImage => {+ return v != null;+ };+ return list.filter(notNull);+};++export type PPTSection = {+ title: string;+ content: string;+ keywords: string;+};++export type TemplateImage = {+ id: string;+ url: string;+};++type DocTemplate = {+ images: TemplateImage[];+ content: unknown;+};++const createBasicCover = async (+ title: string,+ section1: PPTSection+): Promise<DocTemplate> => {+ const templates = (await import('./templates/cover.json')).default;+ const template = getRandomElement(templates);+ replaceText(+ {+ title: title,+ 'section1.title': section1.title,+ 'section1.content': section1.content,+ },+ template+ );+ return {+ images: await getImages(+ {+ 'section1.image': getImageUrlByKeyword(section1.keywords),+ },+ template+ ),+ content: template,+ };+};++function getRandomElement<T>(arr: T[]): T {+ return arr[Math.floor(Math.random() * arr.length)];+}++const basic1section = async (+ title: string,+ section1: PPTSection+): Promise<DocTemplate> => {+ const templates = (await import('./templates/one.json')).default;+ const template = getRandomElement(templates);+ replaceText(+ {+ title: title,+ 'section1.title': section1.title,+ 'section1.content': section1.content,+ },+ template+ );+ const images = await getImages(+ {+ 'section1.image': getImageUrlByKeyword(section1.keywords),+ 'section1.image2': getImageUrlByKeyword(section1.keywords),+ 'section1.image3': getImageUrlByKeyword(section1.keywords),+ },+ template+ );++ return {+ images: images,+ content: template,+ };+};++const basic2section = async (+ title: string,+ section1: PPTSection,+ section2: PPTSection+): Promise<DocTemplate> => {+ const templates = (await import('./templates/two.json')).default;+ const template = getRandomElement(templates);+ replaceText(+ {+ title: title,+ 'section1.title': section1.title,+ 'section1.content': section1.content,+ 'section2.title': section2.title,+ 'section2.content': section2.content,+ },+ template+ );+ return {+ images: await getImages(+ {+ 'section1.image': getImageUrlByKeyword(section1.keywords),+ 'section2.image': getImageUrlByKeyword(section2.keywords),+ background: () =>+ 'https://cdn.affine.pro/ppt-images/background/basic_2_selection_background.png',+ },+ template+ ),+ content: template,+ };+};++const basic3section = async (+ title: string,+ section1: PPTSection,+ section2: PPTSection,+ section3: PPTSection+): Promise<DocTemplate> => {+ const templates = (await import('./templates/three.json')).default;+ const template = getRandomElement(templates);+ replaceText(+ {+ title: title,+ 'section1.title': section1.title,+ 'section1.content': section1.content,+ 'section2.title': section2.title,+ 'section2.content': section2.content,+ 'section3.title': section3.title,+ 'section3.content': section3.content,+ },+ template+ );+ return {+ images: await getImages(+ {+ 'section1.image': getImageUrlByKeyword(section1.keywords),+ 'section2.image': getImageUrlByKeyword(section2.keywords),+ 'section3.image': getImageUrlByKeyword(section3.keywords),+ background: () =>+ 'https://cdn.affine.pro/ppt-images/background/basic_3_selection_background.png',+ },+ template+ ),+ content: template,+ };+};++const basic4section = async (+ title: string,+ section1: PPTSection,+ section2: PPTSection,+ section3: PPTSection,+ section4: PPTSection+): Promise<DocTemplate> => {+ const templates = (await import('./templates/four.json')).default;+ const template = getRandomElement(templates);+ replaceText(+ {+ title: title,+ 'section1.title': section1.title,+ 'section1.content': section1.content,+ 'section2.title': section2.title,+ 'section2.content': section2.content,+ 'section3.title': section3.title,+ 'section3.content': section3.content,+ 'section4.title': section4.title,+ 'section4.content': section4.content,+ },+ template+ );+ return {+ images: await getImages(+ {+ 'section1.image': getImageUrlByKeyword(section1.keywords),+ 'section2.image': getImageUrlByKeyword(section2.keywords),+ 'section3.image': getImageUrlByKeyword(section3.keywords),+ 'section4.image': getImageUrlByKeyword(section4.keywords),+ background: () =>+ 'https://cdn.affine.pro/ppt-images/background/basic_4_selection_background.png',+ },+ template+ ),+ content: template,+ };+};++export type PPTDoc = {+ isCover: boolean;+ title: string;+ sections: PPTSection[];+};++export const basicTheme = (doc: PPTDoc) => {+ if (doc.isCover) {+ return createBasicCover(doc.title, doc.sections[0]);+ }+ if (doc.sections.length === 1) {+ return basic1section(doc.title, doc.sections[0]);+ }+ if (doc.sections.length === 2) {+ return basic2section(doc.title, doc.sections[0], doc.sections[1]);+ }+ if (doc.sections.length === 3) {+ return basic3section(+ doc.title,+ doc.sections[0],+ doc.sections[1],+ doc.sections[2]+ );+ }+ return basic4section(+ doc.title,+ doc.sections[0],+ doc.sections[1],+ doc.sections[2],+ doc.sections[3]+ );+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/cover.json b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/cover.jsonnew file mode 100644index 0000000000..a447cc3f60--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/cover.json@@ -0,0 +1,97 @@+[+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1706086837052,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "QiBH29dycZ",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "WZ9zUizVrs",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "DcoFASHQKI": {+ "index": "a1",+ "seed": 1391437441,+ "xywh": "[-83.54346701558063,-50.225603646128235,1600.17596435546875,179]",+ "rotate": 0,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ },+ "color": "--affine-palette-line-black",+ "fontSize": 128,+ "fontFamily": "blocksuite:surface:Poppins",+ "fontWeight": "400",+ "fontStyle": "normal",+ "textAlign": "left",+ "type": "text",+ "id": "DcoFASHQKI",+ "hasMaxWidth": false+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "Rb6xTvGyzU",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "background",+ "sourceId": "xeeMw2R2FtjRo2Q0H14rsCpImSR9-z54W_PDZUsFvJ8=",+ "width": 1920,+ "height": 1080,+ "index": "a0",+ "xywh": "[-300.7451171875,-355.744140625,1920,1080]",+ "rotate": 0,+ "size": 938620+ },+ "children": []+ },+ {+ "type": "block",+ "id": "Pa1ZO7Udi-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-340.7451171875,-395.744140625,2000,1160]",+ "index": "a0"+ },+ "children": []+ }+ ]+ }+ ]+ }+ }+]diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/four.json b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/four.jsonnew file mode 100644index 0000000000..4440597c1d--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/four.json@@ -0,0 +1,1132 @@+[+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711619462579,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "Z1ykl12cSx",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nk3_3Ly7J4",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "dvNokXHFjJ": {+ "index": "a2",+ "seed": 1481900971,+ "xywh": "[-1983.9163177173398,370.2741425054713,68.49881720241342,68.49881720241348]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "dvNokXHFjJ",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "pjLp5iRHj1": {+ "index": "a7",+ "seed": 1481900971,+ "xywh": "[-1087.3515614427831,370.4416324567778,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "pjLp5iRHj1",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "vrH9SvPlB6": {+ "index": "aB",+ "seed": 1481900971,+ "xywh": "[-1087.3515614427831,730.8057512329431,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "vrH9SvPlB6",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "4"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "UF3qaMw35x": {+ "index": "aF",+ "seed": 1481900971,+ "xywh": "[-1983.8238766248692,730.8057512329431,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "UF3qaMw35x",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TVg0_H3pS-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "index": "a0"+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "lLFwOmRC7W",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-2053.238012404669,-9.923971266973126,1341.3334350585938,283.6666920979818]",+ "background": "--affine-palette-transparent",+ "index": "a1",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 122.66668192545575,+ "scale": 2.481050005858841+ }+ },+ "children": [+ {+ "type": "block",+ "id": "HQ-jnOE1f3",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "FL__cfBte4",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1957.8756949308126,298.9828272123103,810.9499838439583,216.11059503352658]",+ "background": "--affine-palette-transparent",+ "index": "a1V",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.227884570999885,+ "collapse": true,+ "collapsedHeight": 94.5297571493372+ }+ },+ "children": [+ {+ "type": "block",+ "id": "UdkuWp8Pq1",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "SplfMbP19A",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1949.666909116133,409.4267986521621,747.1235944841051,274.25339814778795]",+ "background": "--affine-palette-transparent",+ "index": "a1l",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.8584539953344592,+ "collapse": true,+ "collapsedHeight": 147.5707221358641+ }+ },+ "children": [+ {+ "type": "block",+ "id": "aexenplBOM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "hkkjrzh5U2",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1060.8108545830105,298.9828272123103,810.9499838439583,216.11059503352658]",+ "background": "--affine-palette-transparent",+ "index": "a5",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.227884570999885,+ "collapse": true,+ "collapsedHeight": 94.5297571493372+ }+ },+ "children": [+ {+ "type": "block",+ "id": "tfckfWqMY2",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "CZkdeTlqzf",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1052.6020687683308,409.4267986521621,747.1235944841051,274.25339814778795]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.8584539953344592,+ "collapse": true,+ "collapsedHeight": 147.5707221358641+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FJwQSWbMrK",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "dCmC6nD4oM",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1060.8108545830105,659.9727569688716,810.9499838439583,216.11059503352658]",+ "background": "--affine-palette-transparent",+ "index": "a9",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.227884570999885,+ "collapse": true,+ "collapsedHeight": 94.5297571493372+ }+ },+ "children": [+ {+ "type": "block",+ "id": "hsaCDcCh4T",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "GbdYivh7V_",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1052.6020687683308,770.4167284087234,747.1235944841051,274.25339814778795]",+ "background": "--affine-palette-transparent",+ "index": "aA",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.8584539953344592,+ "collapse": true,+ "collapsedHeight": 147.5707221358641+ }+ },+ "children": [+ {+ "type": "block",+ "id": "m5nGW684z7",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "heDlgO5-AP",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1957.8756949308124,659.9727569688716,810.9499838439583,216.11059503352658]",+ "background": "--affine-palette-transparent",+ "index": "aD",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.227884570999885,+ "collapse": true,+ "collapsedHeight": 94.5297571493372+ }+ },+ "children": [+ {+ "type": "block",+ "id": "e7i3FY50Y9",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section4.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aTPSWy7isi",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1949.6669091161327,770.4167284087234,747.1235944841051,274.25339814778795]",+ "background": "--affine-palette-transparent",+ "index": "aE",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.8584539953344592,+ "collapse": true,+ "collapsedHeight": 147.5707221358641+ }+ },+ "children": [+ {+ "type": "block",+ "id": "eKBpvD2seQ",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section4.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1509.6661094585195,-2898.612292265666,1960.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1509.6661094585195,-2898.612292265666,1960.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "2Y9Hkx2NH_",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "acV",+ "xywh": "[-1477.8992703984247,-2695.0139716592407,442.8571428571429,291.42860049293176]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "wfAA7nMj9S",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section2.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "xywh": "[-1016.5659574101433,-2695.0139716592407,442.8571428571429,291.42860049293176]",+ "index": "ae",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "v0kbq9Ge2L",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section3.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "xywh": "[-555.2326444218619,-2695.0139716592407,442.8571428571429,291.42860049293176]",+ "index": "ag",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "U0VKdP1QXx",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section4.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "xywh": "[-93.89933143358057,-2695.0139716592407,442.8571428571429,291.42860049293176]",+ "index": "ai",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-1505.2500792932615,-2892.496670058301,1870.0890697914701,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 135.67362421639123+ },+ "xywh": "[-1509.6661094585195,-2449.148531089114,589.0618769832358,219.56087840116928]"+ },+ "children": [+ {+ "type": "block",+ "id": "Z0vZzczM9m",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1503.264569392059,-2279.702158995507,505.068393234737,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nVm30fhD_V",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "SWuXaO4zVD",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1048.5978722078141,-2279.702158995507,505.068393234737,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "am",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "m44JtQOkYX",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "dUtL3CwWVp",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1054.9994122742746,-2449.148531089114,589.0618769832358,219.56087840116928]",+ "background": "--affine-palette-transparent",+ "index": "al",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 135.67362421639123+ }+ },+ "children": [+ {+ "type": "block",+ "id": "_ufa27y_Mw",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "LUjOSttIUe",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-589.9311851960954,-2279.702158995507,505.068393234737,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "aq",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "QyiTDLrbQs",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "SgzW7o7hMY",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-596.3327252625559,-2449.148531089114,589.0618769832358,219.56087840116928]",+ "background": "--affine-palette-transparent",+ "index": "ap",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 135.67362421639123+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PE0lR8TFaS",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "3yZ-tCMJ5n",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-132.59791289791826,-2279.702158995507,505.068393234737,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "au",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "NIHjcRX-f8",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section4.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "KK8h_OiRqv",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-138.99945296437875,-2449.148531089114,589.0618769832358,219.56087840116928]",+ "background": "--affine-palette-transparent",+ "index": "at",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 135.67362421639123+ }+ },+ "children": [+ {+ "type": "block",+ "id": "hv1g2gHWbM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section4.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ }+]diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/one.json b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/one.jsonnew file mode 100644index 0000000000..8a9f1c0650--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/one.json@@ -0,0 +1,1544 @@+[+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "one section",+ "createDate": 1711610833606,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "one section"+ }+ ]+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "index": "a2"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "Kl_nXMFhVd",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aI",+ "xywh": "[-1514.2376426616445,-2905.469439482463,527.3333333333333,1087.2819474283258]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-922.880340452472,-2825.1459576709904,1212.5651934196321,236.44460482053137]",+ "background": "--affine-palette-transparent",+ "index": "aB",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ }+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-910.0113897833639,-2608.958384791207,1198.7335362065319,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aF",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "CXWd92w-Qi",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-900.4706500368766,-2493.7715542849137,1187.6524039191502,131.73112646502364]",+ "background": "--affine-palette-transparent",+ "index": "aH",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.2393327741958684,+ "collapse": true,+ "collapsedHeight": 106.29197355851124+ }+ },+ "children": [+ {+ "type": "block",+ "id": "WCIwmm9A3s",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711610833606,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "index": "a2"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "Kl_nXMFhVb",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aI",+ "xywh": "[-161.93471756298595,-2905.227506715997,527.3333333333333,1085.102943835111]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1467.7081022991783,-2825.1459576709904,1212.5651934196321,236.44460482053137]",+ "background": "--affine-palette-transparent",+ "index": "aB",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ }+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1454.8391516300703,-2608.958384791207,1198.7335362065319,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aF",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "CXWd92w-Qi",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1445.298411883583,-2493.7715542849137,1187.6524039191502,131.73112646502364]",+ "background": "--affine-palette-transparent",+ "index": "aH",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.2393327741958684,+ "collapse": true,+ "collapsedHeight": 106.29197355851124+ }+ },+ "children": [+ {+ "type": "block",+ "id": "WCIwmm9A3s",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711610833606,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "index": "a2"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "Kl_nXMFhVc",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aI",+ "xywh": "[-161.93471756298595,-2905.227506715997,527.3333333333333,1085.102943835111]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1467.7081022991783,-2676.3146218911334,1212.5651934196321,236.44460482053137]",+ "background": "--affine-palette-transparent",+ "index": "aB",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ }+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1454.8391516300703,-2457.6331564505895,1198.7335362065319,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aF",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "CXWd92w-Qi",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1445.298411883583,-2342.446325944296,1187.6524039191502,131.73112646502364]",+ "background": "--affine-palette-transparent",+ "index": "aH",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.2393327741958684,+ "collapse": true,+ "collapsedHeight": 106.29197355851124+ }+ },+ "children": [+ {+ "type": "block",+ "id": "WCIwmm9A3s",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "Kl_nXMFhVa",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aI",+ "xywh": "[-1514.2376426616445,-2905.227506715997,527.3333333333333,1085.102943835111]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-910.7394049209178,-2676.3146218911334,1212.5651934196321,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ },+ "xywh": "[-897.8704542518097,-2457.6331564505895,1198.7335362065319,174.0265670977942]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-916.6630478386558,-2362.2267494910393,1214.0190493549892,257.958640225178]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 117.95864022517799,+ "scale": 2.401823909123141+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FgPYlSJXiV",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711619462579,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "Z1ykl12cSx",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nk3_3Ly7J4",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TVg0_H3pS-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "index": "a0"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "SphbFXlgh0",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aX",+ "xywh": "[-2101.800067858677,1.2,654.4250479902054,338.81577464204423]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "_Tf8693XKA",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image2",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "a7",+ "xywh": "[-2101.800067858677,379.2497670673074,654.4250479902054,338.81577464204423]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "UNpbRMah1C",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image3",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aZ",+ "xywh": "[-2101.800067858677,758,654.4250479902054,338.81577464204423]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aWw5W79SOg",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1354.6692632128902,343.3351440816688,1127.5440924085192,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "a5",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "AkKDNgzKb_",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "5zMsJG3EQa",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1351.148559784478,459.149012829487,1120.7742609602965,403.49738953307815]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 213.040363075911+ }+ },+ "children": [+ {+ "type": "block",+ "id": "kt2gfL8Bn7",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711619462579,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "Z1ykl12cSx",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nk3_3Ly7J4",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TVg0_H3pS-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "index": "a0"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "NLvbZwU4PA",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aX",+ "xywh": "[-803.7851622517169,611.1159327724056,632.7030330086453,327.5696260489153]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "HZB7i-Ju4k",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image2",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "a7",+ "xywh": "[-1452.7926216327571,611.1159327724056,632.7030330086453,327.5696260489153]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "UNpbRMah1C",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image3",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aZ",+ "xywh": "[-2101,611.1159327724056,632.7030330086453,327.5696260489153]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aWw5W79SOg",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1700.213151332694,119.59413792685919,1127.5440924085192,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "a5",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "AkKDNgzKb_",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "5zMsJG3EQa",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1696.8282356085826,235.40800667467738,1120.7742609602965,328.06883554312276]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 173.21525653208363+ }+ },+ "children": [+ {+ "type": "block",+ "id": "kt2gfL8Bn7",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711619462579,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "Z1ykl12cSx",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nk3_3Ly7J4",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TVg0_H3pS-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "index": "a0"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "FJGkatSaly",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "a7",+ "xywh": "[-824.172570496749,21.294843323820828,633.142822265625,548.1428571428572]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "8PC-diRv-2",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image2",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "a9",+ "xywh": "[-1224.1725704967491,592.7234426934307,1033.1428222656252,477.28566196986594]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "6MPeRodrBk",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image3",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aB",+ "xywh": "[-2074.45838941416,592.7234426934307,825.1428571428576,477.28566196986594]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "lLFwOmRC7W",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-2000.666688464937,74.64747474307153,1156.1906127929688,283.6666920979818]",+ "background": "--affine-palette-transparent",+ "index": "a1",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 122.66668192545575,+ "scale": 2.481050005858841+ }+ },+ "children": [+ {+ "type": "block",+ "id": "HQ-jnOE1f3",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "CZkdeTlqzf",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1976.4593162571703,258.7718028519709,1133.4093436470516,274.25339814778795]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.8584539953344592,+ "collapse": true,+ "collapsedHeight": 147.5707221358641+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FJwQSWbMrK",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ }+]diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/three.json b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/three.jsonnew file mode 100644index 0000000000..fdb4dbaccd--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/three.json@@ -0,0 +1,3800 @@+[+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "DjqtK4cIvA": {+ "index": "aM",+ "seed": 378347608,+ "xywh": "[-1462.4448858546439,-2671.393416157706,67.74408298065555,68.33333333333334]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "DjqtK4cIvA",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ }+ },+ "lKm7_gD7iU": {+ "index": "aQ",+ "seed": 378347608,+ "xywh": "[-812.4550145808457,-2671.719165096266,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "lKm7_gD7iU",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ }+ },+ "AV7GyFSjSC": {+ "index": "aU",+ "seed": 378347608,+ "xywh": "[-1462.4550145808457,-2190.052498429599,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "AV7GyFSjSC",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ }+ },+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "25om7PUFbo",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aA",+ "xywh": "[-161.93471756298595,-2905.227506715997,527.3333333333333,1085.102943835111]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-1434.996381171989,-2894.647955224467,1212.5651934196321,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ },+ "xywh": "[-1416.2037875851431,-2732.6331564505895,589.0618769832358,174.0265670977942]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1409.5371209184764,-2634.1760451184673,577.0683118545286,385.42432914117944]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 277.7731841600028,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FgPYlSJXiV",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "UR7y5DUg6J",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-765.9487034393142,-2732.6331564505895,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aO",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "-vGl5QJJY0",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "jBhX1Rxtg_",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-759.2820367726474,-2634.1760451184673,582.4016655329141,382.757652301987]",+ "background": "--affine-palette-transparent",+ "index": "aP",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 275.8513248980337,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "S6KKaAhUdj",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "YVjRYKRUu5",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1416.2037875851431,-2253.571851708401,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aS",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "5jyhK9QUxn",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aLe21NECWh",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1409.5371209184764,-2155.114740376279,1237.0683118545285,249.42431896865355]",+ "background": "--affine-palette-transparent",+ "index": "aT",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 179.75872836373244,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "o4dQHdp6sC",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "DjqtK4cIvA": {+ "index": "aM",+ "seed": 378347608,+ "xywh": "[-948.1590843758491,-2671.393416157706,67.74408298065555,68.33333333333334]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "DjqtK4cIvA",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ }+ },+ "lKm7_gD7iU": {+ "index": "aQ",+ "seed": 378347608,+ "xywh": "[-298.169213102051,-2671.719165096266,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "lKm7_gD7iU",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ }+ },+ "AV7GyFSjSC": {+ "index": "aU",+ "seed": 378347608,+ "xywh": "[-948.169213102051,-2190.052498429599,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "AV7GyFSjSC",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ }+ },+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "25om7PUFbo",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aA",+ "xywh": "[-1514.2376426616445,-2905.227506715997,527.3333333333333,1085.102943835111]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-920.7105796931943,-2894.647955224467,1212.5651934196321,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ },+ "xywh": "[-901.9179861063484,-2732.6331564505895,589.0618769832358,174.0265670977942]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-895.2513194396817,-2634.1760451184673,577.0683118545286,385.42432914117944]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 277.7731841600028,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FgPYlSJXiV",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "UR7y5DUg6J",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-251.66290196051943,-2732.6331564505895,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aO",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "-vGl5QJJY0",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "jBhX1Rxtg_",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-244.9962352938527,-2634.1760451184673,582.4016655329141,382.757652301987]",+ "background": "--affine-palette-transparent",+ "index": "aP",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 275.8513248980337,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "S6KKaAhUdj",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "YVjRYKRUu5",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-901.9179861063484,-2253.571851708401,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aS",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "5jyhK9QUxn",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aLe21NECWh",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-895.2513194396817,-2155.114740376279,1237.0683118545285,249.42431896865355]",+ "background": "--affine-palette-transparent",+ "index": "aT",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 179.75872836373244,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "o4dQHdp6sC",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "jHwkvWX2SP",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aU",+ "xywh": "[-1434.0269169013459,-2671.624042427925,507.9999542236329,305.14294215611017]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "lys4Z03uxm",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section2.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aW",+ "xywh": "[-819.3433432898528,-2671.624042427925,507.9999542236329,305.14294215611017]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "9cUOfpMZKC",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section3.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aY",+ "xywh": "[-213.06720179638148,-2671.624042427925,507.9999542236329,305.14294215611017]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-1486.7077268312114,-2894.647955224467,1212.5651934196321,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ },+ "xywh": "[-1469.4870071046314,-2412.6331564505895,589.0618769832358,174.0265670977942]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1462.8203404379647,-2314.175991080571,577.0683118545286,403.7100259882777]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 290.9515848310785,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FgPYlSJXiV",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "UR7y5DUg6J",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-863.2108656111601,-2412.6331564505895,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aO",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "-vGl5QJJY0",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "jBhX1Rxtg_",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-856.5441989444935,-2314.1759910651094,582.4016655329141,400.9168339278503]",+ "background": "--affine-palette-transparent",+ "index": "aP",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 288.9385467482875,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "S6KKaAhUdj",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "cEIG52fU4j",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-250.26805745102206,-2314.1759910651085,582.4016655329141,400.9168339278503]",+ "background": "--affine-palette-transparent",+ "index": "aT",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 288.9385467482875,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "1hMBS097nC",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "oq8oMI8d-n",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-256.9347241176888,-2412.633156450589,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aS",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "ZdWSdxlpOr",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "-Z2wOyOCUl": {+ "index": "aV",+ "seed": 378347608,+ "xywh": "[-1430.8901094973382,-2614.8384684816765,67.74408298065555,68.33333333333334]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "-Z2wOyOCUl",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ }+ },+ "LdVe2K2EQN": {+ "index": "aX",+ "seed": 378347608,+ "xywh": "[-827.0027333037912,-2614.721557410709,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "LdVe2K2EQN",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ }+ },+ "Vssc32X8gW": {+ "index": "aZ",+ "seed": 378347608,+ "xywh": "[-223.11535711024408,-2614.721557410709,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "Vssc32X8gW",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ }+ },+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-1486.7077268312114,-2894.647955224467,1212.5651934196321,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ },+ "xywh": "[-1469.4870071046314,-2591.299792599678,589.0618769832358,174.0265670977942]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1462.8203404379647,-2474.1757884317985,577.0683118545286,549.9957751512243]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 396.37891587882604,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "FgPYlSJXiV",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "UR7y5DUg6J",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-863.2108656111601,-2591.299792599678,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aO",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "-vGl5QJJY0",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "jBhX1Rxtg_",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-856.5441989444935,-2474.175788470573,582.4016655329141,546.1904601143724]",+ "background": "--affine-palette-transparent",+ "index": "aP",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 393.63644635991017,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "S6KKaAhUdj",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "cEIG52fU4j",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-250.26805745102206,-2474.1757884705717,582.4016655329141,546.1904601143724]",+ "background": "--affine-palette-transparent",+ "index": "aT",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 393.63644635991017,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "1hMBS097nC",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "oq8oMI8d-n",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-256.9347241176888,-2591.2997925996774,589.0618769832358,174.0265670977942]",+ "background": "--affine-palette-transparent",+ "index": "aS",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 97.69366829020107+ }+ },+ "children": [+ {+ "type": "block",+ "id": "ZdWSdxlpOr",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "-Z2wOyOCUl": {+ "index": "aV",+ "seed": 378347608,+ "xywh": "[-915.3586377393509,-2638.671822165036,67.74408298065555,68.33333333333334]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "-Z2wOyOCUl",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ }+ },+ "Fmo2Tcj8Fl": {+ "index": "aZ",+ "seed": 378347608,+ "xywh": "[-914.6006596743409,-2375.357453090786,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "Fmo2Tcj8Fl",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ }+ },+ "bDXVat8dj4": {+ "index": "ad",+ "seed": 378347608,+ "xywh": "[-914.6006596743409,-2112.500310233643,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "bDXVat8dj4",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ }+ },+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1514.2376426616445,-2905.469439482463,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "u4QIphd0DC",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aM",+ "xywh": "[-1509.8216124963865,-2903.9812987303267,526.4761425199962,1081.3333347865514]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-971.1762550732241,-2894.6479552244673,1283.422301399543,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 109.30854828921595+ },+ "xywh": "[-869.9555772679123,-2700.442671944919,1219.8729704453162,176.8942269932918]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-863.5540372014515,-2616.3296026670673,1216.9527533796265,180.2289617524957]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 129.8900167910892,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "iPmO1_z9Gt",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "zYl5jpauG1",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-869.9555772679123,-2438.342789709367,1219.8729704453162,176.8942269932918]",+ "background": "--affine-palette-transparent",+ "index": "aX",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 109.30854828921595+ }+ },+ "children": [+ {+ "type": "block",+ "id": "ei9lkUZYoa",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "w6VD-syBgm",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-863.5540372014515,-2354.2297204315155,1216.9527533796265,180.2289617524957]",+ "background": "--affine-palette-transparent",+ "index": "aY",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 129.8900167910892,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "GekGjqgOXO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "jN9kkO5zW0",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-869.9555772679123,-2173.2705763363133,1219.8729704453162,176.8942269932918]",+ "background": "--affine-palette-transparent",+ "index": "ab",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 109.30854828921595+ }+ },+ "children": [+ {+ "type": "block",+ "id": "Yw1-3TH_y1",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "8ezRSvK27E",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-863.5540372014515,-2089.1575070584618,1216.9527533796265,180.2289617524957]",+ "background": "--affine-palette-transparent",+ "index": "ac",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 129.8900167910892,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "YaMbPW1v75",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711615521774,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "aa6W7J2mx2",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "PMd-PuXWK7",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "-Z2wOyOCUl": {+ "index": "aV",+ "seed": 378347608,+ "xywh": "[-1449.4324619593883,-2345.0758660422707,67.74408298065555,68.33333333333334]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "-Z2wOyOCUl",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ }+ },+ "akLeN9eL3Z": {+ "index": "aZ",+ "seed": 378347608,+ "xywh": "[-826.8947976664532,-2345.525578446396,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "akLeN9eL3Z",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ }+ },+ "oNyyPV1iJg": {+ "index": "ad",+ "seed": 378347608,+ "xywh": "[-199.14972218215394,-2345.525578446396,67.74408298065555,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "oNyyPV1iJg",+ "color": "--affine-palette-line-white",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40,+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ }+ },+ "TJhFxmm-4S": {+ "index": "a1",+ "seed": 1730805220,+ "xywh": "[-1509.6661094585195,-2898.612292265666,1879.6362584319918,1087.2819474283258]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "CnuFtpWnKL",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "index": "a2",+ "xywh": "[-1509.6661094585195,-2898.612292265666,1879.6362584319918,1087.2819474283258]"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "u4QIphd0DC",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aM",+ "xywh": "[-1505.2500792932615,-2897.12415151353,1872.7618916829429,375.04758562360485]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "vep0c6lfir",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aB",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.111112543040462,+ "collapse": true,+ "collapsedHeight": 111.99999999999983+ },+ "xywh": "[-1505.2500792932615,-2547.3538041961356,1870.0890697914701,236.44460482053137]"+ },+ "children": [+ {+ "type": "block",+ "id": "fSKn6ISVDM",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "sm_bXJ4OIr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "background": "--affine-palette-transparent",+ "hidden": false,+ "displayMode": "edgeless",+ "index": "aF",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 109.30854828921595+ },+ "xywh": "[-1486.6960783271422,-2335.8151977557804,589.0618769832358,176.8942269932918]"+ },+ "children": [+ {+ "type": "block",+ "id": "8B4rgaGfZO",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "-e1FBf1VVV",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1480.2945382606815,-2251.702128477929,578.2112678162102,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "aL",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "iPmO1_z9Gt",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "wkyVSsZhvb",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-863.400071943408,-2335.8151977557804,589.0618769832358,176.8942269932918]",+ "background": "--affine-palette-transparent",+ "index": "aX",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 109.30854828921595+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TI-VP1M95O",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "o27HkMC_--",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-856.9985318769473,-2251.702128477929,578.2112678162102,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "aY",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "VFwX1ginQI",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "VJ0XDj4Fpr",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-235.65499645910882,-2335.8151977557804,589.0618769832358,176.8942269932918]",+ "background": "--affine-palette-transparent",+ "index": "ab",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.6183018598440544,+ "collapse": true,+ "collapsedHeight": 109.30854828921595+ }+ },+ "children": [+ {+ "type": "block",+ "id": "-iCGy0T361",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "SnAzf_Dy6D",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-229.2534563926481,-2251.702128477929,578.2112678162102,409.5622543957249]",+ "background": "--affine-palette-transparent",+ "index": "ac",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "collapse": true,+ "collapsedHeight": 295.169253504954,+ "scale": 1.387550530864662+ }+ },+ "children": [+ {+ "type": "block",+ "id": "GlVIaFF6sF",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h2",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711619462579,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "Z1ykl12cSx",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nk3_3Ly7J4",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "UVupGyyZN1": {+ "index": "a8",+ "seed": 976364174,+ "xywh": "[-2009.1406565044413,1.1999424525670292,6.286634692326288,1095.5964434998189]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "UVupGyyZN1",+ "color": "--affine-palette-line-black",+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "NJxtDRr8Wz": {+ "index": "aA",+ "seed": 1481900971,+ "xywh": "[-2037.1821400826323,194.25718279849224,68.49881720241342,68.49881720241348]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "NJxtDRr8Wz",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "Og7Aa0FT4P": {+ "index": "aC",+ "seed": 1481900971,+ "xywh": "[-2037.182140082632,515.3284845766241,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "Og7Aa0FT4P",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "xurVVzewkV": {+ "index": "aE",+ "seed": 1481900971,+ "xywh": "[-2037.182140082632,835.9009691523424,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "xurVVzewkV",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TVg0_H3pS-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "index": "a0"+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aWw5W79SOg",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-2000.764655559536,43.90652033724916,1164.4965343960564,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "a5",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "AkKDNgzKb_",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "5zMsJG3EQa",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1997.764655559536,134.577479626362,1819.3423114296422,286.9259086458013]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 151.49242929309233+ }+ },+ "children": [+ {+ "type": "block",+ "id": "kt2gfL8Bn7",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "acZgwhfCWY",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1997.764655559536,457.07244815577957,1819.3423114296422,286.9259086458013]",+ "background": "--affine-palette-transparent",+ "index": "aG",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 151.49242929309233+ }+ },+ "children": [+ {+ "type": "block",+ "id": "8vRFcSMg1V",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "YeHO9NCElw",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-2000.764655559536,366.40148886666674,1164.4965343960564,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "aF",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "mHjARC9Fhu",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "BHC3GyNAdu",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1997.764655559536,779.567416685197,1819.3423114296422,286.9259086458013]",+ "background": "--affine-palette-transparent",+ "index": "aK",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 151.49242929309233+ }+ },+ "children": [+ {+ "type": "block",+ "id": "y5Jbozh1vt",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "I82USJCVZw",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-2000.764655559536,688.8964573960843,1164.4965343960564,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "aJ",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "GejxhqB-wj",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ },+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1711619462579,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "Z1ykl12cSx",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "nk3_3Ly7J4",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "NJxtDRr8Wz": {+ "index": "aA",+ "seed": 1481900971,+ "xywh": "[-1962.5154937610178,107.58622350937945,68.49881720241342,68.49881720241348]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "NJxtDRr8Wz",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "1"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "Lu4iLMmzDn": {+ "index": "aQ",+ "seed": 1481900971,+ "xywh": "[-1136.8615154265685,439.7072383836723,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "Lu4iLMmzDn",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "2"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "TOtG2mlRAJ": {+ "index": "aU",+ "seed": 1481900971,+ "xywh": "[-1962.194869104954,720.7809129074261,68.49881720241342,68]",+ "rotate": 0,+ "shapeType": "ellipse",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-navy",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-transparent",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TOtG2mlRAJ",+ "color": "--affine-palette-line-white",+ "text": {+ "affine:surface:text": true,+ "delta": [+ {+ "insert": "3"+ }+ ]+ },+ "fontFamily": "blocksuite:surface:Inter",+ "fontSize": 40+ },+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "TVg0_H3pS-",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-2101.800074986049,1.1999424525670292,1933.7142508370534,1095.9999738420759]",+ "index": "a0"+ },+ "children": []+ },+ {+ "type": "block",+ "id": "UBMo_osmTh",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section1.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aV",+ "xywh": "[-1893.6960519025406,418.3619095202094,457.3333740234375,236.77541357147118]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "NLvbZwU4PA",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section2.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aX",+ "xywh": "[-783.0291919578789,134.577479626362,457.3333740234375,236.77541357147118]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ },+ {+ "type": "block",+ "id": "-PNfQ_u1PE",+ "flavour": "affine:image",+ "version": 1,+ "props": {+ "caption": "section3.image",+ "sourceId": "PiQbzGAzz2UgK4kqceCMRwNJGD27VuPXmkUV1VIdUpI=",+ "width": 150,+ "height": 150,+ "index": "aZ",+ "xywh": "[-783.0291919578789,747.4910080481044,457.3333740234375,236.77541357147118]",+ "rotate": 0,+ "size": 3837+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aWw5W79SOg",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1926.0980092379216,43.90652033724916,921.8298066942334,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "a5",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "AkKDNgzKb_",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "5zMsJG3EQa",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1923.0980092379216,134.577479626362,918.008998441361,286.9259086458013]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 151.49242929309233+ }+ },+ "children": [+ {+ "type": "block",+ "id": "kt2gfL8Bn7",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "S53e3TYzsE",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1100.2521508241273,375.28962019689266,775.1631400275667,222.8494796636565]",+ "background": "--affine-palette-transparent",+ "index": "aO",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.41767859344831+ }+ },+ "children": [+ {+ "type": "block",+ "id": "y0bj85ZiWg",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "A-DYYZeyH3",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1097.2521508241273,465.9605794860054,764.6756651080276,286.9259086458014]",+ "background": "--affine-palette-transparent",+ "index": "aP",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 151.49242929309239+ }+ },+ "children": [+ {+ "type": "block",+ "id": "zWwZJYEzgz",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "u2tLVHn1OH",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1926.0980092379218,656.8200487589916,921.8298066942334,222.84947966365655]",+ "background": "--affine-palette-transparent",+ "index": "aS",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 2,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.947683980335685,+ "collapse": true,+ "collapsedHeight": 114.01012331779694+ }+ },+ "children": [+ {+ "type": "block",+ "id": "8kjIjQLSP5",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h4",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "h65JXM7SYI",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-1923.0980092379218,747.4910080481044,918.008998441361,286.9259086458013]",+ "background": "--affine-palette-transparent",+ "index": "aT",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 0,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.89399503318206,+ "collapse": true,+ "collapsedHeight": 151.49242929309233+ }+ },+ "children": [+ {+ "type": "block",+ "id": "7yVFZDxhWf",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "text",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section3.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ }+]diff --git a/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/two.json b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/two.jsonnew file mode 100644index 0000000000..194958f76e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/slides/templates/two.json@@ -0,0 +1,297 @@+[+ {+ "type": "page",+ "meta": {+ "id": "doc:home",+ "title": "",+ "createDate": 1712567726055,+ "tags": []+ },+ "blocks": {+ "type": "block",+ "id": "A4KjEzkDl0",+ "flavour": "affine:page",+ "version": 2,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": []+ }+ },+ "children": [+ {+ "type": "block",+ "id": "OpVjGBTYuZ",+ "flavour": "affine:surface",+ "version": 5,+ "props": {+ "elements": {+ "TJhFxmm-4S": {+ "index": "Zz",+ "seed": 1730805220,+ "xywh": "[-509.7051213118268,-469.55707155770506,1924.0508676236536,1089.1141431154101]",+ "rotate": 0,+ "shapeType": "rect",+ "radius": 0,+ "filled": true,+ "fillColor": "--affine-palette-shape-white",+ "strokeWidth": 2,+ "strokeColor": "--affine-palette-line-white",+ "strokeStyle": "solid",+ "shapeStyle": "General",+ "roughness": 1.4,+ "textResizing": 1,+ "maxWidth": false,+ "type": "shape",+ "id": "TJhFxmm-4S",+ "color": "--affine-palette-line-black"+ }+ }+ },+ "children": [+ {+ "type": "block",+ "id": "yJ1n0ocpfH",+ "flavour": "affine:frame",+ "version": 1,+ "props": {+ "title": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ },+ "background": "--affine-palette-transparent",+ "xywh": "[-509.7051213118268,-469.55707155770506,1924.0508676236536,1089.1141431154101]",+ "index": "a0"+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "9t3Ah0wozZ",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-461.8167639829678,-479.74267557148,1390.0495489396078,383.28507166552515]",+ "background": "--affine-palette-transparent",+ "index": "a1",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 8,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.3939460292889514,+ "collapse": true,+ "collapsedHeight": 160.10597857102414+ }+ },+ "children": [+ {+ "type": "block",+ "id": "NHDwZTS59L",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h1",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "LzI7P4hb4X",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-452.57487563328925,-183.9800061178195,871.3963546611783,235.3688641606808]",+ "background": "--affine-palette-transparent",+ "index": "a3",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 8,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.3939460292889514,+ "collapse": true,+ "collapsedHeight": 98.3183669477252+ }+ },+ "children": [+ {+ "type": "block",+ "id": "pMlpAfbEoh",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h5",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "aHToM_8I3t",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[452.1184517179579,-183.9800061178195,871.3963546611783,235.3688641606808]",+ "background": "--affine-palette-transparent",+ "index": "a5",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 8,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 2.3939460292889514,+ "collapse": true,+ "collapsedHeight": 98.3183669477252+ }+ },+ "children": [+ {+ "type": "block",+ "id": "xIuYaOWD8L",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h5",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.title"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "mZBqMOupoM",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[-428.74023932678745,-63.577752506957125,849.0831963889726,551.8234792085989]",+ "background": "--affine-palette-transparent",+ "index": "a6",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 8,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.4981539090092388,+ "collapse": true,+ "collapsedHeight": 368.33564021037836+ }+ },+ "children": [+ {+ "type": "block",+ "id": "MbDU4z8Y4c",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h6",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section1.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ },+ {+ "type": "block",+ "id": "DPQCANC2uz",+ "flavour": "affine:note",+ "version": 1,+ "props": {+ "xywh": "[474.43160999016345,-63.577752506957125,849.0831963889726,551.8234792085989]",+ "background": "--affine-palette-transparent",+ "index": "a8",+ "hidden": false,+ "displayMode": "edgeless",+ "edgeless": {+ "style": {+ "borderRadius": 8,+ "borderSize": 4,+ "borderStyle": "none",+ "shadowType": ""+ },+ "scale": 1.4981539090092388,+ "collapse": true,+ "collapsedHeight": 368.33564021037836+ }+ },+ "children": [+ {+ "type": "block",+ "id": "8jKa1dvzeC",+ "flavour": "affine:paragraph",+ "version": 1,+ "props": {+ "type": "h6",+ "text": {+ "$blocksuite:internal:text$": true,+ "delta": [+ {+ "insert": "section2.content"+ }+ ]+ }+ },+ "children": []+ }+ ]+ }+ ]+ }+ }+]diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/action-reporter.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/action-reporter.tsnew file mode 100644index 0000000000..28acbef29b--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/action-reporter.ts@@ -0,0 +1,12 @@+import { type ActionEventType, AIProvider } from '../provider.js';++export function reportResponse(event: ActionEventType) {+ const lastAction = AIProvider.actionHistory.at(-1);+ if (!lastAction) return;++ AIProvider.slots.actions.emit({+ action: lastAction.action,+ options: lastAction.options,+ event,+ });+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/connector.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/connector.tsnew file mode 100644index 0000000000..d6ab52cf4e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/connector.ts@@ -0,0 +1,88 @@+import {+ type ConnectorElementModel,+ type EdgelessRootService,+ SurfaceBlockComponent,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';++export const getConnectorFromId = (+ id: string,+ surface: EdgelessRootService+) => {+ return surface.elements.filter(+ v => SurfaceBlockComponent.isConnector(v) && v.source.id === id+ ) as ConnectorElementModel[];+};+export const getConnectorToId = (id: string, surface: EdgelessRootService) => {+ return surface.elements.filter(+ v => SurfaceBlockComponent.isConnector(v) && v.target.id === id+ ) as ConnectorElementModel[];+};+export const getConnectorPath = (id: string, surface: EdgelessRootService) => {+ let current: string | undefined = id;+ const set = new Set<string>();+ const result: string[] = [];+ while (current) {+ if (set.has(current)) {+ return result;+ }+ set.add(current);+ const connector = getConnectorToId(current, surface);+ if (connector.length !== 1) {+ return result;+ }+ current = connector[0].source.id;+ if (current) {+ result.unshift(current);+ }+ }+ return result;+};+type ElementTree = {+ id: string;+ children: ElementTree[];+};+export const findTree = (+ rootId: string,+ surface: EdgelessRootService+): ElementTree => {+ const set = new Set<string>();+ const run = (id: string): ElementTree | undefined => {+ if (set.has(id)) {+ return;+ }+ set.add(id);+ const children = getConnectorFromId(id, surface);+ return {+ id,+ children: children.flatMap(model => {+ const childId = model.target.id;+ if (childId) {+ const elementTree = run(childId);+ if (elementTree) {+ return [elementTree];+ }+ }+ return [];+ }),+ };+ };+ const tree = run(rootId);+ assertExists(tree);+ return tree;+};+export const findLeaf = (+ tree: ElementTree,+ id: string+): ElementTree | undefined => {+ if (tree.id === id) {+ return tree;+ }+ for (const child of tree.children) {+ const result = findLeaf(child, id);+ if (result) {+ return result;+ }+ }+ return;+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/custom-specs.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/custom-specs.tsnew file mode 100644index 0000000000..2ea16c9842--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/custom-specs.ts@@ -0,0 +1,22 @@+import { PageEditorBlockSpecs, PageRootService } from '@blocksuite/blocks';+import { literal } from 'lit/static-html.js';++/**+ * Custom PageRootService that does not load fonts+ */+class CustomPageRootService extends PageRootService {+ override loadFonts() {}+}++export const CustomPageEditorBlockSpecs = PageEditorBlockSpecs.map(spec => {+ if (spec.schema.model.flavour === 'affine:page') {+ return {+ ...spec,+ service: CustomPageRootService,+ view: {+ component: literal`affine-page-root`,+ },+ };+ }+ return spec;+});diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.tsnew file mode 100644index 0000000000..ca3a74545b--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.ts@@ -0,0 +1,74 @@+import type { BlockElement, EditorHost } from '@blocksuite/block-std';+import {+ AFFINE_EDGELESS_COPILOT_WIDGET,+ type EdgelessCopilotWidget,+ type EdgelessRootService,+ matchFlavours,+ MindmapElementModel,+ type ShapeElementModel,+} from '@blocksuite/blocks';++export function mindMapToMarkdown(mindmap: MindmapElementModel) {+ let markdownStr = '';++ const traverse = (+ node: MindmapElementModel['tree']['children'][number],+ indent: number = 0+ ) => {+ const text = (node.element as ShapeElementModel).text?.toString() ?? '';++ markdownStr += `${' '.repeat(indent)}- ${text}\n`;++ if (node.children) {+ node.children.forEach(node => traverse(node, indent + 2));+ }+ };++ traverse(mindmap.tree, 0);++ return markdownStr;+}++export function isMindMapRoot(ele: BlockSuite.EdgelessModelType) {+ const group = ele?.group;++ return group instanceof MindmapElementModel && group.tree.element === ele;+}++export function isMindmapChild(ele: BlockSuite.EdgelessModelType) {+ return ele?.group instanceof MindmapElementModel && !isMindMapRoot(ele);+}++export function getService(host: EditorHost) {+ const edgelessService = host.spec.getService(+ 'affine:page'+ ) as EdgelessRootService;++ return edgelessService;+}++export function getEdgelessCopilotWidget(+ host: EditorHost+): EdgelessCopilotWidget {+ const rootBlockId = host.doc.root?.id as string;+ const copilotWidget = host.view.getWidget(+ AFFINE_EDGELESS_COPILOT_WIDGET,+ rootBlockId+ ) as EdgelessCopilotWidget;++ return copilotWidget;+}++export function findNoteBlockModel(blockElement: BlockElement) {+ let curBlock = blockElement;+ while (curBlock) {+ if (matchFlavours(curBlock.model, ['affine:note'])) {+ return curBlock.model;+ }+ if (matchFlavours(curBlock.model, ['affine:page', 'affine:surface'])) {+ return null;+ }+ curBlock = curBlock.parentBlockElement;+ }+ return null;+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.tsnew file mode 100644index 0000000000..9dc1748d1c--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts@@ -0,0 +1,148 @@+import type {+ BlockElement,+ EditorHost,+ TextSelection,+} from '@blocksuite/block-std';+import type { AffineAIPanelWidget } from '@blocksuite/blocks';+import { isInsideEdgelessEditor } from '@blocksuite/blocks';+import { type BlockModel, Slice } from '@blocksuite/store';++import {+ insertFromMarkdown,+ markDownToDoc,+ markdownToSnapshot,+} from './markdown-utils.js';++const getNoteId = (blockElement: BlockElement) => {+ let element = blockElement;+ while (element && element.flavour !== 'affine:note') {+ element = element.parentBlockElement;+ }++ return element.model.id;+};++const setBlockSelection = (+ host: EditorHost,+ parent: BlockElement,+ models: BlockModel[]+) => {+ const selections = models+ .map(model => model.id)+ .map(blockId => host.selection.create('block', { blockId }));++ if (isInsideEdgelessEditor(host)) {+ const surfaceElementId = getNoteId(parent);+ const surfaceSelection = host.selection.create(+ 'surface',+ selections[0].blockId,+ [surfaceElementId],+ true+ );++ selections.push(surfaceSelection);+ host.selection.set(selections);+ } else {+ host.selection.setGroup('note', selections);+ }+};++export const insert = async (+ host: EditorHost,+ content: string,+ selectBlock: BlockElement,+ below: boolean = true+) => {+ const blockParent = selectBlock.parentBlockElement;+ const index = blockParent.model.children.findIndex(+ model => model.id === selectBlock.model.id+ );+ const insertIndex = below ? index + 1 : index;++ const models = await insertFromMarkdown(+ host,+ content,+ blockParent.model.id,+ insertIndex+ );+ await host.updateComplete;+ requestAnimationFrame(() => setBlockSelection(host, blockParent, models));+};++export const insertBelow = async (+ host: EditorHost,+ content: string,+ selectBlock: BlockElement+) => {+ await insert(host, content, selectBlock, true);+};++export const insertAbove = async (+ host: EditorHost,+ content: string,+ selectBlock: BlockElement+) => {+ await insert(host, content, selectBlock, false);+};++export const replace = async (+ host: EditorHost,+ content: string,+ firstBlock: BlockElement,+ selectedModels: BlockModel[],+ textSelection?: TextSelection+) => {+ const firstBlockParent = firstBlock.parentBlockElement;+ const firstIndex = firstBlockParent.model.children.findIndex(+ model => model.id === firstBlock.model.id+ );++ if (textSelection) {+ const { snapshot, job } = await markdownToSnapshot(content, host);+ await job.snapshotToSlice(+ snapshot,+ host.doc,+ firstBlockParent.model.id,+ firstIndex + 1+ );+ } else {+ selectedModels.forEach(model => {+ host.doc.deleteBlock(model);+ });++ const models = await insertFromMarkdown(+ host,+ content,+ firstBlockParent.model.id,+ firstIndex+ );++ await host.updateComplete;+ requestAnimationFrame(() =>+ setBlockSelection(host, firstBlockParent, models)+ );+ }+};++export const copyTextAnswer = async (panel: AffineAIPanelWidget) => {+ const host = panel.host;+ if (!panel.answer) {+ return false;+ }+ return copyText(host, panel.answer);+};++export const copyText = async (host: EditorHost, text: string) => {+ const previewDoc = await markDownToDoc(host, text);+ const models = previewDoc+ .getBlocksByFlavour('affine:note')+ .map(b => b.model)+ .flatMap(model => model.children);+ const slice = Slice.fromModels(previewDoc, models);+ await host.std.clipboard.copySlice(slice);+ const { notificationService } = host.std.spec.getService('affine:page');+ if (notificationService) {+ notificationService.toast('Copied to clipboard');+ }+ return true;+};diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/html.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/html.tsnew file mode 100644index 0000000000..5440b8b968--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/html.ts@@ -0,0 +1,5 @@+export function preprocessHtml(answer: string) {+ const start = answer.indexOf('<!DOCTYPE html>');+ const end = answer.indexOf('</html>');+ return answer.slice(start, end + '</html>'.length);+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/image.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/image.tsnew file mode 100644index 0000000000..6c21c98a22--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/image.ts@@ -0,0 +1,104 @@+import { fetchImage } from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';++export async function fetchImageToFile(+ url: string,+ filename: string,+ imageProxy?: string+): Promise<File | void> {+ try {+ const res = await fetchImage(url, undefined, imageProxy);+ if (res.ok) {+ let blob = await res.blob();+ if (!blob.type || !blob.type.startsWith('image/')) {+ blob = await convertToPng(blob).then(tmp => tmp || blob);+ }+ return new File([blob], filename, { type: blob.type || 'image/png' });+ }+ } catch (err) {+ console.error(err);+ }++ return fetchImageFallback(url, filename);+}++function fetchImageFallback(+ url: string,+ filename: string+): Promise<File | void> {+ return new Promise(resolve => {+ const img = new Image();+ img.onload = () => {+ const c = document.createElement('canvas');+ c.width = img.width;+ c.height = img.height;+ const ctx = c.getContext('2d');+ assertExists(ctx);+ ctx.imageSmoothingEnabled = true;+ ctx.imageSmoothingQuality = 'high';+ ctx.drawImage(img, 0, 0);+ c.toBlob(blob => {+ if (blob) {+ return resolve(new File([blob], filename, { type: blob.type }));+ }+ resolve();+ }, 'image/png');+ };+ img.onerror = () => resolve();+ img.crossOrigin = 'anonymous';+ img.src = url;+ });+}++function convertToPng(blob: Blob): Promise<Blob | null> {+ return new Promise(resolve => {+ const reader = new FileReader();+ reader.addEventListener('load', _ => {+ const img = new Image();+ img.onload = () => {+ const c = document.createElement('canvas');+ c.width = img.width;+ c.height = img.height;+ const ctx = c.getContext('2d');+ assertExists(ctx);+ ctx.imageSmoothingEnabled = true;+ ctx.imageSmoothingQuality = 'high';+ ctx.drawImage(img, 0, 0);+ c.toBlob(resolve, 'image/png');+ };+ img.onerror = () => resolve(null);+ img.src = reader.result as string;+ });+ reader.addEventListener('error', () => resolve(null));+ reader.readAsDataURL(blob);+ });+}++export function readBlobAsURL(blob: Blob | File) {+ return new Promise<string>((resolve, reject) => {+ const reader = new FileReader();+ reader.onload = e => {+ if (typeof e.target?.result === 'string') {+ resolve(e.target.result);+ } else {+ reject();+ }+ };+ reader.onerror = reject;+ reader.readAsDataURL(blob);+ });+}++export function canvasToBlob(+ canvas: HTMLCanvasElement,+ type = 'image/png',+ quality?: number+) {+ return new Promise<Blob | null>(resolve =>+ canvas.toBlob(resolve, type, quality)+ );+}++export function randomSeed(min = 0, max = Date.now()) {+ return Math.round(Math.random() * (max - min)) + min;+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/markdown-utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/markdown-utils.tsnew file mode 100644index 0000000000..7bfc3951ad--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/markdown-utils.ts@@ -0,0 +1,195 @@+import type {+ EditorHost,+ TextRangePoint,+ TextSelection,+} from '@blocksuite/block-std';+import {+ defaultImageProxyMiddleware,+ MarkdownAdapter,+ MixTextAdapter,+ pasteMiddleware,+ PlainTextAdapter,+ titleMiddleware,+} from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import type {+ BlockModel,+ BlockSnapshot,+ Doc,+ DraftModel,+ Slice,+ SliceSnapshot,+} from '@blocksuite/store';+import { DocCollection, Job } from '@blocksuite/store';++const updateSnapshotText = (+ point: TextRangePoint,+ snapshot: BlockSnapshot,+ model: DraftModel+) => {+ const { index, length } = point;+ if (!snapshot.props.text || length === 0) {+ return;+ }+ (snapshot.props.text as Record<string, unknown>).delta =+ model.text?.sliceToDelta(index, length + index);+};++function processSnapshot(+ snapshot: BlockSnapshot,+ text: TextSelection,+ host: EditorHost+) {+ const model = host.doc.getBlockById(snapshot.id);+ assertExists(model);++ const modelId = model.id;+ if (text.from.blockId === modelId) {+ updateSnapshotText(text.from, snapshot, model);+ }+ if (text.to && text.to.blockId === modelId) {+ updateSnapshotText(text.to, snapshot, model);+ }++ // If the snapshot has children, handle them recursively+ snapshot.children.forEach(childSnapshot =>+ processSnapshot(childSnapshot, text, host)+ );+}++/**+ * Processes the text in the given snapshot if there is a text selection.+ * Only the selected portion of the snapshot will be processed.+ */+function processTextInSnapshot(snapshot: SliceSnapshot, host: EditorHost) {+ const { content } = snapshot;+ const text = host.selection.find('text');+ if (!content.length || !text) return;++ content.forEach(snapshot => processSnapshot(snapshot, text, host));+}++export async function getContentFromSlice(+ host: EditorHost,+ slice: Slice,+ type: 'markdown' | 'plain-text' = 'markdown'+) {+ const job = new Job({+ collection: host.std.doc.collection,+ middlewares: [titleMiddleware],+ });+ const snapshot = await job.sliceToSnapshot(slice);+ processTextInSnapshot(snapshot, host);+ const adapter =+ type === 'markdown' ? new MarkdownAdapter(job) : new PlainTextAdapter(job);+ const content = await adapter.fromSliceSnapshot({+ snapshot,+ assets: job.assetsManager,+ });+ return content.file;+}++export async function getPlainTextFromSlice(host: EditorHost, slice: Slice) {+ const job = new Job({+ collection: host.std.doc.collection,+ middlewares: [titleMiddleware],+ });+ const snapshot = await job.sliceToSnapshot(slice);+ processTextInSnapshot(snapshot, host);+ const plainTextAdapter = new PlainTextAdapter(job);+ const plainText = await plainTextAdapter.fromSliceSnapshot({+ snapshot,+ assets: job.assetsManager,+ });+ return plainText.file;+}++export const markdownToSnapshot = async (+ markdown: string,+ host: EditorHost+) => {+ const job = new Job({+ collection: host.std.doc.collection,+ middlewares: [defaultImageProxyMiddleware, pasteMiddleware(host.std)],+ });+ const markdownAdapter = new MixTextAdapter(job);+ const { blockVersions, workspaceVersion, pageVersion } =+ host.std.doc.collection.meta;+ if (!blockVersions || !workspaceVersion || !pageVersion)+ throw new Error(+ 'Need blockVersions, workspaceVersion, pageVersion meta information to get slice'+ );+ const payload = {+ file: markdown,+ assets: job.assetsManager,+ blockVersions,+ pageVersion,+ workspaceVersion,+ workspaceId: host.std.doc.collection.id,+ pageId: host.std.doc.id,+ };++ const snapshot = await markdownAdapter.toSliceSnapshot(payload);+ assertExists(snapshot, 'import markdown failed, expected to get a snapshot');++ return {+ snapshot,+ job,+ };+};++export async function insertFromMarkdown(+ host: EditorHost,+ markdown: string,+ parent?: string,+ index?: number+) {+ const { snapshot, job } = await markdownToSnapshot(markdown, host);++ const snapshots = snapshot.content.flatMap(x => x.children);++ const models: BlockModel[] = [];+ for (let i = 0; i < snapshots.length; i++) {+ const blockSnapshot = snapshots[i];+ const model = await job.snapshotToBlock(+ blockSnapshot,+ host.std.doc,+ parent,+ (index ?? 0) + i+ );+ models.push(model);+ }++ return models;+}++// FIXME: replace when selection is block is buggy right not+export async function replaceFromMarkdown(+ host: EditorHost,+ markdown: string,+ parent?: string,+ index?: number+) {+ const { snapshot, job } = await markdownToSnapshot(markdown, host);+ await job.snapshotToSlice(snapshot, host.doc, parent, index);+}++export async function markDownToDoc(host: EditorHost, answer: string) {+ const schema = host.std.doc.collection.schema;+ // Should not create a new doc in the original collection+ const collection = new DocCollection({ schema });+ collection.meta.initialize();+ const job = new Job({+ collection,+ middlewares: [defaultImageProxyMiddleware],+ });+ const mdAdapter = new MarkdownAdapter(job);+ const doc = await mdAdapter.toDoc({+ file: answer,+ assets: job.assetsManager,+ });+ if (!doc) {+ console.error('Failed to convert markdown to doc');+ }+ return doc as Doc;+}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.tsnew file mode 100644index 0000000000..7a2239562e--- /dev/null+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts@@ -0,0 +1,300 @@+import type { EditorHost } from '@blocksuite/block-std';+import {+ type CopilotSelectionController,+ type FrameBlockModel,+ ImageBlockModel,+ type SurfaceBlockComponent,+} from '@blocksuite/blocks';+import { BlocksUtils, EdgelessRootService } from '@blocksuite/blocks';+import { assertExists } from '@blocksuite/global/utils';+import {+ type BlockModel,+ type DraftModel,+ Slice,+ toDraftModel,+} from '@blocksuite/store';++import { getEdgelessCopilotWidget, getService } from './edgeless.js';+import { getContentFromSlice } from './markdown-utils.js';++export const getRootService = (host: EditorHost) => {+ return host.std.spec.getService('affine:page');+};++export function getEdgelessRootFromEditor(editor: EditorHost) {+ const edgelessRoot = editor.getElementsByTagName('affine-edgeless-root')[0];+ if (!edgelessRoot) {+ alert('Please switch to edgeless mode');+ throw new Error('Please open switch to edgeless mode');+ }+ return edgelessRoot;+}+export function getEdgelessService(editor: EditorHost) {+ const rootService = editor.std.spec.getService('affine:page');+ if (rootService instanceof EdgelessRootService) {+ return rootService;+ }+ alert('Please switch to edgeless mode');+ throw new Error('Please open switch to edgeless mode');+}++export async function selectedToCanvas(editor: EditorHost) {+ const edgelessRoot = getEdgelessRootFromEditor(editor);+ const { notes, frames, shapes, images } = BlocksUtils.splitElements(+ edgelessRoot.service.selection.selectedElements+ );+ if (notes.length + frames.length + images.length + shapes.length === 0) {+ return;+ }+ const canvas = await edgelessRoot.clipboardController.toCanvas(+ [...notes, ...frames, ...images],+ shapes+ );+ if (!canvas) {+ return;+ }+ return canvas;+}++export async function frameToCanvas(+ frame: FrameBlockModel,+ editor: EditorHost+) {+ const edgelessRoot = getEdgelessRootFromEditor(editor);+ const { notes, frames, shapes, images } = BlocksUtils.splitElements(+ edgelessRoot.service.frame.getElementsInFrame(frame, true)+ );+ if (notes.length + frames.length + images.length + shapes.length === 0) {+ return;+ }+ const canvas = await edgelessRoot.clipboardController.toCanvas(+ [...notes, ...frames, ...images],+ shapes+ );+ if (!canvas) {+ return;+ }+ return canvas;+}++export async function selectedToPng(editor: EditorHost) {+ return (await selectedToCanvas(editor))?.toDataURL('image/png');+}++export function getSelectedModels(editorHost: EditorHost) {+ const chain = editorHost.std.command.chain();+ const [_, ctx] = chain+ .getSelectedModels({+ types: ['block', 'text'],+ })+ .run();+ const { selectedModels } = ctx;+ return selectedModels;+}++function traverse(model: DraftModel, drafts: DraftModel[]) {+ const isDatabase = model.flavour === 'affine:database';+ const children = isDatabase+ ? model.children+ : model.children.filter(child => {+ const idx = drafts.findIndex(m => m.id === child.id);+ return idx >= 0;+ });++ children.forEach(child => {+ const idx = drafts.findIndex(m => m.id === child.id);+ if (idx >= 0) {+ drafts.splice(idx, 1);+ }+ traverse(child, drafts);+ });+ model.children = children;+}++export async function getTextContentFromBlockModels(+ editorHost: EditorHost,+ models: BlockModel[],+ type: 'markdown' | 'plain-text' = 'markdown'+) {+ // Currently only filter out images and databases+ const selectedTextModels = models.filter(+ model =>+ !BlocksUtils.matchFlavours(model, ['affine:image', 'affine:database'])+ );+ const drafts = selectedTextModels.map(toDraftModel);+ drafts.forEach(draft => traverse(draft, drafts));+ const slice = Slice.fromModels(editorHost.std.doc, drafts);+ return getContentFromSlice(editorHost, slice, type);+}++export async function getSelectedTextContent(+ editorHost: EditorHost,+ type: 'markdown' | 'plain-text' = 'markdown'+) {+ const selectedModels = getSelectedModels(editorHost);+ assertExists(selectedModels);+ return getTextContentFromBlockModels(editorHost, selectedModels, type);+}++export async function selectAboveBlocks(editorHost: EditorHost, num = 10) {+ let selectedModels = getSelectedModels(editorHost);+ assertExists(selectedModels);++ const lastLeafModel = selectedModels[selectedModels.length - 1];++ let noteModel: BlockModel | null = lastLeafModel;+ let lastRootModel: BlockModel | null = null;+ while (noteModel && noteModel.flavour !== 'affine:note') {+ lastRootModel = noteModel;+ noteModel = editorHost.doc.getParent(noteModel);+ }+ assertExists(noteModel);+ assertExists(lastRootModel);++ const endIndex = noteModel.children.indexOf(lastRootModel) + 1;+ const startIndex = Math.max(0, endIndex - num);+ const startBlock = noteModel.children[startIndex];++ selectedModels = [];+ let stop = false;+ const traverse = (model: BlockModel): void => {+ if (stop) return;++ selectedModels.push(model);++ if (model === lastLeafModel) {+ stop = true;+ return;+ }++ model.children.forEach(child => traverse(child));+ };+ noteModel.children.slice(startIndex, endIndex).forEach(traverse);++ const { selection } = editorHost;+ selection.set([+ selection.create('text', {+ from: {+ blockId: startBlock.id,+ index: 0,+ length: startBlock.text?.length ?? 0,+ },+ to: {+ blockId: lastLeafModel.id,+ index: 0,+ length: selection.find('text')?.from.index ?? 0,+ },+ }),+ ]);++ return getTextContentFromBlockModels(editorHost, selectedModels);+}++export const stopPropagation = (e: Event) => {+ e.stopPropagation();+};++export function getSurfaceElementFromEditor(editor: EditorHost) {+ const { doc } = editor;+ const surfaceModel = doc.getBlockByFlavour('affine:surface')[0];+ assertExists(surfaceModel);++ const surfaceId = surfaceModel.id;+ const surfaceElement = editor.querySelector(+ `affine-surface[data-block-id="${surfaceId}"]`+ ) as SurfaceBlockComponent;+ assertExists(surfaceElement);++ return surfaceElement;+}++export const getFirstImageInFrame = (+ frame: FrameBlockModel,+ editor: EditorHost+) => {+ const edgelessRoot = getEdgelessRootFromEditor(editor);+ const elements = edgelessRoot.service.frame.getElementsInFrame(frame, false);+ const image = elements.find(ele => {+ if (!BlocksUtils.isCanvasElement(ele)) {+ return ele.flavour === 'affine:image';+ }+ return false;+ }) as ImageBlockModel | undefined;+ return image?.id;+};++export const getSelections = (+ host: EditorHost,+ mode: 'flat' | 'highest' = 'flat'+) => {+ const [_, data] = host.command+ .chain()+ .tryAll(chain => [+ chain.getTextSelection(),+ chain.getBlockSelections(),+ chain.getImageSelections(),+ ])+ .getSelectedBlocks({ types: ['text', 'block', 'image'], mode })+ .run();++ return data;+};++export const getSelectedImagesAsBlobs = async (host: EditorHost) => {+ const [_, data] = host.command+ .chain()+ .tryAll(chain => [+ chain.getTextSelection(),+ chain.getBlockSelections(),+ chain.getImageSelections(),+ ])+ .getSelectedBlocks({+ types: ['image'],+ })+ .run();++ const blobs = await Promise.all(+ data.selectedBlocks?.map(async b => {+ const sourceId = (b.model as ImageBlockModel).sourceId;+ if (!sourceId) return null;+ const blob = await host.doc.blobSync.get(sourceId);+ if (!blob) return null;+ return new File([blob], sourceId);+ }) ?? []+ );+ return blobs.filter((blob): blob is File => !!blob);+};++export const getSelectedNoteAnchor = (host: EditorHost, id: string) => {+ return host.querySelector(`[data-portal-block-id="${id}"] .note-background`);+};++export function getCopilotSelectedElems(+ host: EditorHost+): BlockSuite.EdgelessModelType[] {+ const service = getService(host);+ const copilotWidget = getEdgelessCopilotWidget(host);++ if (copilotWidget.visible) {+ return (service.tool.controllers['copilot'] as CopilotSelectionController)+ .selectedElements;+ }++ return service.selection.selectedElements;+}++export const imageCustomInput = async (host: EditorHost) => {+ const selectedElements = getCopilotSelectedElems(host);+ if (selectedElements.length !== 1) return;++ const imageBlock = selectedElements[0];+ if (!(imageBlock instanceof ImageBlockModel)) return;+ if (!imageBlock.sourceId) return;++ const blob = await host.doc.blobSync.get(imageBlock.sourceId);+ if (!blob) return;++ return {+ attachments: [blob],+ };+};diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.tsindex 086441d4f4..4d4d60d502 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts@@ -1,5 +1,5 @@+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { assertExists } from '@blocksuite/global/utils';-import { AIProvider } from '@blocksuite/presets/ai';import { partition } from 'lodash-es';import { CopilotClient } from './copilot-client';diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/setup-provider.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/setup-provider.tsxindex 3e73ab3761..7f6732e0b7 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/setup-provider.tsx+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/setup-provider.tsx@@ -1,11 +1,11 @@import { notify } from '@affine/component';import { authAtom, openSettingModalAtom } from '@affine/core/atoms';+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { mixpanel } from '@affine/core/utils';import { getBaseUrl } from '@affine/graphql';import { Trans } from '@affine/i18n';import { UnauthorizedError } from '@blocksuite/blocks';import { assertExists } from '@blocksuite/global/utils';-import { AIProvider } from '@blocksuite/presets/ai';import { getCurrentStore } from '@toeverything/infra';import type { PromptKey } from './prompt';diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/tracker.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/tracker.tsindex 77fcf1ff80..1ba577ad4e 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/tracker.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/tracker.ts@@ -1,6 +1,6 @@+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { mixpanel } from '@affine/core/utils';import type { EditorHost } from '@blocksuite/block-std';-import { AIProvider } from '@blocksuite/presets/ai';import type { BlockModel } from '@blocksuite/store';import { lowerCase, omit } from 'lodash-es';diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.tsindex aea5e32cc8..ce7c9e12aa 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.ts@@ -1,3 +1,8 @@+import {+ AICodeBlockSpec,+ AIImageBlockSpec,+ AIParagraphBlockSpec,+} from '@affine/core/blocksuite/presets/ai';import type { BlockSpec } from '@blocksuite/block-std';import {BookmarkBlockSpec,@@ -14,11 +19,6 @@ import {ListBlockSpec,NoteBlockSpec,} from '@blocksuite/blocks';-import {- AICodeBlockSpec,- AIImageBlockSpec,- AIParagraphBlockSpec,-} from '@blocksuite/presets/ai';import { CustomAttachmentBlockSpec } from './custom/attachment-block';diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.tsindex 7bb4acee51..92b92e8437 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts@@ -1,3 +1,7 @@+import {+ AIEdgelessRootBlockSpec,+ AIPageRootBlockSpec,+} from '@affine/core/blocksuite/presets/ai';import { mixpanel } from '@affine/core/utils';import type { BlockSpec } from '@blocksuite/block-std';import type { RootService, TelemetryEventMap } from '@blocksuite/blocks';@@ -6,10 +10,6 @@ import {EdgelessRootService,PageRootService,} from '@blocksuite/blocks';-import {- AIEdgelessRootBlockSpec,- AIPageRootBlockSpec,-} from '@blocksuite/presets/ai';function customLoadFonts(service: RootService): void {if (runtimeConfig.isSelfHosted) {diff --git a/packages/frontend/core/src/modules/cloud/services/auth.ts b/packages/frontend/core/src/modules/cloud/services/auth.tsindex 3a2097f681..594ae918ce 100644--- a/packages/frontend/core/src/modules/cloud/services/auth.ts+++ b/packages/frontend/core/src/modules/cloud/services/auth.ts@@ -1,6 +1,6 @@+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { apis } from '@affine/electron-api';import type { OAuthProviderType } from '@affine/graphql';-import { AIProvider } from '@blocksuite/presets/ai';import {ApplicationFocused,ApplicationStarted,diff --git a/packages/frontend/core/src/modules/multi-tab-sidebar/multi-tabs/tabs/chat.tsx b/packages/frontend/core/src/modules/multi-tab-sidebar/multi-tabs/tabs/chat.tsxindex 40c5030b11..bfeaedb553 100644--- a/packages/frontend/core/src/modules/multi-tab-sidebar/multi-tabs/tabs/chat.tsx+++ b/packages/frontend/core/src/modules/multi-tab-sidebar/multi-tabs/tabs/chat.tsx@@ -1,6 +1,6 @@+import { ChatPanel } from '@affine/core/blocksuite/presets/ai';import { assertExists } from '@blocksuite/global/utils';import { AiIcon } from '@blocksuite/icons';-import { ChatPanel } from '@blocksuite/presets/ai';import { useCallback, useEffect, useRef } from 'react';import type { SidebarTab, SidebarTabProps } from '../sidebar-tab';diff --git a/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx b/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsxindex 788fa4aff8..0ccc777bf3 100644--- a/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx+++ b/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx@@ -1,13 +1,13 @@import { Scrollable } from '@affine/component';import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton';+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { AffineErrorBoundary } from '@affine/core/components/affine/affine-error-boundary';import { BlockSuiteEditor } from '@affine/core/components/blocksuite/block-suite-editor';import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';import { PageNotFound } from '@affine/core/pages/404';import { Bound, type EdgelessRootService } from '@blocksuite/blocks';import { DisposableGroup } from '@blocksuite/global/utils';-import { type AffineEditorContainer } from '@blocksuite/presets';-import { AIProvider } from '@blocksuite/presets/ai';+import type { AffineEditorContainer } from '@blocksuite/presets';import type { DocMode } from '@toeverything/infra';import { DocsService, FrameworkScope, useService } from '@toeverything/infra';import {diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsxindex 5485eb6a66..cc9667b0d2 100644--- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx+++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx@@ -1,5 +1,6 @@import { Scrollable } from '@affine/component';import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton';+import { AIProvider } from '@affine/core/blocksuite/presets/ai';import { PageAIOnboarding } from '@affine/core/components/affine/ai-onboarding';import { useAppSettingHelper } from '@affine/core/hooks/affine/use-app-setting-helper';import { RecentPagesService } from '@affine/core/modules/cmdk';@@ -14,7 +15,6 @@ import {} from '@blocksuite/blocks';import { DisposableGroup } from '@blocksuite/global/utils';import { type AffineEditorContainer } from '@blocksuite/presets';-import { AIProvider } from '@blocksuite/presets/ai';import type { Doc as BlockSuiteDoc } from '@blocksuite/store';import type { Doc } from '@toeverything/infra';import {diff --git a/packages/frontend/electron/package.json b/packages/frontend/electron/package.jsonindex 386ed5a168..096445fa4b 100644--- a/packages/frontend/electron/package.json+++ b/packages/frontend/electron/package.json@@ -95,4 +95,4 @@"peerDependencies": {"ts-node": "*"}-}+}\ No newline at end of filediff --git a/tools/cli/package.json b/tools/cli/package.jsonindex 8e248866b3..0f99b321fc 100644--- a/tools/cli/package.json+++ b/tools/cli/package.json@@ -46,4 +46,4 @@"dev": "node --loader ts-node/esm/transpile-only.mjs ./src/bin/dev.ts"},"version": "0.14.0"-}+}\ No newline at end of filediff --git a/tools/cli/src/webpack/config.ts b/tools/cli/src/webpack/config.tsindex 33db290f28..33334a5831 100644--- a/tools/cli/src/webpack/config.ts+++ b/tools/cli/src/webpack/config.ts@@ -152,6 +152,7 @@ export const createConfiguration: (},alias: {yjs: require.resolve('yjs'),+ lit: join(workspaceRoot, 'node_modules', 'lit'),'@blocksuite/block-std': blocksuiteBaseDir? join(blocksuiteBaseDir, 'packages', 'framework', 'block-std', 'src'): join(diff --git a/vitest.config.ts b/vitest.config.tsindex 8c99dab88a..33dfd01849 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -2,18 +2,38 @@ import { resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';-import react from '@vitejs/plugin-react-swc';import * as fg from 'fast-glob';+import swc from 'unplugin-swc';import { defineConfig } from 'vitest/config';const rootDir = fileURLToPath(new URL('.', import.meta.url));export default defineConfig({plugins: [- react({- tsDecorators: true,- }),vanillaExtractPlugin(),+ // https://github.com/vitejs/vite-plugin-react-swc/issues/85#issuecomment-2003922124+ swc.vite({+ jsc: {+ preserveAllComments: true,+ parser: {+ syntax: 'typescript',+ dynamicImport: true,+ tsx: true,+ decorators: true,+ },+ target: 'es2022',+ externalHelpers: false,+ transform: {+ react: {+ runtime: 'automatic',+ },+ useDefineForClassFields: false,+ decoratorVersion: '2022-03',+ },+ },+ sourceMaps: true,+ inlineSourcesContent: true,+ }),],assetsInclude: ['**/*.md', '**/*.zip'],resolve: {diff --git a/yarn.lock b/yarn.lockindex 29cdfe2f40..a4c795e4c8 100644--- a/yarn.lock+++ b/yarn.lock@@ -394,10 +394,12 @@ __metadata:"@dnd-kit/modifiers": "npm:^7.0.0""@dnd-kit/sortable": "npm:^8.0.0""@dnd-kit/utilities": "npm:^3.2.2"+ "@dotlottie/player-component": "npm:^2.7.12""@emotion/cache": "npm:^11.11.0""@emotion/react": "npm:^11.11.4""@emotion/server": "npm:^11.11.0""@emotion/styled": "npm:^11.11.5"+ "@floating-ui/dom": "npm:^1.6.5""@juggle/resize-observer": "npm:^3.4.0""@marsidev/react-turnstile": "npm:^0.7.0""@perfsee/webpack": "npm:^1.12.2"@@ -444,7 +446,7 @@ __metadata:jotai-devtools: "npm:^0.10.0"jotai-effect: "npm:^1.0.0"jotai-scope: "npm:^0.6.0"- lit: "npm:^3.1.2"+ lit: "npm:^3.1.3"lodash-es: "npm:^4.17.21"lottie-react: "npm:^2.4.0"lottie-web: "npm:^5.12.2"@@ -672,6 +674,7 @@ __metadata:string-width: "npm:^7.1.0"ts-node: "npm:^10.9.2"typescript: "npm:^5.4.5"+ unplugin-swc: "npm:^1.4.5"vite: "npm:^5.2.8"vite-plugin-istanbul: "npm:^6.0.0"vite-plugin-static-copy: "npm:^1.0.2"@@ -27508,6 +27511,13 @@ __metadata:languageName: nodelinkType: hard+"load-tsconfig@npm:^0.2.5":+ version: 0.2.5+ resolution: "load-tsconfig@npm:0.2.5"+ checksum: 10/b3176f6f0c86dbdbbc7e337440a803b0b4407c55e2e1cfc53bd3db68e0211448f36428a6075ecf5e286db5d1bf791da756fc0ac4d2447717140fb6a5218ecfb4+ languageName: node+ linkType: hard+"loader-runner@npm:^4.1.0, loader-runner@npm:^4.2.0":version: 4.3.0resolution: "loader-runner@npm:4.3.0"@@ -37043,6 +37053,19 @@ __metadata:languageName: nodelinkType: hard+"unplugin-swc@npm:^1.4.5":+ version: 1.4.5+ resolution: "unplugin-swc@npm:1.4.5"+ dependencies:+ "@rollup/pluginutils": "npm:^5.1.0"+ load-tsconfig: "npm:^0.2.5"+ unplugin: "npm:^1.10.1"+ peerDependencies:+ "@swc/core": ^1.2.108+ checksum: 10/93ea6ef83f131730a156d41d7180741b18203a3c815200040b77a4395d13f591206a23a01001e561e445846e5f361b8bffd50c78962f9349d10f24fa4905fe13+ languageName: node+ linkType: hard+"unplugin@npm:1.0.1":version: 1.0.1resolution: "unplugin@npm:1.0.1"@@ -37055,7 +37078,7 @@ __metadata:languageName: nodelinkType: hard-"unplugin@npm:^1.3.1":+"unplugin@npm:^1.10.1, unplugin@npm:^1.3.1":version: 1.10.1resolution: "unplugin@npm:1.10.1"dependencies: