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:
@@ -44,7 +44,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
`;
|
||||
|
||||
private readonly _resizeObserver = new ResizeObserver(() => {
|
||||
if (this.doc.readonly) {
|
||||
if (this.store.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
const rect = this._textContainer.getBoundingClientRect();
|
||||
bound.h = rect.height / this.gfx.viewport.zoom;
|
||||
|
||||
this.doc.updateBlock(this.model, {
|
||||
this.store.updateBlock(this.model, {
|
||||
xywh: bound.serialize(),
|
||||
});
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
EDGELESS_TEXT_BLOCK_MIN_WIDTH * this.gfx.viewport.zoom
|
||||
);
|
||||
|
||||
this.doc.updateBlock(this.model, {
|
||||
this.store.updateBlock(this.model, {
|
||||
xywh: bound.serialize(),
|
||||
});
|
||||
}
|
||||
@@ -169,7 +169,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
!firstChild ||
|
||||
!matchModels(firstChild, [ListBlockModel, ParagraphBlockModel])
|
||||
) {
|
||||
newParagraphId = this.doc.addBlock(
|
||||
newParagraphId = this.store.addBlock(
|
||||
'affine:paragraph',
|
||||
{},
|
||||
this.model.id,
|
||||
@@ -182,7 +182,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
!lastChild ||
|
||||
!matchModels(lastChild, [ListBlockModel, ParagraphBlockModel])
|
||||
) {
|
||||
newParagraphId = this.doc.addBlock(
|
||||
newParagraphId = this.store.addBlock(
|
||||
'affine:paragraph',
|
||||
{},
|
||||
this.model.id
|
||||
@@ -284,7 +284,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
}
|
||||
|
||||
if (this.model.children.length === 0) {
|
||||
const blockId = this.doc.addBlock(
|
||||
const blockId = this.store.addBlock(
|
||||
'affine:paragraph',
|
||||
{ type: 'text' },
|
||||
this.model.id
|
||||
@@ -339,7 +339,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
minWidth: !hasMaxWidth ? '220px' : undefined,
|
||||
};
|
||||
|
||||
this.contentEditable = String(editing && !this.doc.readonly$.value);
|
||||
this.contentEditable = String(editing && !this.store.readonly$.value);
|
||||
|
||||
return html`
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user