Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore(editor): rename std.doc to std.store (#9596)

Saul-Mironed21ef47ae835
diff --git a/blocksuite/affine/block-attachment/src/utils.ts b/blocksuite/affine/block-attachment/src/utils.ts
index 5ed02be23b..c22e337a51 100644
--- a/blocksuite/affine/block-attachment/src/utils.ts
+++ b/blocksuite/affine/block-attachment/src/utils.ts
@@ -303,7 +303,7 @@ export async function addAttachments(
EMBED_CARD_WIDTH.cubeThick,
EMBED_CARD_HEIGHT.cubeThick
);
- const blockId = std.doc.addBlock(
+ const blockId = std.store.addBlock(
'affine:attachment',
{
name: file.name,
diff --git a/blocksuite/affine/block-code/src/clipboard/index.ts b/blocksuite/affine/block-code/src/clipboard/index.ts
index 3257ec4929..cc1dbce1cb 100644
--- a/blocksuite/affine/block-code/src/clipboard/index.ts
+++ b/blocksuite/affine/block-code/src/clipboard/index.ts
@@ -36,7 +36,7 @@ export class CodeClipboardController {
const e = ctx.get('clipboardState').raw;
e.preventDefault();
- this._std.doc.captureSync();
+ this._std.store.captureSync();
this._std.command
.chain()
.try(cmd => [
@@ -63,7 +63,7 @@ export class CodeClipboardController {
this._clipboard
.paste(
e,
- this._std.doc,
+ this._std.store,
ctx.parentBlock.model.id,
ctx.blockIndex ? ctx.blockIndex + 1 : 1
)
diff --git a/blocksuite/affine/block-database/src/commands.ts b/blocksuite/affine/block-database/src/commands.ts
index d002bf46c2..d051b3ab69 100644
--- a/blocksuite/affine/block-database/src/commands.ts
+++ b/blocksuite/affine/block-database/src/commands.ts
@@ -20,17 +20,17 @@ export const insertDatabaseBlockCommand: Command<
const service = std.getService('affine:database');
if (!service) return;
- const result = std.doc.addSiblingBlocks(
+ const result = std.store.addSiblingBlocks(
targetModel,
[{ flavour: 'affine:database' }],
place
);
if (result.length === 0) return;
- service.initDatabaseBlock(std.doc, targetModel, result[0], viewType, false);
+ service.initDatabaseBlock(std.store, targetModel, result[0], viewType, false);
if (removeEmptyLine && targetModel.text?.length === 0) {
- std.doc.deleteBlock(targetModel);
+ std.store.deleteBlock(targetModel);
}
next({ insertedDatabaseBlockId: result[0] });
diff --git a/blocksuite/affine/block-embed/src/common/insert-embed-card.ts b/blocksuite/affine/block-embed/src/common/insert-embed-card.ts
index 8b14053bce..82add7b2fb 100644
--- a/blocksuite/affine/block-embed/src/common/insert-embed-card.ts
+++ b/blocksuite/affine/block-embed/src/common/insert-embed-card.ts
@@ -50,7 +50,7 @@ export function insertEmbedCard(
const index = parent.children.indexOf(block.model);
host.doc.addBlock(flavour as never, props, parent, index + 1);
} else {
- const rootId = std.doc.root?.id;
+ const rootId = std.store.root?.id;
if (!rootId) return;
const edgelessRoot = std.view.getBlock(rootId);
if (!edgelessRoot) return;
diff --git a/blocksuite/affine/block-image/src/commands/insert-images.ts b/blocksuite/affine/block-image/src/commands/insert-images.ts
index 2cd4e511e9..2a1234c033 100644
--- a/blocksuite/affine/block-image/src/commands/insert-images.ts
+++ b/blocksuite/affine/block-image/src/commands/insert-images.ts
@@ -35,7 +35,7 @@ export const insertImagesCommand: Command<
place
);
if (removeEmptyLine && targetModel.text?.length === 0) {
- std.doc.deleteBlock(targetModel);
+ std.store.deleteBlock(targetModel);
}
return result ?? [];
diff --git a/blocksuite/affine/block-image/src/utils.ts b/blocksuite/affine/block-image/src/utils.ts
index 1c4425a31f..3be3763013 100644
--- a/blocksuite/affine/block-image/src/utils.ts
+++ b/blocksuite/affine/block-image/src/utils.ts
@@ -468,7 +468,7 @@ export async function addImages(
);
const center = Vec.toVec(point);
const bound = calcBoundByOrigin(center, inTopLeft);
- const blockId = std.doc.addBlock(
+ const blockId = std.store.addBlock(
'affine:image',
{
size: file.size,
@@ -484,7 +484,7 @@ export async function addImages(
const uploadPromises = imageFiles.map(async (file, index) => {
const { point, blockId } = dropInfos[index];
- const sourceId = await std.doc.blobSync.set(file);
+ const sourceId = await std.store.blobSync.set(file);
const imageSize = await readImageSize(file);
const center = Vec.toVec(point);
@@ -498,7 +498,7 @@ export async function addImages(
: imageSize.height;
const bound = calcBoundByOrigin(center, inTopLeft, width, height);
- std.doc.withoutTransact(() => {
+ std.store.withoutTransact(() => {
gfx.updateElement(blockId, {
sourceId,
...imageSize,
diff --git a/blocksuite/affine/block-latex/src/commands.ts b/blocksuite/affine/block-latex/src/commands.ts
index 994839e002..82c92c827b 100644
--- a/blocksuite/affine/block-latex/src/commands.ts
+++ b/blocksuite/affine/block-latex/src/commands.ts
@@ -28,7 +28,7 @@ export const insertLatexBlockCommand: Command<
latex: latex ?? '',
};
- const result = std.doc.addSiblingBlocks(
+ const result = std.store.addSiblingBlocks(
targetModel,
[latexBlockProps],
place
@@ -36,7 +36,7 @@ export const insertLatexBlockCommand: Command<
if (result.length === 0) return;
if (removeEmptyLine && targetModel.text?.length === 0) {
- std.doc.deleteBlock(targetModel);
+ std.store.deleteBlock(targetModel);
}
next({
diff --git a/blocksuite/affine/block-list/src/commands/dedent-list.ts b/blocksuite/affine/block-list/src/commands/dedent-list.ts
index 7735750718..dc85196c51 100644
--- a/blocksuite/affine/block-list/src/commands/dedent-list.ts
+++ b/blocksuite/affine/block-list/src/commands/dedent-list.ts
@@ -11,7 +11,7 @@ export const canDedentListCommand: Command<
> = (ctx, next) => {
let { blockId, inlineIndex } = ctx;
const { std } = ctx;
- const { selection, doc } = std;
+ const { selection, store } = std;
if (!blockId) {
const text = selection.find(TextSelection);
/**
@@ -51,25 +51,25 @@ export const canDedentListCommand: Command<
/**
* ccc
*/
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model || !matchFlavours(model, ['affine:list'])) {
return;
}
/**
* bbb
*/
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) {
return;
}
- if (doc.readonly || parent.role !== 'content') {
+ if (store.readonly || parent.role !== 'content') {
// Top most list cannot be unindent
return;
}
/**
* aaa
*/
- const grandParent = doc.getParent(parent);
+ const grandParent = store.getParent(parent);
if (!grandParent) {
return;
}
@@ -93,7 +93,7 @@ export const canDedentListCommand: Command<
export const dedentListCommand: Command<'indentContext'> = (ctx, next) => {
const { indentContext: dedentContext, std } = ctx;
- const { doc, selection, range, host } = std;
+ const { store, selection, range, host } = std;
if (
!dedentContext ||
@@ -108,16 +108,16 @@ export const dedentListCommand: Command<'indentContext'> = (ctx, next) => {
const { blockId } = dedentContext;
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model) return;
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) return;
- const grandParent = doc.getParent(parent);
+ const grandParent = store.getParent(parent);
if (!grandParent) return;
- doc.captureSync();
+ store.captureSync();
/**
* step 1:
@@ -128,13 +128,13 @@ export const dedentListCommand: Command<'indentContext'> = (ctx, next) => {
* - eee <- make eee as ccc's child
* - fff
*/
- const nextSiblings = doc.getNexts(model); // [eee]
- doc.moveBlocks(nextSiblings, model);
+ const nextSiblings = store.getNexts(model); // [eee]
+ store.moveBlocks(nextSiblings, model);
/**
* eee
*/
const nextSibling = nextSiblings.at(0);
- if (nextSibling) correctNumberedListsOrderToPrev(doc, nextSibling);
+ if (nextSibling) correctNumberedListsOrderToPrev(store, nextSibling);
/**
* step 2:
@@ -145,8 +145,8 @@ export const dedentListCommand: Command<'indentContext'> = (ctx, next) => {
* - eee
* - fff
*/
- doc.moveBlocks([model], grandParent, parent, false);
- correctNumberedListsOrderToPrev(doc, model);
+ store.moveBlocks([model], grandParent, parent, false);
+ correctNumberedListsOrderToPrev(store, model);
const textSelection = selection.find(TextSelection);
if (textSelection) {
diff --git a/blocksuite/affine/block-list/src/commands/indent-list.ts b/blocksuite/affine/block-list/src/commands/indent-list.ts
index a6eaabdd57..ed7d6eaf2f 100644
--- a/blocksuite/affine/block-list/src/commands/indent-list.ts
+++ b/blocksuite/affine/block-list/src/commands/indent-list.ts
@@ -14,7 +14,7 @@ export const canIndentListCommand: Command<
> = (ctx, next) => {
let { blockId, inlineIndex } = ctx;
const { std } = ctx;
- const { selection, doc } = std;
+ const { selection, store } = std;
if (!blockId) {
const text = selection.find(TextSelection);
/**
@@ -52,17 +52,17 @@ export const canIndentListCommand: Command<
/**
* ccc
*/
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model || !matchFlavours(model, ['affine:list'])) {
return;
}
- const schema = std.doc.schema;
+ const schema = std.store.schema;
/**
* aaa
*/
- const previousSibling = doc.getPrev(model);
+ const previousSibling = store.getPrev(model);
if (
- doc.readonly ||
+ store.readonly ||
!previousSibling ||
!schema.isValid(model.flavour, previousSibling.flavour)
) {
@@ -72,7 +72,7 @@ export const canIndentListCommand: Command<
/**
* eee
*/
- // const nextSibling = doc.getNext(model);
+ // const nextSibling = store.getNext(model);
return next({
indentContext: {
@@ -101,21 +101,21 @@ export const indentListCommand: Command<'indentContext', never> = (
}
const { blockId } = indentContext;
- const { doc, selection, host, range } = std;
+ const { store, selection, host, range } = std;
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model) return;
- const previousSibling = doc.getPrev(model);
+ const previousSibling = store.getPrev(model);
if (!previousSibling) return;
- const nextSibling = doc.getNext(model);
+ const nextSibling = store.getNext(model);
- doc.captureSync();
+ store.captureSync();
- doc.moveBlocks([model], previousSibling);
- correctNumberedListsOrderToPrev(doc, model);
- if (nextSibling) correctNumberedListsOrderToPrev(doc, nextSibling);
+ store.moveBlocks([model], previousSibling);
+ correctNumberedListsOrderToPrev(store, model);
+ if (nextSibling) correctNumberedListsOrderToPrev(store, nextSibling);
// 123
// > # 456
@@ -128,7 +128,7 @@ export const indentListCommand: Command<'indentContext', never> = (
matchFlavours(nearestHeading, ['affine:paragraph']) &&
nearestHeading.collapsed
) {
- doc.updateBlock(nearestHeading, {
+ store.updateBlock(nearestHeading, {
collapsed: false,
});
}
diff --git a/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts b/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts
index bbfb041f22..21ce5246ca 100644
--- a/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts
+++ b/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts
@@ -12,7 +12,7 @@ export const listToParagraphCommand: Command<
> = (ctx, next) => {
const { id, stopCapturing = true } = ctx;
const std = ctx.std;
- const doc = std.doc;
+ const doc = std.store;
const model = doc.getBlock(id)?.model;
if (!model || !matchFlavours(model, ['affine:list'])) return false;
@@ -26,7 +26,7 @@ export const listToParagraphCommand: Command<
text: model.text?.clone(),
children: model.children,
};
- if (stopCapturing) std.doc.captureSync();
+ if (stopCapturing) std.store.captureSync();
doc.deleteBlock(model, {
deleteChildren: false,
});
diff --git a/blocksuite/affine/block-list/src/utils/forward-delete.ts b/blocksuite/affine/block-list/src/utils/forward-delete.ts
index 6874df900a..b71235df8f 100644
--- a/blocksuite/affine/block-list/src/utils/forward-delete.ts
+++ b/blocksuite/affine/block-list/src/utils/forward-delete.ts
@@ -23,7 +23,7 @@ export function forwardDelete(std: BlockStdScope): true | undefined {
const text = std.selection.find(TextSelection);
if (!text) return;
const isCollapsed = text.isCollapsed();
- const doc = std.doc;
+ const doc = std.store;
const model = doc.getBlock(text.from.blockId)?.model;
if (!model || !matchFlavours(model, ['affine:list'])) return;
const isEnd = isCollapsed && text.from.index === model.text.length;
diff --git a/blocksuite/affine/block-note/src/commands/block-type.ts b/blocksuite/affine/block-note/src/commands/block-type.ts
index 7f182b05aa..9ea10e6304 100644
--- a/blocksuite/affine/block-note/src/commands/block-type.ts
+++ b/blocksuite/affine/block-note/src/commands/block-type.ts
@@ -27,7 +27,7 @@ export const updateBlockType: Command<
> = (ctx, next) => {
const { std, flavour, props } = ctx;
const host = std.host;
- const doc = std.doc;
+ const doc = std.store;
const getSelectedBlocks = () => {
let { selectedBlocks } = ctx;
diff --git a/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts b/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts
index a2976cb50a..c810317112 100644
--- a/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts
+++ b/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts
@@ -11,24 +11,24 @@ export const dedentBlockToRoot: Command<
> = (ctx, next) => {
let { blockId } = ctx;
const { std, stopCapture = true } = ctx;
- const { doc } = std;
+ const { store } = std;
if (!blockId) {
const sel = std.selection.getGroup('note').at(0);
blockId = sel?.blockId;
}
if (!blockId) return;
- const model = std.doc.getBlock(blockId)?.model;
+ const model = std.store.getBlock(blockId)?.model;
if (!model) return;
- let parent = doc.getParent(model);
+ let parent = store.getParent(model);
let changed = false;
while (parent && !matchFlavours(parent, ['affine:note'])) {
if (!changed) {
- if (stopCapture) doc.captureSync();
+ if (stopCapture) store.captureSync();
changed = true;
}
std.command.exec('dedentBlock', { blockId: model.id, stopCapture: true });
- parent = doc.getParent(model);
+ parent = store.getParent(model);
}
if (!changed) {
diff --git a/blocksuite/affine/block-note/src/commands/dedent-block.ts b/blocksuite/affine/block-note/src/commands/dedent-block.ts
index 9944272c29..a761168e96 100644
--- a/blocksuite/affine/block-note/src/commands/dedent-block.ts
+++ b/blocksuite/affine/block-note/src/commands/dedent-block.ts
@@ -30,23 +30,23 @@ export const dedentBlock: Command<
> = (ctx, next) => {
let { blockId } = ctx;
const { std, stopCapture = true } = ctx;
- const { doc } = std;
+ const { store } = std;
if (!blockId) {
const sel = std.selection.getGroup('note').at(0);
blockId = sel?.blockId;
}
if (!blockId) return;
- const model = std.doc.getBlock(blockId)?.model;
+ const model = std.store.getBlock(blockId)?.model;
if (!model) return;
- const parent = doc.getParent(model);
- const grandParent = parent && doc.getParent(parent);
- if (doc.readonly || !parent || parent.role !== 'content' || !grandParent) {
+ const parent = store.getParent(model);
+ const grandParent = parent && store.getParent(parent);
+ if (store.readonly || !parent || parent.role !== 'content' || !grandParent) {
// Top most, can not unindent, do nothing
return;
}
- if (stopCapture) doc.captureSync();
+ if (stopCapture) store.captureSync();
if (
matchFlavours(model, ['affine:paragraph']) &&
@@ -54,14 +54,14 @@ export const dedentBlock: Command<
model.collapsed
) {
const collapsedSiblings = calculateCollapsedSiblings(model);
- doc.moveBlocks([model, ...collapsedSiblings], grandParent, parent, false);
+ store.moveBlocks([model, ...collapsedSiblings], grandParent, parent, false);
return next();
}
try {
- const nextSiblings = doc.getNexts(model);
- doc.moveBlocks(nextSiblings, model);
- doc.moveBlocks([model], grandParent, parent, false);
+ const nextSiblings = store.getNexts(model);
+ store.moveBlocks(nextSiblings, model);
+ store.moveBlocks([model], grandParent, parent, false);
} catch {
return;
}
diff --git a/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts b/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts
index 4f2ca3e931..ec679ea62a 100644
--- a/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts
+++ b/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts
@@ -11,7 +11,7 @@ export const dedentBlocksToRoot: Command<
> = (ctx, next) => {
let { blockIds } = ctx;
const { std, stopCapture = true } = ctx;
- const { doc } = std;
+ const { store } = std;
if (!blockIds || !blockIds.length) {
const text = std.selection.find(TextSelection);
if (text) {
@@ -26,12 +26,12 @@ export const dedentBlocksToRoot: Command<
}
}
- if (!blockIds || !blockIds.length || doc.readonly) return;
+ if (!blockIds || !blockIds.length || store.readonly) return;
- if (stopCapture) doc.captureSync();
+ if (stopCapture) store.captureSync();
for (let i = blockIds.length - 1; i >= 0; i--) {
const model = blockIds[i];
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (parent && !matchFlavours(parent, ['affine:note'])) {
std.command.exec('dedentBlockToRoot', {
blockId: model,
diff --git a/blocksuite/affine/block-note/src/commands/dedent-blocks.ts b/blocksuite/affine/block-note/src/commands/dedent-blocks.ts
index 9e5c3ef146..69b89bc447 100644
--- a/blocksuite/affine/block-note/src/commands/dedent-blocks.ts
+++ b/blocksuite/affine/block-note/src/commands/dedent-blocks.ts
@@ -14,8 +14,8 @@ export const dedentBlocks: Command<
> = (ctx, next) => {
let { blockIds } = ctx;
const { std, stopCapture = true } = ctx;
- const { doc, selection, range, host } = std;
- const { schema } = doc;
+ const { store, selection, range, host } = std;
+ const { schema } = store;
if (!blockIds || !blockIds.length) {
const nativeRange = range.value;
@@ -32,16 +32,16 @@ export const dedentBlocks: Command<
}
}
- if (!blockIds || !blockIds.length || doc.readonly) return;
+ if (!blockIds || !blockIds.length || store.readonly) return;
// Find the first model that can be unindented
let firstDedentIndex = -1;
for (let i = 0; i < blockIds.length; i++) {
- const model = doc.getBlock(blockIds[i])?.model;
+ const model = store.getBlock(blockIds[i])?.model;
if (!model) continue;
- const parent = doc.getParent(blockIds[i]);
+ const parent = store.getParent(blockIds[i]);
if (!parent) continue;
- const grandParent = doc.getParent(parent);
+ const grandParent = store.getParent(parent);
if (!grandParent) continue;
if (schema.isValid(model.flavour, grandParent.flavour)) {
@@ -52,11 +52,11 @@ export const dedentBlocks: Command<
if (firstDedentIndex === -1) return;
- if (stopCapture) doc.captureSync();
+ if (stopCapture) store.captureSync();
const collapsedIds: string[] = [];
blockIds.slice(firstDedentIndex).forEach(id => {
- const model = doc.getBlock(id)?.model;
+ const model = store.getBlock(id)?.model;
if (!model) return;
if (
matchFlavours(model, ['affine:paragraph']) &&
diff --git a/blocksuite/affine/block-note/src/commands/indent-block.ts b/blocksuite/affine/block-note/src/commands/indent-block.ts
index 56d4095d30..5d9e6c1597 100644
--- a/blocksuite/affine/block-note/src/commands/indent-block.ts
+++ b/blocksuite/affine/block-note/src/commands/indent-block.ts
@@ -31,19 +31,19 @@ export const indentBlock: Command<
> = (ctx, next) => {
let { blockId } = ctx;
const { std, stopCapture = true } = ctx;
- const { doc } = std;
- const { schema } = doc;
+ const { store } = std;
+ const { schema } = store;
if (!blockId) {
const sel = std.selection.getGroup('note').at(0);
blockId = sel?.blockId;
}
if (!blockId) return;
- const model = std.doc.getBlock(blockId)?.model;
+ const model = std.store.getBlock(blockId)?.model;
if (!model) return;
- const previousSibling = doc.getPrev(model);
+ const previousSibling = store.getPrev(model);
if (
- doc.readonly ||
+ store.readonly ||
!previousSibling ||
!schema.isValid(model.flavour, previousSibling.flavour)
) {
@@ -51,7 +51,7 @@ export const indentBlock: Command<
return;
}
- if (stopCapture) doc.captureSync();
+ if (stopCapture) store.captureSync();
if (
matchFlavours(model, ['affine:paragraph']) &&
@@ -59,9 +59,9 @@ export const indentBlock: Command<
model.collapsed
) {
const collapsedSiblings = calculateCollapsedSiblings(model);
- doc.moveBlocks([model, ...collapsedSiblings], previousSibling);
+ store.moveBlocks([model, ...collapsedSiblings], previousSibling);
} else {
- doc.moveBlocks([model], previousSibling);
+ store.moveBlocks([model], previousSibling);
}
// update collapsed state of affine list
@@ -69,7 +69,7 @@ export const indentBlock: Command<
matchFlavours(previousSibling, ['affine:list']) &&
previousSibling.collapsed
) {
- doc.updateBlock(previousSibling, {
+ store.updateBlock(previousSibling, {
collapsed: false,
} as Partial<ListBlockModel>);
}
diff --git a/blocksuite/affine/block-note/src/commands/indent-blocks.ts b/blocksuite/affine/block-note/src/commands/indent-blocks.ts
index c8cc90cbf3..3f093696cc 100644
--- a/blocksuite/affine/block-note/src/commands/indent-blocks.ts
+++ b/blocksuite/affine/block-note/src/commands/indent-blocks.ts
@@ -15,8 +15,8 @@ export const indentBlocks: Command<
> = (ctx, next) => {
let { blockIds } = ctx;
const { std, stopCapture = true } = ctx;
- const { doc, selection, range, host } = std;
- const { schema } = doc;
+ const { store, selection, range, host } = std;
+ const { schema } = store;
if (!blockIds || !blockIds.length) {
const nativeRange = range.value;
@@ -33,13 +33,13 @@ export const indentBlocks: Command<
}
}
- if (!blockIds || !blockIds.length || doc.readonly) return;
+ if (!blockIds || !blockIds.length || store.readonly) return;
// Find the first model that can be indented
let firstIndentIndex = -1;
for (let i = 0; i < blockIds.length; i++) {
- const previousSibling = doc.getPrev(blockIds[i]);
- const model = doc.getBlock(blockIds[i])?.model;
+ const previousSibling = store.getPrev(blockIds[i]);
+ const model = store.getBlock(blockIds[i])?.model;
if (
model &&
previousSibling &&
@@ -53,11 +53,11 @@ export const indentBlocks: Command<
// No model can be indented
if (firstIndentIndex === -1) return;
- if (stopCapture) doc.captureSync();
+ if (stopCapture) store.captureSync();
const collapsedIds: string[] = [];
blockIds.slice(firstIndentIndex).forEach(id => {
- const model = doc.getBlock(id)?.model;
+ const model = store.getBlock(id)?.model;
if (!model) return;
if (
matchFlavours(model, ['affine:paragraph']) &&
@@ -72,7 +72,7 @@ export const indentBlocks: Command<
const indentIds = blockIds
.slice(firstIndentIndex)
.filter(id => !collapsedIds.includes(id));
- const firstModel = doc.getBlock(indentIds[0])?.model;
+ const firstModel = store.getBlock(indentIds[0])?.model;
if (!firstModel) return;
{
@@ -88,7 +88,7 @@ export const indentBlocks: Command<
matchFlavours(nearestHeading, ['affine:paragraph']) &&
nearestHeading.collapsed
) {
- doc.updateBlock(nearestHeading, {
+ store.updateBlock(nearestHeading, {
collapsed: false,
});
}
@@ -111,7 +111,7 @@ export const indentBlocks: Command<
matchFlavours(nearestHeading, ['affine:paragraph']) &&
nearestHeading.collapsed
) {
- doc.updateBlock(nearestHeading, {
+ store.updateBlock(nearestHeading, {
collapsed: false,
});
}
diff --git a/blocksuite/affine/block-note/src/move-block.ts b/blocksuite/affine/block-note/src/move-block.ts
index 36e0da8348..364563a4e8 100644
--- a/blocksuite/affine/block-note/src/move-block.ts
+++ b/blocksuite/affine/block-note/src/move-block.ts
@@ -32,7 +32,7 @@ export const moveBlockConfigs: MoveBlockConfig[] = [
name: 'Move Up',
hotkey: ['Mod-Alt-ArrowUp', 'Mod-Shift-ArrowUp'],
action: std => {
- const doc = std.doc;
+ const doc = std.store;
const textSelection = getTextSelection(std);
if (textSelection) {
const currentModel = pathToBlock(
@@ -44,10 +44,10 @@ export const moveBlockConfigs: MoveBlockConfig[] = [
const previousSiblingModel = doc.getPrev(currentModel);
if (!previousSiblingModel) return;
- const parentModel = std.doc.getParent(previousSiblingModel);
+ const parentModel = std.store.getParent(previousSiblingModel);
if (!parentModel) return;
- std.doc.moveBlocks(
+ std.store.moveBlocks(
[currentModel],
parentModel,
previousSiblingModel,
@@ -86,7 +86,7 @@ export const moveBlockConfigs: MoveBlockConfig[] = [
name: 'Move Down',
hotkey: ['Mod-Alt-ArrowDown', 'Mod-Shift-ArrowDown'],
action: std => {
- const doc = std.doc;
+ const doc = std.store;
const textSelection = getTextSelection(std);
if (textSelection) {
const currentModel = pathToBlock(
diff --git a/blocksuite/affine/block-note/src/note-service.ts b/blocksuite/affine/block-note/src/note-service.ts
index 83d520f4a9..c17882c5e0 100644
--- a/blocksuite/affine/block-note/src/note-service.ts
+++ b/blocksuite/affine/block-note/src/note-service.ts
@@ -130,7 +130,7 @@ export class NoteBlockService extends BlockService {
private _focusBlock: BlockComponent | null = null;
private readonly _getClosestNoteByBlockId = (blockId: string) => {
- const doc = this._std.doc;
+ const doc = this._std.store;
let parent = doc.getBlock(blockId)?.model ?? null;
while (parent) {
if (matchFlavours(parent, [NoteBlockSchema.model.flavour])) {
@@ -423,7 +423,7 @@ export class NoteBlockService extends BlockService {
return;
}
- const { view, doc, selection } = ctx.std;
+ const { view, store, selection } = ctx.std;
const element = view.getBlock(blockSelection.blockId);
if (!element) {
@@ -431,14 +431,19 @@ export class NoteBlockService extends BlockService {
}
const { model } = element;
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) {
return;
}
const index = parent.children.indexOf(model) ?? undefined;
- const blockId = doc.addBlock('affine:paragraph', {}, parent, index + 1);
+ const blockId = store.addBlock(
+ 'affine:paragraph',
+ {},
+ parent,
+ index + 1
+ );
const sel = selection.create(TextSelection, {
from: {
diff --git a/blocksuite/affine/block-note/src/quick-action.ts b/blocksuite/affine/block-note/src/quick-action.ts
index a78adadd65..1cdc9d7dd6 100644
--- a/blocksuite/affine/block-note/src/quick-action.ts
+++ b/blocksuite/affine/block-note/src/quick-action.ts
@@ -43,7 +43,7 @@ export const quickActionConfig: QuickActionConfig[] = [
std.selection.clear();
- const doc = std.doc;
+ const doc = std.store;
const autofill = getTitleFromSelectedModels(selectedModels);
promptDocTitle(std, autofill)
.then(title => {
diff --git a/blocksuite/affine/block-paragraph/src/commands/add-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/add-paragraph.ts
index a3634f8ea7..48f2bd992f 100644
--- a/blocksuite/affine/block-paragraph/src/commands/add-paragraph.ts
+++ b/blocksuite/affine/block-paragraph/src/commands/add-paragraph.ts
@@ -12,8 +12,8 @@ export const addParagraphCommand: Command<
}
> = (ctx, next) => {
const { std } = ctx;
- const { doc, selection } = std;
- doc.captureSync();
+ const { store, selection } = std;
+ store.captureSync();
let blockId = ctx.blockId;
if (!blockId) {
@@ -22,7 +22,7 @@ export const addParagraphCommand: Command<
}
if (!blockId) return;
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model) return;
let id: string;
@@ -35,9 +35,9 @@ export const addParagraphCommand: Command<
// aaa
// |
// bbb
- id = doc.addBlock('affine:paragraph', {}, model, 0);
+ id = store.addBlock('affine:paragraph', {}, model, 0);
} else {
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) return;
const index = parent.children.indexOf(model);
if (index < 0) return;
@@ -47,7 +47,7 @@ export const addParagraphCommand: Command<
// after:
// aaa
// |
- id = doc.addBlock('affine:paragraph', {}, parent, index + 1);
+ id = store.addBlock('affine:paragraph', {}, parent, index + 1);
}
focusTextModel(std, id);
diff --git a/blocksuite/affine/block-paragraph/src/commands/append-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/append-paragraph.ts
index 3489fc9cc7..029ccfce9f 100644
--- a/blocksuite/affine/block-paragraph/src/commands/append-paragraph.ts
+++ b/blocksuite/affine/block-paragraph/src/commands/append-paragraph.ts
@@ -12,15 +12,19 @@ export const appendParagraphCommand: Command<
{ text?: string }
> = (ctx, next) => {
const { std, text = '' } = ctx;
- const { doc } = std;
- if (!doc.root) return;
+ const { store } = std;
+ if (!store.root) return;
- const note = getLastNoteBlock(doc);
+ const note = getLastNoteBlock(store);
let noteId = note?.id;
if (!noteId) {
- noteId = doc.addBlock('affine:note', {}, doc.root.id);
+ noteId = store.addBlock('affine:note', {}, store.root.id);
}
- const id = doc.addBlock('affine:paragraph', { text: new Text(text) }, noteId);
+ const id = store.addBlock(
+ 'affine:paragraph',
+ { text: new Text(text) },
+ noteId
+ );
focusTextModel(std, id, text.length);
next();
diff --git a/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts
index 02a310fa13..1f804c9c5b 100644
--- a/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts
+++ b/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts
@@ -12,7 +12,7 @@ export const canDedentParagraphCommand: Command<
> = (ctx, next) => {
let { blockId, inlineIndex } = ctx;
const { std } = ctx;
- const { selection, doc } = std;
+ const { selection, store } = std;
const text = selection.find(TextSelection);
if (!blockId) {
@@ -32,18 +32,18 @@ export const canDedentParagraphCommand: Command<
return;
}
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) {
return;
}
- const parent = doc.getParent(model);
- if (doc.readonly || !parent || parent.role !== 'content') {
+ const parent = store.getParent(model);
+ if (store.readonly || !parent || parent.role !== 'content') {
// Top most, can not unindent, do nothing
return;
}
- const grandParent = doc.getParent(parent);
+ const grandParent = store.getParent(parent);
if (!grandParent) return;
return next({
@@ -58,7 +58,7 @@ export const canDedentParagraphCommand: Command<
export const dedentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
const { indentContext: dedentContext, std } = ctx;
- const { doc, selection, range, host } = std;
+ const { store, selection, range, host } = std;
if (
!dedentContext ||
@@ -73,16 +73,16 @@ export const dedentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
const { blockId } = dedentContext;
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model) return;
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) return;
- const grandParent = doc.getParent(parent);
+ const grandParent = store.getParent(parent);
if (!grandParent) return;
- doc.captureSync();
+ store.captureSync();
if (
matchFlavours(model, ['affine:paragraph']) &&
@@ -90,11 +90,11 @@ export const dedentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
model.collapsed
) {
const collapsedSiblings = calculateCollapsedSiblings(model);
- doc.moveBlocks([model, ...collapsedSiblings], grandParent, parent, false);
+ store.moveBlocks([model, ...collapsedSiblings], grandParent, parent, false);
} else {
- const nextSiblings = doc.getNexts(model);
- doc.moveBlocks(nextSiblings, model);
- doc.moveBlocks([model], grandParent, parent, false);
+ const nextSiblings = store.getNexts(model);
+ store.moveBlocks(nextSiblings, model);
+ store.moveBlocks([model], grandParent, parent, false);
}
const textSelection = selection.find(TextSelection);
diff --git a/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts
index 3bbb5f2cd4..592dd421d1 100644
--- a/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts
+++ b/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts
@@ -14,8 +14,8 @@ export const canIndentParagraphCommand: Command<
> = (cxt, next) => {
let { blockId, inlineIndex } = cxt;
const { std } = cxt;
- const { selection, doc } = std;
- const { schema } = doc;
+ const { selection, store } = std;
+ const { schema } = store;
if (!blockId) {
const text = selection.find(TextSelection);
@@ -35,14 +35,14 @@ export const canIndentParagraphCommand: Command<
return;
}
- const model = std.doc.getBlock(blockId)?.model;
+ const model = std.store.getBlock(blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) {
return;
}
- const previousSibling = doc.getPrev(model);
+ const previousSibling = store.getPrev(model);
if (
- doc.readonly ||
+ store.readonly ||
!previousSibling ||
!schema.isValid(model.flavour, previousSibling.flavour)
) {
@@ -62,7 +62,7 @@ export const canIndentParagraphCommand: Command<
export const indentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
const { indentContext, std } = ctx;
- const { doc, selection, host, range } = std;
+ const { store, selection, host, range } = std;
if (
!indentContext ||
@@ -76,13 +76,13 @@ export const indentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
}
const { blockId } = indentContext;
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model) return;
- const previousSibling = doc.getPrev(model);
+ const previousSibling = store.getPrev(model);
if (!previousSibling) return;
- doc.captureSync();
+ store.captureSync();
{
// > # 123
@@ -95,7 +95,7 @@ export const indentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
matchFlavours(nearestHeading, ['affine:paragraph']) &&
nearestHeading.collapsed
) {
- doc.updateBlock(nearestHeading, {
+ store.updateBlock(nearestHeading, {
collapsed: false,
});
}
@@ -107,9 +107,9 @@ export const indentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
model.collapsed
) {
const collapsedSiblings = calculateCollapsedSiblings(model);
- doc.moveBlocks([model, ...collapsedSiblings], previousSibling);
+ store.moveBlocks([model, ...collapsedSiblings], previousSibling);
} else {
- doc.moveBlocks([model], previousSibling);
+ store.moveBlocks([model], previousSibling);
}
{
@@ -124,7 +124,7 @@ export const indentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
matchFlavours(nearestHeading, ['affine:paragraph']) &&
nearestHeading.collapsed
) {
- doc.updateBlock(nearestHeading, {
+ store.updateBlock(nearestHeading, {
collapsed: false,
});
}
@@ -135,7 +135,7 @@ export const indentParagraphCommand: Command<'indentContext'> = (ctx, next) => {
matchFlavours(previousSibling, ['affine:list']) &&
previousSibling.collapsed
) {
- doc.updateBlock(previousSibling, {
+ store.updateBlock(previousSibling, {
collapsed: false,
} as Partial<ListBlockModel>);
}
diff --git a/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts
index 69ec50437e..d238f4a86c 100644
--- a/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts
+++ b/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts
@@ -13,7 +13,7 @@ export const splitParagraphCommand: Command<
}
> = (ctx, next) => {
const { std } = ctx;
- const { doc, host, selection } = std;
+ const { store, host, selection } = std;
let blockId = ctx.blockId;
if (!blockId) {
const text = selection.find(TextSelection);
@@ -21,7 +21,7 @@ export const splitParagraphCommand: Command<
}
if (!blockId) return;
- const model = doc.getBlock(blockId)?.model;
+ const model = store.getBlock(blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) return;
const inlineEditor = getInlineEditorByModel(host, model);
@@ -38,9 +38,9 @@ export const splitParagraphCommand: Command<
if (model.text.yText.length < splitIndex + splitLength) return;
if (model.children.length > 0 && splitIndex > 0) {
- doc.captureSync();
+ store.captureSync();
const right = model.text.split(splitIndex, splitLength);
- const id = doc.addBlock(
+ const id = store.addBlock(
model.flavour as BlockSuite.Flavour,
{
text: right,
@@ -53,13 +53,13 @@ export const splitParagraphCommand: Command<
return next({ paragraphConvertedId: id });
}
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) return;
const index = parent.children.indexOf(model);
if (index < 0) return;
- doc.captureSync();
+ store.captureSync();
const right = model.text.split(splitIndex, splitLength);
- const id = doc.addBlock(
+ const id = store.addBlock(
model.flavour,
{
text: right,
@@ -68,9 +68,9 @@ export const splitParagraphCommand: Command<
parent,
index + 1
);
- const newModel = doc.getBlock(id)?.model;
+ const newModel = store.getBlock(id)?.model;
if (newModel) {
- doc.moveBlocks(model.children, newModel);
+ store.moveBlocks(model.children, newModel);
} else {
console.error('Failed to find the new model split from the paragraph');
}
diff --git a/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts b/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts
index 63abee9dbd..d7ca743df3 100644
--- a/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts
+++ b/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts
@@ -25,11 +25,10 @@ export const ParagraphKeymapExtension = KeymapExtension(
const isStart = isCollapsed && text.from.index === 0;
if (!isStart) return;
- const { doc } = std;
- const model = doc.getBlock(text.from.blockId)?.model;
+ const { store } = std;
+ const model = store.getBlock(text.from.blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) return;
- // const { model, doc } = this;
const event = ctx.get('keyboardState').raw;
event.preventDefault();
@@ -37,8 +36,8 @@ export const ParagraphKeymapExtension = KeymapExtension(
// firstly switch it to normal text, then delete this empty block.
if (model.type !== 'text') {
// Try to switch to normal text
- doc.captureSync();
- doc.updateBlock(model, { type: 'text' });
+ store.captureSync();
+ store.updateBlock(model, { type: 'text' });
return true;
}
@@ -51,10 +50,10 @@ export const ParagraphKeymapExtension = KeymapExtension(
return true;
},
'Mod-Enter': ctx => {
- const { doc } = std;
+ const { store } = std;
const text = std.selection.find(TextSelection);
if (!text) return;
- const model = doc.getBlock(text.from.blockId)?.model;
+ const model = store.getBlock(text.from.blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) return;
const inlineEditor = getInlineEditorByModel(
std.host,
@@ -65,7 +64,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
const raw = ctx.get('keyboardState').raw;
raw.preventDefault();
if (model.type === 'quote') {
- doc.captureSync();
+ store.captureSync();
inlineEditor.insertText(inlineRange, '\n');
inlineEditor.setInlineRange({
index: inlineRange.index + 1,
@@ -78,10 +77,10 @@ export const ParagraphKeymapExtension = KeymapExtension(
return true;
},
Enter: ctx => {
- const { doc } = std;
+ const { store } = std;
const text = std.selection.find(TextSelection);
if (!text) return;
- const model = doc.getBlock(text.from.blockId)?.model;
+ const model = store.getBlock(text.from.blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) return;
const inlineEditor = getInlineEditorByModel(
std.host,
@@ -112,7 +111,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
textStr === '\n' || textStr.endsWith('\n');
if (isEnd && endWithTwoBlankLines) {
raw.preventDefault();
- doc.captureSync();
+ store.captureSync();
model.text.delete(range.index - 1, 1);
std.command.exec('addParagraph');
return true;
@@ -127,14 +126,14 @@ export const ParagraphKeymapExtension = KeymapExtension(
}
if (model.type.startsWith('h') && model.collapsed) {
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) return true;
const index = parent.children.indexOf(model);
if (index === -1) return true;
const collapsedSiblings = calculateCollapsedSiblings(model);
const rightText = model.text.split(range.index);
- const newId = doc.addBlock(
+ const newId = store.addBlock(
model.flavour,
{ type: model.type, text: rightText },
parent,
diff --git a/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts b/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts
index aed1e576bb..681274a331 100644
--- a/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts
+++ b/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts
@@ -10,18 +10,18 @@ import {
} from '@blocksuite/block-std';
export function forwardDelete(std: BlockStdScope) {
- const { doc, host } = std;
+ const { store, host } = std;
const text = std.selection.find(TextSelection);
if (!text) return;
const isCollapsed = text.isCollapsed();
- const model = doc.getBlock(text.from.blockId)?.model;
+ const model = store.getBlock(text.from.blockId)?.model;
if (!model || !matchFlavours(model, ['affine:paragraph'])) return;
const isEnd = isCollapsed && text.from.index === model.text.length;
if (!isEnd) return;
- const parent = doc.getParent(model);
+ const parent = store.getParent(model);
if (!parent) return;
- const nextSibling = doc.getNext(model);
+ const nextSibling = store.getNext(model);
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
'affine:attachment',
'affine:bookmark',
@@ -42,12 +42,12 @@ export function forwardDelete(std: BlockStdScope) {
if (nextSibling?.text) {
model.text.join(nextSibling.text);
if (nextSibling.children) {
- const parent = doc.getParent(nextSibling);
+ const parent = store.getParent(nextSibling);
if (!parent) return false;
- doc.moveBlocks(nextSibling.children, parent, model, false);
+ store.moveBlocks(nextSibling.children, parent, model, false);
}
- doc.deleteBlock(nextSibling);
+ store.deleteBlock(nextSibling);
return true;
}
@@ -55,11 +55,16 @@ export function forwardDelete(std: BlockStdScope) {
if (nextBlock?.text) {
model.text.join(nextBlock.text);
if (nextBlock.children) {
- const parent = doc.getParent(nextBlock);
+ const parent = store.getParent(nextBlock);
if (!parent) return false;
- doc.moveBlocks(nextBlock.children, parent, doc.getParent(model), false);
+ store.moveBlocks(
+ nextBlock.children,
+ parent,
+ store.getParent(model),
+ false
+ );
}
- doc.deleteBlock(nextBlock);
+ store.deleteBlock(nextBlock);
return true;
}
diff --git a/blocksuite/affine/block-surface-ref/src/commands.ts b/blocksuite/affine/block-surface-ref/src/commands.ts
index 203cbe74b7..f4257fbf2d 100644
--- a/blocksuite/affine/block-surface-ref/src/commands.ts
+++ b/blocksuite/affine/block-surface-ref/src/commands.ts
@@ -27,11 +27,11 @@ export const insertSurfaceRefBlockCommand: Command<
reference,
};
- const surface = getSurfaceBlock(std.doc);
+ const surface = getSurfaceBlock(std.store);
if (!surface) return;
const element = surface.getElementById(reference);
- const blockModel = std.doc.getBlock(reference)?.model ?? null;
+ const blockModel = std.store.getBlock(reference)?.model ?? null;
if (element?.type === 'group') {
surfaceRefProps.refFlavour = 'group';
@@ -42,7 +42,7 @@ export const insertSurfaceRefBlockCommand: Command<
return;
}
- const result = std.doc.addSiblingBlocks(
+ const result = std.store.addSiblingBlocks(
targetModel,
[surfaceRefProps],
place
@@ -50,7 +50,7 @@ export const insertSurfaceRefBlockCommand: Command<
if (result.length === 0) return;
if (removeEmptyLine && targetModel.text?.length === 0) {
- std.doc.deleteBlock(targetModel);
+ std.store.deleteBlock(targetModel);
}
next({
diff --git a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
index 2ea8513ca8..8e12194916 100644
--- a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
+++ b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
@@ -460,7 +460,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
override mounted() {
const crud = this.std.get(EdgelessCRUDExtension);
const { _disposable } = this;
- const surfaceModel = getSurfaceBlock(this.std.doc);
+ const surfaceModel = getSurfaceBlock(this.std.store);
if (!surfaceModel) return;
const referenceElement = crud.getElementById(referenceId);
diff --git a/blocksuite/affine/block-surface/src/commands/auto-align.ts b/blocksuite/affine/block-surface/src/commands/auto-align.ts
index 68cd786f84..370176de8b 100644
--- a/blocksuite/affine/block-surface/src/commands/auto-align.ts
+++ b/blocksuite/affine/block-surface/src/commands/auto-align.ts
@@ -28,7 +28,7 @@ export const autoArrangeElementsCommand: Command<never, never, {}> = (
ctx,
next
) => {
- const { updateBlock } = ctx.std.doc;
+ const { updateBlock } = ctx.std.store;
const gfx = ctx.std.get(GfxControllerIdentifier);
const elements = gfx.selection.selectedElements;
@@ -46,7 +46,7 @@ export const autoResizeElementsCommand: Command<never, never, {}> = (
ctx,
next
) => {
- const { updateBlock } = ctx.std.doc;
+ const { updateBlock } = ctx.std.store;
const gfx = ctx.std.get(GfxControllerIdentifier);
const elements = gfx.selection.selectedElements;
diff --git a/blocksuite/affine/block-surface/src/extensions/crud-extension.ts b/blocksuite/affine/block-surface/src/extensions/crud-extension.ts
index 9ec43238c9..cbccf37cdc 100644
--- a/blocksuite/affine/block-surface/src/extensions/crud-extension.ts
+++ b/blocksuite/affine/block-surface/src/extensions/crud-extension.ts
@@ -75,7 +75,7 @@ export class EdgelessCRUDExtension extends Extension {
index: gfx.layer.generateIndex(),
};
- return this.std.doc.addBlock(
+ return this.std.store.addBlock(
flavour as never,
nProps,
parentId,
@@ -123,14 +123,14 @@ export class EdgelessCRUDExtension extends Extension {
return;
}
- const block = this.std.doc.getBlockById(id);
+ const block = this.std.store.getBlockById(id);
if (block) {
const key = getLastPropsKey(
block.flavour as BlockSuite.EdgelessModelKeys,
{ ...block.yBlock.toJSON(), ...props }
);
key && this.std.get(EditPropsStore).recordLastProps(key, props);
- this.std.doc.updateBlock(block, props);
+ this.std.store.updateBlock(block, props);
}
};
@@ -141,7 +141,7 @@ export class EdgelessCRUDExtension extends Extension {
}
const el =
surface.getElementById(id) ??
- (this.std.doc.getBlockById(
+ (this.std.store.getBlockById(
id
) as BlockSuite.EdgelessBlockModelType | null);
return el;
diff --git a/blocksuite/affine/block-surface/src/utils/add-note.ts b/blocksuite/affine/block-surface/src/utils/add-note.ts
index eb9fa0b92b..97b7c15435 100644
--- a/blocksuite/affine/block-surface/src/utils/add-note.ts
+++ b/blocksuite/affine/block-surface/src/utils/add-note.ts
@@ -93,7 +93,7 @@ export function addNote(
});
const gfx = std.get(GfxControllerIdentifier);
- const doc = std.doc;
+ const doc = std.store;
const blockId = doc.addBlock(
options.childFlavour as BlockSuite.Flavour,
diff --git a/blocksuite/affine/components/src/drag-indicator/file-drop-manager.ts b/blocksuite/affine/components/src/drag-indicator/file-drop-manager.ts
index ef9e87abaa..f3c34b6606 100644
--- a/blocksuite/affine/components/src/drag-indicator/file-drop-manager.ts
+++ b/blocksuite/affine/components/src/drag-indicator/file-drop-manager.ts
@@ -71,7 +71,7 @@ export class FileDropExtension extends LifeCycleWatcher {
let result: DropResult | null = null;
if (element) {
const model = element.model;
- const parent = this.std.doc.getParent(model);
+ const parent = this.std.store.getParent(model);
if (!matchFlavours(parent, ['affine:surface' as BlockSuite.Flavour])) {
result = calcDropTarget(point, model, element);
}
@@ -119,7 +119,7 @@ export class FileDropExtension extends LifeCycleWatcher {
}
get doc() {
- return this.std.doc;
+ return this.std.store;
}
get editorHost(): EditorHost {
@@ -155,7 +155,7 @@ export class FileDropExtension extends LifeCycleWatcher {
let result: DropResult | null = null;
if (element) {
const model = element.model;
- const parent = this.std.doc.getParent(model);
+ const parent = this.std.store.getParent(model);
if (!matchFlavours(parent, ['affine:surface' as BlockSuite.Flavour])) {
result = calcDropTarget(point, model, element);
}
diff --git a/blocksuite/affine/components/src/notification/linked-doc.ts b/blocksuite/affine/components/src/notification/linked-doc.ts
index 3d39d56873..2498f3c0bd 100644
--- a/blocksuite/affine/components/src/notification/linked-doc.ts
+++ b/blocksuite/affine/components/src/notification/linked-doc.ts
@@ -5,7 +5,7 @@ import { toast } from '../toast/toast.js';
function notify(std: BlockStdScope, title: string, message: string) {
const notification = std.getOptional(NotificationProvider);
- const { doc, host } = std;
+ const { store: doc, host } = std;
if (!notification) {
toast(host, title);
diff --git a/blocksuite/affine/components/src/rich-text/dom.ts b/blocksuite/affine/components/src/rich-text/dom.ts
index 341eed6aa4..fd2f5bcf3e 100644
--- a/blocksuite/affine/components/src/rich-text/dom.ts
+++ b/blocksuite/affine/components/src/rich-text/dom.ts
@@ -39,7 +39,7 @@ export function getInlineEditorByModel(
) {
const blockModel =
typeof model === 'string'
- ? editorHost.std.doc.getBlock(model)?.model
+ ? editorHost.std.store.getBlock(model)?.model
: model;
if (!blockModel || matchFlavours(blockModel, ['affine:database'])) {
// Not support database model since it's may be have multiple inline editor instances.
diff --git a/blocksuite/affine/components/src/rich-text/format/delete-text.ts b/blocksuite/affine/components/src/rich-text/format/delete-text.ts
index 5b1425f74d..dceef6a262 100644
--- a/blocksuite/affine/components/src/rich-text/format/delete-text.ts
+++ b/blocksuite/affine/components/src/rich-text/format/delete-text.ts
@@ -62,7 +62,7 @@ export const deleteTextCommand: Command<
selectedElements
.filter(el => el.model.id !== fromElement.model.id)
.forEach(el => {
- ctx.std.doc.deleteBlock(el.model, {
+ ctx.std.store.deleteBlock(el.model, {
bringChildrenTo:
el.model.id === toElement.model.id ? fromElement.model : undefined,
});
diff --git a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-config.ts b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-config.ts
index 3242b52152..400ab764cd 100644
--- a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-config.ts
+++ b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/reference-node/reference-config.ts
@@ -38,7 +38,7 @@ export class ReferenceNodeConfigProvider {
}
get doc() {
- return this.std.doc;
+ return this.std.store;
}
get hidePopup() {
diff --git a/blocksuite/affine/components/src/rich-text/keymap/basic.ts b/blocksuite/affine/components/src/rich-text/keymap/basic.ts
index c56ae18546..bdab1fd0f9 100644
--- a/blocksuite/affine/components/src/rich-text/keymap/basic.ts
+++ b/blocksuite/affine/components/src/rich-text/keymap/basic.ts
@@ -41,7 +41,7 @@ export const textCommonKeymap = (
const text = std.selection.find(TextSelection);
if (!text) return;
- const model = std.doc.getBlock(text.from.blockId)?.model;
+ const model = std.store.getBlock(text.from.blockId)?.model;
if (!model || !model.text) return;
ctx.get('keyboardState').raw.preventDefault();
@@ -62,7 +62,7 @@ export const textCommonKeymap = (
const blockId = blocks.at(-1)?.blockId;
if (!blockId) return;
- const model = std.doc.getBlock(blockId)?.model;
+ const model = std.store.getBlock(blockId)?.model;
if (!model || !model.text) return;
ctx.get('keyboardState').raw.preventDefault();
diff --git a/blocksuite/affine/components/src/rich-text/keymap/bracket.ts b/blocksuite/affine/components/src/rich-text/keymap/bracket.ts
index a8b27c6859..8c2d412735 100644
--- a/blocksuite/affine/components/src/rich-text/keymap/bracket.ts
+++ b/blocksuite/affine/components/src/rich-text/keymap/bracket.ts
@@ -21,7 +21,7 @@ export const bracketKeymap = (
return {
...acc,
[pair.right]: ctx => {
- const { doc, selection } = std;
+ const { store: doc, selection } = std;
if (doc.readonly) return;
const textSelection = selection.find(TextSelection);
@@ -47,7 +47,7 @@ export const bracketKeymap = (
}
},
[pair.left]: ctx => {
- const { doc, selection } = std;
+ const { store: doc, selection } = std;
if (doc.readonly) return;
const textSelection = selection.find(TextSelection);
@@ -98,7 +98,7 @@ export const bracketKeymap = (
return {
...keymap,
'`': ctx => {
- const { doc, selection } = std;
+ const { store: doc, selection } = std;
if (doc.readonly) return;
const textSelection = selection.find(TextSelection);
@@ -128,7 +128,7 @@ export const bracketKeymap = (
};
function tryConvertToLinkedDoc(std: BlockStdScope, inlineEditor: InlineEditor) {
- const root = std.doc.root;
+ const root = std.store.root;
if (!root) return false;
const linkedDocWidgetEle = std.view.getWidget(
'affine-linked-doc-widget',
@@ -154,7 +154,7 @@ function tryConvertToLinkedDoc(std: BlockStdScope, inlineEditor: InlineEditor) {
});
inlineEditor.setInlineRange({ index: inlineRange.index - 1, length: 0 });
- const doc = createDefaultDoc(std.doc.workspace, {
+ const doc = createDefaultDoc(std.store.workspace, {
title: docName,
});
insertLinkedNode({
diff --git a/blocksuite/affine/components/src/rich-text/keymap/format.ts b/blocksuite/affine/components/src/rich-text/keymap/format.ts
index 94984a8d30..548920607b 100644
--- a/blocksuite/affine/components/src/rich-text/keymap/format.ts
+++ b/blocksuite/affine/components/src/rich-text/keymap/format.ts
@@ -14,7 +14,7 @@ export const textFormatKeymap = (std: BlockStdScope) =>
return {
...acc,
[config.hotkey as string]: ctx => {
- const { doc, selection } = std;
+ const { store: doc, selection } = std;
if (doc.readonly) return;
const textSelection = selection.find(TextSelection);
diff --git a/blocksuite/affine/components/src/rich-text/markdown/divider.ts b/blocksuite/affine/components/src/rich-text/markdown/divider.ts
index 328956931d..697689c5ba 100644
--- a/blocksuite/affine/components/src/rich-text/markdown/divider.ts
+++ b/blocksuite/affine/components/src/rich-text/markdown/divider.ts
@@ -10,7 +10,7 @@ export function toDivider(
model: BlockModel,
prefix: string
) {
- const { doc } = std;
+ const { store: doc } = std;
if (
matchFlavours(model, ['affine:divider']) ||
(matchFlavours(model, ['affine:paragraph']) && model.type === 'quote')
diff --git a/blocksuite/affine/components/src/rich-text/markdown/list.ts b/blocksuite/affine/components/src/rich-text/markdown/list.ts
index 35bb5ff9a1..13dc5316a3 100644
--- a/blocksuite/affine/components/src/rich-text/markdown/list.ts
+++ b/blocksuite/affine/components/src/rich-text/markdown/list.ts
@@ -16,7 +16,7 @@ export function toList(
if (!matchFlavours(model, ['affine:paragraph'])) {
return;
}
- const { doc } = std;
+ const { store: doc } = std;
const parent = doc.getParent(model);
if (!parent) return;
diff --git a/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts b/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts
index 7978ce1edd..3b754eb546 100644
--- a/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts
+++ b/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts
@@ -21,7 +21,7 @@ export function markdownInput(
id = text?.from.blockId;
}
if (!id) return;
- const model = std.doc.getBlock(id)?.model;
+ const model = std.store.getBlock(id)?.model;
if (!model) return;
const inline = getInlineEditorByModel(std.host, model);
if (!inline) return;
diff --git a/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts b/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts
index 32f336ffb5..b728a3fe9d 100644
--- a/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts
+++ b/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts
@@ -12,7 +12,7 @@ export function toParagraph(
type: ParagraphType,
prefix: string
) {
- const { doc } = std;
+ const { store: doc } = std;
if (!matchFlavours(model, ['affine:paragraph'])) {
const parent = doc.getParent(model);
if (!parent) return;
diff --git a/blocksuite/affine/components/src/rich-text/markdown/utils.ts b/blocksuite/affine/components/src/rich-text/markdown/utils.ts
index 5aebb07c39..63b870352c 100644
--- a/blocksuite/affine/components/src/rich-text/markdown/utils.ts
+++ b/blocksuite/affine/components/src/rich-text/markdown/utils.ts
@@ -34,6 +34,6 @@ export function beforeConvert(
// *<space>| -> undo
text.insert(' ', index);
focusTextModel(std, model.id, index + 1);
- std.doc.captureSync();
+ std.store.captureSync();
text.delete(0, index + 1);
}
diff --git a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts
index 01398ac3ce..a4e2830182 100644
--- a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts
+++ b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts
@@ -239,10 +239,10 @@ class PasteTr {
linkToDocId,
parseDocUrlService
);
- const model = this.std.doc.getBlock(blockSnapshot.id)?.model;
+ const model = this.std.store.getBlock(blockSnapshot.id)?.model;
if (transformed && model) {
- this.std.doc.captureSync();
- this.std.doc.transact(() => {
+ this.std.store.captureSync();
+ this.std.store.transact(() => {
const text = model.text as Text;
text.clear();
text.applyDelta(delta);
@@ -263,8 +263,8 @@ class PasteTr {
if (!transformed) {
return;
}
- this.std.doc.captureSync();
- this.std.doc.transact(() => {
+ this.std.store.captureSync();
+ this.std.store.transact(() => {
fromPointStateText.clear();
fromPointStateText.applyDelta(delta);
});
@@ -275,8 +275,8 @@ class PasteTr {
const cursorBlock =
this.pointState.model.flavour === 'affine:code' || !this.lastSnapshot
- ? this.std.doc.getBlock(this.pointState.model.id)
- : this.std.doc.getBlock(this.lastSnapshot.id);
+ ? this.std.store.getBlock(this.pointState.model.id)
+ : this.std.store.getBlock(this.lastSnapshot.id);
if (!cursorBlock) {
return;
}
@@ -323,22 +323,22 @@ class PasteTr {
}
if (this.lastSnapshot) {
- const lastModel = this.std.doc.getBlock(this.lastSnapshot.id)?.model;
+ const lastModel = this.std.store.getBlock(this.lastSnapshot.id)?.model;
if (!lastModel) {
return;
}
- this.std.doc.moveBlocks(this.pointState.model.children, lastModel);
+ this.std.store.moveBlocks(this.pointState.model.children, lastModel);
}
- this.std.doc.moveBlocks(
- this.std.doc
+ this.std.store.moveBlocks(
+ this.std.store
.getNexts(this.pointState.model.id)
.slice(0, this.pasteStartModelChildrenCount),
this.pointState.model
);
if (!this.firstSnapshotIsPlainText && this.pointState.text.length == 0) {
- this.std.doc.deleteBlock(this.pointState.model);
+ this.std.store.deleteBlock(this.pointState.model);
}
};
diff --git a/blocksuite/affine/shared/src/commands/block-crud/get-block-index.ts b/blocksuite/affine/shared/src/commands/block-crud/get-block-index.ts
index 45e961405c..280b29250c 100644
--- a/blocksuite/affine/shared/src/commands/block-crud/get-block-index.ts
+++ b/blocksuite/affine/shared/src/commands/block-crud/get-block-index.ts
@@ -14,7 +14,7 @@ export const getBlockIndexCommand: Command<
'`path` is required, you need to pass it in args or ctx before adding this command to the pipeline.'
);
- const parentModel = ctx.std.doc.getParent(path);
+ const parentModel = ctx.std.store.getParent(path);
if (!parentModel) return;
const parent = ctx.std.view.getBlock(parentModel.id);
diff --git a/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts b/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts
index 9028627254..94d5c42959 100644
--- a/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts
+++ b/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts
@@ -5,7 +5,7 @@ import { getNextContentBlock } from '../../utils/index.js';
function getNextBlock(std: BlockSuite.Std, path: string) {
const view = std.view;
- const model = std.doc.getBlock(path)?.model;
+ const model = std.store.getBlock(path)?.model;
if (!model) return null;
const nextModel = getNextContentBlock(std.host, model);
if (!nextModel) return null;
diff --git a/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts b/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts
index 206d659e2e..b9e1cf6c4f 100644
--- a/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts
+++ b/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts
@@ -6,7 +6,7 @@ import { getPrevContentBlock } from '../../utils/index.js';
function getPrevBlock(std: BlockSuite.Std, path: string) {
const view = std.view;
- const model = std.doc.getBlock(path)?.model;
+ const model = std.store.getBlock(path)?.model;
if (!model) return null;
const prevModel = getPrevContentBlock(std.host, model);
if (!prevModel) return null;
diff --git a/blocksuite/affine/shared/src/commands/block-crud/get-selected-blocks.ts b/blocksuite/affine/shared/src/commands/block-crud/get-selected-blocks.ts
index 9c8914016f..0dbb56a062 100644
--- a/blocksuite/affine/shared/src/commands/block-crud/get-selected-blocks.ts
+++ b/blocksuite/affine/shared/src/commands/block-crud/get-selected-blocks.ts
@@ -51,7 +51,7 @@ export const getSelectedBlocksCommand: Command<
const blockSelections = ctx.blockSelections ?? ctx.currentBlockSelections;
if (types.includes('block') && blockSelections) {
const viewStore = ctx.std.view;
- const doc = ctx.std.doc;
+ const doc = ctx.std.store;
const selectedBlockComponents = blockSelections.flatMap(selection => {
const el = viewStore.getBlock(selection.blockId);
if (!el) {
diff --git a/blocksuite/affine/shared/src/commands/model-crud/copy-selected-models.ts b/blocksuite/affine/shared/src/commands/model-crud/copy-selected-models.ts
index aa334488d0..5be64ef32a 100644
--- a/blocksuite/affine/shared/src/commands/model-crud/copy-selected-models.ts
+++ b/blocksuite/affine/shared/src/commands/model-crud/copy-selected-models.ts
@@ -15,7 +15,7 @@ export const copySelectedModelsCommand: Command<'draftedModels' | 'onCopy'> = (
models
.then(models => {
- const slice = Slice.fromModels(ctx.std.doc, models);
+ const slice = Slice.fromModels(ctx.std.store, models);
return ctx.std.clipboard.copy(slice);
})
diff --git a/blocksuite/affine/shared/src/commands/model-crud/delete-selected-models.ts b/blocksuite/affine/shared/src/commands/model-crud/delete-selected-models.ts
index a085ef5fa4..4b95265dde 100644
--- a/blocksuite/affine/shared/src/commands/model-crud/delete-selected-models.ts
+++ b/blocksuite/affine/shared/src/commands/model-crud/delete-selected-models.ts
@@ -14,7 +14,7 @@ export const deleteSelectedModelsCommand: Command<'selectedModels'> = (
}
models.forEach(model => {
- ctx.std.doc.deleteBlock(model);
+ ctx.std.store.deleteBlock(model);
});
return next();
diff --git a/blocksuite/affine/shared/src/commands/model-crud/duplicate-selected-model.ts b/blocksuite/affine/shared/src/commands/model-crud/duplicate-selected-model.ts
index ec7d719862..61c91a7456 100644
--- a/blocksuite/affine/shared/src/commands/model-crud/duplicate-selected-model.ts
+++ b/blocksuite/affine/shared/src/commands/model-crud/duplicate-selected-model.ts
@@ -9,17 +9,17 @@ export const duplicateSelectedModelsCommand: Command<
const model = selectedModels[selectedModels.length - 1];
- const parentModel = std.doc.getParent(model.id);
+ const parentModel = std.store.getParent(model.id);
if (!parentModel) return;
const index = parentModel.children.findIndex(x => x.id === model.id);
draftedModels
.then(models => {
- const slice = Slice.fromModels(std.doc, models);
+ const slice = Slice.fromModels(std.store, models);
return std.clipboard.duplicateSlice(
slice,
- std.doc,
+ std.store,
parentModel.id,
index + 1
);
diff --git a/blocksuite/affine/shared/src/services/drag-handle-config.ts b/blocksuite/affine/shared/src/services/drag-handle-config.ts
index 8f238c5595..a1fe8202b3 100644
--- a/blocksuite/affine/shared/src/services/drag-handle-config.ts
+++ b/blocksuite/affine/shared/src/services/drag-handle-config.ts
@@ -35,7 +35,7 @@ export class DNDAPIExtension extends Extension {
}): SliceSnapshot | null {
const { docId, flavour = 'affine:embed-linked-doc', blockId } = options;
- const slice = Slice.fromModels(this.std.doc, []);
+ const slice = Slice.fromModels(this.std.store, []);
const job = this.std.getJob();
const snapshot = job.sliceToSnapshot(slice);
if (!snapshot) {
diff --git a/blocksuite/affine/shared/src/services/edit-props-store.ts b/blocksuite/affine/shared/src/services/edit-props-store.ts
index 7c89fe64de..8e81dfc786 100644
--- a/blocksuite/affine/shared/src/services/edit-props-store.ts
+++ b/blocksuite/affine/shared/src/services/edit-props-store.ts
@@ -116,7 +116,7 @@ export class EditPropsStore extends LifeCycleWatcher {
}
private _getStorageKey<T extends StoragePropsKey>(key: T) {
- const id = this.std.doc.id;
+ const id = this.std.store.id;
switch (key) {
case 'viewport':
return 'blocksuite:' + id + ':edgelessViewport';
diff --git a/blocksuite/affine/shared/src/services/theme-service.ts b/blocksuite/affine/shared/src/services/theme-service.ts
index 181c2c65c7..54dde1d076 100644
--- a/blocksuite/affine/shared/src/services/theme-service.ts
+++ b/blocksuite/affine/shared/src/services/theme-service.ts
@@ -63,7 +63,7 @@ export class ThemeService extends Extension {
const extension = this.std.getOptional(ThemeExtensionIdentifier);
this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$;
this.edgeless$ =
- extension?.getEdgelessTheme?.(this.std.doc.id) ||
+ extension?.getEdgelessTheme?.(this.std.store.id) ||
getThemeObserver().theme$;
}
diff --git a/blocksuite/affine/shared/src/utils/model/list.ts b/blocksuite/affine/shared/src/utils/model/list.ts
index 08c84a02d8..782b2aa4d3 100644
--- a/blocksuite/affine/shared/src/utils/model/list.ts
+++ b/blocksuite/affine/shared/src/utils/model/list.ts
@@ -45,7 +45,7 @@ export function toNumberedList(
model: BlockModel,
order: number
) {
- const { doc } = std;
+ const { store: doc } = std;
if (!model.text) return;
const parent = doc.getParent(model);
if (!parent) return;
diff --git a/blocksuite/affine/widget-drag-handle/src/drag-handle.ts b/blocksuite/affine/widget-drag-handle/src/drag-handle.ts
index f34af2fd69..1dfd427cf5 100644
--- a/blocksuite/affine/widget-drag-handle/src/drag-handle.ts
+++ b/blocksuite/affine/widget-drag-handle/src/drag-handle.ts
@@ -85,7 +85,7 @@ export class AffineDragHandleWidget extends WidgetComponent<RootBlockModel> {
matchFlavours(this.draggingElements[0].model, ['affine:note']);
if (isDraggedElementNote) {
- const parent = this.std.doc.getParent(closestBlock.model);
+ const parent = this.std.store.getParent(closestBlock.model);
if (!parent) return null;
const parentElement = this._getBlockView(parent.id);
if (!parentElement) return null;
diff --git a/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts b/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts
index deba782587..863f6280ec 100644
--- a/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts
+++ b/blocksuite/affine/widget-drag-handle/src/middleware/new-id-cross-doc.ts
@@ -7,7 +7,7 @@ export const newIdCrossDoc =
let samePage = false;
slots.beforeImport.on(payload => {
if (payload.type === 'slice') {
- samePage = payload.snapshot.pageId === std.doc.id;
+ samePage = payload.snapshot.pageId === std.store.id;
}
if (payload.type === 'block' && !samePage) {
payload.snapshot.id = std.workspace.idGenerator();
diff --git a/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts b/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts
index 38aa402855..47b4caecb6 100644
--- a/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts
+++ b/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts
@@ -13,10 +13,10 @@ export const reorderList =
matchFlavours(model, ['affine:list']) &&
model.type === 'numbered'
) {
- const next = std.doc.getNext(model);
- correctNumberedListsOrderToPrev(std.doc, model);
+ const next = std.store.getNext(model);
+ correctNumberedListsOrderToPrev(std.store, model);
if (next) {
- correctNumberedListsOrderToPrev(std.doc, next);
+ correctNumberedListsOrderToPrev(std.store, next);
}
}
}
diff --git a/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts b/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts
index 00800020bf..2fee0fb9a0 100644
--- a/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts
+++ b/blocksuite/affine/widget-drag-handle/src/middleware/surface-ref-to-embed.ts
@@ -15,7 +15,7 @@ export const surfaceRefToEmbed =
pageId &&
payload.type === 'block' &&
payload.snapshot.flavour === 'affine:surface-ref' &&
- !std.doc.hasBlock(payload.snapshot.id)
+ !std.store.hasBlock(payload.snapshot.id)
) {
const id = payload.snapshot.id;
payload.snapshot.id = std.workspace.idGenerator();
diff --git a/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts b/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts
index 18aa53b607..aa57a91c47 100644
--- a/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts
+++ b/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts
@@ -285,7 +285,7 @@ export class DragEventWatcher {
return;
}
const model = element.model;
- const parent = this._std.doc.getParent(model.id);
+ const parent = this._std.store.getParent(model.id);
if (!parent) return;
if (matchFlavours(parent, ['affine:surface'])) {
return;
@@ -327,11 +327,11 @@ export class DragEventWatcher {
content: first.children,
};
job
- .snapshotToSlice(snapshotWithoutNote, std.doc, parent, index)
+ .snapshotToSlice(snapshotWithoutNote, std.store, parent, index)
.then(() => {
- const block = std.doc.getBlock(id)?.model;
+ const block = std.store.getBlock(id)?.model;
if (block) {
- std.doc.deleteBlock(block);
+ std.store.deleteBlock(block);
}
})
.catch(console.error);
@@ -363,7 +363,7 @@ export class DragEventWatcher {
const std = this._std;
const job = this._getJob();
job
- .snapshotToSlice(snapshot, std.doc, surfaceBlockModel.id)
+ .snapshotToSlice(snapshot, std.store, surfaceBlockModel.id)
.catch(console.error);
};
@@ -456,7 +456,7 @@ export class DragEventWatcher {
);
const slice = Slice.fromModels(
- this._std.doc,
+ this._std.store,
blocks.map(block => block.model)
);
@@ -467,7 +467,7 @@ export class DragEventWatcher {
};
private readonly _trackLinkedDocCreated = (id: string) => {
- const isNewBlock = !this._std.doc.hasBlock(id);
+ const isNewBlock = !this._std.store.hasBlock(id);
if (!isNewBlock) {
return;
}
@@ -517,7 +517,7 @@ export class DragEventWatcher {
// use snapshot
const slice = await job.snapshotToSlice(
snapshot,
- std.doc,
+ std.store,
parent,
index
);
diff --git a/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts b/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts
index 6010db3e7b..e6a8e0597f 100644
--- a/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts
+++ b/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts
@@ -287,7 +287,7 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
);
this.disposables.add(
- this.std.doc.slots.blockUpdated.on(() => {
+ this.std.store.slots.blockUpdated.on(() => {
this._updateSelections(this._remoteSelections.peek());
})
);
diff --git a/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts b/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts
index 86651d59fa..4971598a44 100644
--- a/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts
+++ b/blocksuite/affine/widget-remote-selection/src/manager/remote-color-manager.ts
@@ -5,7 +5,7 @@ import { multiPlayersColor } from './color-picker';
export class RemoteColorManager {
private get awarenessStore() {
- return this.std.doc.workspace.awarenessStore;
+ return this.std.store.workspace.awarenessStore;
}
constructor(readonly std: BlockStdScope) {
diff --git a/blocksuite/affine/widget-scroll-anchoring/src/scroll-anchoring.ts b/blocksuite/affine/widget-scroll-anchoring/src/scroll-anchoring.ts
index d8cf2f19c1..259ea599c1 100644
--- a/blocksuite/affine/widget-scroll-anchoring/src/scroll-anchoring.ts
+++ b/blocksuite/affine/widget-scroll-anchoring/src/scroll-anchoring.ts
@@ -108,7 +108,7 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
// listen for document updates
this.disposables.add(
- this.std.doc.slots.blockUpdated
+ this.std.store.slots.blockUpdated
.filter(v => v.type === 'add' && v.id === id)
.once(() => this.#moveToAnchorInEdgeless(id))
);
@@ -157,7 +157,7 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
// listen for document updates
this.disposables.add(
- this.std.doc.slots.blockUpdated
+ this.std.store.slots.blockUpdated
.filter(v => v.type === 'add' && v.id === id)
.once(() => this.#moveToAnchorInPage(id))
);
diff --git a/blocksuite/blocks/src/_common/export-manager/export-manager.ts b/blocksuite/blocks/src/_common/export-manager/export-manager.ts
index ea249c1210..c0cd5a5d82 100644
--- a/blocksuite/blocks/src/_common/export-manager/export-manager.ts
+++ b/blocksuite/blocks/src/_common/export-manager/export-manager.ts
@@ -110,7 +110,7 @@ export class ExportManager {
};
get doc(): Store {
- return this.std.doc;
+ return this.std.store;
}
get editorHost(): EditorHost {
diff --git a/blocksuite/blocks/src/root-block/clipboard/index.ts b/blocksuite/blocks/src/root-block/clipboard/index.ts
index f1f6e329a4..7255edd112 100644
--- a/blocksuite/blocks/src/root-block/clipboard/index.ts
+++ b/blocksuite/blocks/src/root-block/clipboard/index.ts
@@ -60,10 +60,10 @@ export class PageClipboard {
this._std.clipboard.use(copy);
this._std.clipboard.use(paste);
this._std.clipboard.use(
- replaceIdMiddleware(this._std.doc.workspace.idGenerator)
+ replaceIdMiddleware(this._std.store.workspace.idGenerator)
);
this._std.clipboard.use(
- titleMiddleware(this._std.doc.workspace.meta.docMetas)
+ titleMiddleware(this._std.store.workspace.meta.docMetas)
);
this._std.clipboard.use(defaultImageProxyMiddleware);
@@ -85,10 +85,10 @@ export class PageClipboard {
this._std.clipboard.unuse(copy);
this._std.clipboard.unuse(paste);
this._std.clipboard.unuse(
- replaceIdMiddleware(this._std.doc.workspace.idGenerator)
+ replaceIdMiddleware(this._std.store.workspace.idGenerator)
);
this._std.clipboard.unuse(
- titleMiddleware(this._std.doc.workspace.meta.docMetas)
+ titleMiddleware(this._std.store.workspace.meta.docMetas)
);
this._std.clipboard.unuse(defaultImageProxyMiddleware);
},
@@ -138,7 +138,7 @@ export class PageClipboard {
const e = ctx.get('clipboardState').raw;
e.preventDefault();
- this._std.doc.captureSync();
+ this._std.store.captureSync();
this._std.command
.chain()
.try(cmd => [
@@ -188,7 +188,7 @@ export class PageClipboard {
this._std.clipboard
.paste(
e,
- this._std.doc,
+ this._std.store,
ctx.parentBlock.model.id,
ctx.blockIndex ? ctx.blockIndex + 1 : 1
)
diff --git a/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/mindmap-menu.ts b/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/mindmap-menu.ts
index 9486e01943..247fc3d02f 100644
--- a/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/mindmap-menu.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/mindmap-menu.ts
@@ -317,7 +317,9 @@ export class EdgelessMindmapMenu extends EdgelessToolbarToolMixin(
</div>
`;
})}
- ${this.std.doc.get(FeatureFlagService).getFlag('enable_mind_map_import')
+ ${this.std.store
+ .get(FeatureFlagService)
+ .getFlag('enable_mind_map_import')
? this._importMindMapEntry()
: nothing}
</div>
diff --git a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts
index 3fe8ee6f80..9e36b191b3 100644
--- a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts
@@ -29,7 +29,7 @@ export function addText(gfx: GfxController, event: PointerEventState) {
});
gfx.doc.captureSync();
const textElement = gfx.getElementById(id) as TextElementModel;
- const edgelessView = gfx.std.view.getBlock(gfx.std.doc.root!.id);
+ const edgelessView = gfx.std.view.getBlock(gfx.std.store.root!.id);
mountTextElementEditor(
textElement,
edgelessView as EdgelessRootBlockComponent
diff --git a/blocksuite/blocks/src/root-block/root-service.ts b/blocksuite/blocks/src/root-block/root-service.ts
index 31f52b78b9..7d1aaf2735 100644
--- a/blocksuite/blocks/src/root-block/root-service.ts
+++ b/blocksuite/blocks/src/root-block/root-service.ts
@@ -41,7 +41,7 @@ export abstract class RootService extends BlockService {
}
get viewportElement() {
- const rootId = this.std.doc.root?.id;
+ const rootId = this.std.store.root?.id;
if (!rootId) return null;
const rootComponent = this.std.view.getBlock(
rootId
diff --git a/blocksuite/blocks/src/root-block/widgets/format-bar/config.ts b/blocksuite/blocks/src/root-block/widgets/format-bar/config.ts
index 96946fde91..4f0a109668 100644
--- a/blocksuite/blocks/src/root-block/widgets/format-bar/config.ts
+++ b/blocksuite/blocks/src/root-block/widgets/format-bar/config.ts
@@ -383,10 +383,10 @@ export const BUILT_IN_GROUPS: MenuItemGroup<FormatBarContext>[] = [
ctx.draftedModels
.then(models => {
- const slice = Slice.fromModels(ctx.std.doc, models);
+ const slice = Slice.fromModels(ctx.std.store, models);
return ctx.std.clipboard.duplicateSlice(
slice,
- ctx.std.doc,
+ ctx.std.store,
ctx.parentBlock?.model.id,
ctx.blockIndex ? ctx.blockIndex + 1 : 1
);
diff --git a/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts b/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts
index a1b15a7838..08dfc2e344 100644
--- a/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts
+++ b/blocksuite/blocks/src/root-block/widgets/keyboard-toolbar/config.ts
@@ -155,7 +155,7 @@ const textToolActionItems: KeyboardToolbarActionItem[] = [
name: 'Text',
icon: TextIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:paragraph'),
+ std.store.schema.flavourSchemaMap.has('affine:paragraph'),
action: ({ std }) => {
std.command.exec('updateBlockType', {
flavour: 'affine:paragraph',
@@ -167,7 +167,7 @@ const textToolActionItems: KeyboardToolbarActionItem[] = [
name: `Heading ${i}`,
icon: HeadingIcon(i),
showWhen: ({ std }: KeyboardToolbarContext) =>
- std.doc.schema.flavourSchemaMap.has('affine:paragraph'),
+ std.store.schema.flavourSchemaMap.has('affine:paragraph'),
action: ({ std }: KeyboardToolbarContext) => {
std.command.exec('updateBlockType', {
flavour: 'affine:paragraph',
@@ -177,7 +177,7 @@ const textToolActionItems: KeyboardToolbarActionItem[] = [
})),
{
name: 'CodeBlock',
- showWhen: ({ std }) => std.doc.schema.flavourSchemaMap.has('affine:code'),
+ showWhen: ({ std }) => std.store.schema.flavourSchemaMap.has('affine:code'),
icon: CodeBlockIcon(),
action: ({ std }) => {
std.command.exec('updateBlockType', {
@@ -188,7 +188,7 @@ const textToolActionItems: KeyboardToolbarActionItem[] = [
{
name: 'Quote',
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:paragraph'),
+ std.store.schema.flavourSchemaMap.has('affine:paragraph'),
icon: QuoteIcon(),
action: ({ std }) => {
std.command.exec('updateBlockType', {
@@ -201,7 +201,7 @@ const textToolActionItems: KeyboardToolbarActionItem[] = [
name: 'Divider',
icon: DividerIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:divider'),
+ std.store.schema.flavourSchemaMap.has('affine:divider'),
action: ({ std }) => {
std.command.exec('updateBlockType', {
flavour: 'affine:divider',
@@ -213,7 +213,7 @@ const textToolActionItems: KeyboardToolbarActionItem[] = [
name: 'Inline equation',
icon: TeXIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:paragraph'),
+ std.store.schema.flavourSchemaMap.has('affine:paragraph'),
action: ({ std }) => {
std.command.chain().getTextSelection().insertInlineLatex().run();
},
@@ -224,7 +224,7 @@ const listToolActionItems: KeyboardToolbarActionItem[] = [
{
name: 'BulletedList',
icon: BulletedListIcon(),
- showWhen: ({ std }) => std.doc.schema.flavourSchemaMap.has('affine:list'),
+ showWhen: ({ std }) => std.store.schema.flavourSchemaMap.has('affine:list'),
action: ({ std }) => {
std.command.exec('updateBlockType', {
flavour: 'affine:list',
@@ -237,7 +237,7 @@ const listToolActionItems: KeyboardToolbarActionItem[] = [
{
name: 'NumberedList',
icon: NumberedListIcon(),
- showWhen: ({ std }) => std.doc.schema.flavourSchemaMap.has('affine:list'),
+ showWhen: ({ std }) => std.store.schema.flavourSchemaMap.has('affine:list'),
action: ({ std }) => {
std.command.exec('updateBlockType', {
flavour: 'affine:list',
@@ -250,7 +250,7 @@ const listToolActionItems: KeyboardToolbarActionItem[] = [
{
name: 'CheckBox',
icon: CheckBoxCheckLinearIcon(),
- showWhen: ({ std }) => std.doc.schema.flavourSchemaMap.has('affine:list'),
+ showWhen: ({ std }) => std.store.schema.flavourSchemaMap.has('affine:list'),
action: ({ std }) => {
std.command.exec('updateBlockType', {
flavour: 'affine:list',
@@ -269,13 +269,13 @@ const pageToolGroup: KeyboardToolPanelGroup = {
name: 'NewPage',
icon: NewPageIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:embed-linked-doc'),
+ std.store.schema.flavourSchemaMap.has('affine:embed-linked-doc'),
action: ({ std }) => {
std.command
.chain()
.getSelectedModels()
.inline(({ selectedModels }) => {
- const newDoc = createDefaultDoc(std.doc.workspace);
+ const newDoc = createDefaultDoc(std.store.workspace);
if (!selectedModels?.length) return;
insertContent(std.host, selectedModels[0], REFERENCE_NODE, {
reference: {
@@ -297,7 +297,7 @@ const pageToolGroup: KeyboardToolPanelGroup = {
);
if (!linkedDocWidget) return false;
- return std.doc.schema.flavourSchemaMap.has('affine:embed-linked-doc');
+ return std.store.schema.flavourSchemaMap.has('affine:embed-linked-doc');
},
action: ({ rootComponent, closeToolPanel }) => {
const { std } = rootComponent;
@@ -344,7 +344,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Image',
icon: ImageIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:image'),
+ std.store.schema.flavourSchemaMap.has('affine:image'),
action: ({ std }) => {
std.command
.chain()
@@ -357,13 +357,13 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Link',
icon: LinkIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:bookmark'),
+ std.store.schema.flavourSchemaMap.has('affine:bookmark'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
if (!model) return;
- const parentModel = std.doc.getParent(model);
+ const parentModel = std.store.getParent(model);
if (!parentModel) return;
const index = parentModel.children.indexOf(model) + 1;
@@ -374,7 +374,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
{ mode: 'page', parentModel, index }
);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
@@ -382,7 +382,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Attachment',
icon: AttachmentIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:attachment'),
+ std.store.schema.flavourSchemaMap.has('affine:attachment'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
@@ -397,7 +397,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
await addSiblingAttachmentBlocks(std.host, [file], maxFileSize, model);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
@@ -407,13 +407,13 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
style: `color: white`,
}),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:embed-youtube'),
+ std.store.schema.flavourSchemaMap.has('affine:embed-youtube'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
if (!model) return;
- const parentModel = std.doc.getParent(model);
+ const parentModel = std.store.getParent(model);
if (!parentModel) return;
const index = parentModel.children.indexOf(model) + 1;
@@ -424,7 +424,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
{ mode: 'page', parentModel, index }
);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
@@ -432,13 +432,13 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Github',
icon: GithubIcon({ style: `color: black` }),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:embed-github'),
+ std.store.schema.flavourSchemaMap.has('affine:embed-github'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
if (!model) return;
- const parentModel = std.doc.getParent(model);
+ const parentModel = std.store.getParent(model);
if (!parentModel) return;
const index = parentModel.children.indexOf(model) + 1;
@@ -449,7 +449,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
{ mode: 'page', parentModel, index }
);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
@@ -457,13 +457,13 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Figma',
icon: FigmaDuotoneIcon,
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:embed-figma'),
+ std.store.schema.flavourSchemaMap.has('affine:embed-figma'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
if (!model) return;
- const parentModel = std.doc.getParent(model);
+ const parentModel = std.store.getParent(model);
if (!parentModel) {
return;
}
@@ -475,7 +475,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
{ mode: 'page', parentModel, index }
);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
@@ -483,13 +483,13 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Loom',
icon: LoomLogoIcon({ style: `color: #625DF5` }),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:embed-loom'),
+ std.store.schema.flavourSchemaMap.has('affine:embed-loom'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
if (!model) return;
- const parentModel = std.doc.getParent(model);
+ const parentModel = std.store.getParent(model);
if (!parentModel) return;
const index = parentModel.children.indexOf(model) + 1;
@@ -500,7 +500,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
{ mode: 'page', parentModel, index }
);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
@@ -508,7 +508,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
name: 'Equation',
icon: TeXIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:latex'),
+ std.store.schema.flavourSchemaMap.has('affine:latex'),
action: ({ std }) => {
std.command
.chain()
@@ -526,9 +526,9 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
const documentGroupFrameToolGroup: DynamicKeyboardToolPanelGroup = ({
std,
}) => {
- const { doc } = std;
+ const { store } = std;
- const frameModels = doc
+ const frameModels = store
.getBlocksByFlavour('affine:frame')
.map(block => block.model) as FrameBlockModel[];
@@ -548,7 +548,7 @@ const documentGroupFrameToolGroup: DynamicKeyboardToolPanelGroup = ({
},
}));
- const surfaceModel = getSurfaceBlock(doc);
+ const surfaceModel = getSurfaceBlock(store);
const groupElements = surfaceModel
? surfaceModel.getElementsByType('group')
@@ -641,7 +641,7 @@ const databaseToolGroup: KeyboardToolPanelGroup = {
name: 'Table view',
icon: DatabaseTableViewIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:database'),
+ std.store.schema.flavourSchemaMap.has('affine:database'),
action: ({ std }) => {
std.command
.chain()
@@ -658,7 +658,7 @@ const databaseToolGroup: KeyboardToolPanelGroup = {
name: 'Kanban view',
icon: DatabaseKanbanViewIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:database'),
+ std.store.schema.flavourSchemaMap.has('affine:database'),
action: ({ std }) => {
std.command
.chain()
@@ -896,7 +896,7 @@ export const defaultKeyboardToolbarConfig: KeyboardToolbarConfig = {
name: 'Image',
icon: ImageIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:image'),
+ std.store.schema.flavourSchemaMap.has('affine:image'),
action: ({ std }) => {
std.command
.chain()
@@ -909,7 +909,7 @@ export const defaultKeyboardToolbarConfig: KeyboardToolbarConfig = {
name: 'Attachment',
icon: AttachmentIcon(),
showWhen: ({ std }) =>
- std.doc.schema.flavourSchemaMap.has('affine:attachment'),
+ std.store.schema.flavourSchemaMap.has('affine:attachment'),
action: async ({ std }) => {
const { selectedModels } = std.command.exec('getSelectedModels');
const model = selectedModels?.[0];
@@ -924,24 +924,24 @@ export const defaultKeyboardToolbarConfig: KeyboardToolbarConfig = {
await addSiblingAttachmentBlocks(std.host, [file], maxFileSize, model);
if (model.text?.length === 0) {
- std.doc.deleteBlock(model);
+ std.store.deleteBlock(model);
}
},
},
{
name: 'Undo',
icon: UndoIcon(),
- disableWhen: ({ std }) => !std.doc.canUndo,
+ disableWhen: ({ std }) => !std.store.canUndo,
action: ({ std }) => {
- std.doc.undo();
+ std.store.undo();
},
},
{
name: 'Redo',
icon: RedoIcon(),
- disableWhen: ({ std }) => !std.doc.canRedo,
+ disableWhen: ({ std }) => !std.store.canRedo,
action: ({ std }) => {
- std.doc.redo();
+ std.store.redo();
},
},
{
diff --git a/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts b/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts
index c4803109ed..53a57d2ffd 100644
--- a/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts
+++ b/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts
@@ -673,7 +673,7 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
icon: CopyIcon,
tooltip: slashMenuToolTips['Copy'],
action: ({ rootComponent, model }) => {
- const slice = Slice.fromModels(rootComponent.std.doc, [model]);
+ const slice = Slice.fromModels(rootComponent.std.store, [model]);
rootComponent.std.clipboard
.copy(slice)
diff --git a/blocksuite/framework/block-std/src/event/dispatcher.ts b/blocksuite/framework/block-std/src/event/dispatcher.ts
index 1fb446389b..d435dc051e 100644
--- a/blocksuite/framework/block-std/src/event/dispatcher.ts
+++ b/blocksuite/framework/block-std/src/event/dispatcher.ts
@@ -350,7 +350,7 @@ export class UIEventDispatcher extends LifeCycleWatcher {
);
const flavourHandlers = blockIds
- .map(blockId => this.std.doc.getBlock(blockId)?.flavour)
+ .map(blockId => this.std.store.getBlock(blockId)?.flavour)
.filter((flavour): flavour is string => {
if (!flavour) return false;
if (flavourSeen[flavour]) return false;
@@ -364,7 +364,7 @@ export class UIEventDispatcher extends LifeCycleWatcher {
events.push(...idHandlers, ...flavourHandlers);
blockIds = blockIds
.map(blockId => {
- const parent = this.std.doc.getParent(blockId);
+ const parent = this.std.store.getParent(blockId);
return parent?.id;
})
.filter((id): id is string => !!id);
diff --git a/blocksuite/framework/block-std/src/extension/service.ts b/blocksuite/framework/block-std/src/extension/service.ts
index 47cf062871..fd435d30c4 100644
--- a/blocksuite/framework/block-std/src/extension/service.ts
+++ b/blocksuite/framework/block-std/src/extension/service.ts
@@ -34,7 +34,7 @@ export abstract class BlockService extends Extension {
}
get doc() {
- return this.std.doc;
+ return this.std.store;
}
get host() {
diff --git a/blocksuite/framework/block-std/src/gfx/controller.ts b/blocksuite/framework/block-std/src/gfx/controller.ts
index 4a4a707fd0..17c15e2fbd 100644
--- a/blocksuite/framework/block-std/src/gfx/controller.ts
+++ b/blocksuite/framework/block-std/src/gfx/controller.ts
@@ -50,7 +50,7 @@ export class GfxController extends LifeCycleWatcher {
readonly viewport: Viewport = new Viewport();
get doc() {
- return this.std.doc;
+ return this.std.store;
}
get elementsBound() {
diff --git a/blocksuite/framework/block-std/src/gfx/selection.ts b/blocksuite/framework/block-std/src/gfx/selection.ts
index ae9509916f..21c38f78e0 100644
--- a/blocksuite/framework/block-std/src/gfx/selection.ts
+++ b/blocksuite/framework/block-std/src/gfx/selection.ts
@@ -316,7 +316,7 @@ export class GfxSelectionManager extends GfxExtension {
}
const { blocks = [], elements = [] } = groupBy(selection.elements, id => {
- return this.std.doc.getBlockById(id) ? 'blocks' : 'elements';
+ return this.std.store.getBlockById(id) ? 'blocks' : 'elements';
});
let instances: (SurfaceSelection | CursorSelection)[] = [];
diff --git a/blocksuite/framework/block-std/src/gfx/surface-middleware.ts b/blocksuite/framework/block-std/src/gfx/surface-middleware.ts
index 7876626d96..ed5ecd705f 100644
--- a/blocksuite/framework/block-std/src/gfx/surface-middleware.ts
+++ b/blocksuite/framework/block-std/src/gfx/surface-middleware.ts
@@ -51,7 +51,7 @@ export class SurfaceMiddlewareExtension extends LifeCycleWatcher {
this.std.provider.getAll(SurfaceMiddlewareBuilderIdentifier).values()
);
- const dispose = onSurfaceAdded(this.std.doc, surface => {
+ const dispose = onSurfaceAdded(this.std.store, surface => {
if (surface) {
surface.applyMiddlewares(builders.map(builder => builder.middleware));
queueMicrotask(() => dispose());
diff --git a/blocksuite/framework/block-std/src/gfx/view/view-manager.ts b/blocksuite/framework/block-std/src/gfx/view/view-manager.ts
index b7d92bd4ef..4542098374 100644
--- a/blocksuite/framework/block-std/src/gfx/view/view-manager.ts
+++ b/blocksuite/framework/block-std/src/gfx/view/view-manager.ts
@@ -107,7 +107,7 @@ export class ViewManager extends GfxExtension {
updateViewOnElementChange(this.gfx.surface);
} else {
this._disposable.add(
- onSurfaceAdded(this.std.doc, surface => {
+ onSurfaceAdded(this.std.store, surface => {
if (surface) {
updateViewOnElementChange(surface);
}
diff --git a/blocksuite/framework/block-std/src/range/range-binding.ts b/blocksuite/framework/block-std/src/range/range-binding.ts
index 849fa1c2c1..8095d778c2 100644
--- a/blocksuite/framework/block-std/src/range/range-binding.ts
+++ b/blocksuite/framework/block-std/src/range/range-binding.ts
@@ -16,7 +16,7 @@ export class RangeBinding {
| null = null;
private readonly _computePath = (modelId: string) => {
- const block = this.host.std.doc.getBlock(modelId)?.model;
+ const block = this.host.std.store.getBlock(modelId)?.model;
if (!block) return [];
const path: string[] = [];
diff --git a/blocksuite/framework/block-std/src/scope/block-std-scope.ts b/blocksuite/framework/block-std/src/scope/block-std-scope.ts
index 78ba90ab9a..2019f13e21 100644
--- a/blocksuite/framework/block-std/src/scope/block-std-scope.ts
+++ b/blocksuite/framework/block-std/src/scope/block-std-scope.ts
@@ -74,16 +74,12 @@ export class BlockStdScope {
return this.provider.getAll(LifeCycleWatcherIdentifier);
}
- get doc() {
- return this.store;
- }
-
get clipboard() {
return this.get(Clipboard);
}
get workspace() {
- return this.doc.workspace;
+ return this.store.workspace;
}
get command() {
@@ -198,7 +194,7 @@ export class BlockStdScope {
render() {
const element = new EditorHost();
element.std = this;
- element.doc = this.doc;
+ element.doc = this.store;
this._getHost = () => element;
this._lifeCycleWatchers.forEach(watcher => {
watcher.rendered.call(watcher);
diff --git a/blocksuite/framework/block-std/src/selection/manager.ts b/blocksuite/framework/block-std/src/selection/manager.ts
index 2137bda8a5..9145f87453 100644
--- a/blocksuite/framework/block-std/src/selection/manager.ts
+++ b/blocksuite/framework/block-std/src/selection/manager.ts
@@ -76,7 +76,7 @@ export class SelectionManager extends LifeCycleWatcher {
constructor(std: BlockStdScope) {
super(std);
- this._id = `${this.std.doc.id}:${nanoid()}`;
+ this._id = `${this.std.store.id}:${nanoid()}`;
this._setupDefaultSelections();
this._store.awareness.on(
'change',
@@ -100,7 +100,7 @@ export class SelectionManager extends LifeCycleWatcher {
if (id === this._store.awareness.clientID) return;
// selection id starts with the same block collection id from others clients would be considered as remote selections
const selection = Object.entries(state.selectionV2)
- .filter(([key]) => key.startsWith(this.std.doc.id))
+ .filter(([key]) => key.startsWith(this.std.store.id))
.flatMap(([_, selection]) => selection);
const selections = selection
@@ -191,8 +191,8 @@ export class SelectionManager extends LifeCycleWatcher {
if (this.disposables.disposed) {
this.disposables = new DisposableGroup();
}
- this.std.doc.history.on('stack-item-added', this._itemAdded);
- this.std.doc.history.on('stack-item-popped', this._itemPopped);
+ this.std.store.history.on('stack-item-added', this._itemAdded);
+ this.std.store.history.on('stack-item-popped', this._itemPopped);
this.disposables.add(
this._store.slots.update.on(({ id }) => {
if (id === this._store.awareness.clientID) {
@@ -224,8 +224,8 @@ export class SelectionManager extends LifeCycleWatcher {
}
override unmounted() {
- this.std.doc.history.off('stack-item-added', this._itemAdded);
- this.std.doc.history.off('stack-item-popped', this._itemPopped);
+ this.std.store.history.off('stack-item-added', this._itemAdded);
+ this.std.store.history.off('stack-item-popped', this._itemPopped);
this.slots.changed.dispose();
this.disposables.dispose();
this.clear();
diff --git a/blocksuite/framework/block-std/src/view/element/block-component.ts b/blocksuite/framework/block-std/src/view/element/block-component.ts
index 81b09387e0..1cc4a57f74 100644
--- a/blocksuite/framework/block-std/src/view/element/block-component.ts
+++ b/blocksuite/framework/block-std/src/view/element/block-component.ts
@@ -218,7 +218,7 @@ export class BlockComponent<
this.std.view.setBlock(this);
- const disposable = this.std.doc.slots.blockUpdated.on(({ type, id }) => {
+ const disposable = this.std.store.slots.blockUpdated.on(({ type, id }) => {
if (id === this.model.id && type === 'delete') {
this.std.view.deleteBlock(this);
disposable.dispose();
diff --git a/blocksuite/framework/block-std/src/view/view-store.ts b/blocksuite/framework/block-std/src/view/view-store.ts
index fccdab75be..d2b13f71a8 100644
--- a/blocksuite/framework/block-std/src/view/view-store.ts
+++ b/blocksuite/framework/block-std/src/view/view-store.ts
@@ -9,7 +9,7 @@ export class ViewStore extends LifeCycleWatcher {
private readonly _fromId = (
blockId: string | undefined | null
): BlockComponent | null => {
- const id = blockId ?? this.std.doc.root?.id;
+ const id = blockId ?? this.std.store.root?.id;
if (!id) {
return null;
}
diff --git a/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts b/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts
index 6e52ad5005..d473f8a8ff 100644
--- a/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts
+++ b/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts
@@ -194,7 +194,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {
if (this._answers.length > 0) {
const latestAnswer = this._answers.pop();
this._answers = [];
- const schema = this.schema ?? this.host?.std.doc.workspace.schema;
+ const schema = this.schema ?? this.host?.std.store.workspace.schema;
let provider: ServiceProvider;
if (this.host) {
provider = this.host.std.provider;
diff --git a/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts b/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts
index 3d9acf178a..13c9845324 100644
--- a/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts
+++ b/packages/frontend/core/src/blocksuite/presets/_common/utils/markdown-utils.ts
@@ -80,15 +80,15 @@ export async function getContentFromSlice(
type: 'markdown' | 'plain-text' = 'markdown'
) {
const job = new Job({
- schema: host.std.doc.workspace.schema,
- blobCRUD: host.std.doc.workspace.blobSync,
+ schema: host.std.store.workspace.schema,
+ blobCRUD: host.std.store.workspace.blobSync,
docCRUD: {
- create: (id: string) => host.std.doc.workspace.createDoc({ id }),
- get: (id: string) => host.std.doc.workspace.getDoc(id),
- delete: (id: string) => host.std.doc.workspace.removeDoc(id),
+ create: (id: string) => host.std.store.workspace.createDoc({ id }),
+ get: (id: string) => host.std.store.workspace.getDoc(id),
+ delete: (id: string) => host.std.store.workspace.removeDoc(id),
},
middlewares: [
- titleMiddleware(host.std.doc.workspace.meta.docMetas),
+ titleMiddleware(host.std.store.workspace.meta.docMetas),
embedSyncedDocMiddleware('content'),
],
});
@@ -110,14 +110,14 @@ export async function getContentFromSlice(
export async function getPlainTextFromSlice(host: EditorHost, slice: Slice) {
const job = new Job({
- schema: host.std.doc.workspace.schema,
- blobCRUD: host.std.doc.workspace.blobSync,
+ schema: host.std.store.workspace.schema,
+ blobCRUD: host.std.store.workspace.blobSync,
docCRUD: {
- create: (id: string) => host.std.doc.workspace.createDoc({ id }),
- get: (id: string) => host.std.doc.workspace.getDoc(id),
- delete: (id: string) => host.std.doc.workspace.removeDoc(id),
+ create: (id: string) => host.std.store.workspace.createDoc({ id }),
+ get: (id: string) => host.std.store.workspace.getDoc(id),
+ delete: (id: string) => host.std.store.workspace.removeDoc(id),
},
- middlewares: [titleMiddleware(host.std.doc.workspace.meta.docMetas)],
+ middlewares: [titleMiddleware(host.std.store.workspace.meta.docMetas)],
});
const snapshot = job.sliceToSnapshot(slice);
if (!snapshot) {
@@ -137,12 +137,12 @@ export const markdownToSnapshot = async (
host: EditorHost
) => {
const job = new Job({
- schema: host.std.doc.workspace.schema,
- blobCRUD: host.std.doc.workspace.blobSync,
+ schema: host.std.store.workspace.schema,
+ blobCRUD: host.std.store.workspace.blobSync,
docCRUD: {
- create: (id: string) => host.std.doc.workspace.createDoc({ id }),
- get: (id: string) => host.std.doc.workspace.getDoc(id),
- delete: (id: string) => host.std.doc.workspace.removeDoc(id),
+ create: (id: string) => host.std.store.workspace.createDoc({ id }),
+ get: (id: string) => host.std.store.workspace.getDoc(id),
+ delete: (id: string) => host.std.store.workspace.removeDoc(id),
},
middlewares: [defaultImageProxyMiddleware, pasteMiddleware(host.std)],
});
@@ -150,8 +150,8 @@ export const markdownToSnapshot = async (
const payload = {
file: markdown,
assets: job.assetsManager,
- workspaceId: host.std.doc.workspace.id,
- pageId: host.std.doc.id,
+ workspaceId: host.std.store.workspace.id,
+ pageId: host.std.store.id,
};
const snapshot = await markdownAdapter.toSliceSnapshot(payload);
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts
index 5cf05c6b07..2162e27e3e 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/editor-actions.ts
@@ -147,7 +147,7 @@ export const copyTextAnswer = async (panel: AffineAIPanelWidget) => {
export const copyText = async (host: EditorHost, text: string) => {
const previewDoc = await markDownToDoc(
host.std.provider,
- host.std.doc.schema,
+ host.std.store.schema,
text
);
const models = previewDoc
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts
index bc48324ba7..4a227cbb86 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts
@@ -124,7 +124,7 @@ export async function getTextContentFromBlockModels(
);
const drafts = selectedTextModels.map(toDraftModel);
drafts.forEach(draft => traverse(draft, drafts));
- const slice = Slice.fromModels(editorHost.std.doc, drafts);
+ const slice = Slice.fromModels(editorHost.std.store, drafts);
return getContentFromSlice(editorHost, slice, type);
}