mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
refactor(editor): playground doc collection typing migration (#9593)
This commit is contained in:
@@ -30,7 +30,7 @@ import {
|
|||||||
import { type SerializedXYWH, SignalWatcher } from '@blocksuite/global/utils';
|
import { type SerializedXYWH, SignalWatcher } from '@blocksuite/global/utils';
|
||||||
import type { DeltaInsert } from '@blocksuite/inline';
|
import type { DeltaInsert } from '@blocksuite/inline';
|
||||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js';
|
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js';
|
||||||
import { css, html, nothing } from 'lit';
|
import { css, html, nothing } from 'lit';
|
||||||
import { customElement, property, state } from 'lit/decorators.js';
|
import { customElement, property, state } from 'lit/decorators.js';
|
||||||
@@ -158,7 +158,9 @@ export class CollabDebugMenu extends SignalWatcher(ShadowlessElement) {
|
|||||||
const zipTransformer = this.rootService.transformers.zip;
|
const zipTransformer = this.rootService.transformers.zip;
|
||||||
await zipTransformer.exportDocs(
|
await zipTransformer.exportDocs(
|
||||||
this.collection,
|
this.collection,
|
||||||
[...this.collection.docs.values()].map(collection => collection.getDoc())
|
Array.from(this.collection.docs.values()).map(collection =>
|
||||||
|
collection.getStore()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,7 +613,7 @@ export class CollabDebugMenu extends SignalWatcher(ShadowlessElement) {
|
|||||||
private accessor _docMode: DocMode = 'page';
|
private accessor _docMode: DocMode = 'page';
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor collection!: DocCollection;
|
accessor collection!: Workspace;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor docsPanel!: DocsPanel;
|
accessor docsPanel!: DocsPanel;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
|||||||
import type { SerializedXYWH } from '@blocksuite/global/utils';
|
import type { SerializedXYWH } from '@blocksuite/global/utils';
|
||||||
import type { DeltaInsert } from '@blocksuite/inline/types';
|
import type { DeltaInsert } from '@blocksuite/inline/types';
|
||||||
import { AffineEditorContainer, type CommentPanel } from '@blocksuite/presets';
|
import { AffineEditorContainer, type CommentPanel } from '@blocksuite/presets';
|
||||||
import { type DocCollection, Job, Text } from '@blocksuite/store';
|
import { Job, Text, type Workspace } from '@blocksuite/store';
|
||||||
import type { SlDropdown } from '@shoelace-style/shoelace';
|
import type { SlDropdown } from '@shoelace-style/shoelace';
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js';
|
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js';
|
||||||
import { css, html } from 'lit';
|
import { css, html } from 'lit';
|
||||||
@@ -329,7 +329,9 @@ export class StarterDebugMenu extends ShadowlessElement {
|
|||||||
private async _exportSnapshot() {
|
private async _exportSnapshot() {
|
||||||
await ZipTransformer.exportDocs(
|
await ZipTransformer.exportDocs(
|
||||||
this.collection,
|
this.collection,
|
||||||
[...this.collection.docs.values()].map(collection => collection.getDoc())
|
Array.from(this.collection.docs.values()).map(collection =>
|
||||||
|
collection.getStore()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1019,7 +1021,7 @@ export class StarterDebugMenu extends ShadowlessElement {
|
|||||||
accessor blockTypeDropdown!: SlDropdown;
|
accessor blockTypeDropdown!: SlDropdown;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor collection!: DocCollection;
|
accessor collection!: Workspace;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor commentPanel!: CommentPanel;
|
accessor commentPanel!: CommentPanel;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { Slot } from '@blocksuite/global/utils';
|
import { Slot } from '@blocksuite/global/utils';
|
||||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
import { type DocCollection } from '@blocksuite/store';
|
import { type Workspace } from '@blocksuite/store';
|
||||||
import { Signal, signal } from '@preact/signals-core';
|
import { Signal, signal } from '@preact/signals-core';
|
||||||
import type { TemplateResult } from 'lit';
|
import type { TemplateResult } from 'lit';
|
||||||
|
|
||||||
@@ -109,14 +109,14 @@ export function mockNotificationService(editor: AffineEditorContainer) {
|
|||||||
return notificationService;
|
return notificationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mockParseDocUrlService(collection: DocCollection) {
|
export function mockParseDocUrlService(collection: Workspace) {
|
||||||
const parseDocUrlService: ParseDocUrlService = {
|
const parseDocUrlService: ParseDocUrlService = {
|
||||||
parseDocUrl: (url: string) => {
|
parseDocUrl: (url: string) => {
|
||||||
if (url && URL.canParse(url)) {
|
if (url && URL.canParse(url)) {
|
||||||
const path = decodeURIComponent(new URL(url).hash.slice(1));
|
const path = decodeURIComponent(new URL(url).hash.slice(1));
|
||||||
const item =
|
const item =
|
||||||
path.length > 0
|
path.length > 0
|
||||||
? [...collection.docs.values()].find(doc => doc.id === path)
|
? Array.from(collection.docs.values()).find(doc => doc.id === path)
|
||||||
: null;
|
: null;
|
||||||
if (item) {
|
if (item) {
|
||||||
return {
|
return {
|
||||||
@@ -185,7 +185,7 @@ export function mockPeekViewExtension(
|
|||||||
} satisfies PeekViewService);
|
} satisfies PeekViewService);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mockGenerateDocUrlService(collection: DocCollection) {
|
export function mockGenerateDocUrlService(collection: Workspace) {
|
||||||
const generateDocUrlService: GenerateDocUrlService = {
|
const generateDocUrlService: GenerateDocUrlService = {
|
||||||
generateDocUrl: (docId: string, params?: ReferenceParams) => {
|
generateDocUrl: (docId: string, params?: ReferenceParams) => {
|
||||||
const doc = collection.getDoc(docId);
|
const doc = collection.getDoc(docId);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { EditorHost, ExtensionType } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
import {
|
import {
|
||||||
CommunityCanvasTextFonts,
|
CommunityCanvasTextFonts,
|
||||||
DocModeExtension,
|
DocModeExtension,
|
||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
SpecProvider,
|
SpecProvider,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { AffineEditorContainer } from '@blocksuite/presets';
|
import { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
import type { Workspace } from '@blocksuite/store';
|
import type { ExtensionType, Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import { AttachmentViewerPanel } from '../../_common/components/attachment-viewer-panel.js';
|
import { AttachmentViewerPanel } from '../../_common/components/attachment-viewer-panel.js';
|
||||||
import { CollabDebugMenu } from '../../_common/components/collab-debug-menu.js';
|
import { CollabDebugMenu } from '../../_common/components/collab-debug-menu.js';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ZipTransformer } from '@blocksuite/blocks';
|
import { ZipTransformer } from '@blocksuite/blocks';
|
||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
export async function affineSnapshot(collection: DocCollection, id: string) {
|
export async function affineSnapshot(collection: Workspace, id: string) {
|
||||||
const doc = collection.createDoc({ id });
|
const doc = collection.createDoc({ id });
|
||||||
doc.load();
|
doc.load();
|
||||||
// Add root block and surface block at root level
|
// Add root block and surface block at root level
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
export const embed: InitFn = (collection: DocCollection, id: string) => {
|
export const embed: InitFn = (collection: Workspace, id: string) => {
|
||||||
const doc = collection.getDoc(id) ?? collection.createDoc({ id });
|
const doc = collection.getDoc(id) ?? collection.createDoc({ id });
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
export const empty: InitFn = (collection: DocCollection, id: string) => {
|
export const empty: InitFn = (collection: Workspace, id: string) => {
|
||||||
const doc = collection.getDoc(id) ?? collection.createDoc({ id });
|
const doc = collection.getDoc(id) ?? collection.createDoc({ id });
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import { DEFAULT_ROUGHNESS } from '@blocksuite/affine-model';
|
|||||||
import type { SerializedXYWH } from '@blocksuite/global/utils';
|
import type { SerializedXYWH } from '@blocksuite/global/utils';
|
||||||
import {
|
import {
|
||||||
Boxed,
|
Boxed,
|
||||||
type DocCollection,
|
|
||||||
nanoid,
|
nanoid,
|
||||||
native2Y,
|
native2Y,
|
||||||
Text,
|
Text,
|
||||||
type Y,
|
type Workspace,
|
||||||
} from '@blocksuite/store';
|
} from '@blocksuite/store';
|
||||||
|
import type * as Y from 'yjs';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
@@ -46,10 +46,7 @@ function createShapes(count: number): Record<string, unknown> {
|
|||||||
const SHAPES_COUNT = 100;
|
const SHAPES_COUNT = 100;
|
||||||
const RANGE = 2000;
|
const RANGE = 2000;
|
||||||
|
|
||||||
export const heavyWhiteboard: InitFn = (
|
export const heavyWhiteboard: InitFn = (collection: Workspace, id: string) => {
|
||||||
collection: DocCollection,
|
|
||||||
id: string
|
|
||||||
) => {
|
|
||||||
const count = Number(params.get('count')) || SHAPES_COUNT;
|
const count = Number(params.get('count')) || SHAPES_COUNT;
|
||||||
const enableShapes = !!params.get('shapes');
|
const enableShapes = !!params.get('shapes');
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
|
|
||||||
export const heavy: InitFn = (collection: DocCollection, docId: string) => {
|
export const heavy: InitFn = (collection: Workspace, docId: string) => {
|
||||||
const count = Number(params.get('count')) || 1000;
|
const count = Number(params.get('count')) || 1000;
|
||||||
|
|
||||||
const doc = collection.createDoc({ id: docId });
|
const doc = collection.createDoc({ id: docId });
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
export const linked: InitFn = (collection: DocCollection, id: string) => {
|
export const linked: InitFn = (collection: Workspace, id: string) => {
|
||||||
const docA = collection.getDoc(id) ?? collection.createDoc({ id });
|
const docA = collection.getDoc(id) ?? collection.createDoc({ id });
|
||||||
|
|
||||||
const docBId = 'doc:linked-page';
|
const docBId = 'doc:linked-page';
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { RefNodeSlotsProvider } from '@blocksuite/affine-components/rich-text';
|
import { RefNodeSlotsProvider } from '@blocksuite/affine-components/rich-text';
|
||||||
import { AffineEditorContainer } from '@blocksuite/presets';
|
import { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
export const multiEditor: InitFn = (collection: DocCollection, id: string) => {
|
export const multiEditor: InitFn = (collection: Workspace, id: string) => {
|
||||||
const doc = collection.createDoc({ id });
|
const doc = collection.createDoc({ id });
|
||||||
doc.load(() => {
|
doc.load(() => {
|
||||||
// Add root block and surface block at root level
|
// Add root block and surface block at root level
|
||||||
@@ -48,7 +48,7 @@ multiEditor.displayName = 'Multiple Editor Example';
|
|||||||
multiEditor.description = 'Multiple Editor basic example';
|
multiEditor.description = 'Multiple Editor basic example';
|
||||||
|
|
||||||
export const multiEditorVertical: InitFn = (
|
export const multiEditorVertical: InitFn = (
|
||||||
collection: DocCollection,
|
collection: Workspace,
|
||||||
docId: string
|
docId: string
|
||||||
) => {
|
) => {
|
||||||
const doc = collection.createDoc({ id: docId });
|
const doc = collection.createDoc({ id: docId });
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
export const pendingStructs: InitFn = (
|
export const pendingStructs: InitFn = (collection: Workspace, id: string) => {
|
||||||
collection: DocCollection,
|
|
||||||
id: string
|
|
||||||
) => {
|
|
||||||
const doc = collection.createDoc({ id });
|
const doc = collection.createDoc({ id });
|
||||||
const tempDoc = collection.createDoc({ id: 'tempDoc' });
|
const tempDoc = collection.createDoc({ id: 'tempDoc' });
|
||||||
doc.load();
|
doc.load();
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { MarkdownTransformer } from '@blocksuite/blocks';
|
import { MarkdownTransformer } from '@blocksuite/blocks';
|
||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
const presetMarkdown = `Click the 🔁 button to switch between editors dynamically - they are fully compatible!`;
|
const presetMarkdown = `Click the 🔁 button to switch between editors dynamically - they are fully compatible!`;
|
||||||
|
|
||||||
export const preset: InitFn = async (collection: DocCollection, id: string) => {
|
export const preset: InitFn = async (collection: Workspace, id: string) => {
|
||||||
const doc = collection.createDoc({ id });
|
const doc = collection.createDoc({ id });
|
||||||
doc.load();
|
doc.load();
|
||||||
// Add root block and surface block at root level
|
// Add root block and surface block at root level
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { MarkdownTransformer } from '@blocksuite/blocks';
|
import { MarkdownTransformer } from '@blocksuite/blocks';
|
||||||
import { type DocCollection, Text } from '@blocksuite/store';
|
import { Text, type Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { InitFn } from './utils';
|
import type { InitFn } from './utils';
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ This article has also been published [in PDF format](https://www.inkandswitch.co
|
|||||||
|
|
||||||
We welcome your feedback: [@inkandswitch](https://twitter.com/inkandswitch) or hello@inkandswitch.com.`;
|
We welcome your feedback: [@inkandswitch](https://twitter.com/inkandswitch) or hello@inkandswitch.com.`;
|
||||||
|
|
||||||
export const synced: InitFn = (collection: DocCollection, id: string) => {
|
export const synced: InitFn = (collection: Workspace, id: string) => {
|
||||||
const docMain = collection.getDoc(id) ?? collection.createDoc({ id });
|
const docMain = collection.getDoc(id) ?? collection.createDoc({ id });
|
||||||
|
|
||||||
const docSyncedPageId = 'doc:synced-page';
|
const docSyncedPageId = 'doc:synced-page';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { DocCollection } from '@blocksuite/store';
|
import type { Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
export interface InitFn {
|
export interface InitFn {
|
||||||
(collection: DocCollection, docId: string): Promise<void> | void;
|
(collection: Workspace, docId: string): Promise<void> | void;
|
||||||
id: string;
|
id: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import type { DocCollection } from '@blocksuite/store';
|
import type { Workspace } from '@blocksuite/store';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
import type { InitFn } from './utils.js';
|
import type { InitFn } from './utils.js';
|
||||||
|
|
||||||
export const versionMismatch: InitFn = (
|
export const versionMismatch: InitFn = (collection: Workspace, id: string) => {
|
||||||
collection: DocCollection,
|
|
||||||
id: string
|
|
||||||
) => {
|
|
||||||
const doc = collection.createDoc({ id });
|
const doc = collection.createDoc({ id });
|
||||||
const tempDoc = collection.createDoc({ id: 'tempDoc' });
|
const tempDoc = collection.createDoc({ id: 'tempDoc' });
|
||||||
doc.load();
|
doc.load();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import '../../style.css';
|
|||||||
import '../dev-format.js';
|
import '../dev-format.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type ExtensionType,
|
|
||||||
WidgetViewMapExtension,
|
WidgetViewMapExtension,
|
||||||
WidgetViewMapIdentifier,
|
WidgetViewMapIdentifier,
|
||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
@@ -19,6 +18,7 @@ import { effects as blocksEffects } from '@blocksuite/blocks/effects';
|
|||||||
import * as globalUtils from '@blocksuite/global/utils';
|
import * as globalUtils from '@blocksuite/global/utils';
|
||||||
import * as editor from '@blocksuite/presets';
|
import * as editor from '@blocksuite/presets';
|
||||||
import { effects as presetsEffects } from '@blocksuite/presets/effects';
|
import { effects as presetsEffects } from '@blocksuite/presets/effects';
|
||||||
|
import type { ExtensionType } from '@blocksuite/store';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import * as store from '@blocksuite/store';
|
import * as store from '@blocksuite/store';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { AffineSchemas, SpecProvider, TestUtils } from '@blocksuite/blocks';
|
import { AffineSchemas, SpecProvider, TestUtils } from '@blocksuite/blocks';
|
||||||
import type { BlockSuiteFlags } from '@blocksuite/global/types';
|
import type { BlockSuiteFlags } from '@blocksuite/global/types';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { Job, nanoid, Schema } from '@blocksuite/store';
|
||||||
import { type BlockCollection, Job, nanoid, Schema } from '@blocksuite/store';
|
|
||||||
import {
|
import {
|
||||||
createAutoIncrementIdGenerator,
|
createAutoIncrementIdGenerator,
|
||||||
type DocCollectionOptions,
|
type DocCollectionOptions,
|
||||||
@@ -50,7 +49,7 @@ export function createStarterDocCollection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const flags: Partial<BlockSuiteFlags> = Object.fromEntries(
|
const flags: Partial<BlockSuiteFlags> = Object.fromEntries(
|
||||||
[...params.entries()]
|
Array.from(params.entries())
|
||||||
.filter(([key]) => key.startsWith('enable_'))
|
.filter(([key]) => key.startsWith('enable_'))
|
||||||
.map(([k, v]) => [k, v === 'true'])
|
.map(([k, v]) => [k, v === 'true'])
|
||||||
);
|
);
|
||||||
@@ -98,32 +97,6 @@ export function createStarterDocCollection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function initStarterDocCollection(collection: TestWorkspace) {
|
export async function initStarterDocCollection(collection: TestWorkspace) {
|
||||||
// init from other clients
|
|
||||||
if (room && !params.has('init')) {
|
|
||||||
const firstCollection = collection.docs.values().next().value as
|
|
||||||
| BlockCollection
|
|
||||||
| undefined;
|
|
||||||
let firstDoc = firstCollection?.getDoc();
|
|
||||||
if (!firstDoc) {
|
|
||||||
await new Promise<string>(resolve =>
|
|
||||||
collection.slots.docCreated.once(resolve)
|
|
||||||
);
|
|
||||||
const firstCollection = collection.docs.values().next().value as
|
|
||||||
| BlockCollection
|
|
||||||
| undefined;
|
|
||||||
firstDoc = firstCollection?.getDoc();
|
|
||||||
}
|
|
||||||
assertExists(firstDoc);
|
|
||||||
const doc = firstDoc;
|
|
||||||
|
|
||||||
doc.load();
|
|
||||||
if (!doc.root) {
|
|
||||||
await new Promise(resolve => doc.slots.rootAdded.once(resolve));
|
|
||||||
}
|
|
||||||
doc.resetHistory();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use built-in init function
|
// use built-in init function
|
||||||
const functionMap = new Map<
|
const functionMap = new Map<
|
||||||
string,
|
string,
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import {
|
import { BlockServiceWatcher, type EditorHost } from '@blocksuite/block-std';
|
||||||
BlockServiceWatcher,
|
|
||||||
type EditorHost,
|
|
||||||
type ExtensionType,
|
|
||||||
} from '@blocksuite/block-std';
|
|
||||||
import {
|
import {
|
||||||
AffineFormatBarWidget,
|
AffineFormatBarWidget,
|
||||||
CommunityCanvasTextFonts,
|
CommunityCanvasTextFonts,
|
||||||
@@ -19,7 +15,7 @@ import {
|
|||||||
toolbarDefaultConfig,
|
toolbarDefaultConfig,
|
||||||
} from '@blocksuite/blocks';
|
} from '@blocksuite/blocks';
|
||||||
import { AffineEditorContainer, CommentPanel } from '@blocksuite/presets';
|
import { AffineEditorContainer, CommentPanel } from '@blocksuite/presets';
|
||||||
import type { DocCollection } from '@blocksuite/store';
|
import type { ExtensionType, Workspace } from '@blocksuite/store';
|
||||||
|
|
||||||
import { AttachmentViewerPanel } from '../../_common/components/attachment-viewer-panel.js';
|
import { AttachmentViewerPanel } from '../../_common/components/attachment-viewer-panel.js';
|
||||||
import { CustomFramePanel } from '../../_common/components/custom-frame-panel.js';
|
import { CustomFramePanel } from '../../_common/components/custom-frame-panel.js';
|
||||||
@@ -47,7 +43,7 @@ function configureFormatBar(formatBar: AffineFormatBarWidget) {
|
|||||||
toolbarDefaultConfig(formatBar);
|
toolbarDefaultConfig(formatBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mountDefaultDocEditor(collection: DocCollection) {
|
export async function mountDefaultDocEditor(collection: Workspace) {
|
||||||
const app = document.getElementById('app');
|
const app = document.getElementById('app');
|
||||||
if (!app) return;
|
if (!app) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user