From 694158eea3d2b04fb68a80f3207940954d4c6dcc Mon Sep 17 00:00:00 2001 From: Whitewater Date: Sun, 3 May 2026 23:33:41 +0800 Subject: [PATCH] feat(playground): export Y.Doc from debug menu (#14893) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - add an Export Y.Doc debug menu item - encode the active store spaceDoc with Y.encodeStateAsUpdate - download the update as a binary ydoc-update file ## Test - yarn workspace @blocksuite/playground build ## Summary by CodeRabbit * **New Features** * Added Y.Doc export functionality to the debug menu, enabling users to download the current space document state as a binary update file through the "Test Operations" → "Export" menu. --- .../apps/_common/components/starter-debug-menu.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/blocksuite/playground/apps/_common/components/starter-debug-menu.ts b/blocksuite/playground/apps/_common/components/starter-debug-menu.ts index 00419c226..f6990a7c2 100644 --- a/blocksuite/playground/apps/_common/components/starter-debug-menu.ts +++ b/blocksuite/playground/apps/_common/components/starter-debug-menu.ts @@ -70,6 +70,7 @@ import { css, html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import * as lz from 'lz-string'; import type { Pane } from 'tweakpane'; +import * as Y from 'yjs'; import type { CommentPanel } from '../../comment/index.js'; import { createTestEditor } from '../../starter/utils/extensions.js'; @@ -337,6 +338,14 @@ export class StarterDebugMenu extends ShadowlessElement { ); } + private _exportYDoc() { + const encodeUpdate = Y.encodeStateAsUpdate(this.doc.spaceDoc); + const blob = new Blob([new Uint8Array(encodeUpdate)], { + type: 'application/octet-stream', + }); + download(blob, 'ydoc-update'); + } + private _getStoreManager() { return this.editor.std.get(StoreExtensionManagerIdentifier); } @@ -834,6 +843,9 @@ export class StarterDebugMenu extends ShadowlessElement { Export Snapshot + + Export Y.Doc +