fix(core): ai lit element import (#7257)

Fix ai lit component import error.

f57a665819/packages/frontend/core/package.json (L13-L16)
This commit is contained in:
L-Sun
2024-06-19 04:26:49 +00:00
parent dddfcdbabb
commit 501fa0bb91
47 changed files with 190 additions and 202 deletions

View File

@@ -11,7 +11,10 @@
"./*": "./src/*" "./*": "./src/*"
}, },
"sideEffects": [ "sideEffects": [
"./src/**/*.css" "./src/**/*.css",
"./src/blocksuite/**/*.ts",
"./src/components/blocksuite/**/*.ts",
"./src/components/blocksuite/**/*.tsx"
], ],
"dependencies": { "dependencies": {
"@affine-test/fixtures": "workspace:*", "@affine-test/fixtures": "workspace:*",

View File

@@ -1,4 +1,4 @@
import './ask-ai-panel.js'; import './ask-ai-panel';
import { type EditorHost, WithDisposable } from '@blocksuite/block-std'; import { type EditorHost, WithDisposable } from '@blocksuite/block-std';
import { import {
@@ -14,7 +14,7 @@ import { customElement, property, query } from 'lit/decorators.js';
import { ref } from 'lit/directives/ref.js'; import { ref } from 'lit/directives/ref.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import { getRootService } from '../../utils/selection-utils.js'; import { getRootService } from '../../utils/selection-utils';
type buttonSize = 'small' | 'middle' | 'large'; type buttonSize = 'small' | 'middle' | 'large';
type toggleType = 'hover' | 'click'; type toggleType = 'hover' | 'click';

View File

@@ -7,7 +7,7 @@ import { css, html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import { getRootService } from '../../utils/selection-utils.js'; import { getRootService } from '../../utils/selection-utils';
@customElement('ask-ai-panel') @customElement('ask-ai-panel')
export class AskAIPanel extends WithDisposable(LitElement) { export class AskAIPanel extends WithDisposable(LitElement) {

View File

@@ -9,21 +9,21 @@ import {
} from '@blocksuite/blocks'; } from '@blocksuite/blocks';
import type { TemplateResult } from 'lit'; import type { TemplateResult } from 'lit';
import { actionToHandler } from '../actions/doc-handler.js'; import { actionToHandler } from '../actions/doc-handler';
import { actionToHandler as edgelessActionToHandler } from '../actions/edgeless-handler.js'; import { actionToHandler as edgelessActionToHandler } from '../actions/edgeless-handler';
import { import {
imageFilterStyles, imageFilterStyles,
imageProcessingTypes, imageProcessingTypes,
textTones, textTones,
translateLangs, translateLangs,
} from '../actions/types.js'; } from '../actions/types';
import { getAIPanel } from '../ai-panel.js'; import { getAIPanel } from '../ai-panel';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
import { import {
getSelectedImagesAsBlobs, getSelectedImagesAsBlobs,
getSelectedTextContent, getSelectedTextContent,
getSelections, getSelections,
} from '../utils/selection-utils.js'; } from '../utils/selection-utils';
import { import {
AIDoneIcon, AIDoneIcon,
AIImageIcon, AIImageIcon,
@@ -45,7 +45,7 @@ import {
SelectionIcon, SelectionIcon,
ShorterIcon, ShorterIcon,
ToneIcon, ToneIcon,
} from './icons.js'; } from './icons';
export const translateSubItem: AISubItemConfig[] = translateLangs.map(lang => { export const translateSubItem: AISubItemConfig[] = translateLangs.map(lang => {
return { return {

View File

@@ -9,7 +9,7 @@ import {
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { Slice } from '@blocksuite/store'; import { Slice } from '@blocksuite/store';
import { getMarkdownFromSlice } from './markdown-utils.js'; import { getMarkdownFromSlice } from './markdown-utils';
export const getRootService = (host: EditorHost) => { export const getRootService = (host: EditorHost) => {
return host.std.spec.getService('affine:page'); return host.std.spec.getService('affine:page');

View File

@@ -13,16 +13,16 @@ import {
buildFinishConfig, buildFinishConfig,
buildGeneratingConfig, buildGeneratingConfig,
getAIPanel, getAIPanel,
} from '../ai-panel.js'; } from '../ai-panel';
import { createTextRenderer } from '../messages/text.js'; import { createTextRenderer } from '../messages/text';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
import { reportResponse } from '../utils/action-reporter.js'; import { reportResponse } from '../utils/action-reporter';
import { import {
getSelectedImagesAsBlobs, getSelectedImagesAsBlobs,
getSelectedTextContent, getSelectedTextContent,
getSelections, getSelections,
selectAboveBlocks, selectAboveBlocks,
} from '../utils/selection-utils.js'; } from '../utils/selection-utils';
export function bindTextStream( export function bindTextStream(
stream: BlockSuitePresets.TextStream, stream: BlockSuitePresets.TextStream,

View File

@@ -17,41 +17,38 @@ import { assertExists } from '@blocksuite/global/utils';
import { Slice } from '@blocksuite/store'; import { Slice } from '@blocksuite/store';
import type { TemplateResult } from 'lit'; import type { TemplateResult } from 'lit';
import { getAIPanel } from '../ai-panel.js'; import { getAIPanel } from '../ai-panel';
import { import {
createMindmapExecuteRenderer, createMindmapExecuteRenderer,
createMindmapRenderer, createMindmapRenderer,
} from '../messages/mindmap.js'; } from '../messages/mindmap';
import { createSlidesRenderer } from '../messages/slides-renderer.js'; import { createSlidesRenderer } from '../messages/slides-renderer';
import { createTextRenderer } from '../messages/text.js'; import { createTextRenderer } from '../messages/text';
import { import { createIframeRenderer, createImageRenderer } from '../messages/wrapper';
createIframeRenderer, import { AIProvider } from '../provider';
createImageRenderer, import { reportResponse } from '../utils/action-reporter';
} from '../messages/wrapper.js';
import { AIProvider } from '../provider.js';
import { reportResponse } from '../utils/action-reporter.js';
import { import {
getEdgelessCopilotWidget, getEdgelessCopilotWidget,
isMindmapChild, isMindmapChild,
isMindMapRoot, isMindMapRoot,
} from '../utils/edgeless.js'; } from '../utils/edgeless';
import { copyTextAnswer } from '../utils/editor-actions.js'; import { copyTextAnswer } from '../utils/editor-actions';
import { getContentFromSlice } from '../utils/markdown-utils.js'; import { getContentFromSlice } from '../utils/markdown-utils';
import { import {
getCopilotSelectedElems, getCopilotSelectedElems,
getSelectedNoteAnchor, getSelectedNoteAnchor,
getSelections, getSelections,
} from '../utils/selection-utils.js'; } from '../utils/selection-utils';
import { EXCLUDING_COPY_ACTIONS, IMAGE_ACTIONS } from './consts.js'; import { EXCLUDING_COPY_ACTIONS, IMAGE_ACTIONS } from './consts';
import { bindTextStream } from './doc-handler.js'; import { bindTextStream } from './doc-handler';
import { import {
actionToErrorResponse, actionToErrorResponse,
actionToGenerating, actionToGenerating,
actionToResponse, actionToResponse,
getElementToolbar, getElementToolbar,
responses, responses,
} from './edgeless-response.js'; } from './edgeless-response';
import type { CtxRecord } from './types.js'; import type { CtxRecord } from './types';
type AnswerRenderer = NonNullable< type AnswerRenderer = NonNullable<
AffineAIPanelWidget['config'] AffineAIPanelWidget['config']

View File

@@ -22,26 +22,26 @@ import {
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import type { TemplateResult } from 'lit'; import type { TemplateResult } from 'lit';
import { AIPenIcon, ChatWithAIIcon } from '../_common/icons.js'; import { AIPenIcon, ChatWithAIIcon } from '../_common/icons';
import { insertFromMarkdown } from '../_common/markdown-utils.js'; import { insertFromMarkdown } from '../_common/markdown-utils';
import { getSurfaceElementFromEditor } from '../_common/selection-utils.js'; import { getSurfaceElementFromEditor } from '../_common/selection-utils';
import { getAIPanel } from '../ai-panel.js'; import { getAIPanel } from '../ai-panel';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
import { reportResponse } from '../utils/action-reporter.js'; import { reportResponse } from '../utils/action-reporter';
import { import {
getEdgelessCopilotWidget, getEdgelessCopilotWidget,
getService, getService,
isMindMapRoot, isMindMapRoot,
} from '../utils/edgeless.js'; } from '../utils/edgeless';
import { preprocessHtml } from '../utils/html.js'; import { preprocessHtml } from '../utils/html';
import { fetchImageToFile } from '../utils/image.js'; import { fetchImageToFile } from '../utils/image';
import { import {
getCopilotSelectedElems, getCopilotSelectedElems,
getEdgelessRootFromEditor, getEdgelessRootFromEditor,
getEdgelessService, getEdgelessService,
} from '../utils/selection-utils.js'; } from '../utils/selection-utils';
import { EXCLUDING_INSERT_ACTIONS, generatingStages } from './consts.js'; import { EXCLUDING_INSERT_ACTIONS, generatingStages } from './consts';
import type { CtxRecord } from './types.js'; import type { CtxRecord } from './types';
type FinishConfig = Exclude< type FinishConfig = Exclude<
AffineAIPanelWidget['config'], AffineAIPanelWidget['config'],

View File

@@ -1,2 +1,2 @@
export * from './doc-handler.js'; export * from './doc-handler';
export * from './types.js'; export * from './types';

View File

@@ -23,20 +23,20 @@ import {
InsertTopIcon, InsertTopIcon,
ReplaceIcon, ReplaceIcon,
RetryIcon, RetryIcon,
} from './_common/icons.js'; } from './_common/icons';
import { INSERT_ABOVE_ACTIONS } from './actions/consts.js'; import { INSERT_ABOVE_ACTIONS } from './actions/consts';
import { createTextRenderer } from './messages/text.js'; import { createTextRenderer } from './messages/text';
import { AIProvider } from './provider.js'; import { AIProvider } from './provider';
import { reportResponse } from './utils/action-reporter.js'; import { reportResponse } from './utils/action-reporter';
import { findNoteBlockModel, getService } from './utils/edgeless.js'; import { findNoteBlockModel, getService } from './utils/edgeless';
import { import {
copyTextAnswer, copyTextAnswer,
insertAbove, insertAbove,
insertBelow, insertBelow,
replace, replace,
} from './utils/editor-actions.js'; } from './utils/editor-actions';
import { insertFromMarkdown } from './utils/markdown-utils.js'; import { insertFromMarkdown } from './utils/markdown-utils';
import { getSelections } from './utils/selection-utils.js'; import { getSelections } from './utils/selection-utils';
function getSelection(host: EditorHost) { function getSelection(host: EditorHost) {
const textSelection = host.selection.find('text'); const textSelection = host.selection.find('text');

View File

@@ -19,16 +19,16 @@ import {
import { assertInstanceOf } from '@blocksuite/global/utils'; import { assertInstanceOf } from '@blocksuite/global/utils';
import { literal, unsafeStatic } from 'lit/static-html.js'; import { literal, unsafeStatic } from 'lit/static-html.js';
import { buildAIPanelConfig } from './ai-panel.js'; import { buildAIPanelConfig } from './ai-panel';
import { setupCodeToolbarEntry } from './entries/code-toolbar/setup-code-toolbar.js'; import { setupCodeToolbarEntry } from './entries/code-toolbar/setup-code-toolbar';
import { import {
setupEdgelessCopilot, setupEdgelessCopilot,
setupEdgelessElementToolbarEntry, setupEdgelessElementToolbarEntry,
} from './entries/edgeless/index.js'; } from './entries/edgeless/index';
import { setupFormatBarEntry } from './entries/format-bar/setup-format-bar.js'; import { setupFormatBarEntry } from './entries/format-bar/setup-format-bar';
import { setupImageToolbarEntry } from './entries/image-toolbar/setup-image-toolbar.js'; import { setupImageToolbarEntry } from './entries/image-toolbar/setup-image-toolbar';
import { setupSlashMenuEntry } from './entries/slash-menu/setup-slash-menu.js'; import { setupSlashMenuEntry } from './entries/slash-menu/setup-slash-menu';
import { setupSpaceEntry } from './entries/space/setup-space.js'; import { setupSpaceEntry } from './entries/space/setup-space';
export const AIPageRootBlockSpec: BlockSpec = { export const AIPageRootBlockSpec: BlockSpec = {
...PageRootBlockSpec, ...PageRootBlockSpec,

View File

@@ -21,11 +21,11 @@ import {
AIPresentationIcon, AIPresentationIcon,
ArrowDownIcon, ArrowDownIcon,
ArrowUpIcon, ArrowUpIcon,
} from '../../_common/icons.js'; } from '../../_common/icons';
import { createTextRenderer } from '../../messages/text.js'; import { createTextRenderer } from '../../messages/text';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
import { renderImages } from '../components/images.js'; import { renderImages } from '../components/images';
import { HISTORY_IMAGE_ACTIONS } from '../const.js'; import { HISTORY_IMAGE_ACTIONS } from '../const';
const icons: Record<string, TemplateResult<1>> = { const icons: Record<string, TemplateResult<1>> = {
'Fix spelling for it': AIDoneIcon, 'Fix spelling for it': AIDoneIcon,

View File

@@ -15,14 +15,10 @@ import {
NoteDisplayMode, NoteDisplayMode,
} from '@blocksuite/blocks'; } from '@blocksuite/blocks';
import { import { CreateIcon, InsertBelowIcon, ReplaceIcon } from '../../_common/icons';
CreateIcon, import { reportResponse } from '../../utils/action-reporter';
InsertBelowIcon, import { insertBelow, replace } from '../../utils/editor-actions';
ReplaceIcon, import { insertFromMarkdown } from '../../utils/markdown-utils';
} 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 { matchFlavours } = BlocksUtils;

View File

@@ -1,12 +1,12 @@
import './action-wrapper.js'; import './action-wrapper';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
import { html, nothing } from 'lit'; import { html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { createTextRenderer } from '../../messages/text.js'; import { createTextRenderer } from '../../messages/text';
import { renderImages } from '../components/images.js'; import { renderImages } from '../components/images';
@customElement('chat-text') @customElement('chat-text')
export class ChatText extends WithDisposable(ShadowlessElement) { export class ChatText extends WithDisposable(ShadowlessElement) {
@property({ attribute: false }) @property({ attribute: false })

View File

@@ -10,11 +10,11 @@ import { css, html, LitElement, nothing, type PropertyValues } from 'lit';
import { customElement, property, query, state } from 'lit/decorators.js'; import { customElement, property, query, state } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js'; import { repeat } from 'lit/directives/repeat.js';
import { CopyIcon, MoreIcon, RetryIcon } from '../../_common/icons.js'; import { CopyIcon, MoreIcon, RetryIcon } from '../../_common/icons';
import { AIProvider } from '../../provider.js'; import { AIProvider } from '../../provider';
import { copyText } from '../../utils/editor-actions.js'; import { copyText } from '../../utils/editor-actions';
import type { ChatContextValue, ChatMessage } from '../chat-context.js'; import type { ChatContextValue, ChatMessage } from '../chat-context';
import { PageEditorActions } from './actions-handle.js'; import { PageEditorActions } from './actions-handle';
noop(Tooltip); noop(Tooltip);

View File

@@ -1,4 +1,4 @@
import './action-wrapper.js'; import './action-wrapper';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
@@ -6,8 +6,8 @@ import { html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
import { renderImages } from '../components/images.js'; import { renderImages } from '../components/images';
@customElement('action-image-to-text') @customElement('action-image-to-text')
export class ActionImageToText extends WithDisposable(ShadowlessElement) { export class ActionImageToText extends WithDisposable(ShadowlessElement) {

View File

@@ -1,4 +1,4 @@
import './action-wrapper.js'; import './action-wrapper';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
@@ -6,8 +6,8 @@ import { html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
import { renderImages } from '../components/images.js'; import { renderImages } from '../components/images';
@customElement('action-image') @customElement('action-image')
export class ActionImage extends WithDisposable(ShadowlessElement) { export class ActionImage extends WithDisposable(ShadowlessElement) {

View File

@@ -1,4 +1,4 @@
import './action-wrapper.js'; import './action-wrapper';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
@@ -6,8 +6,8 @@ import { html } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import { createIframeRenderer } from '../../messages/wrapper.js'; import { createIframeRenderer } from '../../messages/wrapper';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
@customElement('action-make-real') @customElement('action-make-real')
export class ActionMakeReal extends WithDisposable(ShadowlessElement) { export class ActionMakeReal extends WithDisposable(ShadowlessElement) {

View File

@@ -1,4 +1,4 @@
import './action-wrapper.js'; import './action-wrapper';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
@@ -8,7 +8,7 @@ import { html } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
noop(MiniMindmapPreview); noop(MiniMindmapPreview);

View File

@@ -1,5 +1,5 @@
import './action-wrapper.js'; import './action-wrapper';
import '../../messages/slides-renderer.js'; import '../../messages/slides-renderer';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
@@ -7,7 +7,7 @@ import { html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
@customElement('action-slides') @customElement('action-slides')
export class ActionSlides extends WithDisposable(ShadowlessElement) { export class ActionSlides extends WithDisposable(ShadowlessElement) {

View File

@@ -1,4 +1,4 @@
import './action-wrapper.js'; import './action-wrapper';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/block-std'; import { WithDisposable } from '@blocksuite/block-std';
@@ -6,8 +6,8 @@ import { css, html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import { createTextRenderer } from '../../messages/text.js'; import { createTextRenderer } from '../../messages/text';
import type { ChatAction } from '../chat-context.js'; import type { ChatAction } from '../chat-context';
@customElement('action-text') @customElement('action-text')
export class ActionText extends WithDisposable(LitElement) { export class ActionText extends WithDisposable(LitElement) {

View File

@@ -2,7 +2,7 @@ import { WithDisposable } from '@blocksuite/block-std';
import { css, html, LitElement } from 'lit'; import { css, html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { AIStarIconWithAnimation } from '../_common/icons.js'; import { AIStarIconWithAnimation } from '../_common/icons';
@customElement('ai-loading') @customElement('ai-loading')
export class AILoading extends WithDisposable(LitElement) { export class AILoading extends WithDisposable(LitElement) {

View File

@@ -17,15 +17,15 @@ import {
CurrentSelectionIcon, CurrentSelectionIcon,
DocIcon, DocIcon,
SmallImageIcon, SmallImageIcon,
} from '../_common/icons.js'; } from '../_common/icons';
import { import {
getEdgelessRootFromEditor, getEdgelessRootFromEditor,
getSelectedImagesAsBlobs, getSelectedImagesAsBlobs,
getSelectedTextContent, getSelectedTextContent,
getTextContentFromBlockModels, getTextContentFromBlockModels,
selectedToCanvas, selectedToCanvas,
} from '../utils/selection-utils.js'; } from '../utils/selection-utils';
import type { ChatContextValue } from './chat-context.js'; import type { ChatContextValue } from './chat-context';
const cardsStyles = css` const cardsStyles = css`
.card-wrapper { .card-wrapper {

View File

@@ -12,11 +12,11 @@ import {
ChatSendIcon, ChatSendIcon,
CloseIcon, CloseIcon,
ImageIcon, ImageIcon,
} from '../_common/icons.js'; } from '../_common/icons';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
import { reportResponse } from '../utils/action-reporter.js'; import { reportResponse } from '../utils/action-reporter';
import { readBlobAsURL } from '../utils/image.js'; import { readBlobAsURL } from '../utils/image';
import type { ChatContextValue, ChatMessage } from './chat-context.js'; import type { ChatContextValue, ChatMessage } from './chat-context';
const MaximumImageCount = 8; const MaximumImageCount = 8;

View File

@@ -1,16 +1,16 @@
import '../messages/slides-renderer.js'; import '../messages/slides-renderer';
import './ai-loading.js'; import './ai-loading';
import '../messages/text.js'; import '../messages/text';
import './actions/text.js'; import './actions/text';
import './actions/action-wrapper.js'; import './actions/action-wrapper';
import './actions/make-real.js'; import './actions/make-real';
import './actions/slides.js'; import './actions/slides';
import './actions/mindmap.js'; import './actions/mindmap';
import './actions/chat-text.js'; import './actions/chat-text';
import './actions/copy-more.js'; import './actions/copy-more';
import './actions/image-to-text.js'; import './actions/image-to-text';
import './actions/image.js'; import './actions/image';
import './chat-cards.js'; import './chat-cards';
import type { import type {
BaseSelection, BaseSelection,
@@ -30,27 +30,19 @@ import { customElement, property, query, state } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js'; import { repeat } from 'lit/directives/repeat.js';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import { import { AffineAvatarIcon, AffineIcon, DownArrowIcon } from '../_common/icons';
AffineAvatarIcon,
AffineIcon,
DownArrowIcon,
} from '../_common/icons.js';
import { import {
GeneralErrorRenderer, GeneralErrorRenderer,
PaymentRequiredErrorRenderer, PaymentRequiredErrorRenderer,
} from '../messages/error.js'; } from '../messages/error';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
import { insertBelow } from '../utils/editor-actions.js'; import { insertBelow } from '../utils/editor-actions';
import { import {
EdgelessEditorActions, EdgelessEditorActions,
PageEditorActions, PageEditorActions,
} from './actions/actions-handle.js'; } from './actions/actions-handle';
import type { import type { ChatContextValue, ChatItem, ChatMessage } from './chat-context';
ChatContextValue, import { HISTORY_IMAGE_ACTIONS } from './const';
ChatItem,
ChatMessage,
} from './chat-context.js';
import { HISTORY_IMAGE_ACTIONS } from './const.js';
@customElement('chat-panel-messages') @customElement('chat-panel-messages')
export class ChatPanelMessages extends WithDisposable(ShadowlessElement) { export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {

View File

@@ -1,5 +1,5 @@
import './chat-panel-input.js'; import './chat-panel-input';
import './chat-panel-messages.js'; import './chat-panel-messages';
import type { EditorHost } from '@blocksuite/block-std'; import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std';
@@ -9,14 +9,14 @@ import { css, html, type PropertyValues } from 'lit';
import { customElement, property, state } from 'lit/decorators.js'; import { customElement, property, state } from 'lit/decorators.js';
import { createRef, type Ref, ref } from 'lit/directives/ref.js'; import { createRef, type Ref, ref } from 'lit/directives/ref.js';
import { AIHelpIcon, SmallHintIcon } from '../_common/icons.js'; import { AIHelpIcon, SmallHintIcon } from '../_common/icons';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
import { import {
getSelectedImagesAsBlobs, getSelectedImagesAsBlobs,
getSelectedTextContent, getSelectedTextContent,
} from '../utils/selection-utils.js'; } from '../utils/selection-utils';
import type { ChatAction, ChatContextValue, ChatItem } from './chat-context.js'; import type { ChatAction, ChatContextValue, ChatItem } from './chat-context';
import type { ChatPanelMessages } from './chat-panel-messages.js'; import type { ChatPanelMessages } from './chat-panel-messages';
@customElement('chat-panel') @customElement('chat-panel')
export class ChatPanel extends WithDisposable(ShadowlessElement) { export class ChatPanel extends WithDisposable(ShadowlessElement) {

View File

@@ -2,9 +2,9 @@ import type { EditorHost } from '@blocksuite/block-std';
import type { EdgelessRootService } from '@blocksuite/blocks'; import type { EdgelessRootService } from '@blocksuite/blocks';
import type { BlockSnapshot } from '@blocksuite/store'; import type { BlockSnapshot } from '@blocksuite/store';
import { markdownToSnapshot } from '../_common/markdown-utils.js'; import { markdownToSnapshot } from '../_common/markdown-utils';
import { getSurfaceElementFromEditor } from '../_common/selection-utils.js'; import { getSurfaceElementFromEditor } from '../_common/selection-utils';
import { basicTheme } from '../slides/template.js'; import { basicTheme } from '../slides/template';
type PPTSection = { type PPTSection = {
title: string; title: string;

View File

@@ -1,4 +1,4 @@
import '../../_common/components/ask-ai-button.js'; import '../../_common/components/ask-ai-button';
import type { import type {
AffineCodeToolbarWidget, AffineCodeToolbarWidget,
@@ -12,9 +12,9 @@ const buttonOptions: AskAIButtonOptions = {
panelWidth: 240, panelWidth: 240,
}; };
import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button.js'; import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button';
import { buildAICodeItemGroups } from '../../_common/config.js'; import { buildAICodeItemGroups } from '../../_common/config';
import { AIStarIcon } from '../../_common/icons.js'; import { AIStarIcon } from '../../_common/icons';
export function setupCodeToolbarEntry(codeToolbar: AffineCodeToolbarWidget) { export function setupCodeToolbarEntry(codeToolbar: AffineCodeToolbarWidget) {
const onAskAIClick = () => { const onAskAIClick = () => {

View File

@@ -28,7 +28,7 @@ import {
SelectionIcon, SelectionIcon,
ShorterIcon, ShorterIcon,
ToneIcon, ToneIcon,
} from '../../_common/icons.js'; } from '../../_common/icons';
import { import {
actionToHandler, actionToHandler,
imageOnlyShowWhen, imageOnlyShowWhen,
@@ -36,22 +36,22 @@ import {
mindmapRootShowWhen, mindmapRootShowWhen,
noteBlockOrTextShowWhen, noteBlockOrTextShowWhen,
noteWithCodeBlockShowWen, noteWithCodeBlockShowWen,
} from '../../actions/edgeless-handler.js'; } from '../../actions/edgeless-handler';
import { import {
imageFilterStyles, imageFilterStyles,
imageProcessingTypes, imageProcessingTypes,
textTones, textTones,
translateLangs, translateLangs,
} from '../../actions/types.js'; } from '../../actions/types';
import { getAIPanel } from '../../ai-panel.js'; import { getAIPanel } from '../../ai-panel';
import { AIProvider } from '../../provider.js'; import { AIProvider } from '../../provider';
import { mindMapToMarkdown } from '../../utils/edgeless.js'; import { mindMapToMarkdown } from '../../utils/edgeless';
import { canvasToBlob, randomSeed } from '../../utils/image.js'; import { canvasToBlob, randomSeed } from '../../utils/image';
import { import {
getCopilotSelectedElems, getCopilotSelectedElems,
getEdgelessRootFromEditor, getEdgelessRootFromEditor,
imageCustomInput, imageCustomInput,
} from '../../utils/selection-utils.js'; } from '../../utils/selection-utils';
const translateSubItem = translateLangs.map(lang => { const translateSubItem = translateLangs.map(lang => {
return { return {

View File

@@ -8,7 +8,7 @@ import { EdgelessCopilotToolbarEntry } from '@blocksuite/blocks';
import { noop } from '@blocksuite/global/utils'; import { noop } from '@blocksuite/global/utils';
import { html } from 'lit'; import { html } from 'lit';
import { edgelessActionGroups } from './actions-config.js'; import { edgelessActionGroups } from './actions-config';
noop(EdgelessCopilotToolbarEntry); noop(EdgelessCopilotToolbarEntry);

View File

@@ -1,4 +1,4 @@
import '../../_common/components/ask-ai-button.js'; import '../../_common/components/ask-ai-button';
import { import {
type AffineFormatBarWidget, type AffineFormatBarWidget,
@@ -6,7 +6,7 @@ import {
} from '@blocksuite/blocks'; } from '@blocksuite/blocks';
import { html, type TemplateResult } from 'lit'; import { html, type TemplateResult } from 'lit';
import { AIItemGroups } from '../../_common/config.js'; import { AIItemGroups } from '../../_common/config';
export function setupFormatBarEntry(formatBar: AffineFormatBarWidget) { export function setupFormatBarEntry(formatBar: AffineFormatBarWidget) {
toolbarDefaultConfig(formatBar); toolbarDefaultConfig(formatBar);

View File

@@ -1,4 +1,4 @@
import '../../_common/components/ask-ai-button.js'; import '../../_common/components/ask-ai-button';
import type { import type {
AffineImageToolbarWidget, AffineImageToolbarWidget,
@@ -6,8 +6,8 @@ import type {
} from '@blocksuite/blocks'; } from '@blocksuite/blocks';
import { html } from 'lit'; import { html } from 'lit';
import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button.js'; import type { AskAIButtonOptions } from '../../_common/components/ask-ai-button';
import { buildAIImageItemGroups } from '../../_common/config.js'; import { buildAIImageItemGroups } from '../../_common/config';
const AIImageItemGroups = buildAIImageItemGroups(); const AIImageItemGroups = buildAIImageItemGroups();
const buttonOptions: AskAIButtonOptions = { const buttonOptions: AskAIButtonOptions = {

View File

@@ -1,2 +1,2 @@
export * from './format-bar/setup-format-bar.js'; export * from './format-bar/setup-format-bar';
export * from './space/setup-space.js'; export * from './space/setup-space';

View File

@@ -15,9 +15,9 @@ import {
import { assertExists } from '@blocksuite/global/utils'; import { assertExists } from '@blocksuite/global/utils';
import { html } from 'lit'; import { html } from 'lit';
import { AIItemGroups } from '../../_common/config.js'; import { AIItemGroups } from '../../_common/config';
import { handleInlineAskAIAction } from '../../actions/doc-handler.js'; import { handleInlineAskAIAction } from '../../actions/doc-handler';
import { AIProvider } from '../../provider.js'; import { AIProvider } from '../../provider';
export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) { export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
const AIItems = AIItemGroups.map(group => group.items).flat(); const AIItems = AIItemGroups.map(group => group.items).flat();

View File

@@ -1,7 +1,7 @@
import type { AffineAIPanelWidget } from '@blocksuite/blocks'; import type { AffineAIPanelWidget } from '@blocksuite/blocks';
import { handleInlineAskAIAction } from '../../actions/doc-handler.js'; import { handleInlineAskAIAction } from '../../actions/doc-handler';
import { AIProvider } from '../../provider.js'; import { AIProvider } from '../../provider';
export function setupSpaceEntry(panel: AffineAIPanelWidget) { export function setupSpaceEntry(panel: AffineAIPanelWidget) {
panel.handleEvent('keyDown', ctx => { panel.handleEvent('keyDown', ctx => {

View File

@@ -1,7 +1,7 @@
export * from './actions/index.js'; export * from './actions/index';
export * from './ai-spec.js'; export * from './ai-spec';
export { ChatPanel } from './chat-panel/index.js'; export { ChatPanel } from './chat-panel/index';
export * from './entries/edgeless/actions-config.js'; export * from './entries/edgeless/actions-config';
export * from './entries/index.js'; export * from './entries/index';
export * from './messages/index.js'; export * from './messages/index';
export * from './provider.js'; export * from './provider';

View File

@@ -2,8 +2,8 @@ import { type EditorHost, WithDisposable } from '@blocksuite/block-std';
import { html, LitElement, nothing, type TemplateResult } from 'lit'; import { html, LitElement, nothing, type TemplateResult } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { ErrorTipIcon } from '../_common/icons.js'; import { ErrorTipIcon } from '../_common/icons';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
@customElement('ai-error-wrapper') @customElement('ai-error-wrapper')
class AIErrorWrapper extends WithDisposable(LitElement) { class AIErrorWrapper extends WithDisposable(LitElement) {

View File

@@ -1,2 +1,2 @@
export * from './text.js'; export * from './text';
export * from './wrapper.js'; export * from './wrapper';

View File

@@ -7,7 +7,7 @@ import { markdownToMindmap, MiniMindmapPreview } from '@blocksuite/blocks';
import { noop } from '@blocksuite/global/utils'; import { noop } from '@blocksuite/global/utils';
import { html, nothing } from 'lit'; import { html, nothing } from 'lit';
import { getAIPanel } from '../ai-panel.js'; import { getAIPanel } from '../ai-panel';
noop(MiniMindmapPreview); noop(MiniMindmapPreview);

View File

@@ -11,8 +11,8 @@ import { css, html, LitElement, nothing } from 'lit';
import { customElement, property, query } from 'lit/decorators.js'; import { customElement, property, query } from 'lit/decorators.js';
import { createRef, type Ref, ref } from 'lit/directives/ref.js'; import { createRef, type Ref, ref } from 'lit/directives/ref.js';
import { getAIPanel } from '../ai-panel.js'; import { getAIPanel } from '../ai-panel';
import { PPTBuilder } from '../slides/index.js'; import { PPTBuilder } from '../slides/index';
export const createSlidesRenderer: ( export const createSlidesRenderer: (
host: EditorHost, host: EditorHost,

View File

@@ -16,8 +16,8 @@ import { customElement, property, query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js'; import { classMap } from 'lit/directives/class-map.js';
import { keyed } from 'lit/directives/keyed.js'; import { keyed } from 'lit/directives/keyed.js';
import { CustomPageEditorBlockSpecs } from '../utils/custom-specs.js'; import { CustomPageEditorBlockSpecs } from '../utils/custom-specs';
import { markDownToDoc } from '../utils/markdown-utils.js'; import { markDownToDoc } from '../utils/markdown-utils';
const textBlockStyles = css` const textBlockStyles = css`
${ParagraphBlockComponent.styles} ${ParagraphBlockComponent.styles}

View File

@@ -3,8 +3,8 @@ import type { AffineAIPanelWidgetConfig } from '@blocksuite/blocks';
import { css, html, LitElement, nothing } from 'lit'; import { css, html, LitElement, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { getAIPanel } from '../ai-panel.js'; import { getAIPanel } from '../ai-panel';
import { preprocessHtml } from '../utils/html.js'; import { preprocessHtml } from '../utils/html';
type AIAnswerWrapperOptions = { type AIAnswerWrapperOptions = {
height: number; height: number;

View File

@@ -2,14 +2,14 @@ import type { EditorHost } from '@blocksuite/block-std';
import type { EdgelessRootService } from '@blocksuite/blocks'; import type { EdgelessRootService } from '@blocksuite/blocks';
import type { BlockSnapshot } from '@blocksuite/store'; import type { BlockSnapshot } from '@blocksuite/store';
import { markdownToSnapshot } from '../_common/markdown-utils.js'; import { markdownToSnapshot } from '../_common/markdown-utils';
import { getSurfaceElementFromEditor } from '../_common/selection-utils.js'; import { getSurfaceElementFromEditor } from '../_common/selection-utils';
import { import {
basicTheme, basicTheme,
type PPTDoc, type PPTDoc,
type PPTSection, type PPTSection,
type TemplateImage, type TemplateImage,
} from './template.js'; } from './template';
export const PPTBuilder = (host: EditorHost) => { export const PPTBuilder = (host: EditorHost) => {
const service = host.spec.getService<EdgelessRootService>('affine:page'); const service = host.spec.getService<EdgelessRootService>('affine:page');

View File

@@ -1,7 +1,7 @@
import { Bound } from '@blocksuite/blocks'; import { Bound } from '@blocksuite/blocks';
import { nanoid } from '@blocksuite/store'; import { nanoid } from '@blocksuite/store';
import { AIProvider } from '../provider.js'; import { AIProvider } from '../provider';
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const replaceText = (text: Record<string, string>, template: any) => { const replaceText = (text: Record<string, string>, template: any) => {

View File

@@ -1,4 +1,4 @@
import { type ActionEventType, AIProvider } from '../provider.js'; import { type ActionEventType, AIProvider } from '../provider';
export function reportResponse(event: ActionEventType) { export function reportResponse(event: ActionEventType) {
const lastAction = AIProvider.actionHistory.at(-1); const lastAction = AIProvider.actionHistory.at(-1);

View File

@@ -11,7 +11,7 @@ import {
insertFromMarkdown, insertFromMarkdown,
markDownToDoc, markDownToDoc,
markdownToSnapshot, markdownToSnapshot,
} from './markdown-utils.js'; } from './markdown-utils';
const getNoteId = (blockElement: BlockElement) => { const getNoteId = (blockElement: BlockElement) => {
let element = blockElement; let element = blockElement;

View File

@@ -14,8 +14,8 @@ import {
toDraftModel, toDraftModel,
} from '@blocksuite/store'; } from '@blocksuite/store';
import { getEdgelessCopilotWidget, getService } from './edgeless.js'; import { getEdgelessCopilotWidget, getService } from './edgeless';
import { getContentFromSlice } from './markdown-utils.js'; import { getContentFromSlice } from './markdown-utils';
export const getRootService = (host: EditorHost) => { export const getRootService = (host: EditorHost) => {
return host.std.spec.getService('affine:page'); return host.std.spec.getService('affine:page');