mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 09:52:49 +08:00
refactor(editor): reduce dependency to doc collection (#9492)
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
"lit-html": "^3.2.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"shiki": "^1.12.0",
|
||||
"yjs": "^13.6.21",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"exports": {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
KEYBOARD_ALLOW_DEFAULT,
|
||||
type KeyboardBindingContext,
|
||||
} from '@blocksuite/inline';
|
||||
import type { Y } from '@blocksuite/store';
|
||||
import type * as Y from 'yjs';
|
||||
import { z, type ZodObject, type ZodTypeAny } from 'zod';
|
||||
|
||||
import { MarkdownMatcherIdentifier } from './markdown-matcher.js';
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
InlineRange,
|
||||
KeyboardBindingHandler,
|
||||
} from '@blocksuite/inline';
|
||||
import type { Y } from '@blocksuite/store';
|
||||
import type * as Y from 'yjs';
|
||||
import type { ZodTypeAny } from 'zod';
|
||||
|
||||
export type InlineSpecs<
|
||||
|
||||
@@ -4,12 +4,11 @@ import { unsafeCSSVar } from '@blocksuite/affine-shared/theme';
|
||||
import { type BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';
|
||||
import { noop, SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
||||
import { DoneIcon } from '@blocksuite/icons/lit';
|
||||
import type { Y } from '@blocksuite/store';
|
||||
import { DocCollection } from '@blocksuite/store';
|
||||
import { effect, type Signal, signal } from '@preact/signals-core';
|
||||
import { css, html } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
import { codeToTokensBase, type ThemedToken } from 'shiki';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { InlineManagerExtension } from '../../../../extension/index.js';
|
||||
import { LatexEditorUnitSpecExtension } from '../../affine-inline-specs.js';
|
||||
@@ -111,7 +110,7 @@ export class LatexEditorMenu extends SignalWatcher(
|
||||
override connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
const doc = new DocCollection.Y.Doc();
|
||||
const doc = new Y.Doc();
|
||||
this.yText = doc.getText('latex');
|
||||
this.yText.insert(0, this.latexSignal.value);
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ import {
|
||||
type KeyboardBindingContext,
|
||||
type VLine,
|
||||
} from '@blocksuite/inline';
|
||||
import type { Y } from '@blocksuite/store';
|
||||
import { DocCollection, Text } from '@blocksuite/store';
|
||||
import { Text } from '@blocksuite/store';
|
||||
import { effect } from '@preact/signals-core';
|
||||
import { css, html, type TemplateResult } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { classMap } from 'lit/directives/class-map.js';
|
||||
import * as Y from 'yjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { onVBeforeinput, onVCompositionEnd } from './hooks.js';
|
||||
@@ -289,7 +289,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
|
||||
if (!this.undoManager) {
|
||||
this.undoManager = new DocCollection.Y.UndoManager(this._yText, {
|
||||
this.undoManager = new Y.UndoManager(this._yText, {
|
||||
trackedOrigins: new Set([this._yText.doc.clientID]),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user