mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(editor): reduce dependency to doc collection (#9492)
This commit is contained in:
@@ -17,12 +17,12 @@ import {
|
||||
type BlockModel,
|
||||
type BlockSnapshot,
|
||||
type DeltaOperation,
|
||||
DocCollection,
|
||||
fromJSON,
|
||||
type JobMiddleware,
|
||||
type SliceSnapshot,
|
||||
type Text,
|
||||
} from '@blocksuite/store';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { REFERENCE_NODE } from '../../consts';
|
||||
import {
|
||||
@@ -357,7 +357,7 @@ class PasteTr {
|
||||
!matchFlavours(this.pointState.model, ['affine:code'])
|
||||
) {
|
||||
const text = fromJSON(this.lastSnapshot.props.text) as Text;
|
||||
const doc = new DocCollection.Y.Doc();
|
||||
const doc = new Y.Doc();
|
||||
const temp = doc.getMap('temp');
|
||||
temp.set('text', text.yText);
|
||||
this.lastIndex = text.length;
|
||||
|
||||
@@ -6,10 +6,10 @@ import {
|
||||
DisposableGroup,
|
||||
Slot,
|
||||
} from '@blocksuite/global/utils';
|
||||
import { DocCollection } from '@blocksuite/store';
|
||||
import { computed, type Signal, signal } from '@preact/signals-core';
|
||||
import clonedeep from 'lodash.clonedeep';
|
||||
import mergeWith from 'lodash.mergewith';
|
||||
import * as Y from 'yjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { makeDeepOptional, NodePropsSchema } from '../utils/index.js';
|
||||
@@ -63,9 +63,9 @@ function isSessionProp(key: string): key is keyof SessionProps {
|
||||
function customizer(_target: unknown, source: unknown) {
|
||||
if (
|
||||
ColorSchema.safeParse(source).success ||
|
||||
source instanceof DocCollection.Y.Text ||
|
||||
source instanceof DocCollection.Y.Array ||
|
||||
source instanceof DocCollection.Y.Map
|
||||
source instanceof Y.Text ||
|
||||
source instanceof Y.Array ||
|
||||
source instanceof Y.Map
|
||||
) {
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export function createDefaultDoc(
|
||||
const rootId = doc.addBlock('affine:page', {
|
||||
title: new doc.Text(title),
|
||||
});
|
||||
collection.setDocMeta(doc.id, {
|
||||
collection.meta.setDocMeta(doc.id, {
|
||||
title,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user