mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
feat(editor): add editor store (#9584)
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
ShadowlessElement,
|
||||
} from '@blocksuite/block-std';
|
||||
import { deserializeXYWH, WithDisposable } from '@blocksuite/global/utils';
|
||||
import { type BlockModel, type Query } from '@blocksuite/store';
|
||||
import { type BlockModel, type Query, Store } from '@blocksuite/store';
|
||||
import { css, nothing } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
@@ -118,9 +118,10 @@ export class SurfaceRefNotePortal extends WithDisposable(ShadowlessElement) {
|
||||
query: this.query,
|
||||
readonly: true,
|
||||
});
|
||||
const store = new Store({ blocks: doc });
|
||||
const previewSpec = SpecProvider.getInstance().getSpec('page:preview');
|
||||
return new BlockStdScope({
|
||||
doc,
|
||||
store,
|
||||
extensions: previewSpec.value.slice(),
|
||||
}).render();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import {
|
||||
DisposableGroup,
|
||||
type SerializedXYWH,
|
||||
} from '@blocksuite/global/utils';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
import { type Blocks, Store } from '@blocksuite/store';
|
||||
import { css, html, nothing, type TemplateResult } from 'lit';
|
||||
import { query, state } from 'lit/decorators.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
@@ -545,10 +545,15 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
||||
const _previewSpec = this._previewSpec.value;
|
||||
|
||||
if (!this._viewportEditor) {
|
||||
this._viewportEditor = new BlockStdScope({
|
||||
doc: this._previewDoc!,
|
||||
extensions: _previewSpec,
|
||||
}).render();
|
||||
if (this._previewDoc) {
|
||||
const store = new Store({ blocks: this._previewDoc });
|
||||
this._viewportEditor = new BlockStdScope({
|
||||
store,
|
||||
extensions: _previewSpec,
|
||||
}).render();
|
||||
} else {
|
||||
console.error('Preview doc is not found');
|
||||
}
|
||||
}
|
||||
|
||||
return html`<div class="ref-content">
|
||||
|
||||
Reference in New Issue
Block a user