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

This commit is contained in:
Saul-Mirone
2025-01-09 04:16:28 +00:00
parent 58ce86533e
commit d21ef47ae8
89 changed files with 359 additions and 348 deletions
@@ -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) {
@@ -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,
});
}
@@ -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,
});
@@ -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;