mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
refactor(editor): rename store api (#9518)
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
} from '@blocksuite/blocks';
|
||||
import { WithDisposable } from '@blocksuite/global/utils';
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import type { BlockCollection, DocCollection } from '@blocksuite/store';
|
||||
import type { Doc, Workspace } from '@blocksuite/store';
|
||||
import { css, html, nothing } from 'lit';
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
@@ -64,23 +64,23 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
|
||||
`;
|
||||
|
||||
createDoc = () => {
|
||||
createDocBlock(this.editor.doc.collection);
|
||||
createDocBlock(this.editor.doc.workspace);
|
||||
};
|
||||
|
||||
gotoDoc = (doc: BlockCollection) => {
|
||||
gotoDoc = (doc: Doc) => {
|
||||
const url = this.editor.std
|
||||
.getOptional(GenerateDocUrlProvider)
|
||||
?.generateDocUrl(doc.id);
|
||||
if (url) history.pushState({}, '', url);
|
||||
|
||||
this.editor.doc = doc.getDoc();
|
||||
this.editor.doc = doc.getBlocks();
|
||||
this.editor.doc.load();
|
||||
this.editor.doc.resetHistory();
|
||||
this.requestUpdate();
|
||||
};
|
||||
|
||||
private get collection() {
|
||||
return this.editor.doc.collection;
|
||||
return this.editor.doc.workspace;
|
||||
}
|
||||
|
||||
private get docs() {
|
||||
@@ -110,7 +110,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
|
||||
});
|
||||
|
||||
this.disposables.add(
|
||||
this.editor.doc.collection.slots.docListUpdated.on(() => {
|
||||
this.editor.doc.workspace.slots.docListUpdated.on(() => {
|
||||
this.requestUpdate();
|
||||
})
|
||||
);
|
||||
@@ -146,7 +146,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
|
||||
removeModeFromStorage(doc.id);
|
||||
// When delete the current doc, we need to set the editor doc to the first remaining doc
|
||||
if (isDeleteCurrent) {
|
||||
this.editor.doc = this.docs[0].getDoc();
|
||||
this.editor.doc = this.docs[0].getBlocks();
|
||||
}
|
||||
};
|
||||
return html`<div class="doc-item" @click="${click}" style="${style}">
|
||||
@@ -169,7 +169,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
|
||||
accessor onClose!: () => void;
|
||||
}
|
||||
|
||||
function createDocBlock(collection: DocCollection) {
|
||||
function createDocBlock(collection: Workspace) {
|
||||
const id = collection.idGenerator();
|
||||
createDefaultDoc(collection, { id });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user