mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
refactor(editor): rename doc to store on block components (#12173)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Unified internal data access by replacing all references from `doc` to `store` across all components, blocks, widgets, and utilities. This affects how readonly state, block operations, and service retrieval are handled throughout the application. - **Tests** - Updated all test utilities and test cases to use `store` instead of `doc` for document-related operations. - **Chores** - Updated context providers and property names to reflect the change from `doc` to `store` for improved consistency and maintainability. No user-facing features or behaviors have changed. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -22,7 +22,7 @@ export class RangeBinding {
|
||||
let parent: BlockModel | null = block;
|
||||
while (parent) {
|
||||
path.unshift(parent.id);
|
||||
parent = this.host.doc.getParent(parent);
|
||||
parent = this.host.store.getParent(parent);
|
||||
}
|
||||
|
||||
return path;
|
||||
@@ -54,7 +54,7 @@ export class RangeBinding {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
this.host.doc.transact(() => {
|
||||
this.host.store.transact(() => {
|
||||
startText.delete(from.index, from.length);
|
||||
startText.insert(event.data ?? '', from.index);
|
||||
endText.delete(0, to.length);
|
||||
@@ -65,9 +65,9 @@ export class RangeBinding {
|
||||
// delete from lowest to highest
|
||||
.reverse()
|
||||
.forEach(block => {
|
||||
const parent = this.host.doc.getParent(block.model);
|
||||
const parent = this.host.store.getParent(block.model);
|
||||
if (!parent) return;
|
||||
this.host.doc.deleteBlock(block.model, {
|
||||
this.host.store.deleteBlock(block.model, {
|
||||
bringChildrenTo: parent,
|
||||
});
|
||||
});
|
||||
@@ -129,9 +129,9 @@ export class RangeBinding {
|
||||
this.host.requestUpdate();
|
||||
await this.host.updateComplete;
|
||||
|
||||
this.host.doc.captureSync();
|
||||
this.host.store.captureSync();
|
||||
|
||||
this.host.doc.transact(() => {
|
||||
this.host.store.transact(() => {
|
||||
endText.delete(0, to.length);
|
||||
startText.delete(from.index, from.length);
|
||||
startText.insert(event.data, from.index);
|
||||
@@ -142,9 +142,9 @@ export class RangeBinding {
|
||||
// delete from lowest to highest
|
||||
.reverse()
|
||||
.forEach(block => {
|
||||
const parent = this.host.doc.getParent(block.model);
|
||||
const parent = this.host.store.getParent(block.model);
|
||||
if (!parent) return;
|
||||
this.host.doc.deleteBlock(block.model, {
|
||||
this.host.store.deleteBlock(block.model, {
|
||||
bringChildrenTo: parent,
|
||||
});
|
||||
});
|
||||
@@ -256,7 +256,7 @@ export class RangeBinding {
|
||||
return;
|
||||
}
|
||||
|
||||
const model = this.host.doc.getModelById(textSelection.blockId);
|
||||
const model = this.host.store.getModelById(textSelection.blockId);
|
||||
// If the model is not found, the selection maybe in another editor
|
||||
if (!model) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user