mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 10:52:40 +08:00
feat(editor): add editor store (#9584)
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
type JobMiddleware,
|
||||
type Query,
|
||||
type Schema,
|
||||
Store,
|
||||
} from '@blocksuite/affine/store';
|
||||
import { css, html, nothing, type PropertyValues } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
@@ -286,7 +287,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
|
||||
this._doc,
|
||||
html`<div class="ai-answer-text-editor affine-page-viewport">
|
||||
${new BlockStdScope({
|
||||
doc: this._doc,
|
||||
store: new Store({ blocks: this._doc }),
|
||||
extensions: this.options.extensions ?? CustomPageEditorBlockSpecs,
|
||||
}).render()}
|
||||
</div>`
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import { AffineSchemas } from '@blocksuite/affine/blocks/schemas';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { Schema } from '@blocksuite/affine/store';
|
||||
import { Schema, Store } from '@blocksuite/affine/store';
|
||||
import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
|
||||
@@ -208,7 +208,7 @@ export class AISlidesRenderer extends WithDisposable(LitElement) {
|
||||
${ref(this._editorContainer)}
|
||||
>
|
||||
${new BlockStdScope({
|
||||
doc: this._doc,
|
||||
store: new Store({ blocks: this._doc }),
|
||||
extensions:
|
||||
SpecProvider.getInstance().getSpec('edgeless:preview').value,
|
||||
}).render()}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import { type Blocks, Job, Schema } from '@blocksuite/affine/store';
|
||||
import { type Blocks, Job, Schema, Store } from '@blocksuite/affine/store';
|
||||
import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
@@ -175,7 +175,7 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {
|
||||
})}
|
||||
>
|
||||
${new BlockStdScope({
|
||||
doc: this.doc,
|
||||
store: new Store({ blocks: this.doc }),
|
||||
extensions: MiniMindmapSpecs,
|
||||
}).render()}
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
ThemeExtensionIdentifier,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { Bound } from '@blocksuite/affine/global/utils';
|
||||
import type { Block, Blocks } from '@blocksuite/affine/store';
|
||||
import { type Block, type Blocks, Store } from '@blocksuite/affine/store';
|
||||
import { createSignalFromObservable } from '@blocksuite/affine-shared/utils';
|
||||
import type { Container } from '@blocksuite/global/di';
|
||||
import type { Signal } from '@preact/signals-core';
|
||||
@@ -90,7 +90,7 @@ export const EdgelessSnapshot = (props: Props) => {
|
||||
if (!doc) return;
|
||||
|
||||
const editorHost = new BlockStdScope({
|
||||
doc,
|
||||
store: new Store({ blocks: doc }),
|
||||
extensions: [
|
||||
...SpecProvider.getInstance().getSpec('edgeless:preview').value,
|
||||
getThemeExtension(framework),
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createPageModeSpecs } from '@affine/core/components/blocksuite/block-su
|
||||
import type { AffineDNDData } from '@affine/core/types/dnd';
|
||||
import { BlockStdScope } from '@blocksuite/affine/block-std';
|
||||
import { DndApiExtensionIdentifier } from '@blocksuite/affine/blocks';
|
||||
import { type SliceSnapshot } from '@blocksuite/affine/store';
|
||||
import { type SliceSnapshot, Store } from '@blocksuite/affine/store';
|
||||
import { Service } from '@toeverything/infra';
|
||||
|
||||
import type { DocsService } from '../../doc';
|
||||
@@ -69,7 +69,7 @@ export class DndService extends Service {
|
||||
}
|
||||
|
||||
const std = new BlockStdScope({
|
||||
doc,
|
||||
store: new Store({ blocks: doc }),
|
||||
extensions: createPageModeSpecs(this.framework),
|
||||
});
|
||||
const dndAPI = std.get(DndApiExtensionIdentifier);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { BlockStdScope } from '@blocksuite/affine/block-std';
|
||||
import { PageEditorBlockSpecs } from '@blocksuite/affine/blocks';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { type Blocks, Store } from '@blocksuite/affine/store';
|
||||
import { LiveData } from '@toeverything/infra';
|
||||
import { useMemo } from 'react';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -45,7 +45,7 @@ export function signalToLiveData<T>(
|
||||
export function createBlockStdScope(doc: Blocks) {
|
||||
logger.debug('createBlockStdScope', doc.id);
|
||||
const std = new BlockStdScope({
|
||||
doc,
|
||||
store: new Store({ blocks: doc }),
|
||||
extensions: PageEditorBlockSpecs,
|
||||
});
|
||||
return std;
|
||||
|
||||
Reference in New Issue
Block a user