Saul-Mirone
2024-07-31 01:38:53 +00:00
parent cd823fe118
commit c7217ed443
8 changed files with 118 additions and 101 deletions

View File

@@ -3,8 +3,8 @@
"private": true,
"type": "module",
"devDependencies": {
"@blocksuite/global": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/store": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/global": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/store": "0.16.0-canary-202407301803-87f6a75",
"react": "18.3.1",
"react-dom": "18.3.1",
"vitest": "1.6.0"

View File

@@ -14,10 +14,10 @@
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/blocks": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/global": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/presets": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/store": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/blocks": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/global": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/presets": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/store": "0.16.0-canary-202407301803-87f6a75",
"@datastructures-js/binary-search-tree": "^5.3.2",
"foxact": "^0.2.33",
"fuse.js": "^7.0.0",
@@ -34,8 +34,8 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/block-std": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/presets": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/block-std": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/presets": "0.16.0-canary-202407301803-87f6a75",
"@testing-library/react": "^16.0.0",
"async-call-rpc": "^6.4.0",
"fake-indexeddb": "^6.0.0",

View File

@@ -78,12 +78,12 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@blocksuite/block-std": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/blocks": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/global": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/block-std": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/blocks": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/global": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/icons": "2.1.61",
"@blocksuite/presets": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/store": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/presets": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/store": "0.16.0-canary-202407301803-87f6a75",
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-interactions": "^7.6.17",

View File

@@ -19,13 +19,13 @@
"@affine/graphql": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/block-std": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/blocks": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/global": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/block-std": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/blocks": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/global": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/icons": "2.1.61",
"@blocksuite/inline": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/presets": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/store": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/inline": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/presets": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/store": "0.16.0-canary-202407301803-87f6a75",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",

View File

@@ -4,13 +4,12 @@ import type {
AffineAIPanelWidgetConfig,
} from '@blocksuite/blocks';
import {
BlocksUtils,
CodeBlockComponent,
DividerBlockComponent,
ListBlockComponent,
ParagraphBlockComponent,
} from '@blocksuite/blocks';
import { type BlockSelector, BlockViewType, type Doc } from '@blocksuite/store';
import { BlockViewType, type Doc, type Query } 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';
@@ -183,8 +182,9 @@ export class AIAnswerText extends WithDisposable(LitElement) {
}
};
private readonly _selector: BlockSelector = block =>
BlocksUtils.matchFlavours(block.model, [
private readonly _query: Query = {
mode: 'strict',
match: [
'affine:page',
'affine:note',
'affine:surface',
@@ -192,9 +192,8 @@ export class AIAnswerText extends WithDisposable(LitElement) {
'affine:code',
'affine:list',
'affine:divider',
])
? BlockViewType.Display
: BlockViewType.Hidden;
].map(flavour => ({ flavour, viewType: BlockViewType.Display })),
};
private readonly _updateDoc = () => {
if (this._answers.length > 0) {
@@ -204,10 +203,10 @@ export class AIAnswerText extends WithDisposable(LitElement) {
markDownToDoc(this.host, latestAnswer)
.then(doc => {
this._doc = doc.blockCollection.getDoc({
selector: this._selector,
query: this._query,
});
this.disposables.add(() => {
doc.blockCollection.clearSelector(this._selector);
doc.blockCollection.clearQuery(this._query);
});
this._doc.awarenessStore.setReadonly(
this._doc.blockCollection,

View File

@@ -29,10 +29,10 @@
"@affine/env": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/native": "workspace:*",
"@blocksuite/block-std": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/blocks": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/presets": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/store": "0.16.0-canary-202407290703-75a91ff",
"@blocksuite/block-std": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/blocks": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/presets": "0.16.0-canary-202407301803-87f6a75",
"@blocksuite/store": "0.16.0-canary-202407301803-87f6a75",
"@electron-forge/cli": "^7.3.0",
"@electron-forge/core": "^7.3.0",
"@electron-forge/core-utils": "^7.3.0",