refactor(editor): rename store api (#9518)

This commit is contained in:
Saul-Mirone
2025-01-04 12:51:56 +00:00
parent 650e4fb6b2
commit c773982ced
83 changed files with 293 additions and 290 deletions
@@ -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 });
}