mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
refactor(editor): rename model.doc to store (#12172)
This commit is contained in:
@@ -387,7 +387,7 @@ export function responseToExpandMindmap(host: EditorHost, ctx: AIContext) {
|
||||
|
||||
if (!subtree) return;
|
||||
|
||||
surface.doc.transact(() => {
|
||||
surface.store.transact(() => {
|
||||
const updateNodeSize = (node: typeof subtree) => {
|
||||
fitContent(node.element as ShapeElementModel);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { literal } from 'lit/static-html.js';
|
||||
|
||||
export const AIChatBlockSpec: ExtensionType[] = [
|
||||
BlockViewExtension('affine:embed-ai-chat', model => {
|
||||
const parent = model.doc.getParent(model.id);
|
||||
const parent = model.store.getParent(model.id);
|
||||
|
||||
if (parent?.flavour === 'affine:surface') {
|
||||
return literal`affine-edgeless-ai-chat`;
|
||||
|
||||
@@ -42,7 +42,7 @@ export class MindmapSurfaceBlock extends BlockComponent<SurfaceBlockModel> {
|
||||
}
|
||||
|
||||
private _adjustNodeWidth() {
|
||||
this.model.doc.transact(() => {
|
||||
this.model.store.transact(() => {
|
||||
this.model.elementModels.forEach(element => {
|
||||
if (element.type === 'shape') {
|
||||
fitContent(element as ShapeElementModel);
|
||||
|
||||
@@ -74,7 +74,7 @@ export function PDFViewerEmbedded({ model }: AttachmentViewerProps) {
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||
|
||||
const peek = useCallback(() => {
|
||||
const target = model.doc.getBlock(model.id);
|
||||
const target = model.store.getBlock(model.id);
|
||||
if (!target) return;
|
||||
peekView.open({ element: target }).catch(console.error);
|
||||
}, [peekView, model]);
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function getAttachmentBlob(model: AttachmentBlockModel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const doc = model.doc;
|
||||
const doc = model.store;
|
||||
let blob = await doc.blobSync.get(sourceId);
|
||||
|
||||
if (blob) {
|
||||
|
||||
@@ -16,7 +16,7 @@ export function patchForPDFEmbedView(reactToLit: ReactToLit): ExtensionType {
|
||||
const bound = Bound.deserialize(model.props.xywh);
|
||||
bound.w = 537 + 24 + 2;
|
||||
bound.h = 759 + 46 + 24 + 2;
|
||||
model.doc.updateBlock(model, {
|
||||
model.store.updateBlock(model, {
|
||||
embed: true,
|
||||
style: 'pdf',
|
||||
xywh: bound.serialize(),
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ const ToggleButton = ({ model }: { model: EmbedSyncedDocModel }) => {
|
||||
}, [model.props.preFoldHeight$, model.xywh$]);
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
model.doc.captureSync();
|
||||
model.store.captureSync();
|
||||
|
||||
batch(() => {
|
||||
const { x, y, w, h } = model.elementBound;
|
||||
|
||||
+4
-4
@@ -55,7 +55,7 @@ const EdgelessNoteToggleButton = ({ note }: { note: NoteBlockModel }) => {
|
||||
|
||||
const dispose = selection.slots.updated.subscribe(() => {
|
||||
if (selection.has(note.id) && selection.editing) {
|
||||
note.doc.transact(() => {
|
||||
note.store.transact(() => {
|
||||
note.props.edgeless.collapse = false;
|
||||
});
|
||||
}
|
||||
@@ -68,7 +68,7 @@ const EdgelessNoteToggleButton = ({ note }: { note: NoteBlockModel }) => {
|
||||
track.edgeless.pageBlock.headerToolbar.toggle({
|
||||
type: collapsed ? 'expand' : 'collapse',
|
||||
});
|
||||
note.doc.transact(() => {
|
||||
note.store.transact(() => {
|
||||
if (collapsed) {
|
||||
note.props.edgeless.collapse = false;
|
||||
} else {
|
||||
@@ -134,7 +134,7 @@ const PageBlockInfoButton = ({ note }: { note: NoteBlockModel }) => {
|
||||
|
||||
return (
|
||||
<DocInfoButton
|
||||
docId={note.doc.id}
|
||||
docId={note.store.id}
|
||||
trackFn={trackFn}
|
||||
data-testid="edgeless-note-info-button"
|
||||
/>
|
||||
@@ -148,7 +148,7 @@ const NoteCopyLinkButton = ({ note }: { note: NoteBlockModel }) => {
|
||||
|
||||
return (
|
||||
<CopyLinkButton
|
||||
pageId={note.doc.id}
|
||||
pageId={note.store.id}
|
||||
blockId={note.id}
|
||||
mode="edgeless"
|
||||
trackFn={trackFn}
|
||||
|
||||
@@ -26,11 +26,13 @@ export function patchForEdgelessNoteConfig(
|
||||
reactToLit(<EdgelessNoteHeader note={note} />),
|
||||
pageBlockTitle: ({ note }) => {
|
||||
const journalService = framework.get(JournalService);
|
||||
const isJournal = !!journalService.journalDate$(note.doc.id).value;
|
||||
const isJournal = !!journalService.journalDate$(note.store.id).value;
|
||||
if (isJournal) {
|
||||
return reactToLit(<BlocksuiteEditorJournalDocTitle page={note.doc} />);
|
||||
return reactToLit(
|
||||
<BlocksuiteEditorJournalDocTitle page={note.store} />
|
||||
);
|
||||
} else {
|
||||
return html`<doc-title .doc=${note.doc}></doc-title>`;
|
||||
return html`<doc-title .doc=${note.store}></doc-title>`;
|
||||
}
|
||||
},
|
||||
pageBlockViewportFitAnimation: insidePeekView
|
||||
|
||||
@@ -42,7 +42,7 @@ function createCopyLinkToBlockMenuItem(
|
||||
},
|
||||
select: () => {
|
||||
const serverService = framework.get(ServerService);
|
||||
const pageId = model.doc.id;
|
||||
const pageId = model.store.id;
|
||||
const { editor } = framework.get(EditorService);
|
||||
const mode = editor.mode$.value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user